From a6f334f8377263f971a6f696b8c292bfb5d7c587 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 4 Jul 2022 11:39:06 +0800 Subject: [PATCH] remove all warnings --- RedPandaIDE/cpprefacter.cpp | 2 +- RedPandaIDE/cpprefacter.h | 2 +- RedPandaIDE/debugger.cpp | 32 +- RedPandaIDE/editor.cpp | 11 +- RedPandaIDE/editor.h | 2 +- RedPandaIDE/mainwindow.cpp | 42 +- RedPandaIDE/parser/cpppreprocessor.cpp | 81 ++- RedPandaIDE/parser/cpptokenizer.cpp | 7 +- RedPandaIDE/parser/statementmodel.cpp | 22 +- RedPandaIDE/project.cpp | 101 +++- RedPandaIDE/projecttemplate.cpp | 42 +- RedPandaIDE/qsynedit/CodeFolding.cpp | 2 +- RedPandaIDE/qsynedit/MiscProcs.cpp | 460 +----------------- RedPandaIDE/qsynedit/MiscProcs.h | 67 +-- RedPandaIDE/qsynedit/SynEdit.cpp | 30 +- RedPandaIDE/qsynedit/SynEdit.h | 2 +- RedPandaIDE/qsynedit/TextBuffer.cpp | 6 +- RedPandaIDE/qsynedit/TextPainter.cpp | 1 - .../qsynedit/exporter/synhtmlexporter.cpp | 4 +- RedPandaIDE/qsynedit/highlighter/asm.cpp | 6 +- RedPandaIDE/qsynedit/highlighter/base.cpp | 11 + RedPandaIDE/qsynedit/highlighter/base.h | 1 + RedPandaIDE/settings.cpp | 12 +- .../compilersetdirectorieswidget.cpp | 2 +- .../compilersetoptionwidget.cpp | 6 +- .../settingsdialog/executorgeneralwidget.cpp | 2 +- .../settingsdialog/projectcompilerwidget.cpp | 4 +- .../settingsdialog/projectgeneralwidget.cpp | 8 + RedPandaIDE/settingsdialog/settingswidget.cpp | 4 +- RedPandaIDE/settingsdialog/toolsgitwidget.cpp | 2 +- RedPandaIDE/utils.cpp | 21 +- RedPandaIDE/utils.h | 2 +- RedPandaIDE/vcs/gitlogdialog.cpp | 4 +- .../widgets/codecompletionlistview.cpp | 2 +- RedPandaIDE/widgets/macroinfomodel.cpp | 2 +- RedPandaIDE/widgets/newclassdialog.cpp | 2 +- RedPandaIDE/widgets/ojproblemsetmodel.cpp | 2 +- RedPandaIDE/widgets/searchdialog.ui | 2 +- 38 files changed, 364 insertions(+), 647 deletions(-) diff --git a/RedPandaIDE/cpprefacter.cpp b/RedPandaIDE/cpprefacter.cpp index 0f94dd88..81c6a952 100644 --- a/RedPandaIDE/cpprefacter.cpp +++ b/RedPandaIDE/cpprefacter.cpp @@ -106,7 +106,7 @@ static QString fullParentName(PStatement statement) { return ""; } } -void CppRefacter::renameSymbol(Editor *editor, const BufferCoord &pos, const QString &word, const QString &newWord) +void CppRefacter::renameSymbol(Editor *editor, const BufferCoord &pos, const QString &newWord) { if (!editor->parser()->freeze()) return; diff --git a/RedPandaIDE/cpprefacter.h b/RedPandaIDE/cpprefacter.h index 73d8503e..93af26f8 100644 --- a/RedPandaIDE/cpprefacter.h +++ b/RedPandaIDE/cpprefacter.h @@ -34,7 +34,7 @@ public: bool findOccurence(Editor * editor, const BufferCoord& pos); bool findOccurence(const QString& statementFullname, SearchFileScope scope); - void renameSymbol(Editor* editor, const BufferCoord& pos, const QString& word, const QString& newWord); + void renameSymbol(Editor* editor, const BufferCoord& pos, const QString& newWord); private: void doFindOccurenceInEditor(PStatement statement, Editor* editor, const PCppParser& parser); void doFindOccurenceInProject(PStatement statement, std::shared_ptr project, const PCppParser& parser); diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index be41eab0..f602db68 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -835,6 +835,8 @@ void DebugReader::processResult(const QByteArray &result) case GDBMIResultType::UpdateVarValue: handleUpdateVarValue(multiValues["changelist"].array()); return; + default: + return; } } @@ -2511,16 +2513,28 @@ void MemoryModel::updateMemory(const QStringList &value) QList newModel; for (int i=0;i(); memoryLine->startAddress = -1; if (dataLst.length()>0) { - memoryLine->startAddress = stringToHex(dataLst[0],0); - for (int j=1;j=0) - memoryLine->datas.append((unsigned char)data); + bool isOk; + memoryLine->startAddress = stringToHex(dataLst[0],isOk); + if (isOk) { + for (int j=1;jdatas.append((unsigned char)data); + else + memoryLine->datas.append(0); + } + } else { + memoryLine->startAddress=0; } + } newModel.append(memoryLine); } @@ -2551,12 +2565,12 @@ void MemoryModel::updateMemory(const QStringList &value) } } -int MemoryModel::rowCount(const QModelIndex &parent) const +int MemoryModel::rowCount(const QModelIndex &/*parent*/) const { return mLines.count(); } -int MemoryModel::columnCount(const QModelIndex &parent) const +int MemoryModel::columnCount(const QModelIndex &/*parent*/) const { return mDataPerLine; } @@ -2600,7 +2614,7 @@ bool MemoryModel::setData(const QModelIndex &index, const QVariant &value, int r if (role == Qt::EditRole && mStartAddress>0) { bool ok; unsigned char val = ("0x"+value.toString()).toUInt(&ok,16); - if (!ok || val>255) + if (!ok) return false; emit setMemoryData(mStartAddress+mDataPerLine*index.row()+col,val); return true; @@ -2608,7 +2622,7 @@ bool MemoryModel::setData(const QModelIndex &index, const QVariant &value, int r return false; } -Qt::ItemFlags MemoryModel::flags(const QModelIndex &index) const +Qt::ItemFlags MemoryModel::flags(const QModelIndex &/*index*/) const { Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; if (mStartAddress!=0) diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index c4928d85..207a3112 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -562,10 +562,6 @@ void Editor::focusOutEvent(QFocusEvent *event) pMainWindow->functionTip()->hide(); } -static bool isSpaceOrRightParenthesis(const QChar& ch) { - return ch.isSpace() || ch==')' || ch=="]" || ch=="}"; -} - void Editor::keyPressEvent(QKeyEvent *event) { bool handled = false; @@ -3427,7 +3423,7 @@ QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/ if (statement->kind == StatementKind::skFunction || statement->kind == StatementKind::skConstructor || statement->kind == StatementKind::skDestructor) { - PStatement parentScope = statement->parentScope.lock(); + //PStatement parentScope = statement->parentScope.lock(); // if (parentScope && parentScope->kind == StatementKind::skNamespace) { // PStatementList namespaceStatementsList = // mParser->findNamespace(parentScope->command); @@ -3449,8 +3445,7 @@ QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/ // } // } // } else - result = getHintForFunction(statement, parentScope, - mFilename,line); + result = getHintForFunction(statement,mFilename,line); } else if (statement->line>0) { QFileInfo fileInfo(statement->fileName); result = mParser->prettyPrintStatement(statement,mFilename, line) + " - " @@ -3494,7 +3489,7 @@ QString Editor::getErrorHint(const PSyntaxIssue& issue) } } -QString Editor::getHintForFunction(const PStatement &statement, const PStatement &scopeStatement, const QString& filename, int line) +QString Editor::getHintForFunction(const PStatement &statement, const QString& filename, int line) { QFileInfo fileInfo(statement->fileName); QString result; diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index 57fa6da9..c4493fa5 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -275,7 +275,7 @@ private: QString getParserHint(const QStringList& expression,const QString& s, int line); void showDebugHint(const QString& s,int line); QString getErrorHint(const PSyntaxIssue& issue); - QString getHintForFunction(const PStatement& statement, const PStatement& scope, + QString getHintForFunction(const PStatement& statement, const QString& filename, int line); void updateFunctionTip(bool showTip); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 492d1137..0135f150 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -835,7 +835,7 @@ void MainWindow::setActiveBreakpoint(QString FileName, int Line, bool setFocus) } } -void MainWindow::updateDPI(int oldDPI, int newDPI) +void MainWindow::updateDPI(int oldDPI, int /*newDPI*/) { //applySettings(); if (oldDPI<1) @@ -6436,6 +6436,8 @@ void MainWindow::on_actionRename_Symbol_triggered() Editor * editor = mEditorList->getEditor(); if (!editor) return; + if (!editor->parser()) + return; editor->beginUpdate(); BufferCoord oldCaretXY = editor->caretXY(); // mClassBrowserModel.beginUpdate(); @@ -6446,16 +6448,12 @@ void MainWindow::on_actionRename_Symbol_triggered() // mClassBrowserModel.EndTreeUpdate; editor->setCursor(oldCursor); }); - QString word = editor->wordAtCursor(); - if (word.isEmpty()) - return; -// if (!isIdentifier(word)) { -// return; -// } - - if (isCppKeyword(word)) { - return; + QStringList expression = editor->getExpressionAtPosition(oldCaretXY); + if (expression.isEmpty() && oldCaretXY.ch>1) { + BufferCoord coord=oldCaretXY; + coord.ch--; + expression = editor->getExpressionAtPosition(coord); } if (editor->inProject() && mProject) { @@ -6465,13 +6463,8 @@ void MainWindow::on_actionRename_Symbol_triggered() mProject->cppParser()->parseFile(editor->filename(), editor->inProject(), false, false); } } - QStringList expression = editor->getExpressionAtPosition(oldCaretXY); - if (expression.isEmpty() && oldCaretXY.ch>1) { - BufferCoord coord=oldCaretXY; - coord.ch--; - expression = editor->getExpressionAtPosition(coord); - } - // Find it's definition + + // Find it's definition PStatement oldStatement = editor->parser()->findStatementOf( editor->filename(), expression, @@ -6496,6 +6489,19 @@ void MainWindow::on_actionRename_Symbol_triggered() return; } } + //not in project + PStatement oldStatement = editor->parser()->findStatementOf( + editor->filename(), + expression, + oldCaretXY.line); + if (!oldStatement) + return; + QString word = oldStatement->command; + if (word.isEmpty()) + return; + if (isCppKeyword(word)) { + return; + } bool ok; QString newWord = QInputDialog::getText(editor, @@ -6515,7 +6521,7 @@ void MainWindow::on_actionRename_Symbol_triggered() } CppRefacter refactor; - refactor.renameSymbol(editor,oldCaretXY,word,newWord); + refactor.renameSymbol(editor,oldCaretXY,newWord); editor->reparse(); } diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index 507a8461..0c80eb05 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -208,7 +208,11 @@ void CppPreprocessor::dumpDefinesTo(const QString &fileName) const stream<name,define->args,define->value) .arg(define->hardCoded).arg(define->formatValue) +#if QT_VERSION_CHECK(5,15,0) + <baseFile<<" : "<baseFile<<" : " + #if QT_VERSION_CHECK(5,15,0) + <includeFiles.keys()) { - stream<<"\t--"+s<dependingFiles) { - stream<<"\t^^"+s<dependedFiles) { - stream<<"\t&&"+s<usings) { - stream<<"\t++"+s<statements) { if (statement) { stream<command,statement->fullName)<command,statement->fullName) + #if QT_VERSION_CHECK(5,15,0) + <line).arg(token->text)<line).arg(token->text) +#if QT_VERSION_CHECK(5,15,0) + <line) .arg(statement->definitionFileName) .arg(statement->definitionLine); - out<children.isEmpty()) continue; - out<command<<" {"<command<<" {" + #if QT_VERSION_CHECK(5,15,0) + <children,out,level+1); - out<compilerSets().defaultIndex()); mOptions.modelType = (ProjectModelType)ini.GetLongValue("Project", "ModelType", (int)ProjectModelType::Custom); - if (mOptions.compilerSet >= pSettings->compilerSets().size() + if (mOptions.compilerSet >= (int)pSettings->compilerSets().size() || mOptions.compilerSet < 0) { // TODO: change from indices to names QMessageBox::critical( nullptr, @@ -1685,9 +1739,27 @@ void Project::loadOptions(SimpleIni& ini) mOptions.type = ProjectType::GUI; mOptions.privateResource = fromByteArray(ini.GetValue("Project", "PrivateResource", "")); - mOptions.resourceIncludes = fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",QString::SkipEmptyParts); - mOptions.objFiles = fromByteArray(ini.GetValue("Project", "ObjFiles", "")).split(";",QString::SkipEmptyParts); - mOptions.includeDirs = fromByteArray(ini.GetValue("Project", "IncludeDirs", "")).split(";",QString::SkipEmptyParts); + mOptions.resourceIncludes = fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";", +#if QT_VERSION_CHECK(5,15,0) + Qt::SkipEmptyParts +#else + QString::SkipEmptyParts +#endif + ); + mOptions.objFiles = fromByteArray(ini.GetValue("Project", "ObjFiles", "")).split(";", +#if QT_VERSION_CHECK(5,15,0) + Qt::SkipEmptyParts +#else + QString::SkipEmptyParts +#endif + ); + mOptions.includeDirs = fromByteArray(ini.GetValue("Project", "IncludeDirs", "")).split(";", +#if QT_VERSION_CHECK(5,15,0) + Qt::SkipEmptyParts +#else + QString::SkipEmptyParts +#endif + ); mOptions.compilerCmd = fromByteArray(ini.GetValue("Project", "CompilerOptions", "")); mOptions.isCpp = ini.GetBoolValue("Project", "Use_GPP", false); mOptions.exeOutput = fromByteArray(ini.GetValue("Project", "ExeOutput", "")); @@ -2480,7 +2552,6 @@ bool ProjectModelSortFilterProxy::lessThan(const QModelIndex &source_left, const { if (!sourceModel()) return false; - ProjectModel* projectModel = dynamic_cast(sourceModel()); ProjectModelNode* pLeft=nullptr; if (source_left.isValid()) pLeft = static_cast(source_left.internalPointer()); diff --git a/RedPandaIDE/projecttemplate.cpp b/RedPandaIDE/projecttemplate.cpp index 57564fe5..5e74bb36 100644 --- a/RedPandaIDE/projecttemplate.cpp +++ b/RedPandaIDE/projecttemplate.cpp @@ -129,11 +129,43 @@ void ProjectTemplate::readTemplateFile(const QString &fileName) mOptions.icon = mIni->GetValue("Project", "Icon", ""); mOptions.type = static_cast(mIni->GetLongValue("Project", "Type", 0)); // default = gui - mOptions.objFiles = fromByteArray(mIni->GetValue("Project", "ObjFiles", "")).split(";",QString::SkipEmptyParts); - mOptions.includeDirs = fromByteArray(mIni->GetValue("Project", "Includes", "")).split(";",QString::SkipEmptyParts); - mOptions.binDirs = fromByteArray(mIni->GetValue("Project", "Bins", "")).split(";",QString::SkipEmptyParts); - mOptions.libDirs = fromByteArray(mIni->GetValue("Project", "Libs", "")).split(";",QString::SkipEmptyParts); - mOptions.resourceIncludes = fromByteArray(mIni->GetValue("Project", "ResourceIncludes", "")).split(";",QString::SkipEmptyParts); + mOptions.objFiles = fromByteArray(mIni->GetValue("Project", "ObjFiles", "")).split(";", +#if QT_VERSION_CHECK(5,15,0) + Qt::SkipEmptyParts +#else + QString::SkipEmptyParts +#endif + ); + mOptions.includeDirs = fromByteArray(mIni->GetValue("Project", "Includes", "")).split(";", +#if QT_VERSION_CHECK(5,15,0) + Qt::SkipEmptyParts +#else + QString::SkipEmptyParts +#endif + ); + mOptions.binDirs = fromByteArray(mIni->GetValue("Project", "Bins", "")).split(";", +#if QT_VERSION_CHECK(5,15,0) + Qt::SkipEmptyParts +#else + QString::SkipEmptyParts +#endif + ); + + mOptions.libDirs = fromByteArray(mIni->GetValue("Project", "Libs", "")).split(";", +#if QT_VERSION_CHECK(5,15,0) + Qt::SkipEmptyParts +#else + QString::SkipEmptyParts +#endif + ); + + mOptions.resourceIncludes = fromByteArray(mIni->GetValue("Project", "ResourceIncludes", "")).split(";", +#if QT_VERSION_CHECK(5,15,0) + Qt::SkipEmptyParts +#else + QString::SkipEmptyParts +#endif + ); mOptions.compilerCmd = fromByteArray(mIni->GetValue("Project", "Compiler", "")); mOptions.cppCompilerCmd = fromByteArray(mIni->GetValue("Project", "CppCompiler", "")); mOptions.linkerCmd = fromByteArray(mIni->GetValue("Project", "Linker","")); diff --git a/RedPandaIDE/qsynedit/CodeFolding.cpp b/RedPandaIDE/qsynedit/CodeFolding.cpp index 80f6e8c7..085f5ab5 100644 --- a/RedPandaIDE/qsynedit/CodeFolding.cpp +++ b/RedPandaIDE/qsynedit/CodeFolding.cpp @@ -39,8 +39,8 @@ PSynEditFoldRegion SynEditFoldRegions::get(int index) } SynEditCodeFolding::SynEditCodeFolding(): - fillIndents(false), indentGuides(true), + fillIndents(false), showCollapsedLine(true), collapsedLineColor(QColor("black")), folderBarLinesColor(QColor("black")), diff --git a/RedPandaIDE/qsynedit/MiscProcs.cpp b/RedPandaIDE/qsynedit/MiscProcs.cpp index 9c415549..c6d4d3d4 100644 --- a/RedPandaIDE/qsynedit/MiscProcs.cpp +++ b/RedPandaIDE/qsynedit/MiscProcs.cpp @@ -26,42 +26,6 @@ int minMax(int x, int mi, int ma) return std::max( x, mi ); } -void swapInt(int &l, int &r) -{ - int tmp = r; - r = l; - l = tmp; -} - -QPoint maxPoint(const QPoint &P1, const QPoint &P2) -{ - if ( (P2.y() > P1.y()) || ( (P2.y() == P1.y()) && (P2.x() > P1.x())) ) { - return P2; - } else { - return P1; - } -} - -QPoint minPoint(const QPoint &P1, const QPoint &P2) -{ - if ( (P2.y() < P1.y()) || ( (P2.y() == P1.y()) && (P2.x() < P1.x())) ) { - return P2; - } else { - return P1; - } -} - -PIntArray getIntArray(size_t Count, int InitialValue) -{ - return std::make_shared(Count,InitialValue); -} - -void internalFillRect(QPainter *painter, const QRect &rcPaint, const QColor& color) -{ - painter->fillRect(rcPaint,color); -} - - bool IsPowerOfTwo(int TabWidth) { if (TabWidth<2) return false; @@ -74,176 +38,6 @@ bool IsPowerOfTwo(int TabWidth) { return (nW == TabWidth); } -QString ConvertTabs1Ex(const QString &Line, int TabWidth, bool &HasTabs) { - QString Result = Line; // increment reference count only - int nBeforeTab; - if (GetHasTabs(Line, nBeforeTab)) { - QChar* pDest; - HasTabs = true; - pDest = Result.data()+nBeforeTab+1; - // this will make a copy of Line - // We have at least one tab in the string, and the tab width is 1. - // pDest points to the first tab char. We overwrite all tabs with spaces. - while (*pDest!=0) { - if (*pDest == '\t') { - *pDest = ' '; - }; - pDest++; - } - } else - HasTabs = false; - return Result; -} - -QString ConvertTabs1(const QString &Line, int TabWidth) { - bool HasTabs; - return ConvertTabs1Ex(Line, TabWidth, HasTabs); -} - -QString ConvertTabs2nEx(const QString &Line, int TabWidth, bool &HasTabs) { - QString Result = Line; // increment reference count only - int DestLen; - if (GetHasTabs(Line, DestLen)) { - HasTabs = true; - int pSrc = 1 + DestLen; - // We have at least one tab in the string, and the tab width equals 2^n. - // pSrc points to the first tab char in Line. We get the number of tabs - // and the length of the expanded string now. - int TabCount = 0; - int TabMask = (TabWidth - 1) ^ 0x7FFFFFFF; - do { - if (Line[pSrc] == '\t') { - DestLen = (DestLen + TabWidth) & TabMask; - TabCount++; - } else - DestLen ++ ; - } while (pSrc < Line.length()); - // Set the length of the expanded string. - Result.resize(DestLen); - DestLen = 0; - pSrc = 0; - QChar * pDest = Result.data(); - // We use another TabMask here to get the difference to 2^n. - TabMask = TabWidth - 1; - do { - if (Line[pSrc] == '\t') { - int i = TabWidth - (DestLen & TabMask); - DestLen += i; - //This is used for both drawing and other stuff and is meant to be #9 and not #32 - do { - *pDest = '\t'; - pDest ++ ; - i--; - } while (i > 0); - TabCount -- ; - if (TabCount == 0) { - do { - pSrc++ ; - *pDest = Line[pSrc]; - pDest++; - } while (pSrc < Line.length()); - return Result; - } - } else { - *pDest = Line[pSrc]; - pDest ++ ; - DestLen ++; - } - pSrc++; - } while (pSrc < Line.length()); - - } else - HasTabs = false; - return Result; -} - -QString ConvertTabs2n(const QString &Line, int TabWidth) { - bool HasTabs; - return ConvertTabs2nEx(Line, TabWidth, HasTabs); -} - -ConvertTabsProc GetBestConvertTabsProc(int TabWidth) -{ - if (TabWidth < 2) - return &ConvertTabs1; - else if (IsPowerOfTwo(TabWidth)) - return &ConvertTabs2n; - else - return &ConvertTabs; -} - -QString ConvertTabs(const QString &Line, int TabWidth) -{ - bool HasTabs; - return ConvertTabsEx(Line, TabWidth, HasTabs); -} - -ConvertTabsProcEx GetBestConvertTabsProcEx(int TabWidth) -{ - if (TabWidth < 2) - return &ConvertTabs1Ex; - else if (IsPowerOfTwo(TabWidth)) - return &ConvertTabs2nEx; - else - return &ConvertTabsEx; -} - -QString ConvertTabsEx(const QString &Line, int TabWidth, bool &HasTabs) -{ - QString Result = Line; // increment reference count only - int DestLen; - int pSrc; - QChar* pDest; - if (GetHasTabs(Line, DestLen)) { - HasTabs = true; - pSrc = (DestLen+1); - // We have at least one tab in the string, and the tab width is greater - // than 1. pSrc points to the first tab char in Line. We get the number - // of tabs and the length of the expanded string now. - int TabCount = 0; - do { - if (Line[pSrc] == '\t') { - DestLen = DestLen + TabWidth - DestLen % TabWidth; - TabCount++; - } else { - DestLen ++; - } - pSrc++; - } while (pSrc 1) { - if ((TabWidth <= 1) || !GetHasTabs(Line, iChar) ) { - Result = Index; - } else { - if (iChar + 1 >= Index) { - Result = Index; - } else { - // iChar is number of chars before first Tab - Result = iChar; - // Index is *not* zero-based - iChar++; - Index -= iChar; - int pNext = iChar; - while (Index > 0) { - if (pNext>=Line.length()) { - Result += Index; - break; - } - if (Line[pNext] == '\t') { - Result += TabWidth; - Result -= Result % TabWidth; - } else - Result++; - Index--; - pNext++; - } - // done with zero-based computation - Result++; - } - } - } else - Result = 1; - return Result; -} - -int CaretPos2CharIndex(int Position, int TabWidth, const QString &Line, bool &InsideTabChar) -{ - int Result; - int iPos; - InsideTabChar = false; - if (Position > 1) { - if ( (TabWidth <= 1) || !GetHasTabs(Line, iPos) ) { - Result = Position; - } else { - if (iPos + 1 >= Position) { - Result = Position; - } else { - // iPos is number of chars before first #9 - Result = iPos + 1; - int pNext = Result; - // for easier computation go zero-based (mod-operation) - Position -=1; - while (iPos < Position) { - if (pNext>=Line.length()) - break; - if (Line[pNext] == '\t') { - iPos+=TabWidth; - iPos-=iPos % TabWidth; - if (iPos > Position) { - InsideTabChar = true; - break; - } - } else - iPos++; - Result++; - pNext++; - } - } - } - } else - Result = Position; - return Result; -} - -int StrScanForCharInSet(const QString &Line, int Start, const QSet& AChars) -{ - for (int i=Start;i &AChars) -{ - for (int i=Line.size()-1;i>=Start;i--) { - if (AChars.contains(Line[i])) { - return i; - } - } - return -1; -} - -int GetEOL(const QString &Line, int start) +int getEOL(const QString &Line, int start) { if (start<0 || start>=Line.size()) { return start; @@ -385,57 +68,6 @@ int GetEOL(const QString &Line, int start) return Line.size(); } -QString EncodeString(const QString &s) -{ - QString Result; - Result.resize(s.length()*2); // worst case - int j=0; - for (const QChar& ch: s) { - if (ch == '\\' ) { - Result[j] = '\\'; - Result[j+1] = '\\'; - j+=2; - } else if (ch == '/') { - Result[j] = '\\'; - Result[j+1] = '.'; - j+=2; - } else { - Result[j]=ch; - j+=1; - } - } - Result.resize(j); - return Result; -} - -QString DecodeString(const QString &s) -{ - QString Result; - Result.resize(s.length()); // worst case - int j = 0; - int i = 0; - while (i < s.length()) { - if (i Params) { @@ -477,71 +109,6 @@ bool EnumHighlighterAttris(PSynHighlighter Highlighter, bool SkipDuplicates, highlighterAttriProc, Params, HighlighterList); } -uint16_t fcstab[] = { - 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, - 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, - 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, - 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, - 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, - 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, - 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, - 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, - 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, - 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, - 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, - 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, - 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, - 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, - 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, - 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, - 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, - 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, - 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, - 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, - 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, - 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, - 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, - 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, - 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, - 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, - 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, - 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, - 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, - 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, - 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, - 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 -}; - -uint16_t CalcFCS(unsigned char *ABuf, int ABufSize) -{ - uint16_t CurFCS = 0xffff; - unsigned char* P = ABuf; - while (ABufSize>0) { - CurFCS = (CurFCS >> 8) ^ fcstab[(CurFCS ^ *P) & 0xff]; - ABufSize -- ; - P ++ ; - } - return CurFCS; -} - -void SynDrawGradient(QPaintDevice *ACanvas, const QColor &AStartColor, const QColor &AEndColor, int , const QRect &ARect, bool AHorizontal) -{ - QPainter painter(ACanvas); - if (AHorizontal) { - int Size = ARect.right() - ARect.left(); - QLinearGradient gradient(0,0,Size,0); - gradient.setColorAt(0,AStartColor); - gradient.setColorAt(1,AEndColor); - painter.fillRect(ARect,gradient); - } else { - int Size = ARect.bottom() - ARect.top(); - QLinearGradient gradient(0,0,0,Size); - gradient.setColorAt(0,AStartColor); - gradient.setColorAt(1,AEndColor); - painter.fillRect(ARect,gradient); - } -} - int mulDiv(int a, int b, int c) { //todo: handle overflow? @@ -562,7 +129,7 @@ bool isWordChar(const QChar& ch) { return (ch == '_') || ch.isLetterOrNumber(); } -int StrScanForWordChar(const QString &s, int startPos) +int findWordChar(const QString &s, int startPos) { for (int i=startPos-1;i=0) { @@ -593,7 +160,7 @@ int StrRScanForWordChar(const QString &s, int startPos) return 0; } -int StrRScanForNonWordChar(const QString &s, int startPos) +int findLastNonWordChar(const QString &s, int startPos) { int i = startPos-1; while (i>=0) { @@ -604,21 +171,6 @@ int StrRScanForNonWordChar(const QString &s, int startPos) return 0; } -int CountLines(const QString &Line, int start) -{ - int Result = 0; - int i=start; - while (i cord2.line) || ( diff --git a/RedPandaIDE/qsynedit/MiscProcs.h b/RedPandaIDE/qsynedit/MiscProcs.h index cbb6a810..de4190c2 100644 --- a/RedPandaIDE/qsynedit/MiscProcs.h +++ b/RedPandaIDE/qsynedit/MiscProcs.h @@ -33,65 +33,17 @@ class QPainter; class QRect; class QColor; -using IntArray = QVector; -using PIntArray = std::shared_ptr; - int minMax(int x, int mi, int ma); int mulDiv(int a, int b, int c); -void swapInt(int& l, int &r); BufferCoord maxBufferCoord(const BufferCoord& P1, const BufferCoord& P2); BufferCoord minBufferCoord(const BufferCoord& P1, const BufferCoord& P2); -QPoint maxPoint(const QPoint& P1, const QPoint& P2); -QPoint minPoint(const QPoint& P1, const QPoint& P2); -PIntArray getIntArray(size_t Count, int InitialValue); - -void internalFillRect(QPainter* painter, const QRect& rcPaint, const QColor& color); - -// Converting tabs to spaces: To use the function several times it's better -// to use a function pointer that is set to the fastest conversion function. -using ConvertTabsProc = std::function; - -ConvertTabsProc GetBestConvertTabsProc(int TabWidth); - -// This is the slowest conversion function which can handle TabWidth <> 2^n. -QString ConvertTabs(const QString& Line, int TabWidth); - -using ConvertTabsProcEx = std::function; - -ConvertTabsProcEx GetBestConvertTabsProcEx(int TabWidth); -// This is the slowest conversion function which can handle TabWidth <> 2^n. -QString ConvertTabsEx(const QString& Line, int TabWidth, bool& HasTabs); - -bool GetHasTabs(const QString& line, int& CharsBefore); - -int GetExpandedLength(const QString& aStr, int aTabWidth); - -int CharIndex2CaretPos(int Index, int TabWidth, - const QString& Line); - -int CaretPos2CharIndex(int Position, int TabWidth, const QString& Line, - bool& InsideTabChar); - -// search for the first char of set AChars in Line, starting at index Start -int StrScanForCharInSet(const QString& Line, int Start, const QSet& AChars); -// the same, but searching backwards -int StrRScanForCharInSet(const QString& Line, int Start, const QSet& AChars); - -int GetEOL(const QString& Line, int start); -int CountLines(const QString& Line, int start); +int getEOL(const QString& Line, int start); QStringList splitStrings(const QString& text); int calSpanLines(const BufferCoord& startPos, const BufferCoord& endPos); -// Remove all '/' characters from string by changing them into '\.'. -// Change all '\' characters into '\\' to allow for unique decoding. -QString EncodeString(const QString & s); - -// Decodes string, encoded with EncodeString. -QString DecodeString(const QString& s); - using HighlighterAttriProc = std::function Params)>; @@ -99,17 +51,10 @@ using HighlighterAttriProc = std::function Params); - -// Calculates Frame Check Sequence (FCS) 16-bit Checksum (as defined in RFC 1171) -uint16_t CalcFCS(unsigned char* ABuf, int ABufSize); - -void SynDrawGradient(QPaintDevice* ACanvas, const QColor& AStartColor, const QColor& AEndColor, - int ASteps, const QRect& ARect, bool AHorizontal); - SynFontStyles getFontStyles(const QFont& font); /** @@ -117,28 +62,28 @@ SynFontStyles getFontStyles(const QFont& font); * Note: the index of first char in s in 1 * @return index of the char founded , 0 if not found */ -int StrScanForWordChar(const QString& s, int startPos); +int findWordChar(const QString& s, int startPos); /** * Find the first occurency of non word char in s, starting from startPos * Note: the index of first char in s in 1 * @return index of the char founded , 0 if not found */ -int StrScanForNonWordChar(const QString& s, int startPos); +int findNonWordChar(const QString& s, int startPos); /** * Find the first occurency of word char in s right to left, starting from startPos * Note: the index of first char in s in 1 * @return index of the char founded , 0 if not found */ -int StrRScanForWordChar(const QString& s, int startPos); +int findLastWordChar(const QString& s, int startPos); /** * Find the first occurency of non word char in s right to left, starting from startPos * Note: the index of first char in s in 1 * @return index of the char founded , 0 if not found */ -int StrRScanForNonWordChar(const QString& s, int startPos); +int findLastNonWordChar(const QString& s, int startPos); void ensureNotAfter(BufferCoord& cord1, BufferCoord& cord2); diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 4e3b0ffd..4354ad2e 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -1083,7 +1083,7 @@ bool SynEdit::colSelAvail() const return false; if (mBlockBegin.ch == mBlockEnd.ch && mBlockBegin.line == mBlockEnd.line) return false; - if (mBlockBegin.line == mBlockEnd.line && mBlockBegin.ch!=mBlockBegin.ch) + if (mBlockBegin.line == mBlockEnd.line && mBlockBegin.ch!=mBlockEnd.ch) return true; DisplayCoord coordBegin = bufferToDisplayPos(mBlockBegin); DisplayCoord coordEnd = bufferToDisplayPos(mBlockEnd); @@ -1398,23 +1398,23 @@ BufferCoord SynEdit::nextWordPosEx(const BufferCoord &XY) if (CY < mDocument->count()) { Line = mDocument->getString(CY); CY++; - CX=StrScanForWordChar(Line,1); + CX=findWordChar(Line,1); if (CX==0) CX=1; } } else { // find next "whitespace" if current char is an IdentChar if (!Line[CX-1].isSpace()) - CX = StrScanForNonWordChar(Line,CX); + CX = findNonWordChar(Line,CX); // if "whitespace" found, find the next IdentChar if (CX > 0) - CX = StrScanForWordChar(Line, CX); + CX = findWordChar(Line, CX); // if one of those failed position at the begin of next line if (CX == 0) { if (CY < mDocument->count()) { Line = mDocument->getString(CY); CY++; - CX=StrScanForWordChar(Line,1); + CX=findWordChar(Line,1); if (CX==0) CX=1; } else { @@ -1441,7 +1441,7 @@ BufferCoord SynEdit::wordStartEx(const BufferCoord &XY) CX = std::min(CX, Line.length()+1); if (CX > 1) { if (isWordChar(Line[CX - 2])) - CX = StrRScanForNonWordChar(Line, CX - 1) + 1; + CX = findLastNonWordChar(Line, CX - 1) + 1; } } return BufferCoord{CX,CY}; @@ -1461,7 +1461,7 @@ BufferCoord SynEdit::wordEndEx(const BufferCoord &XY) QString Line = mDocument->getString(CY - 1); if (CX <= Line.length() && CX-1>=0) { if (isWordChar(Line[CX - 1])) - CX = StrScanForNonWordChar(Line, CX); + CX = findNonWordChar(Line, CX); if (CX == 0) CX = Line.length() + 1; } @@ -1487,20 +1487,20 @@ BufferCoord SynEdit::prevWordPosEx(const BufferCoord &XY) if (CY > 1) { CY -- ; Line = mDocument->getString(CY - 1); - CX = StrRScanForWordChar(Line, Line.length())+1; + CX = findLastWordChar(Line, Line.length())+1; } } else { // if previous char is a "whitespace" search for the last IdentChar if (!isWordChar(Line[CX - 2])) - CX = StrRScanForWordChar(Line, CX - 1); + CX = findLastWordChar(Line, CX - 1); if (CX > 0) // search for the first IdentChar of this "word" - CX = StrRScanForNonWordChar(Line, CX - 1)+1; + CX = findLastNonWordChar(Line, CX - 1)+1; if (CX == 0) { // find last IdentChar in the previous line if (CY > 1) { CY -- ; Line = mDocument->getString(CY - 1); - CX = StrRScanForWordChar(Line, Line.length())+1; + CX = findLastWordChar(Line, Line.length())+1; } else { CX = 1; } @@ -2539,15 +2539,12 @@ void SynEdit::doTabKey() setSelectedTextEmpty(); } QString Spaces; - int NewCaretX = 0; if (mOptions.testFlag(eoTabsToSpaces)) { int cols = charToColumn(mCaretY,mCaretX); i = tabWidth() - (cols) % tabWidth(); Spaces = QString(i,' '); - NewCaretX = mCaretX + i; } else { Spaces = '\t'; - NewCaretX = mCaretX + 1; } setSelTextPrimitive(QStringList(Spaces)); } @@ -2701,7 +2698,6 @@ void SynEdit::computeCaret() int X=iMousePos.x(); int Y=iMousePos.y(); - BufferCoord oldCaret = caretXY(); DisplayCoord vCaretNearestPos = pixelsToNearestRowColumn(X, Y); vCaretNearestPos.Row = minMax(vCaretNearestPos.Row, 1, displayLineCount()); setInternalDisplayXY(vCaretNearestPos); @@ -2806,7 +2802,7 @@ void SynEdit::doBlockIndent() insertionPos.ch = std::min(BB.ch, BE.ch); else insertionPos.ch = 1; - insertBlock(insertionPos, insertionPos, strToInsert); + insertBlock(insertionPos, strToInsert); //adjust caret and selection oldCaretPos.ch = x; if (BB.ch > 1) @@ -3247,7 +3243,7 @@ void SynEdit::doOnStatusChange(SynStatusChanges) mStatusChanges = SynStatusChange::scNone; } -void SynEdit::insertBlock(const BufferCoord& startPos, const BufferCoord& endPos, const QStringList& blockText) +void SynEdit::insertBlock(const BufferCoord& startPos, const QStringList& blockText) { setCaretAndSelection(startPos, startPos, startPos); setSelTextPrimitiveEx(SynSelectionMode::Column, blockText); diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index 209daab4..b707ad53 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -506,7 +506,7 @@ private: void internalSetCaretY(int Value); void setStatusChanged(SynStatusChanges changes); void doOnStatusChange(SynStatusChanges changes); - void insertBlock(const BufferCoord& startPos, const BufferCoord& endPos, const QStringList& blockText); + void insertBlock(const BufferCoord& startPos, const QStringList& blockText); void updateScrollbars(); void updateCaret(); void recalcCharExtent(); diff --git a/RedPandaIDE/qsynedit/TextBuffer.cpp b/RedPandaIDE/qsynedit/TextBuffer.cpp index 9e3c1ad3..20a71455 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.cpp +++ b/RedPandaIDE/qsynedit/TextBuffer.cpp @@ -29,8 +29,8 @@ SynDocument::SynDocument(const QFont& font, QObject *parent): QObject(parent), - mTabWidth(4), mFontMetrics(font), + mTabWidth(4), mMutex(QMutex::Recursive) { @@ -157,7 +157,7 @@ SynRangeState SynDocument::ranges(int Index) } else { ListIndexOutOfBounds(Index); } - return {0}; + return SynRangeState(); } void SynDocument::insertItem(int Index, const QString &s) @@ -827,7 +827,7 @@ void SynDocument::invalidAllLineColumns() SynDocumentLine::SynDocumentLine(): fString(), fObject(nullptr), - fRange{0,0,0,0,0}, + fRange(), fColumns(-1) { } diff --git a/RedPandaIDE/qsynedit/TextPainter.cpp b/RedPandaIDE/qsynedit/TextPainter.cpp index 85acee48..0ec61a16 100644 --- a/RedPandaIDE/qsynedit/TextPainter.cpp +++ b/RedPandaIDE/qsynedit/TextPainter.cpp @@ -693,7 +693,6 @@ void SynEditTextPainter::PaintFoldAttributes() int indentLevel = braceLevel ; if (edit->tabWidth()>0) indentLevel = LineIndent / edit->tabWidth(); - int levelDiff = std::max(0,braceLevel - indentLevel); // Step horizontal coord //TabSteps = edit->mTabWidth; TabSteps = 0; diff --git a/RedPandaIDE/qsynedit/exporter/synhtmlexporter.cpp b/RedPandaIDE/qsynedit/exporter/synhtmlexporter.cpp index b1a3f2dd..85fab021 100644 --- a/RedPandaIDE/qsynedit/exporter/synhtmlexporter.cpp +++ b/RedPandaIDE/qsynedit/exporter/synhtmlexporter.cpp @@ -79,7 +79,7 @@ QString SynHTMLExporter::ColorToHTML(const QColor &AColor) QString SynHTMLExporter::GetStyleName(PSynHighlighter Highlighter, PSynHighlighterAttribute Attri) { QString result; - EnumHighlighterAttris(Highlighter,false, + enumHighlighterAttributes(Highlighter,false, std::bind( &SynHTMLExporter::StyleNameCallback,this, std::placeholders::_1, std::placeholders::_2, @@ -161,7 +161,7 @@ QString SynHTMLExporter::GetHeader() { using namespace std::placeholders; QString Styles; - EnumHighlighterAttris(mHighlighter, true, + enumHighlighterAttributes(mHighlighter, true, std::bind(&SynHTMLExporter::AttriToCSSCallback, this, _1, _2, _3, _4), {&Styles}); diff --git a/RedPandaIDE/qsynedit/highlighter/asm.cpp b/RedPandaIDE/qsynedit/highlighter/asm.cpp index 8db3dd38..30264ed6 100644 --- a/RedPandaIDE/qsynedit/highlighter/asm.cpp +++ b/RedPandaIDE/qsynedit/highlighter/asm.cpp @@ -377,19 +377,19 @@ bool SynEditASMHighlighter::getTokenFinished() const return true; } -bool SynEditASMHighlighter::isLastLineCommentNotFinished(int state) const +bool SynEditASMHighlighter::isLastLineCommentNotFinished(int /*state*/) const { return true; } -bool SynEditASMHighlighter::isLastLineStringNotFinished(int state) const +bool SynEditASMHighlighter::isLastLineStringNotFinished(int /*state*/) const { return true; } SynRangeState SynEditASMHighlighter::getRangeState() const { - return {0,0,0,0,0}; + return SynRangeState(); } void SynEditASMHighlighter::setState(const SynRangeState&) diff --git a/RedPandaIDE/qsynedit/highlighter/base.cpp b/RedPandaIDE/qsynedit/highlighter/base.cpp index 58b38126..beffc84e 100644 --- a/RedPandaIDE/qsynedit/highlighter/base.cpp +++ b/RedPandaIDE/qsynedit/highlighter/base.cpp @@ -249,3 +249,14 @@ int SynRangeState::getLastIndent() return -1; return indents.back(); } + +SynRangeState::SynRangeState(): + state(0), + braceLevel(0), + bracketLevel(0), + parenthesisLevel(0), + leftBraces(0), + rightBraces(0), + firstIndentThisLine(0) +{ +} diff --git a/RedPandaIDE/qsynedit/highlighter/base.h b/RedPandaIDE/qsynedit/highlighter/base.h index b49a5356..c4854620 100644 --- a/RedPandaIDE/qsynedit/highlighter/base.h +++ b/RedPandaIDE/qsynedit/highlighter/base.h @@ -48,6 +48,7 @@ struct SynRangeState { (need by auto indent) */ bool operator==(const SynRangeState& s2); int getLastIndent(); + SynRangeState(); }; typedef int SynTokenKind; diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index ecea7fc3..37493743 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -1487,6 +1487,7 @@ Settings::CompilerSet::CompilerSet(const QString& compilerFolder): } Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set): + mFullLoaded(set.mFullLoaded), mCCompiler(set.mCCompiler), mCppCompiler(set.mCppCompiler), mMake(set.mMake), @@ -1509,8 +1510,7 @@ Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set): mCustomCompileParams(set.mCustomCompileParams), mCustomLinkParams(set.mCustomLinkParams), mAutoAddCharsetParams(set.mAutoAddCharsetParams), - mCompileOptions(set.mCompileOptions), - mFullLoaded(set.mFullLoaded) + mCompileOptions(set.mCompileOptions) { } @@ -2493,7 +2493,7 @@ void Settings::CompilerSets::saveSets() for (size_t i=0;i=mList.size()) { + if (mDefaultIndex>=(int)mList.size()) { mDefaultIndex = mList.size()-1; } mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS); @@ -2538,7 +2538,7 @@ void Settings::CompilerSets::loadSets() return; } findSets(); - if ( mList.size() <= mDefaultIndex) + if ( (int)mList.size() <= mDefaultIndex) mDefaultIndex = mList.size()-1; pCurrentSet = defaultSet(); if (!pCurrentSet) { @@ -2601,7 +2601,7 @@ void Settings::CompilerSets::deleteSet(int index) mSettings->mSettings.endGroup(); } mList.erase(std::begin(mList)+index); - if (mDefaultIndex>=mList.size()) { + if (mDefaultIndex>=(int)mList.size()) { mDefaultIndex = mList.size()-1; } saveSets(); @@ -2629,7 +2629,7 @@ Settings::PCompilerSet Settings::CompilerSets::defaultSet() Settings::PCompilerSet Settings::CompilerSets::getSet(int index) { - if (index>=0 && index=0 && index<(int)mList.size()) { return mList[index]; } return PCompilerSet(); diff --git a/RedPandaIDE/settingsdialog/compilersetdirectorieswidget.cpp b/RedPandaIDE/settingsdialog/compilersetdirectorieswidget.cpp index b3adf699..077ccae6 100644 --- a/RedPandaIDE/settingsdialog/compilersetdirectorieswidget.cpp +++ b/RedPandaIDE/settingsdialog/compilersetdirectorieswidget.cpp @@ -78,7 +78,7 @@ void CompilerSetDirectoriesWidget::on_btnAdd_pressed() } } -void CompilerSetDirectoriesWidget::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) +void CompilerSetDirectoriesWidget::selectionChanged(const QItemSelection &selected, const QItemSelection &/*deselected*/) { ui->btnDelete->setEnabled(!selected.isEmpty()); } diff --git a/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp b/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp index ddec7863..db1fb1c3 100644 --- a/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp +++ b/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp @@ -132,7 +132,7 @@ void CompilerSetOptionWidget::doLoad() ui->btnRemoveCompilerSet->setEnabled(true); } int index=pSettings->compilerSets().defaultIndex(); - for (int i=0;icompilerSets().size();i++) { + for (size_t i=0;icompilerSets().size();i++) { ui->cbCompilerSet->addItem(pSettings->compilerSets().getSet(i)->name()); } if (index < 0 || index>=ui->cbCompilerSet->count()) { @@ -289,7 +289,7 @@ void CompilerSetOptionWidget::updateIcons() pIconsManager->setIcon(ui->btnChooseResourceCompiler, IconsManager::ACTION_FILE_OPEN_FOLDER); } -void CompilerSetOptionWidget::on_cbEncoding_currentTextChanged(const QString &arg1) +void CompilerSetOptionWidget::on_cbEncoding_currentTextChanged(const QString &/*arg1*/) { QString userData = ui->cbEncoding->currentData().toString(); if (userData == ENCODING_AUTO_DETECT @@ -308,7 +308,7 @@ void CompilerSetOptionWidget::on_cbEncoding_currentTextChanged(const QString &ar } -void CompilerSetOptionWidget::on_cbEncodingDetails_currentTextChanged(const QString &arg1) +void CompilerSetOptionWidget::on_cbEncodingDetails_currentTextChanged(const QString &/*arg1*/) { } diff --git a/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp index 07ee93b9..5104bca3 100644 --- a/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp @@ -68,7 +68,7 @@ void ExecutorGeneralWidget::on_btnBrowse_clicked() } } -void ExecutorGeneralWidget::updateIcons(const QSize &size) +void ExecutorGeneralWidget::updateIcons(const QSize &/*size*/) { pIconsManager->setIcon(ui->btnBrowse,IconsManager::ACTION_FILE_OPEN_FOLDER); } diff --git a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp index b3738b7a..c0f7022b 100644 --- a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp @@ -120,7 +120,7 @@ void ProjectCompilerWidget::on_cbCompilerSet_currentIndexChanged(int) refreshOptions(); } -void ProjectCompilerWidget::on_cbEncoding_currentTextChanged(const QString &arg1) +void ProjectCompilerWidget::on_cbEncoding_currentTextChanged(const QString &/*arg1*/) { QString userData = ui->cbEncoding->currentData().toString(); if (userData == ENCODING_AUTO_DETECT @@ -139,7 +139,7 @@ void ProjectCompilerWidget::on_cbEncoding_currentTextChanged(const QString &arg1 } -void ProjectCompilerWidget::on_cbEncodingDetails_currentTextChanged(const QString &arg1) +void ProjectCompilerWidget::on_cbEncodingDetails_currentTextChanged(const QString &/*arg1*/) { } diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp index 0daa933a..37e4c1aa 100644 --- a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp @@ -105,7 +105,11 @@ void ProjectGeneralWidget::doSave() project->options().isCpp = ui->cbDefaultCpp->isChecked(); project->options().supportXPThemes = ui->cbSupportXPTheme->isChecked(); if (mIconPath.isEmpty() +#if QT_VERSION_CHECK(5,15,0) + || !ui->lbIcon->pixmap(Qt::ReturnByValue).isNull()) { +#else || !ui->lbIcon->pixmap() || ui->lbIcon->pixmap()->isNull()) { +#endif project->options().icon = ""; } else { QString iconPath = QFileInfo(project->filename()).absoluteDir().absoluteFilePath("app.ico"); @@ -120,7 +124,11 @@ void ProjectGeneralWidget::doSave() } } if (!mIconPath.endsWith(".ico",PATH_SENSITIVITY) && QImageWriter::supportedImageFormats().contains("ico")) { +#if QT_VERSION_CHECK(5,15,0) + ui->lbIcon->pixmap(Qt::ReturnByValue).save(iconPath,"ico"); +#else ui->lbIcon->pixmap()->save(iconPath,"ico"); +#endif } else QFile::copy(mIconPath, iconPath); project->options().icon = iconPath; diff --git a/RedPandaIDE/settingsdialog/settingswidget.cpp b/RedPandaIDE/settingsdialog/settingswidget.cpp index 2d52e912..850a957f 100644 --- a/RedPandaIDE/settingsdialog/settingswidget.cpp +++ b/RedPandaIDE/settingsdialog/settingswidget.cpp @@ -34,8 +34,8 @@ SettingsWidget::SettingsWidget(const QString &name, const QString &group, QWidget *parent): QWidget(parent), mSettingsChanged(false), - mName(name), - mGroup(group) + mGroup(group), + mName(name) { } diff --git a/RedPandaIDE/settingsdialog/toolsgitwidget.cpp b/RedPandaIDE/settingsdialog/toolsgitwidget.cpp index 2be01b35..3ead34ab 100644 --- a/RedPandaIDE/settingsdialog/toolsgitwidget.cpp +++ b/RedPandaIDE/settingsdialog/toolsgitwidget.cpp @@ -33,7 +33,7 @@ void ToolsGitWidget::doSave() pMainWindow->applySettings(); } -void ToolsGitWidget::updateIcons(const QSize &size) +void ToolsGitWidget::updateIcons(const QSize &/*size*/) { pIconsManager->setIcon(ui->btnBrowseGit,IconsManager::ACTION_FILE_OPEN_FOLDER); } diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 9809f60f..1259458d 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -596,7 +596,12 @@ void stringsToFile(const QStringList &list, const QString &fileName) if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { QTextStream stream(&file); for (QString s:list) { - stream<", tr("Path to the current project's folder")); } -int MacroInfoModel::rowCount(const QModelIndex &parent) const +int MacroInfoModel::rowCount(const QModelIndex &/*parent*/) const { return mMacroInfos.count(); } diff --git a/RedPandaIDE/widgets/newclassdialog.cpp b/RedPandaIDE/widgets/newclassdialog.cpp index a9e17575..f880baa2 100644 --- a/RedPandaIDE/widgets/newclassdialog.cpp +++ b/RedPandaIDE/widgets/newclassdialog.cpp @@ -72,7 +72,7 @@ void NewClassDialog::on_btnCancel_clicked() this->reject(); } -void NewClassDialog::closeEvent(QCloseEvent *event) +void NewClassDialog::closeEvent(QCloseEvent */*event*/) { this->reject(); } diff --git a/RedPandaIDE/widgets/ojproblemsetmodel.cpp b/RedPandaIDE/widgets/ojproblemsetmodel.cpp index 6316eafa..fb9b8117 100644 --- a/RedPandaIDE/widgets/ojproblemsetmodel.cpp +++ b/RedPandaIDE/widgets/ojproblemsetmodel.cpp @@ -444,7 +444,7 @@ Qt::ItemFlags OJProblemModel::flags(const QModelIndex &idx) const return flags; } -int OJProblemModel::columnCount(const QModelIndex &parent) const +int OJProblemModel::columnCount(const QModelIndex &/*parent*/) const { return 2; } diff --git a/RedPandaIDE/widgets/searchdialog.ui b/RedPandaIDE/widgets/searchdialog.ui index 208bb47f..17b5be13 100644 --- a/RedPandaIDE/widgets/searchdialog.ui +++ b/RedPandaIDE/widgets/searchdialog.ui @@ -126,7 +126,7 @@ - + 0