2021-08-29 00:48:23 +08:00
|
|
|
#include "codecompletionlistview.h"
|
2021-09-29 19:40:03 +08:00
|
|
|
#include "../mainwindow.h"
|
|
|
|
#include "../editor.h"
|
|
|
|
#include "../editorlist.h"
|
2021-08-29 00:48:23 +08:00
|
|
|
|
|
|
|
CodeCompletionListView::CodeCompletionListView(QWidget *parent) : QListView(parent)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CodeCompletionListView::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
|
|
|
if (event->key() == Qt::Key_Up
|
|
|
|
|| event->key() == Qt::Key_Down) {
|
|
|
|
QListView::keyPressEvent(event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!mKeypressedCallback || !mKeypressedCallback(event)) {
|
|
|
|
QListView::keyPressEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-29 19:40:03 +08:00
|
|
|
void CodeCompletionListView::focusInEvent(QFocusEvent *event)
|
|
|
|
{
|
|
|
|
Editor *editor = pMainWindow->editorList()->getEditor();
|
|
|
|
if (editor) {
|
|
|
|
editor->showCaret();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-29 00:48:23 +08:00
|
|
|
const KeyPressedCallback &CodeCompletionListView::keypressedCallback() const
|
|
|
|
{
|
|
|
|
return mKeypressedCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CodeCompletionListView::setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback)
|
|
|
|
{
|
|
|
|
mKeypressedCallback = newKeypressedCallback;
|
|
|
|
}
|
|
|
|
|