2021-08-23 21:50:53 +08:00
|
|
|
#include "codecompletionview.h"
|
|
|
|
#include "ui_codecompletionview.h"
|
|
|
|
|
2021-08-24 09:59:44 +08:00
|
|
|
#include <QKeyEvent>
|
|
|
|
|
2021-08-23 21:50:53 +08:00
|
|
|
CodeCompletionView::CodeCompletionView(QWidget *parent) :
|
2021-08-24 09:59:44 +08:00
|
|
|
QWidget(parent)
|
2021-08-23 21:50:53 +08:00
|
|
|
{
|
2021-08-24 09:59:44 +08:00
|
|
|
setWindowFlags(Qt::Popup);
|
|
|
|
mListView = new CodeCompletionListView(this);
|
|
|
|
setLayout(new QVBoxLayout());
|
|
|
|
layout()->addWidget(mListView);
|
|
|
|
layout()->setMargin(0);
|
2021-08-23 21:50:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CodeCompletionView::~CodeCompletionView()
|
|
|
|
{
|
2021-08-24 09:59:44 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CodeCompletionView::setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback)
|
|
|
|
{
|
|
|
|
mListView->setKeypressedCallback(newKeypressedCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
CodeCompletionListView::CodeCompletionListView(QWidget *parent) : QListView(parent)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CodeCompletionListView::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
|
|
|
if (!mKeypressedCallback(event)) {
|
|
|
|
QListView::keyPressEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const KeyPressedCallback &CodeCompletionListView::keypressedCallback() const
|
|
|
|
{
|
|
|
|
return mKeypressedCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CodeCompletionListView::setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback)
|
|
|
|
{
|
|
|
|
mKeypressedCallback = newKeypressedCallback;
|
2021-08-23 21:50:53 +08:00
|
|
|
}
|