RedPanda-CPP/RedPandaIDE/widgets/codecompletionlistview.cpp

40 lines
968 B
C++
Raw Normal View History

2021-08-29 00:48:23 +08:00
#include "codecompletionlistview.h"
#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);
}
}
void CodeCompletionListView::focusInEvent(QFocusEvent *)
{
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;
}