- fix: code suggestion popup window don't highlight current item
- fix: the order of symbols in local and system headers in the suggestion popopup is wrong
This commit is contained in:
parent
7207994d57
commit
2ae8521bca
|
@ -99,8 +99,10 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
||||||
} else {
|
} else {
|
||||||
initParser();
|
initParser();
|
||||||
}
|
}
|
||||||
mCompletionPopup = std::make_shared<CodeCompletionPopup>();
|
// mCompletionPopup = std::make_shared<CodeCompletionPopup>();
|
||||||
mHeaderCompletionPopup = std::make_shared<HeaderCompletionPopup>();
|
// mHeaderCompletionPopup = std::make_shared<HeaderCompletionPopup>();
|
||||||
|
mCompletionPopup = pMainWindow->completionPopup();
|
||||||
|
mHeaderCompletionPopup = pMainWindow->headerCompletionPopup();
|
||||||
|
|
||||||
applySettings();
|
applySettings();
|
||||||
applyColorScheme(pSettings->editor().colorScheme());
|
applyColorScheme(pSettings->editor().colorScheme());
|
||||||
|
|
|
@ -122,6 +122,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
//class browser
|
//class browser
|
||||||
ui->classBrowser->setModel(&mClassBrowserModel);
|
ui->classBrowser->setModel(&mClassBrowserModel);
|
||||||
|
|
||||||
|
mCompletionPopup = std::make_shared<CodeCompletionPopup>();
|
||||||
|
mHeaderCompletionPopup = std::make_shared<HeaderCompletionPopup>();
|
||||||
|
|
||||||
updateAppTitle();
|
updateAppTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,7 +944,17 @@ void MainWindow::prepareDebugger()
|
||||||
|
|
||||||
|
|
||||||
// Reset watch vars
|
// Reset watch vars
|
||||||
// mDebugger->deleteWatchVars(false);
|
// mDebugger->deleteWatchVars(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::shared_ptr<HeaderCompletionPopup> &MainWindow::headerCompletionPopup() const
|
||||||
|
{
|
||||||
|
return mHeaderCompletionPopup;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::shared_ptr<CodeCompletionPopup> &MainWindow::completionPopup() const
|
||||||
|
{
|
||||||
|
return mCompletionPopup;
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchDialog *MainWindow::searchDialog() const
|
SearchDialog *MainWindow::searchDialog() const
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "widgets/searchresultview.h"
|
#include "widgets/searchresultview.h"
|
||||||
#include "widgets/classbrowser.h"
|
#include "widgets/classbrowser.h"
|
||||||
|
#include "widgets/codecompletionpopup.h"
|
||||||
|
#include "widgets/headercompletionpopup.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
|
@ -91,6 +93,10 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const std::shared_ptr<CodeCompletionPopup> &completionPopup() const;
|
||||||
|
|
||||||
|
const std::shared_ptr<HeaderCompletionPopup> &headerCompletionPopup() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void openFiles(const QStringList& files);
|
void openFiles(const QStringList& files);
|
||||||
void openFile(const QString& filename);
|
void openFile(const QString& filename);
|
||||||
|
@ -232,6 +238,9 @@ private:
|
||||||
bool mQuitting;
|
bool mQuitting;
|
||||||
QElapsedTimer mParserTimer;
|
QElapsedTimer mParserTimer;
|
||||||
|
|
||||||
|
std::shared_ptr<CodeCompletionPopup> mCompletionPopup;
|
||||||
|
std::shared_ptr<HeaderCompletionPopup> mHeaderCompletionPopup;
|
||||||
|
|
||||||
SearchResultModel mSearchResultModel;
|
SearchResultModel mSearchResultModel;
|
||||||
PSearchResultListModel mSearchResultListModel;
|
PSearchResultListModel mSearchResultListModel;
|
||||||
PSearchResultTreeModel mSearchResultTreeModel;
|
PSearchResultTreeModel mSearchResultTreeModel;
|
||||||
|
@ -244,6 +253,7 @@ private:
|
||||||
int mPreviousHeight;
|
int mPreviousHeight;
|
||||||
PCompileSuccessionTask mCompileSuccessionTask;
|
PCompileSuccessionTask mCompileSuccessionTask;
|
||||||
|
|
||||||
|
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
|
@ -105,6 +105,7 @@ bool CodeCompletionPopup::search(const QString &phrase, bool autoHideOnSingleRes
|
||||||
setCursor(oldCursor);
|
setCursor(oldCursor);
|
||||||
|
|
||||||
if (!mCompletionStatementList.isEmpty()) {
|
if (!mCompletionStatementList.isEmpty()) {
|
||||||
|
mListView->setCurrentIndex(mModel->index(0,0));
|
||||||
// if only one suggestion, and is exactly the symbol to search, hide the frame (the search is over)
|
// if only one suggestion, and is exactly the symbol to search, hide the frame (the search is over)
|
||||||
// if only one suggestion and auto hide , don't show the frame
|
// if only one suggestion and auto hide , don't show the frame
|
||||||
if(mCompletionStatementList.count() == 1)
|
if(mCompletionStatementList.count() == 1)
|
||||||
|
@ -223,9 +224,9 @@ static bool sortByScopeComparator(PStatement statement1,PStatement statement2){
|
||||||
} else if (statement2->kind == StatementKind::skKeyword) {
|
} else if (statement2->kind == StatementKind::skKeyword) {
|
||||||
return false;
|
return false;
|
||||||
// Show stuff from local headers first
|
// Show stuff from local headers first
|
||||||
} else if (statement1->inSystemHeader && !(statement2->inSystemHeader)) {
|
|
||||||
return true;
|
|
||||||
} else if (!(statement1->inSystemHeader) && statement2->inSystemHeader) {
|
} else if (!(statement1->inSystemHeader) && statement2->inSystemHeader) {
|
||||||
|
return true;
|
||||||
|
} else if (statement1->inSystemHeader && !(statement2->inSystemHeader)) {
|
||||||
return false;
|
return false;
|
||||||
// Show local statements first
|
// Show local statements first
|
||||||
} else if (statement1->scope != StatementScope::ssGlobal
|
} else if (statement1->scope != StatementScope::ssGlobal
|
||||||
|
@ -254,11 +255,11 @@ static bool sortWithUsageComparator(PStatement statement1,PStatement statement2)
|
||||||
} else if (statement1->freqTop < statement2->freqTop) {
|
} else if (statement1->freqTop < statement2->freqTop) {
|
||||||
return false;
|
return false;
|
||||||
// show keywords first
|
// show keywords first
|
||||||
} else if ((statement1->kind == StatementKind::skKeyword)
|
|
||||||
&& (statement2->kind != StatementKind::skKeyword)) {
|
|
||||||
return true;
|
|
||||||
} else if ((statement1->kind != StatementKind::skKeyword)
|
} else if ((statement1->kind != StatementKind::skKeyword)
|
||||||
&& (statement2->kind == StatementKind::skKeyword)) {
|
&& (statement2->kind == StatementKind::skKeyword)) {
|
||||||
|
return true;
|
||||||
|
} else if ((statement1->kind == StatementKind::skKeyword)
|
||||||
|
&& (statement2->kind != StatementKind::skKeyword)) {
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
return statement1->command < statement2->command;
|
return statement1->command < statement2->command;
|
||||||
|
|
|
@ -64,6 +64,7 @@ bool HeaderCompletionPopup::search(const QString &phrase, bool autoHideOnSingleR
|
||||||
setCursor(oldCursor);
|
setCursor(oldCursor);
|
||||||
|
|
||||||
if (!mCompletionList.isEmpty()) {
|
if (!mCompletionList.isEmpty()) {
|
||||||
|
mListView->setCurrentIndex(mModel->index(0,0));
|
||||||
if (mCompletionList.count() == 1) {
|
if (mCompletionList.count() == 1) {
|
||||||
// if only one suggestion and auto hide , don't show the frame
|
// if only one suggestion and auto hide , don't show the frame
|
||||||
if (autoHideOnSingleResult)
|
if (autoHideOnSingleResult)
|
||||||
|
@ -95,7 +96,9 @@ QString HeaderCompletionPopup::selectedFilename()
|
||||||
int index = mListView->currentIndex().row();
|
int index = mListView->currentIndex().row();
|
||||||
if (index>=0 && index<mCompletionList.count())
|
if (index>=0 && index<mCompletionList.count())
|
||||||
return mCompletionList[index];
|
return mCompletionList[index];
|
||||||
else
|
else if (mCompletionList.count()>0) {
|
||||||
|
return mCompletionList.front();
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue