work save: header completion suggestion done

This commit is contained in:
royqh1979@gmail.com 2021-08-29 10:14:07 +08:00
parent f1ae5bfdfd
commit 7207994d57
21 changed files with 357 additions and 164 deletions

View File

@ -3,6 +3,7 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
CONFIG += nokey
QMAKE_CXXFLAGS_RELEASE += -Werror=return-type
QMAKE_CXXFLAGS_DEBUG += -Werror=return-type

View File

@ -91,7 +91,7 @@ int Compiler::getLineNumberFromOutputLine(QString &line)
pos = line.indexOf(',');
}
if (pos>=0) {
result = line.mid(0,pos).toInt();
result = line.midRef(0,pos).toInt();
if (result > 0)
line.remove(0,pos+1);
}
@ -107,7 +107,7 @@ int Compiler::getColunmnFromOutputLine(QString &line)
pos = line.indexOf(',');
}
if (pos>=0) {
result = line.mid(0,pos).toInt();
result = line.midRef(0,pos).toInt();
if (result > 0)
line.remove(0,pos+1);
}
@ -154,7 +154,6 @@ void Compiler::processOutput(QString &line)
QString inFilePrefix = QString("In file included from ");
QString fromPrefix = QString("from ");
PCompileIssue issue = std::make_shared<CompileIssue>();
QString description;
issue->type = CompileIssueType::Other;
issue->endColumn = -1;
if (line.startsWith(inFilePrefix)) {
@ -252,8 +251,7 @@ QString Compiler::getCharsetArgument(const QByteArray& encoding)
encodingName = encoding;
}
result += QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(encodingName)
.arg(systemEncodingName);
.arg(encodingName,systemEncodingName);
}
return result;
}
@ -265,7 +263,7 @@ QString Compiler::getCCompileArguments(bool checkSyntax)
result += " -fsyntax-only";
}
for (PCompilerOption pOption: compilerSet()->options()) {
foreach (const PCompilerOption& pOption, compilerSet()->options()) {
if (pOption->value > 0 && pOption->isC) {
if (pOption->choices.isEmpty()) {
result += " " + pOption->setting;
@ -291,7 +289,7 @@ QString Compiler::getCppCompileArguments(bool checkSyntax)
result += " -fsyntax-only";
}
for (PCompilerOption pOption: compilerSet()->options()) {
foreach (const PCompilerOption& pOption, compilerSet()->options()) {
if (pOption->value > 0 && pOption->isCpp) {
if (pOption->choices.isEmpty()) {
result += " "+pOption->setting;
@ -314,7 +312,7 @@ QString Compiler::getCppCompileArguments(bool checkSyntax)
QString Compiler::getCIncludeArguments()
{
QString result;
for (const QString& folder:compilerSet()->CIncludeDirs()) {
foreach (const QString& folder,compilerSet()->CIncludeDirs()) {
result += QString(" -I\"%1\"").arg(folder);
}
return result;
@ -323,7 +321,7 @@ QString Compiler::getCIncludeArguments()
QString Compiler::getCppIncludeArguments()
{
QString result;
for (const QString& folder:compilerSet()->CppIncludeDirs()) {
foreach (const QString& folder,compilerSet()->CppIncludeDirs()) {
result += QString(" -I\"%1\"").arg(folder);
}
return result;
@ -333,7 +331,7 @@ QString Compiler::getLibraryArguments()
{
QString result;
for (const QString& folder:compilerSet()->libDirs()) {
foreach (const QString& folder, compilerSet()->libDirs()) {
result += QString(" -L\"%1\"").arg(folder);
}
@ -343,7 +341,7 @@ QString Compiler::getLibraryArguments()
}
//options like "-static" must be added after "-lxxx"
for (PCompilerOption pOption: compilerSet()->options()) {
foreach (const PCompilerOption& pOption, compilerSet()->options()) {
if (pOption->value > 0 && pOption->isLinker) {
if (pOption->choices.isEmpty()) {
result += " " + pOption->setting;
@ -377,7 +375,7 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q
process.connect(&process, &QProcess::readyReadStandardOutput,[&process,this](){
this->log(QString::fromLocal8Bit( process.readAllStandardOutput()));
});
process.connect(&process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),[&process,this](){
process.connect(&process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),[this](){
this->error(COMPILE_PROCESS_END);
});
process.start();

View File

@ -29,15 +29,17 @@ using namespace std;
SaveException::SaveException(const QString& reason) {
mReason = reason;
mReasonBuffer = mReason.toLocal8Bit();
}
SaveException::SaveException(const QString&& reason) {
mReason = reason;
mReasonBuffer = mReason.toLocal8Bit();
}
const QString& SaveException::reason() const noexcept{
return mReason;
}
const char *SaveException::what() const noexcept {
return mReason.toLocal8Bit();
const char* SaveException::what() const noexcept {
return mReasonBuffer;
}
int Editor::newfileCount=0;
@ -98,6 +100,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
initParser();
}
mCompletionPopup = std::make_shared<CodeCompletionPopup>();
mHeaderCompletionPopup = std::make_shared<HeaderCompletionPopup>();
applySettings();
applyColorScheme(pSettings->editor().colorScheme());
@ -255,8 +258,8 @@ void Editor::undoSymbolCompletion(int pos)
if (pos<0 || pos+1>=lineText().length())
return;
QChar DeletedChar = lineText()[pos];
QChar NextChar = lineText()[pos+1];
QChar DeletedChar = lineText().at(pos);
QChar NextChar = lineText().at(pos+1);
if ((tokenType == SynHighlighterTokenType::Character) && (DeletedChar != '\''))
return;
if (tokenType == SynHighlighterTokenType::StringEscapeSequence)
@ -454,7 +457,7 @@ void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y)
PSyntaxIssueList lst = getSyntaxIssuesAtLine(aLine);
if (lst) {
bool hasError=false;
for (PSyntaxIssue issue : *lst) {
for (const PSyntaxIssue& issue : *lst) {
if (issue->issueType == CompileIssueType::Error) {
hasError = true;
break;;
@ -488,7 +491,7 @@ void Editor::onGetEditingAreas(int Line, SynEditingAreaList &areaList)
// StrToThemeColor(tc,devEditor.Syntax.Values[cWN]);
PSyntaxIssueList lst = getSyntaxIssuesAtLine(Line);
if (lst) {
for (PSyntaxIssue issue: *lst) {
for (const PSyntaxIssue& issue: *lst) {
PSynEditingArea p=std::make_shared<SynEditingArea>();
p->beginX = issue->col;
p->endX = issue->endCol;
@ -556,6 +559,7 @@ void Editor::onPreparePaintHighlightToken(int row, int column, const QString &to
StatementKind kind = mParser->getKindOfStatement(statement);
if (kind == StatementKind::skUnknown) {
if ((pEndPos.Line>=1)
&& (pEndPos.Char>=0)
&& (pEndPos.Char < lines()->getString(pEndPos.Line-1).length())
&& (lines()->getString(pEndPos.Line-1)[pEndPos.Char] == '(')) {
kind = StatementKind::skFunction;
@ -760,7 +764,7 @@ Editor::PSyntaxIssueList Editor::getSyntaxIssuesAtLine(int line)
Editor::PSyntaxIssue Editor::getSyntaxIssueAtPosition(const BufferCoord &pos)
{
PSyntaxIssueList lst = getSyntaxIssuesAtLine(pos.Line);
for (PSyntaxIssue issue: *lst) {
foreach (const PSyntaxIssue& issue, *lst) {
if (issue->startChar<=pos.Char && pos.Char<=issue->endChar)
return issue;
}
@ -865,7 +869,7 @@ void Editor::onStatusChanged(SynStatusChanges changes)
// mainForm.CaretList.AddCaret(self,fText.CaretY,fText.CaretX);
}
void Editor::onGutterClicked(Qt::MouseButton button, int x, int y, int line)
void Editor::onGutterClicked(Qt::MouseButton button, int , int , int line)
{
if (button == Qt::LeftButton) {
toggleBreakpoint(line);
@ -878,7 +882,7 @@ QChar Editor::getCurrentChar()
if (lineText().length()<caretX())
return QChar();
else
return lineText()[caretX()-1];
return lineText().at(caretX()-1);
}
bool Editor::handleSymbolCompletion(QChar key)
@ -1429,7 +1433,50 @@ void Editor::showCompletion(bool autoComplete)
void Editor::showHeaderCompletion(bool autoComplete)
{
//todo:
// if not devCodeCompletion.Enabled then
// Exit;
if (mHeaderCompletionPopup->isVisible()) // already in search, don't do it again
return;
// Position it at the top of the next line
QPoint p = RowColumnToPixels(displayXY());
p.setY(p.y() + textHeight() + 2);
mHeaderCompletionPopup->move(mapToGlobal(p));
// fHeaderCompletionBox.IgnoreCase := devCodeCompletion.IgnoreCase;
// fHeaderCompletionBox.ShowCount := devCodeCompletion.MaxCount;
//Set Font size;
mHeaderCompletionPopup->setFont(font());
// Redirect key presses to completion box if applicable
mHeaderCompletionPopup->setKeypressedCallback([this](QKeyEvent* event)->bool{
return onHeaderCompletionKeyPressed(event);
});
mHeaderCompletionPopup->setParser(mParser);
BufferCoord pBeginPos,pEndPos;
QString word = getWordAtPosition(caretXY(),pBeginPos,pEndPos,
WordPurpose::wpHeaderCompletionStart);
if (word.isEmpty())
return;
if (!word.startsWith('"') && !word.startsWith('<'))
return;
if (word.lastIndexOf('"')>0 || word.lastIndexOf('>')>0)
return;
mHeaderCompletionPopup->show();
mHeaderCompletionPopup->setSearchLocal(word.startsWith('"'));
word.remove(0,1);
mHeaderCompletionPopup->prepareSearch(word, mFilename);
// Filter the whole statement list
if (mHeaderCompletionPopup->search(word, autoComplete)) //only one suggestion and it's not input while typing
headerCompletionInsert(); // if only have one suggestion, just use it
}
bool Editor::testInFunc(int x, int y)
@ -1503,7 +1550,7 @@ void Editor::completionInsert(bool appendFunc)
|| statement->kind == StatementKind::skConstructor
|| statement->kind == StatementKind::skDestructor) {
if ((p.Char >= lineText().length()) // it's the last char on line
|| (lineText()[p.Char] != '(')) { // it don't have '(' after it
|| (lineText().at(p.Char) != '(')) { // it don't have '(' after it
if (statement->fullName!="std::endl")
funcAddOn = "()";
}
@ -1546,11 +1593,46 @@ void Editor::completionInsert(bool appendFunc)
mCompletionPopup->hide();
}
void Editor::headerCompletionInsert()
{
QString headerName = mHeaderCompletionPopup->selectedFilename();
if (headerName.isEmpty())
return;
// delete the part of the word that's already been typed ...
BufferCoord p = caretXY();
int posBegin = p.Char-1;
int posEnd = p.Char-1;
QString sLine = lineText();
while ((posBegin>0) &&
(isIdentChar(sLine[posBegin-1]) || (sLine[posBegin-1]=='.')))
posBegin--;
while ((posEnd < sLine.length())
&& (isIdentChar(sLine[posEnd]) || (sLine[posEnd]=='.')))
posEnd++;
p.Char = posBegin+1;
setBlockBegin(p);
p.Char = posEnd+1;
setBlockEnd(p);
setSelText(headerName);
mCompletionPopup->hide();
}
bool Editor::onCompletionKeyPressed(QKeyEvent *event)
{
bool processed = false;
if (!mCompletionPopup->isEnabled())
return false;
QString oldPhrase = mCompletionPopup->phrase();
WordPurpose purpose = WordPurpose::wpCompletion;
if (oldPhrase.startsWith('#')) {
purpose = WordPurpose::wpDirective;
} else if (oldPhrase.startsWith('@')) {
purpose = WordPurpose::wpJavadoc;
}
QString phrase;
BufferCoord pBeginPos,pEndPos;
switch (event->key()) {
@ -1560,7 +1642,7 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
QChar(), nullptr); // Simulate backspace in editor
phrase = getWordAtPosition(caretXY(),
pBeginPos,pEndPos,
WordPurpose::wpCompletion);
purpose);
mLastIdCharPressed = phrase.length();
mCompletionPopup->search(phrase, false);
return true;
@ -1583,9 +1665,9 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
QChar ch = event->text().front();
if (isIdentChar(ch)) {
setSelText(ch);
phrase = phrase = getWordAtPosition(caretXY(),
phrase = getWordAtPosition(caretXY(),
pBeginPos,pEndPos,
WordPurpose::wpCompletion);
purpose);
mLastIdCharPressed = phrase.length();
mCompletionPopup->search(phrase, false);
return true;
@ -1598,6 +1680,59 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
return processed;
}
bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
{
bool processed = false;
if (!mCompletionPopup->isEnabled())
return false;
QString phrase;
BufferCoord pBeginPos,pEndPos;
switch (event->key()) {
case Qt::Key_Backspace:
ExecuteCommand(
SynEditorCommand::ecDeleteLastChar,
QChar(), nullptr); // Simulate backspace in editor
phrase = getWordAtPosition(caretXY(),
pBeginPos,pEndPos,
WordPurpose::wpHeaderCompletion);
mLastIdCharPressed = phrase.length();
mHeaderCompletionPopup->search(phrase, false);
return true;
case Qt::Key_Escape:
mHeaderCompletionPopup->hide();
return true;
case Qt::Key_Return:
case Qt::Key_Tab:
//CompletionInsert(devCodeCompletion.AppendFunc);
headerCompletionInsert();
mHeaderCompletionPopup->hide();
return true;
default:
if (event->text().isEmpty()) {
//stop completion
mHeaderCompletionPopup->hide();
keyPressEvent(event);
return true;
}
}
QChar ch = event->text().front();
if (isIdentChar(ch)) {
setSelText(ch);
phrase = getWordAtPosition(caretXY(),
pBeginPos,pEndPos,
WordPurpose::wpHeaderCompletion);
mLastIdCharPressed = phrase.length();
mHeaderCompletionPopup->search(phrase, false);
return true;
} else {
//stop completion
mHeaderCompletionPopup->hide();
keyPressEvent(event);
return true;
}
return processed;
}
QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin, BufferCoord &pWordEnd, WordPurpose purpose)
{
QString result = "";
@ -2066,6 +2201,7 @@ void Editor::applyColorScheme(const QString& schemeName)
if (item) {
mCompletionPopup->colors().insert(StatementKind::skPreprocessor,item->foreground());
mCompletionPopup->colors().insert(StatementKind::skEnum,item->foreground());
mHeaderCompletionPopup->setSuggestionColor(item->foreground());
}
item = pColorManager->getItem(schemeName, SYNS_AttrReservedWord);
if (item) {

View File

@ -9,6 +9,7 @@
#include "common.h"
#include "parser/cppparser.h"
#include "widgets/codecompletionpopup.h"
#include "widgets/headercompletionpopup.h"
class SaveException: public std::exception {
@ -21,6 +22,7 @@ public:
const char *what() const noexcept override;
private:
QString mReason;
QByteArray mReasonBuffer;
};
class Editor : public SynEdit
@ -169,7 +171,10 @@ private:
void completionInsert(bool appendFunc=false);
void headerCompletionInsert();
bool onCompletionKeyPressed(QKeyEvent* event);
bool onHeaderCompletionKeyPressed(QKeyEvent* event);
private:
static int newfileCount;
@ -193,6 +198,7 @@ private:
int mActiveBreakpointLine;
PCppParser mParser;
std::shared_ptr<CodeCompletionPopup> mCompletionPopup;
std::shared_ptr<HeaderCompletionPopup> mHeaderCompletionPopup;
int mLastIdCharPressed;
bool mUseCppSyntax;

View File

@ -32,11 +32,11 @@ MainWindow* pMainWindow;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
ui(new Ui::MainWindow),
mSearchDialog(nullptr),
mQuitting(false),
mMessageControlChanged(false),
mTabMessagesTogglingState(false),
mCheckSyntaxInBack(false),
mSearchDialog(nullptr),
mQuitting(false)
mCheckSyntaxInBack(false)
{
ui->setupUi(this);
// status bar
@ -135,8 +135,8 @@ void MainWindow::updateForEncodingInfo() {
if (editor!=NULL) {
mFileEncodingStatus->setText(
QString("%1(%2)")
.arg(QString(editor->encodingOption()))
.arg(QString(editor->fileEncoding())));
.arg(QString(editor->encodingOption())
,QString(editor->fileEncoding())));
ui->actionAuto_Detect->setChecked(editor->encodingOption() == ENCODING_AUTO_DETECT);
ui->actionEncode_in_ANSI->setChecked(editor->encodingOption() == ENCODING_SYSTEM_DEFAULT);
ui->actionEncode_in_UTF_8->setChecked(editor->encodingOption() == ENCODING_UTF8);
@ -304,23 +304,25 @@ void MainWindow::updateAppTitle()
else
str = e->filename();
if (mDebugger->executing()) {
setWindowTitle(QString("%1 - [%2] - %3 %4").arg(str).arg(appName)
.arg(tr("Debugging")).arg(DEVCPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3").arg(str).arg(appName)
.arg(tr("Debugging")));
setWindowTitle(QString("%1 - [%2] - %3 %4")
.arg(str,appName,tr("Debugging"),DEVCPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,appName,tr("Debugging")));
} else if (mCompilerManager->running()) {
setWindowTitle(QString("%1 - [%2] - %3 %4").arg(str).arg(appName)
.arg(tr("Running")).arg(DEVCPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3").arg(str).arg(appName)
.arg(tr("Running")));
setWindowTitle(QString("%1 - [%2] - %3 %4")
.arg(str,appName,tr("Running"),DEVCPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,appName,tr("Running")));
} else if (mCompilerManager->compiling()) {
setWindowTitle(QString("%1 - [%2] - %3 %4").arg(str).arg(appName)
.arg(tr("Compiling")).arg(DEVCPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3").arg(str).arg(appName)
.arg(tr("Compiling")));
setWindowTitle(QString("%1 - [%2] - %3 %4")
.arg(str,appName,tr("Compiling"),DEVCPP_VERSION));
app->setApplicationName(QString("%1 - [%2] - %3")
.arg(str,appName,tr("Compiling")));
} else {
this->setWindowTitle(QString("%1 - %2 %3").arg(str).arg(appName).arg(DEVCPP_VERSION));
app->setApplicationName(QString("%1 - %2").arg(str).arg(appName));
this->setWindowTitle(QString("%1 - %2 %3")
.arg(str,appName,DEVCPP_VERSION));
app->setApplicationName(QString("%1 - %2")
.arg(str,appName));
}
}
// else if Assigned(fProject) then begin
@ -342,7 +344,7 @@ void MainWindow::updateAppTitle()
// Application.Title := Format('%s - %s', [fProject.Name, appName]);
// end;
else {
setWindowTitle(QString("%1 %2").arg(appName).arg(DEVCPP_VERSION));
setWindowTitle(QString("%1 %2").arg(appName,DEVCPP_VERSION));
app->setApplicationName(QString("%1").arg(appName));
}
}
@ -370,7 +372,7 @@ void MainWindow::updateDebugEval(const QString &value)
void MainWindow::rebuildOpenedFileHisotryMenu()
{
mMenuRecentFiles->clear();
for (QAction* action:mRecentFileActions) {
foreach (QAction* action,mRecentFileActions) {
action->setParent(nullptr);
action->deleteLater();
}
@ -379,10 +381,10 @@ void MainWindow::rebuildOpenedFileHisotryMenu()
mMenuRecentFiles->setEnabled(false);
} else {
mMenuRecentFiles->setEnabled(true);
for (QString filename: pSettings->history().openedFiles()) {
for (const QString& filename: pSettings->history().openedFiles()) {
QAction* action = new QAction();
action->setText(filename);
connect(action, &QAction::triggered, [filename,this](bool checked = false){
connect(action, &QAction::triggered, [&filename,this](bool){
this->openFile(filename);
});
mRecentFileActions.append(action);
@ -471,7 +473,7 @@ void MainWindow::openFiles(const QStringList &files)
auto end = finally([this] {
this->mEditorList->endUpdate();
});
for (QString file:files) {
for (const QString& file:files) {
openFile(file);
}
mEditorList->endUpdate();
@ -804,16 +806,16 @@ void MainWindow::debug()
updateEditorActions();
// Add library folders
for (QString dir:compilerSet->libDirs()) {
foreach (QString dir,compilerSet->libDirs()) {
mDebugger->sendCommand("dir",
QString("\"%1\"").arg(dir.replace('\\','/')));
}
// Add include folders
for (QString dir:compilerSet->CIncludeDirs()) {
foreach (QString dir,compilerSet->CIncludeDirs()) {
mDebugger->sendCommand("dir",
QString("\"%1\"").arg(dir.replace('\\','/')));
}
for (QString dir:compilerSet->CppIncludeDirs()) {
foreach (QString dir,compilerSet->CppIncludeDirs()) {
mDebugger->sendCommand("dir",
QString("\"%1\"").arg(dir.replace('\\','/')));
}
@ -1123,7 +1125,7 @@ void MainWindow::onCompileFinished()
if (issue->type == CompileIssueType::Error) {
ui->tableIssues->selectRow(i);
QModelIndex index =ui->tableIssues->model()->index(i,0);
ui->tableIssues->doubleClicked(index);
emit ui->tableIssues->doubleClicked(index);
}
}
@ -1133,7 +1135,7 @@ void MainWindow::onCompileFinished()
if (issue->type == CompileIssueType::Warning) {
ui->tableIssues->selectRow(i);
QModelIndex index =ui->tableIssues->model()->index(i,0);
ui->tableIssues->doubleClicked(index);
emit ui->tableIssues->doubleClicked(index);
}
}
// Then try to find anything with a line number...
@ -1452,13 +1454,13 @@ bool MainWindow::debugInferiorhasBreakpoint()
if (e==nullptr)
return false;
if (!e->inProject()) {
for (PBreakpoint breakpoint:mDebugger->breakpointModel()->breakpoints()) {
for (const PBreakpoint& breakpoint:mDebugger->breakpointModel()->breakpoints()) {
if (e->filename() == breakpoint->filename) {
return true;
}
}
} else {
for (PBreakpoint breakpoint:mDebugger->breakpointModel()->breakpoints()) {
for (const PBreakpoint& breakpoint:mDebugger->breakpointModel()->breakpoints()) {
Editor* e1 = mEditorList->getOpenedEditorByFilename(breakpoint->filename);
if (e1->inProject()) {
return true;

View File

@ -381,7 +381,7 @@ PStatement CppParser::findStatementStartingFrom(const QString &fileName, const Q
return result;
// not found
// search members of all usings (in current scope )
for (const QString& namespaceName:scopeStatement->usingList) {
foreach (const QString& namespaceName, scopeStatement->usingList) {
result = findStatementInNamespace(phrase,namespaceName);
if (result)
return result;
@ -514,7 +514,7 @@ QSet<QString> CppParser::getFileIncludes(const QString &filename)
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
if (fileIncludes) {
for (const QString& file: fileIncludes->includeFiles.keys()) {
foreach (const QString& file, fileIncludes->includeFiles.keys()) {
list.insert(file);
}
}
@ -636,7 +636,7 @@ void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNo
mFilesScannedCount = 0;
// parse header files in the first parse
for (const QString& file:files) {
foreach (const QString& file,files) {
if (isHfile(file)) {
mFilesScannedCount++;
emit onProgress(file,mFilesToScanCount,mFilesScannedCount);
@ -646,7 +646,7 @@ void CppParser::parseFile(const QString &fileName, bool inProject, bool onlyIfNo
}
}
//we only parse CFile in the second parse
for (const QString& file:files) {
foreach (const QString& file,files) {
if (isCfile(file)) {
mFilesScannedCount++;
emit onProgress(file,mFilesToScanCount,mFilesScannedCount);
@ -684,7 +684,7 @@ void CppParser::parseFileList(bool updateView)
mFilesScannedCount = 0;
mFilesToScanCount = mFilesToScan.count();
// parse header files in the first parse
for (const QString& file:mFilesToScan) {
foreach (const QString& file, mFilesToScan) {
if (isHfile(file)) {
mFilesScannedCount++;
emit onProgress(mCurrentFile,mFilesToScanCount,mFilesScannedCount);
@ -694,7 +694,7 @@ void CppParser::parseFileList(bool updateView)
}
}
//we only parse CFile in the second parse
for (const QString& file:mFilesToScan) {
foreach (const QString& file,mFilesToScan) {
if (isCfile(file)) {
mFilesScannedCount++;
emit onProgress(mCurrentFile,mFilesToScanCount,mFilesScannedCount);
@ -2274,7 +2274,7 @@ void CppParser::handlePreprocessor()
// Mention progress to user if we enter a NEW file
bool ok;
int line = s.mid(delimPos+1).toInt(&ok);
int line = s.midRef(delimPos+1).toInt(&ok);
if (line == 1) {
mFilesScannedCount++;
mFilesToScanCount++;
@ -3008,7 +3008,7 @@ void CppParser::inheritClassStatement(const PStatement& derived, bool isStruct,
else
access = StatementClassScope::scsPrivate;
}
for (const PStatement& statement : base->children) {
foreach (const PStatement& statement, base->children) {
if (statement->classScope == StatementClassScope::scsPrivate
|| statement->kind == StatementKind::skConstructor
|| statement->kind == StatementKind::skDestructor)
@ -3085,7 +3085,7 @@ PStatement CppParser::findStatementInScope(const QString &name, const QString &n
PStatementList namespaceStatementsList = findNamespace(scope->command);
if (!namespaceStatementsList)
return PStatement();
for (const PStatement& namespaceStatement: *namespaceStatementsList) {
foreach (const PStatement& namespaceStatement, *namespaceStatementsList) {
PStatement result=doFindStatementInScope(name,noNameArgs,kind,namespaceStatement);
if (result)
return result;
@ -3112,7 +3112,7 @@ PStatement CppParser::findStatementInNamespace(const QString &name, const QStrin
PStatementList namespaceStatementsList=findNamespace(namespaceName);
if (!namespaceStatementsList)
return PStatement();
for (const PStatement& namespaceStatement:*namespaceStatementsList) {
foreach (const PStatement& namespaceStatement,*namespaceStatementsList) {
PStatement result = findMemberOfStatement(name,namespaceStatement);
if (result)
return result;
@ -3146,7 +3146,7 @@ PStatement CppParser::doFindStatementInScope(const QString &name,
{
const StatementMap& statementMap =mStatementList.childrenStatements(scope);
for (const PStatement& statement: statementMap.values(name)) {
foreach (const PStatement& statement, statementMap.values(name)) {
if (statement->kind == kind && statement->noNameArgs == noNameArgs) {
return statement;
}
@ -3224,7 +3224,7 @@ QSet<QString> CppParser::calculateFilesToBeReparsed(const QString &fileName)
PFileIncludes p=mPreprocessor.includesList().value(name);
if (!p)
continue;
for (const QString& s:p->dependedFiles) {
foreach (const QString& s,p->dependedFiles) {
if (!processed.contains(s)) {
queue.enqueue(s);
}

View File

@ -154,7 +154,7 @@ void CppPreprocessor::invalidDefinesInFile(const QString &fileName)
{
PDefineMap defineMap = mFileDefines.value(fileName,PDefineMap());
if (defineMap) {
for (const PDefine& define:*defineMap) {
foreach (const PDefine& define, *defineMap) {
const PDefine& p = mDefines.value(define->name);
if (p == define) {
mDefines.remove(define->name);
@ -186,26 +186,26 @@ void CppPreprocessor::dumpIncludesListTo(const QString &fileName) const
for (const PFileIncludes& fileIncludes:mIncludesList) {
stream<<fileIncludes->baseFile<<" : "<<Qt::endl;
stream<<"\t**includes:**"<<Qt::endl;
for (const QString& s:fileIncludes->includeFiles.keys()) {
foreach (const QString& s,fileIncludes->includeFiles.keys()) {
stream<<"\t--"+s<<Qt::endl;
}
stream<<"\t**depends on:**"<<Qt::endl;
for (const QString& s:fileIncludes->dependingFiles) {
foreach (const QString& s,fileIncludes->dependingFiles) {
stream<<"\t^^"+s<<Qt::endl;
}
stream<<"\t**depended by:**"<<Qt::endl;
for (const QString& s:fileIncludes->dependedFiles) {
foreach (const QString& s,fileIncludes->dependedFiles) {
stream<<"\t&&"+s<<Qt::endl;
}
stream<<"\t**using:**"<<Qt::endl;
for (const QString& s:fileIncludes->usings) {
foreach (const QString& s,fileIncludes->usings) {
stream<<"\t++"+s<<Qt::endl;
}
stream<<"\t**statements:**"<<Qt::endl;
for (PStatement& statement:fileIncludes->statements) {
foreach (const PStatement& statement,fileIncludes->statements) {
if (statement) {
stream<<QString("\t**%1 , %2").arg(statement->command)
.arg(statement->fullName)<<Qt::endl;
stream<<QString("\t**%1 , %2")
.arg(statement->command,statement->fullName)<<Qt::endl;
}
}
}
@ -709,7 +709,7 @@ void CppPreprocessor::addDefinesInFile(const QString &fileName)
//first add the defines in the files it included
PFileIncludes fileIncludes = getFileIncludesEntry(fileName);
if (fileIncludes) {
for (const QString& s:fileIncludes->includeFiles.keys()) {
foreach (const QString& s,fileIncludes->includeFiles.keys()) {
addDefinesInFile(s);
}
}
@ -717,7 +717,7 @@ void CppPreprocessor::addDefinesInFile(const QString &fileName)
// then add the defines defined in it
PDefineMap defineList = mFileDefines.value(fileName, PDefineMap());
if (defineList) {
for (const PDefine& define: defineList->values()) {
foreach (const PDefine& define, defineList->values()) {
mDefines.insert(define->name,define);
}
}
@ -739,7 +739,7 @@ void CppPreprocessor::parseArgs(PDefine define)
QString formatStr = "";
DefineArgTokenType lastTokenType=DefineArgTokenType::Other;
int index;
for (const PDefineArgToken& token: tokens) {
foreach (const PDefineArgToken& token, tokens) {
switch(token->type) {
case DefineArgTokenType::Identifier:
index = define->argList.indexOf(token->value);
@ -872,7 +872,7 @@ QStringList CppPreprocessor::removeComments(const QStringList &text)
currentType=ContentType::Other;
break;
case ContentType::RawString:
if (line.mid(0,pos).endsWith(')'+delimiter))
if (line.midRef(0,pos).endsWith(')'+delimiter))
currentType = ContentType::Other;
break;
case ContentType::Other:

View File

@ -50,7 +50,7 @@ void CppTokenizer::dumpTokens(const QString &fileName)
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QTextStream stream(&file);
for (const PToken& token:mTokenList) {
foreach (const PToken& token,mTokenList) {
stream<<QString("%1,%2").arg(token->line).arg(token->text)<<Qt::endl;
}
}
@ -149,7 +149,7 @@ QString CppTokenizer::getNextToken(bool bSkipParenthesis, bool bSkipArray, bool
int delimPos = result.lastIndexOf(':');
if (delimPos >= 0) {
bool ok;
mCurrentLine = result.mid(delimPos+1).toInt(&ok)-1; // fCurrLine is 0 based
mCurrentLine = result.midRef(delimPos+1).toInt(&ok)-1; // fCurrLine is 0 based
}
}
done = (result != "");
@ -369,7 +369,7 @@ void CppTokenizer::simplifyArgs(QString &output)
QString temp;
QString lastSpace = "";
bool parentheseStart = true;
for (const QChar& ch:output.trimmed()) {
foreach (const QChar& ch,output.trimmed()) {
if (isSpaceChar(ch)) {
if (!parentheseStart)
lastSpace+=ch;

View File

@ -4,6 +4,7 @@
#include <QFile>
#include <QFileInfo>
#include <QDebug>
#include <QGlobalStatic>
QStringList CppDirectives;
QStringList JavadocTags;
@ -14,25 +15,25 @@ QSet<QString> STLPointers;
QSet<QString> STLContainers;
QSet<QString> STLElementMethods;
static QSet<QString> CppHeaderExts;
static QSet<QString> CppSourceExts;
Q_GLOBAL_STATIC(QSet<QString>,CppHeaderExts)
Q_GLOBAL_STATIC(QSet<QString>,CppSourceExts)
void initParser()
{
CppHeaderExts.insert("h");
CppHeaderExts.insert("hpp");
CppHeaderExts.insert("rh");
CppHeaderExts.insert("hh");
CppHeaderExts.insert("hxx");
CppHeaderExts.insert("inl");
CppHeaderExts.insert("");
CppHeaderExts->insert("h");
CppHeaderExts->insert("hpp");
CppHeaderExts->insert("rh");
CppHeaderExts->insert("hh");
CppHeaderExts->insert("hxx");
CppHeaderExts->insert("inl");
CppHeaderExts->insert("");
CppSourceExts.insert("c");
CppSourceExts.insert("cpp");
CppSourceExts.insert("cc");
CppSourceExts.insert("cxx");
CppSourceExts.insert("c++");
CppSourceExts.insert("cp");
CppSourceExts->insert("c");
CppSourceExts->insert("cpp");
CppSourceExts->insert("cc");
CppSourceExts->insert("cxx");
CppSourceExts->insert("c++");
CppSourceExts->insert("cp");
// skip itself
CppKeywords.insert("and",SkipType::skItself);
CppKeywords.insert("and_eq",SkipType::skItself);
@ -393,7 +394,7 @@ bool isHfile(const QString& filename)
return false;
QFileInfo fileInfo(filename);
return CppHeaderExts.contains(fileInfo.suffix().toLower());
return CppHeaderExts->contains(fileInfo.suffix().toLower());
}
@ -403,7 +404,7 @@ bool isCfile(const QString& filename)
return false;
QFileInfo fileInfo(filename);
return CppSourceExts.contains(fileInfo.suffix().toLower());
return CppSourceExts->contains(fileInfo.suffix().toLower());
}
PStatement CppScopes::findScopeAtLine(int line)

View File

@ -120,10 +120,10 @@ int StatementModel::deleteMember(StatementMap &map, const PStatement& statement)
void StatementModel::dumpStatementMap(StatementMap &map, QTextStream &out, int level)
{
QString indent(level,'\t');
for (PStatement statement:map.values()) {
foreach (const PStatement& statement,map) {
out<<indent<<QString("%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12")
.arg(statement->command).arg(int(statement->kind))
.arg(statement->type).arg(statement->fullName)
.arg(statement->type,statement->fullName)
.arg((size_t)(statement->parentScope.lock().get()))
.arg((int)statement->classScope)
.arg(statement->fileName)

View File

@ -570,8 +570,6 @@ int StrScanForNonWordChar(const QString &s, int startPos)
int StrRScanForWordChar(const QString &s, int startPos)
{
int i = startPos-1;
if (i>s.length())
return 0;
while (i>=0) {
if (isWordChar(s[i]))
return i+1;
@ -583,8 +581,6 @@ int StrRScanForWordChar(const QString &s, int startPos)
int StrRScanForNonWordChar(const QString &s, int startPos)
{
int i = startPos-1;
if (i>s.length())
return 0;
while (i>=0) {
if (!isWordChar(s[i]))
return i+1;

View File

@ -56,7 +56,7 @@ int SynSearch::findAll(const QString &keyword)
return mResults.size();
}
QString SynSearch::replace(const QString &aOccurrence, const QString &aReplacement)
QString SynSearch::replace(const QString &, const QString &aReplacement)
{
return aReplacement;
}

View File

@ -297,7 +297,7 @@ void SynEdit::setInsertMode(bool value)
if (mInserting != value) {
mInserting = value;
updateCaret();
statusChanged(scInsertMode);
emit statusChanged(scInsertMode);
}
}
@ -1179,7 +1179,7 @@ BufferCoord SynEdit::WordStartEx(const BufferCoord &XY)
// valid line?
if ((CY >= 1) && (CY <= mLines->count())) {
QString Line = mLines->getString(CY - 1);
CX = std::min(CX, Line.length()+1);
CX = std::min(CX, Line.length());
if (CX-1 >= 0) {
if (!(Line[CX - 1].isSpace()))
CX = StrRScanForNonWordChar(Line, CX - 1) + 1;
@ -1539,7 +1539,7 @@ void SynEdit::doDeleteLastChar()
setCaretX(newCaretX);
updateLastCaretX();
mStateFlags.setFlag(SynStateFlag::sfCaretChanged);
statusChanged(SynStatusChange::scCaretX);
emit statusChanged(SynStatusChange::scCaretX);
} else {
// delete char
internalSetCaretX(mCaretX - 1);
@ -2635,7 +2635,7 @@ void SynEdit::recalcCharExtent()
bool hasStyles[] = {false,false,false,false};
int size = 4;
if (mHighlighter && mHighlighter->attributes().count()>0) {
for (PSynHighlighterAttribute attribute: mHighlighter->attributes().values()) {
for (const PSynHighlighterAttribute& attribute: mHighlighter->attributes()) {
for (int i=0;i<size;i++) {
if (attribute->styles().testFlag(styles[i]))
hasStyles[i] = true;
@ -3003,7 +3003,7 @@ PSynEditFoldRange SynEdit::collapsedFoldStartAtLine(int Line)
return PSynEditFoldRange();
}
void SynEdit::doOnPaintTransientEx(SynTransientType TransientType, bool Lock)
void SynEdit::doOnPaintTransientEx(SynTransientType , bool )
{
//todo: we can't draw to canvas outside paintEvent
}
@ -3243,7 +3243,7 @@ void SynEdit::setReadOnly(bool readOnly)
{
if (mReadOnly != readOnly) {
mReadOnly = readOnly;
statusChanged(scReadOnly);
emit statusChanged(scReadOnly);
}
}
@ -3870,7 +3870,7 @@ QString SynEdit::selText()
result += mLines->getString(i);
result+=lineBreak();
}
result += mLines->getString(Last).left(ColTo-1);
result += mLines->getString(Last).leftRef(ColTo-1);
return result;
}
case SynSelectionMode::smColumn:
@ -4340,7 +4340,7 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
return result;
}
void SynEdit::DoLinesDeleted(int FirstLine, int Count)
void SynEdit::DoLinesDeleted(int , int )
{
// // gutter marks
// for i := 0 to Marks.Count - 1 do begin
@ -4356,7 +4356,7 @@ void SynEdit::DoLinesDeleted(int FirstLine, int Count)
// end;
}
void SynEdit::DoLinesInserted(int FirstLine, int Count)
void SynEdit::DoLinesInserted(int , int )
{
// // gutter marks
// for i := 0 to Marks.Count - 1 do begin
@ -4606,7 +4606,7 @@ int SynEdit::InsertTextByLineMode(const QString &Value)
QString Str;
int Result = 0;
mCaretX = 1;
statusChanged(SynStatusChange::scCaretX);
emit statusChanged(SynStatusChange::scCaretX);
// Insert string before current line
Start = 0;
do {
@ -4659,12 +4659,12 @@ void SynEdit::onGetEditingAreas(int, SynEditingAreaList &)
}
void SynEdit::onGutterGetText(int aLine, QString &aText)
void SynEdit::onGutterGetText(int , QString &)
{
}
void SynEdit::onGutterPaint(QPainter &painter, int aLine, int X, int Y)
void SynEdit::onGutterPaint(QPainter &, int , int , int )
{
}
@ -4674,7 +4674,8 @@ void SynEdit::onPaint(QPainter &)
}
void SynEdit::onPreparePaintHighlightToken(int row, int column, const QString &token, PSynHighlighterAttribute attr, SynFontStyles &style, QColor &foreground, QColor &background)
void SynEdit::onPreparePaintHighlightToken(int , int , const QString &,
PSynHighlighterAttribute , SynFontStyles &, QColor &, QColor &)
{
}
@ -5188,7 +5189,7 @@ void SynEdit::paintEvent(QPaintEvent *event)
paintCaret(painter, rcCaret);
}
void SynEdit::resizeEvent(QResizeEvent *e)
void SynEdit::resizeEvent(QResizeEvent *)
{
//resize the cache image
std::shared_ptr<QImage> image = std::make_shared<QImage>(clientWidth(),clientHeight(),
@ -5407,7 +5408,7 @@ void SynEdit::inputMethodEvent(QInputMethodEvent *event)
}
}
void SynEdit::leaveEvent(QEvent *event)
void SynEdit::leaveEvent(QEvent *)
{
setCursor(Qt::ArrowCursor);
}
@ -5458,7 +5459,7 @@ void SynEdit::setModified(bool Value)
if (mOptions.testFlag(SynEditorOption::eoGroupUndo) && (!Value) && mUndoList->CanUndo())
mUndoList->AddGroupBreak();
mUndoList->setInitialState(!Value);
statusChanged(SynStatusChange::scModified);
emit statusChanged(SynStatusChange::scModified);
}
}

View File

@ -273,7 +273,7 @@ void SynEditStringList::addStrings(const QStringList &Strings)
int SynEditStringList::getTextLength()
{
int Result = 0;
for (const PSynEditStringRec& line: mList ) {
foreach (const PSynEditStringRec& line, mList ) {
Result += line->fString.length();
if (mFileEndingType == FileEndingType::Windows) {
Result += 2;
@ -783,7 +783,7 @@ void SynEditUndoList::PushItem(PSynEditUndoItem Item)
mItems.append(Item);
EnsureMaxEntries();
if (Item->changeReason()!= SynChangeReason::crGroupBreak)
addedUndo();
emit addedUndo();
}
void SynEditUndoList::Unlock()

View File

@ -22,7 +22,6 @@ void SynEditTextPainter::paintTextLines(const QRect& clip)
bCurrentLine = false;
// If the right edge is visible and in the invalid area, prepare to paint it.
// Do this first to realize the pen when getting the dc variable.
QString SynTabGlyphString = SynTabGlyph;
bDoRightEdge = false;
if (edit->mRightEdge > 0) { // column value
nRightEdge = edit->textOffset()+ edit->mRightEdge * edit->mCharWidth; // pixel value
@ -75,7 +74,6 @@ void SynEditTextPainter::paintGutter(const QRect& clip)
{
int cRow;
QRect rcLine, rcFold;
QList<int> aGutterOffs;
QString s;
int vLine;
int vLineTop;
@ -392,7 +390,7 @@ void SynEditTextPainter::PaintEditAreas(const SynEditingAreaList &areaList)
rc=rcLine;
rc.setBottom(rc.bottom()-1);
setDrawingColors(false);
for (PSynEditingArea p:areaList) {
for (const PSynEditingArea& p:areaList) {
if (p->beginX > LastCol)
continue;
if (p->endX < FirstCol)
@ -536,7 +534,6 @@ void SynEditTextPainter::PaintHighlightToken(bool bFillToEOL)
bool SynEditTextPainter::TokenIsSpaces(bool &bSpacesTest, const QString& Token, bool& bIsSpaces)
{
QString pTok;
if (!bSpacesTest) {
bSpacesTest = true;
for (QChar ch:Token) {
@ -622,7 +619,6 @@ void SynEditTextPainter::AddHighlightToken(const QString &Token, int ColumnsBefo
void SynEditTextPainter::PaintFoldAttributes()
{
int TabSteps, LineIndent, LastNonBlank, X, Y, cRow, vLine;
QBrush DottedPenDesc;
// Paint indent guides. Use folds to determine indent value of these
// Use a separate loop so we can use a custom pen
// Paint indent guides using custom pen
@ -933,7 +929,7 @@ void SynEditTextPainter::PaintLines()
}
}
void SynEditTextPainter::drawMark(PSynEditMark aMark, int &aGutterOff, int aMarkRow)
void SynEditTextPainter::drawMark(PSynEditMark , int &, int )
{
//todo
}

View File

@ -1259,7 +1259,7 @@ QStringList &Settings::CompilerSet::libDirs()
return mLibDirs;
}
const QString &Settings::CompilerSet::dumpMachine()
const QString &Settings::CompilerSet::dumpMachine() const
{
return mDumpMachine;
}
@ -1269,7 +1269,7 @@ void Settings::CompilerSet::setDumpMachine(const QString &value)
mDumpMachine = value;
}
const QString &Settings::CompilerSet::version()
const QString &Settings::CompilerSet::version() const
{
return mVersion;
}
@ -1279,7 +1279,7 @@ void Settings::CompilerSet::setVersion(const QString &value)
mVersion = value;
}
const QString &Settings::CompilerSet::type()
const QString &Settings::CompilerSet::type() const
{
return mType;
}
@ -1289,7 +1289,7 @@ void Settings::CompilerSet::setType(const QString& value)
mType = value;
}
const QString &Settings::CompilerSet::name()
const QString &Settings::CompilerSet::name() const
{
return mName;
}
@ -1299,12 +1299,12 @@ void Settings::CompilerSet::setName(const QString &value)
mName = value;
}
QStringList& Settings::CompilerSet::defines()
const QStringList& Settings::CompilerSet::defines() const
{
return mDefines;
}
const QString &Settings::CompilerSet::target()
const QString &Settings::CompilerSet::target() const
{
return mTarget;
}
@ -1319,7 +1319,7 @@ void Settings::CompilerSet::setUseCustomCompileParams(bool value)
mUseCustomCompileParams = value;
}
bool Settings::CompilerSet::useCustomLinkParams()
bool Settings::CompilerSet::useCustomLinkParams() const
{
return mUseCustomLinkParams;
}
@ -1329,7 +1329,7 @@ void Settings::CompilerSet::setUseCustomLinkParams(bool value)
mUseCustomLinkParams = value;
}
const QString &Settings::CompilerSet::customCompileParams()
const QString &Settings::CompilerSet::customCompileParams() const
{
return mCustomCompileParams;
}
@ -1339,7 +1339,7 @@ void Settings::CompilerSet::setCustomCompileParams(const QString &value)
mCustomCompileParams = value;
}
const QString &Settings::CompilerSet::customLinkParams()
const QString &Settings::CompilerSet::customLinkParams() const
{
return mCustomLinkParams;
}
@ -1349,7 +1349,7 @@ void Settings::CompilerSet::setCustomLinkParams(const QString &value)
mCustomLinkParams = value;
}
bool Settings::CompilerSet::autoAddCharsetParams()
bool Settings::CompilerSet::autoAddCharsetParams() const
{
return mAutoAddCharsetParams;
}
@ -1784,7 +1784,7 @@ QString Settings::CompilerSet::findProgramInBinDirs(const QString name)
QByteArray Settings::CompilerSet::iniOptions() const
{
QByteArray result;
for (PCompilerOption p:mOptions) {
for (const PCompilerOption& p:mOptions) {
result.append(ValueToChar[p->value]);
}
return result;
@ -1808,14 +1808,14 @@ QByteArray Settings::CompilerSet::getCompilerOutput(const QString &binDir, const
return result.trimmed();
}
bool Settings::CompilerSet::useCustomCompileParams()
bool Settings::CompilerSet::useCustomCompileParams() const
{
return mUseCustomCompileParams;
}
Settings::CompilerSets::CompilerSets(Settings *settings):
mSettings(settings),
mDefaultIndex(-1)
mDefaultIndex(-1),
mSettings(settings)
{
}
@ -1914,7 +1914,7 @@ void Settings::CompilerSets::addSets(const QString &folder)
void Settings::CompilerSets::clearSets()
{
for (int i=0;i<mList.size();i++) {
for (size_t i=0;i<mList.size();i++) {
mSettings->mSettings.beginGroup(QString(SETTING_COMPILTER_SET).arg(i));
mSettings->mSettings.remove("");
mSettings->mSettings.endGroup();
@ -1932,7 +1932,7 @@ void Settings::CompilerSets::findSets()
void Settings::CompilerSets::saveSets()
{
for (int i=0;i<mList.size();i++) {
for (size_t i=0;i<mList.size();i++) {
saveSet(i);
}
if (mDefaultIndex>=mList.size()) {
@ -2395,12 +2395,12 @@ Settings::History::History(Settings *settings):_Base(settings, SETTING_HISTORY)
}
QStringList &Settings::History::openedFiles()
const QStringList &Settings::History::openedFiles() const
{
return mOpenedFiles;
}
QStringList &Settings::History::openedProjects()
const QStringList &Settings::History::openedProjects() const
{
return mOpenedProjects;
}

View File

@ -375,8 +375,8 @@ public:
public:
explicit History(Settings *settings);
QStringList& openedFiles();
QStringList& openedProjects();
const QStringList& openedFiles() const;
const QStringList& openedProjects() const;
bool addToOpenedFiles(const QString& filename);
private:
QStringList mOpenedFiles;
@ -488,27 +488,27 @@ public:
QStringList& CppIncludeDirs();
QStringList& libDirs();
const QString& dumpMachine();
const QString& dumpMachine() const;
void setDumpMachine(const QString& value);
const QString& version();
const QString& version() const;
void setVersion(const QString& value);
const QString& type();
const QString& type() const;
void setType(const QString& value);
const QString& name();
const QString& name() const;
void setName(const QString& value);
QStringList& defines();
const QString& target();
const QStringList& defines() const;
const QString& target() const;
void setTarget(const QString& value);
bool useCustomCompileParams();
bool useCustomCompileParams() const;
void setUseCustomCompileParams(bool value);
bool useCustomLinkParams();
bool useCustomLinkParams() const;
void setUseCustomLinkParams(bool value);
const QString& customCompileParams();
const QString& customCompileParams() const;
void setCustomCompileParams(const QString& value);
const QString& customLinkParams();
const QString& customLinkParams() const;
void setCustomLinkParams(const QString& value);
bool autoAddCharsetParams();
bool autoAddCharsetParams() const;
void setAutoAddCharsetParams(bool value);
CompilerOptionList& options();

View File

@ -708,6 +708,11 @@ bool CodeCompletionPopup::isIncluded(const QString &fileName)
return mIncludedFiles.contains(fileName);
}
const QString &CodeCompletionPopup::phrase() const
{
return mPhrase;
}
void CodeCompletionPopup::showEvent(QShowEvent *)
{
mListView->setFocus();

View File

@ -107,6 +107,7 @@ protected:
// QObject interface
public:
bool event(QEvent *event) override;
const QString &phrase() const;
};
#endif // CODECOMPLETIONPOPUP_H

View File

@ -88,6 +88,17 @@ void HeaderCompletionPopup::setSuggestionColor(const QColor &color)
mModel->setColor(color);
}
QString HeaderCompletionPopup::selectedFilename()
{
if (!isEnabled())
return "";
int index = mListView->currentIndex().row();
if (index>=0 && index<mCompletionList.count())
return mCompletionList[index];
else
return "";
}
void HeaderCompletionPopup::filterList(const QString &member)
{
mCompletionList.clear();
@ -149,8 +160,10 @@ void HeaderCompletionPopup::addFilesInPath(const QString &path)
if (!dir.exists())
return;
foreach (const QFileInfo& fileInfo, dir.entryInfoList()) {
if (fileInfo.fileName().startsWith("."))
continue;
QString suffix = fileInfo.suffix().toLower();
if (suffix == ".h" || suffix == ".hpp" || suffix == "") {
if (suffix == "h" || suffix == "hpp" || suffix == "") {
addFile(fileInfo.fileName());
}
}
@ -172,6 +185,36 @@ void HeaderCompletionPopup::addFilesInSubDir(const QString &baseDirPath, const Q
addFilesInPath(subDirPath);
}
bool HeaderCompletionPopup::searchLocal() const
{
return mSearchLocal;
}
void HeaderCompletionPopup::setSearchLocal(bool newSearchLocal)
{
mSearchLocal = newSearchLocal;
}
bool HeaderCompletionPopup::ignoreCase() const
{
return mIgnoreCase;
}
void HeaderCompletionPopup::setIgnoreCase(bool newIgnoreCase)
{
mIgnoreCase = newIgnoreCase;
}
const QString &HeaderCompletionPopup::phrase() const
{
return mPhrase;
}
void HeaderCompletionPopup::setParser(const PCppParser &newParser)
{
mParser = newParser;
}
void HeaderCompletionPopup::showEvent(QShowEvent *)
{
mListView->setFocus();

View File

@ -29,6 +29,7 @@ public:
bool search(const QString& phrase, bool autoHideOnSingleResult);
void setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback);
void setSuggestionColor(const QColor& color);
QString selectedFilename();
private:
void filterList(const QString& member);
@ -59,6 +60,12 @@ protected:
// QObject interface
public:
bool event(QEvent *event) override;
void setParser(const PCppParser &newParser);
const QString &phrase() const;
bool ignoreCase() const;
void setIgnoreCase(bool newIgnoreCase);
bool searchLocal() const;
void setSearchLocal(bool newSearchLocal);
};
#endif // HEADERCOMPLETIONPOPUP_H