diff --git a/RedPandaIDE/compiler/compilerinfo.h b/RedPandaIDE/compiler/compilerinfo.h index 1f0c3d53..56a7a289 100644 --- a/RedPandaIDE/compiler/compilerinfo.h +++ b/RedPandaIDE/compiler/compilerinfo.h @@ -4,7 +4,6 @@ #include #include #include -#include #define COMPILER_CLANG "Clang" #define COMPILER_GCC "GCC" #define COMPILER_GCC_UTF8 "GCC_UTF8" diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index aed6dee4..39251297 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -142,7 +142,7 @@ void CppParser::clearProjectFiles() mProjectFiles.clear(); } -QList CppParser::getListOfFunctions(const QString &fileName, const QString &phrase, int line) +QList CppParser::getListOfFunctions(const QString &fileName, const QString &phrase, int line) const { QMutexLocker locker(&mMutex); QList result; @@ -185,7 +185,7 @@ QList CppParser::getListOfFunctions(const QString &fileName, const Q return result; } -PStatement CppParser::findScopeStatement(const QString &filename, int line) +PStatement CppParser::findScopeStatement(const QString &filename, int line) const { QMutexLocker locker(&mMutex); if (mParsing) { @@ -203,13 +203,13 @@ PStatement CppParser::doFindScopeStatement(const QString &filename, int line) co return fileInfo->findScopeAtLine(line); } -PParsedFileInfo CppParser::findFileInfo(const QString &filename) +PParsedFileInfo CppParser::findFileInfo(const QString &filename) const { QMutexLocker locker(&mMutex); PParsedFileInfo fileInfo = mPreprocessor.findFileInfo(filename); return fileInfo; } -QString CppParser::findFirstTemplateParamOf(const QString &fileName, const QString &phrase, const PStatement& currentScope) +QString CppParser::findFirstTemplateParamOf(const QString &fileName, const QString &phrase, const PStatement& currentScope) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -217,7 +217,7 @@ QString CppParser::findFirstTemplateParamOf(const QString &fileName, const QStri return doFindFirstTemplateParamOf(fileName,phrase,currentScope); } -QString CppParser::findTemplateParamOf(const QString &fileName, const QString &phrase, int index, const PStatement ¤tScope) +QString CppParser::findTemplateParamOf(const QString &fileName, const QString &phrase, int index, const PStatement ¤tScope) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -225,7 +225,7 @@ QString CppParser::findTemplateParamOf(const QString &fileName, const QString &p return doFindTemplateParamOf(fileName,phrase,index,currentScope); } -PStatement CppParser::findFunctionAt(const QString &fileName, int line) +PStatement CppParser::findFunctionAt(const QString &fileName, int line) const { QMutexLocker locker(&mMutex); PParsedFileInfo fileInfo = mPreprocessor.findFileInfo(fileName); @@ -262,7 +262,7 @@ int CppParser::findLastOperator(const QString &phrase) const return -1; } -PStatementList CppParser::findNamespace(const QString &name) +PStatementList CppParser::findNamespace(const QString &name) const { QMutexLocker locker(&mMutex); return doFindNamespace(name); @@ -274,7 +274,7 @@ PStatementList CppParser::doFindNamespace(const QString &name) const } -PStatement CppParser::findStatement(const QString &fullname) +PStatement CppParser::findStatement(const QString &fullname) const { QMutexLocker locker(&mMutex); return doFindStatement(fullname); @@ -309,7 +309,7 @@ PStatement CppParser::doFindStatement(const QString &fullname) const return statement; } -PStatement CppParser::findStatementOf(const QString &fileName, const QString &phrase, int line) +PStatement CppParser::findStatementOf(const QString &fileName, const QString &phrase, int line) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -324,7 +324,7 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, const QString & PStatement CppParser::findStatementOf(const QString &fileName, const QString &phrase, const PStatement& currentScope, - PStatement &parentScopeType) + PStatement &parentScopeType) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -495,7 +495,7 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, PEvalStatement CppParser::evalExpression( const QString &fileName, QStringList &phraseExpression, - const PStatement ¤tScope) + const PStatement ¤tScope) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -518,7 +518,7 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, const QString & } -PStatement CppParser::findStatementOf(const QString &fileName, const QStringList &expression, const PStatement ¤tScope) +PStatement CppParser::findStatementOf(const QString &fileName, const QStringList &expression, const PStatement ¤tScope) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -588,7 +588,7 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, const QStringLi } -PStatement CppParser::findStatementOf(const QString &fileName, const QStringList &expression, int line) +PStatement CppParser::findStatementOf(const QString &fileName, const QStringList &expression, int line) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -610,7 +610,7 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, const QStringLi return statement; } -PStatement CppParser::findAliasedStatement(const PStatement &statement) +PStatement CppParser::findAliasedStatement(const PStatement &statement) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -618,7 +618,7 @@ PStatement CppParser::findAliasedStatement(const PStatement &statement) return doFindAliasedStatement(statement); } -QList CppParser::listTypeStatements(const QString &fileName, int line) +QList CppParser::listTypeStatements(const QString &fileName, int line) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -764,7 +764,7 @@ PStatement CppParser::findStatementStartingFrom(const QString &fileName, const Q return PStatement(); } -PStatement CppParser::findTypeDefinitionOf(const QString &fileName, const QString &aType, const PStatement& currentClass) +PStatement CppParser::findTypeDefinitionOf(const QString &fileName, const QString &aType, const PStatement& currentClass) const { QMutexLocker locker(&mMutex); @@ -774,7 +774,7 @@ PStatement CppParser::findTypeDefinitionOf(const QString &fileName, const QStrin return doFindTypeDefinitionOf(fileName,aType,currentClass); } -PStatement CppParser::findTypeDef(const PStatement &statement, const QString &fileName) +PStatement CppParser::findTypeDef(const PStatement &statement, const QString &fileName) const { QMutexLocker locker(&mMutex); @@ -803,7 +803,7 @@ bool CppParser::freeze(const QString &serialId) return true; } -QStringList CppParser::getClassesList() +QStringList CppParser::getClassesList() const { QMutexLocker locker(&mMutex); @@ -825,7 +825,7 @@ QStringList CppParser::getClassesList() return list; } -QStringList CppParser::getFileDirectIncludes(const QString &filename) +QStringList CppParser::getFileDirectIncludes(const QString &filename) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -858,13 +858,13 @@ QSet CppParser::internalGetIncludedFiles(const QString &filename) const return list; } -QSet CppParser::getIncludedFiles(const QString &filename) +QSet CppParser::getIncludedFiles(const QString &filename) const { QMutexLocker locker(&mMutex); return internalGetIncludedFiles(filename); } -QSet CppParser::getFileUsings(const QString &filename) +QSet CppParser::getFileUsings(const QString &filename) const { QMutexLocker locker(&mMutex); return internalGetFileUsings(filename); @@ -894,7 +894,7 @@ QSet CppParser::internalGetFileUsings(const QString &filename) const return result; } -QString CppParser::getHeaderFileName(const QString &relativeTo, const QString &headerName, bool fromNext) +QString CppParser::getHeaderFileName(const QString &relativeTo, const QString &headerName, bool fromNext) const { QMutexLocker locker(&mMutex); QString currentDir = includeTrailingPathDelimiter(extractFileDir(relativeTo)); @@ -927,7 +927,7 @@ QString CppParser::getHeaderFileName(const QString &relativeTo, const QString &h projectIncludes); } -bool CppParser::isLineVisible(const QString &fileName, int line) +bool CppParser::isLineVisible(const QString &fileName, int line) const { QMutexLocker locker(&mMutex); if (mParsing) { @@ -955,7 +955,7 @@ void CppParser::invalidateFile(const QString &fileName) mParsing = false; } -bool CppParser::isIncludeLine(const QString &line) +bool CppParser::isIncludeLine(const QString &line) const { QString trimmedLine = line.trimmed(); if ((trimmedLine.length() > 0) @@ -966,7 +966,7 @@ bool CppParser::isIncludeLine(const QString &line) return false; } -bool CppParser::isIncludeNextLine(const QString &line) +bool CppParser::isIncludeNextLine(const QString &line) const { QString trimmedLine = line.trimmed(); if ((trimmedLine.length() > 0) @@ -977,13 +977,13 @@ bool CppParser::isIncludeNextLine(const QString &line) return false; } -bool CppParser::isProjectHeaderFile(const QString &fileName) +bool CppParser::isProjectHeaderFile(const QString &fileName) const { QMutexLocker locker(&mMutex); return ::isSystemHeaderFile(fileName,mPreprocessor.projectIncludePaths()); } -bool CppParser::isSystemHeaderFile(const QString &fileName) +bool CppParser::isSystemHeaderFile(const QString &fileName) const { QMutexLocker locker(&mMutex); return ::isSystemHeaderFile(fileName,mPreprocessor.includePaths()); @@ -1188,7 +1188,7 @@ void CppParser::unFreeze() mLockCount--; } -bool CppParser::fileScanned(const QString &fileName) +bool CppParser::fileScanned(const QString &fileName) const { QMutexLocker locker(&mMutex); if (mParsing) @@ -1196,7 +1196,7 @@ bool CppParser::fileScanned(const QString &fileName) return mPreprocessor.fileScanned(fileName); } -bool CppParser::isFileParsed(const QString &filename) +bool CppParser::isFileParsed(const QString &filename) const { return mPreprocessor.fileScanned(filename); } @@ -1214,7 +1214,7 @@ QString CppParser::getScopePrefix(const PStatement& statement) const{ } } -QString CppParser::prettyPrintStatement(const PStatement& statement, const QString& filename, int line) +QString CppParser::prettyPrintStatement(const PStatement& statement, const QString& filename, int line) const { QString result; switch(statement->kind) { diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index 99aba6d6..6c9d40c3 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -56,38 +56,38 @@ public: void clearProjectFiles(); QList getListOfFunctions(const QString& fileName, const QString& phrase, - int line); - PStatement findScopeStatement(const QString& filename, int line); - PParsedFileInfo findFileInfo(const QString &filename); + int line) const; + PStatement findScopeStatement(const QString& filename, int line) const; + PParsedFileInfo findFileInfo(const QString &filename) const; QString findFirstTemplateParamOf(const QString& fileName, const QString& phrase, - const PStatement& currentScope); + const PStatement& currentScope) const; QString findTemplateParamOf(const QString& fileName, const QString& phrase, int index, - const PStatement& currentScope); + const PStatement& currentScope) const; PStatement findFunctionAt(const QString& fileName, - int line); + int line) const; int findLastOperator(const QString& phrase) const; - PStatementList findNamespace(const QString& name); // return a list of PSTATEMENTS (of the namespace) - PStatement findStatement(const QString& fullname); + PStatementList findNamespace(const QString& name) const; // return a list of PSTATEMENTS (of the namespace) + PStatement findStatement(const QString& fullname) const; PStatement findStatementOf(const QString& fileName, const QString& phrase, - int line); + int line) const; PStatement findStatementOf(const QString& fileName, const QString& phrase, const PStatement& currentScope, - PStatement& parentScopeType); + PStatement& parentScopeType) const; PStatement findStatementOf(const QString& fileName, const QStringList& expression, - const PStatement& currentScope); + const PStatement& currentScope) const; PStatement findStatementOf(const QString& fileName, const QStringList& expression, - int line); - PStatement findAliasedStatement(const PStatement& statement); + int line) const; + PStatement findAliasedStatement(const PStatement& statement) const; - QList listTypeStatements(const QString& fileName,int line); + QList listTypeStatements(const QString& fileName,int line) const; /** * @brief evaluate the expression @@ -98,27 +98,27 @@ public: */ PEvalStatement evalExpression(const QString& fileName, QStringList& expression, - const PStatement& currentScope); + const PStatement& currentScope) const; PStatement findTypeDefinitionOf(const QString& fileName, const QString& aType, - const PStatement& currentClass); + const PStatement& currentClass) const; PStatement findTypeDef(const PStatement& statement, - const QString& fileName); + const QString& fileName) const; bool freeze(); // Freeze/Lock (stop reparse while searching) bool freeze(const QString& serialId); // Freeze/Lock (stop reparse while searching) - QStringList getClassesList(); - QStringList getFileDirectIncludes(const QString& filename); - QSet getIncludedFiles(const QString& filename); - QSet getFileUsings(const QString& filename); + QStringList getClassesList() const; + QStringList getFileDirectIncludes(const QString& filename) const; + QSet getIncludedFiles(const QString& filename) const; + QSet getFileUsings(const QString& filename) const; - QString getHeaderFileName(const QString& relativeTo, const QString& headerName, bool fromNext=false);// both + QString getHeaderFileName(const QString& relativeTo, const QString& headerName, bool fromNext=false) const; void invalidateFile(const QString& fileName); - bool isLineVisible(const QString& fileName, int line); - bool isIncludeLine(const QString &line); - bool isIncludeNextLine(const QString &line); - bool isProjectHeaderFile(const QString& fileName); - bool isSystemHeaderFile(const QString& fileName); + bool isLineVisible(const QString& fileName, int line) const; + bool isIncludeLine(const QString &line) const; + bool isIncludeNextLine(const QString &line) const; + bool isProjectHeaderFile(const QString& fileName) const; + bool isSystemHeaderFile(const QString& fileName) const; void parseFile(const QString& fileName, bool inProject, bool onlyIfNotParsed = false, bool updateView = true, std::shared_ptr parserPtr = nullptr); @@ -127,11 +127,11 @@ public: bool parsing() const; void resetParser(); void unFreeze(); // UnFree/UnLock (reparse while searching) - bool fileScanned(const QString& fileName); + bool fileScanned(const QString& fileName) const; - bool isFileParsed(const QString& filename); + bool isFileParsed(const QString& filename) const; - QString prettyPrintStatement(const PStatement& statement, const QString& filename, int line = -1); + QString prettyPrintStatement(const PStatement& statement, const QString& filename, int line = -1) const; bool enabled() const; void setEnabled(bool newEnabled); @@ -742,7 +742,7 @@ private: #ifdef QT_DEBUG int mLastIndex; #endif - QRecursiveMutex mMutex; + mutable QRecursiveMutex mMutex; QMap mCppKeywords; QSet mCppTypeKeywords; diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index 1d2a0962..8cff9282 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -121,7 +121,7 @@ public: return mScannedFiles; } - const QSet &projectIncludePaths() { + const QSet &projectIncludePaths() const { return mProjectIncludePaths; } diff --git a/RedPandaIDE/widgets/classbrowser.cpp b/RedPandaIDE/widgets/classbrowser.cpp index 09a34236..068be8dc 100644 --- a/RedPandaIDE/widgets/classbrowser.cpp +++ b/RedPandaIDE/widgets/classbrowser.cpp @@ -463,7 +463,7 @@ bool ClassBrowserModel::isScopeStatement(const PStatement &statement) } } -QModelIndex ClassBrowserModel::modelIndexForStatement(const QString &key) +QModelIndex ClassBrowserModel::modelIndexForStatement(const QString &key) const { QMutexLocker locker(&mMutex); if (mUpdating) diff --git a/RedPandaIDE/widgets/classbrowser.h b/RedPandaIDE/widgets/classbrowser.h index 6ba9dc02..420b909b 100644 --- a/RedPandaIDE/widgets/classbrowser.h +++ b/RedPandaIDE/widgets/classbrowser.h @@ -62,7 +62,7 @@ public: ProjectClassBrowserType classBrowserType() const; void setClassBrowserType(ProjectClassBrowserType newClassBrowserType); - QModelIndex modelIndexForStatement(const QString& key); + QModelIndex modelIndexForStatement(const QString& key) const; signals: void refreshStarted(); void refreshEnd(); @@ -86,7 +86,7 @@ private: PCppParser mParser; bool mUpdating; int mUpdateCount; - QRecursiveMutex mMutex; + mutable QRecursiveMutex mMutex; QString mCurrentFile; std::shared_ptr > > mColors; ProjectClassBrowserType mClassBrowserType; diff --git a/RedPandaIDE/widgets/codecompletionpopup.h b/RedPandaIDE/widgets/codecompletionpopup.h index 3ca8953a..331e6ace 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.h +++ b/RedPandaIDE/widgets/codecompletionpopup.h @@ -183,7 +183,7 @@ private: QSet mAddedStatements; QString mMemberPhrase; QString mMemberOperator; - QRecursiveMutex mMutex; + mutable QRecursiveMutex mMutex; std::shared_ptr > > mColors; CodeCompletionListItemDelegate* mDelegate; diff --git a/libs/qsynedit/qsynedit/document.cpp b/libs/qsynedit/qsynedit/document.cpp index 9176a29d..9ebe2c47 100644 --- a/libs/qsynedit/qsynedit/document.cpp +++ b/libs/qsynedit/qsynedit/document.cpp @@ -54,7 +54,7 @@ static void listIndexOutOfBounds(int index) { -int Document::parenthesisLevel(int line) +int Document::parenthesisLevel(int line) const { QMutexLocker locker(&mMutex); if (line>=0 && line < mLines.size()) { @@ -63,7 +63,7 @@ int Document::parenthesisLevel(int line) return 0; } -int Document::bracketLevel(int line) +int Document::bracketLevel(int line) const { QMutexLocker locker(&mMutex); if (line>=0 && line < mLines.size()) { @@ -72,7 +72,7 @@ int Document::bracketLevel(int line) return 0; } -int Document::braceLevel(int line) +int Document::braceLevel(int line) const { QMutexLocker locker(&mMutex); if (line>=0 && line < mLines.size()) { @@ -81,7 +81,7 @@ int Document::braceLevel(int line) return 0; } -int Document::lineWidth(int line) +int Document::lineWidth(int line) const { QMutexLocker locker(&mMutex); if (line>=0 && line < mLines.size()) { @@ -92,7 +92,7 @@ int Document::lineWidth(int line) return 0; } -int Document::lineWidth(int line, const QString &newText) +int Document::lineWidth(int line, const QString &newText) const { QMutexLocker locker(&mMutex); if (line<0 || line >= mLines.size()) @@ -105,7 +105,7 @@ int Document::lineWidth(int line, const QString &newText) } } -int Document::blockLevel(int line) +int Document::blockLevel(int line) const { QMutexLocker locker(&mMutex); if (line>=0 && line < mLines.size()) { @@ -114,7 +114,7 @@ int Document::blockLevel(int line) return 0; } -int Document::blockStarted(int line) +int Document::blockStarted(int line) const { QMutexLocker locker(&mMutex); if (line>=0 && line < mLines.size()) { @@ -123,7 +123,7 @@ int Document::blockStarted(int line) return 0; } -int Document::blockEnded(int line) +int Document::blockEnded(int line) const { QMutexLocker locker(&mMutex); if (line>=0 && line < mLines.size()) { @@ -135,7 +135,7 @@ int Document::blockEnded(int line) return 0; } -int Document::maxLineWidth() { +int Document::maxLineWidth() const { QMutexLocker locker(&mMutex); if (mIndexOfLongestLine >= 0) { return mLines[mIndexOfLongestLine]->width(); @@ -158,7 +158,7 @@ QString Document::lineBreak() const return "\n"; } -SyntaxState Document::getSyntaxState(int line) +SyntaxState Document::getSyntaxState(int line) const { QMutexLocker locker(&mMutex); if (line>=0 && line < mLines.size()) { @@ -189,7 +189,7 @@ void Document::addItem(const QString &s) endUpdate(); } -bool Document::getAppendNewLineAtEOF() +bool Document::getAppendNewLineAtEOF() const { QMutexLocker locker(&mMutex); return mAppendNewLineAtEOF; @@ -210,7 +210,7 @@ void Document::setSyntaxState(int line, const SyntaxState& state) mLines[line]->setSyntaxState(state); } -QString Document::getLine(int line) +QString Document::getLine(int line) const { QMutexLocker locker(&mMutex); if (line<0 || line>=mLines.count()) { @@ -219,7 +219,7 @@ QString Document::getLine(int line) return mLines[line]->lineText(); } -int Document::getLineGlyphsCount(int line) +int Document::getLineGlyphsCount(int line) const { QMutexLocker locker(&mMutex); if (line<0 || line>=mLines.count()) { @@ -237,13 +237,13 @@ int Document::getLineGlyphsCount(int line) // return mLines[index]->glyphStartCharList(); // } -int Document::count() +int Document::count() const { QMutexLocker locker(&mMutex); return mLines.count(); } -QString Document::text() +QString Document::text() const { QMutexLocker locker(&mMutex); return getTextStr(); @@ -274,7 +274,7 @@ void Document::setContents(const QStringList &text) } } -QStringList Document::contents() +QStringList Document::contents() const { QMutexLocker locker(&mMutex); QStringList result; @@ -332,7 +332,7 @@ void Document::addLines(const QStringList &strings) } } -int Document::getTextLength() +int Document::getTextLength() const { QMutexLocker locker(&mMutex); int Result = 0; @@ -790,13 +790,13 @@ void Document::saveToFile(QFile &file, const QByteArray& encoding, } } -QString Document::glyph(int line, int glyphIdx) +QString Document::glyph(int line, int glyphIdx) const { QMutexLocker locker(&mMutex); return mLines[line]->glyph(glyphIdx); } -QString Document::glyphAt(int line, int charPos) +QString Document::glyphAt(int line, int charPos) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -806,7 +806,7 @@ QString Document::glyphAt(int line, int charPos) return mLines[line]->glyph(glyphIdx); } -int Document::charToGlyphStartChar(int line, int charPos) +int Document::charToGlyphStartChar(int line, int charPos) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -889,7 +889,7 @@ int GlyphCalculator::stringWidth(const QString &str, int left, const QFontMetric return right - left; } -int Document::glyphCount(int line) +int Document::glyphCount(int line) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -897,7 +897,7 @@ int Document::glyphCount(int line) return mLines[line]->glyphsCount(); } -int Document::glyphStartChar(int line, int glyphIdx) +int Document::glyphStartChar(int line, int glyphIdx) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -905,7 +905,7 @@ int Document::glyphStartChar(int line, int glyphIdx) return mLines[line]->glyphStartChar(glyphIdx); } -int Document::glyphLength(int line, int glyphIdx) +int Document::glyphLength(int line, int glyphIdx) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -913,7 +913,7 @@ int Document::glyphLength(int line, int glyphIdx) return mLines[line]->glyphLength(glyphIdx); } -int Document::glyphStartPostion(int line, int glyphIdx) +int Document::glyphStartPostion(int line, int glyphIdx) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -921,7 +921,7 @@ int Document::glyphStartPostion(int line, int glyphIdx) return mLines[line]->glyphStartPosition(glyphIdx); } -int Document::glyphWidth(int line, int glyphIdx) +int Document::glyphWidth(int line, int glyphIdx) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -929,7 +929,7 @@ int Document::glyphWidth(int line, int glyphIdx) return mLines[line]->glyphWidth(glyphIdx); } -int Document::charToGlyphIndex(int line, int charIdx) +int Document::charToGlyphIndex(int line, int charIdx) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -974,7 +974,7 @@ QList GlyphCalculator::calcGlyphPositionList(const QString &lineText, const return glyphPostionList; } -int Document::xposToGlyphIndex(int line, int xpos) +int Document::xposToGlyphIndex(int line, int xpos) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -996,7 +996,7 @@ int Document::xposToGlyphIndex(int strWidth, QList glyphPositionList, int x // return glyphPositionList.length()-1; } -int Document::charToGlyphStartPosition(int line, int charPos) +int Document::charToGlyphStartPosition(int line, int charPos) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -1006,7 +1006,7 @@ int Document::charToGlyphStartPosition(int line, int charPos) return mLines[line]->glyphStartPosition(glyphIdx); } -int Document::xposToGlyphStartChar(int line, int xpos) +int Document::xposToGlyphStartChar(int line, int xpos) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -1016,7 +1016,7 @@ int Document::xposToGlyphStartChar(int line, int xpos) return mLines[line]->glyphStartChar(glyphIdx); } -int Document::charToGlyphStartPosition(int line, const QString newStr, int charPos) +int Document::charToGlyphStartPosition(int line, const QString newStr, int charPos) const { QMutexLocker locker(&mMutex); if (line>=0 && linelineText() == newStr) { @@ -1033,7 +1033,7 @@ int Document::charToGlyphStartPosition(int line, const QString newStr, int charP } } -int Document::xposToGlyphStartChar(int line, const QString newStr, int xpos) +int Document::xposToGlyphStartChar(int line, const QString newStr, int xpos) const { QMutexLocker locker(&mMutex); if (line<0 || line>=count()) @@ -1233,7 +1233,7 @@ int Document::getLineWidth(int line) return mLines[line]->mWidth; } -NewlineType Document::getNewlineType() +NewlineType Document::getNewlineType() const { QMutexLocker locker(&mMutex); return mNewlineType; @@ -1245,7 +1245,7 @@ void Document::setNewlineType(const NewlineType &fileEndingType) mNewlineType = fileEndingType; } -bool Document::empty() +bool Document::empty() const { QMutexLocker locker(&mMutex); return mLines.count()==0; diff --git a/libs/qsynedit/qsynedit/document.h b/libs/qsynedit/qsynedit/document.h index df2b0ba0..cb4ae6df 100644 --- a/libs/qsynedit/qsynedit/document.h +++ b/libs/qsynedit/qsynedit/document.h @@ -295,7 +295,7 @@ public: * @param line line index (starts from 0) * @return */ - int parenthesisLevel(int line); + int parenthesisLevel(int line) const; /** * @brief get nesting level of brackets at the end of the specified line @@ -305,7 +305,7 @@ public: * @param line line index (starts from 0) * @return */ - int bracketLevel(int line); + int bracketLevel(int line) const; /** * @brief get nesting level of braces at the end of the specified line @@ -315,7 +315,7 @@ public: * @param line line index (starts from 0) * @return */ - int braceLevel(int line); + int braceLevel(int line) const; /** * @brief get width of the specified line @@ -325,7 +325,7 @@ public: * @param line line index (starts frome 0) * @return */ - int lineWidth(int line); + int lineWidth(int line) const; /** * @brief get width of the specified text / line @@ -340,7 +340,7 @@ public: * @param newText the new text * @return */ - int lineWidth(int line, const QString &newText); + int lineWidth(int line, const QString &newText) const; /** * @brief get block (indent) level of the specified line @@ -350,21 +350,21 @@ public: * @param line line index (starts frome 0) * @return */ - int blockLevel(int line); + int blockLevel(int line) const; /** * @brief get count of new blocks (indent) started on the specified line * @param line line index (starts frome 0) * @return */ - int blockStarted(int line); + int blockStarted(int line) const; /** * @brief get count of blocks (indent) ended on the specified line * @param line line index (starts frome 0) * @return */ - int blockEnded(int line); + int blockEnded(int line) const; /** * @brief get index of the longest line (has the max width) @@ -373,7 +373,7 @@ public: * * @return */ - int maxLineWidth(); + int maxLineWidth() const; /** * @brief get line break of the current document @@ -390,7 +390,7 @@ public: * @param line line index (starts frome 0) * @return */ - SyntaxState getSyntaxState(int line); + SyntaxState getSyntaxState(int line) const; /** * @brief set state of the syntax highlighter after parsing the specified line. @@ -410,7 +410,7 @@ public: * @param line line index (starts frome 0) * @return */ - QString getLine(int line); + QString getLine(int line) const; /** * @brief get count of the glyphs on the specified line. @@ -420,7 +420,7 @@ public: * @param line line index (starts frome 0) * @return */ - int getLineGlyphsCount(int line); + int getLineGlyphsCount(int line) const; // /** // * @brief get position list of the glyphs on the specified line. @@ -440,7 +440,7 @@ public: * * @return */ - int count(); + int count() const; /** * @brief get all the text in the document. @@ -450,7 +450,7 @@ public: * * @return */ - QString text(); + QString text() const; /** * @brief set the text of the document @@ -478,7 +478,7 @@ public: * * @return */ - QStringList contents(); + QStringList contents() const; void putLine(int index, const QString& s, bool notify=true); @@ -488,7 +488,7 @@ public: int addLine(const QString& s); void addLines(const QStringList& strings); - int getTextLength(); + int getTextLength() const; void clear(); void deleteAt(int index); void deleteLines(int index, int numLines); @@ -500,17 +500,17 @@ public: void saveToFile(QFile& file, const QByteArray& encoding, const QByteArray& defaultEncoding, QByteArray& realEncoding); - QString glyph(int line, int glyphIdx); - QString glyphAt(int line, int charPos); + QString glyph(int line, int glyphIdx) const; + QString glyphAt(int line, int charPos) const; int stringWidth(const QString &str, int left) const { return mGlyphCalculator.stringWidth(str, left); } - int charToGlyphStartChar(int line, int charPos); + int charToGlyphStartChar(int line, int charPos) const; //int columnToGlyphStartColumn(int line, int charPos); - int glyphCount(int line); + int glyphCount(int line) const; /** * @brief get start index of the chars representing the specified glyph in the specified line. * @@ -520,7 +520,7 @@ public: * @param glyphIdx index of the glyph in the line (starting from 0) * @return char index in the line text (start from 0) */ - int glyphStartChar(int line, int glyphIdx); + int glyphStartChar(int line, int glyphIdx) const; /** * @brief get count of the chars representing the specified glyph in the specified line. @@ -531,7 +531,7 @@ public: * @param glyphIdx index of the glyph in the line (starting from 0) * @return */ - int glyphLength(int line, int glyphIdx); + int glyphLength(int line, int glyphIdx) const; /** * @brief get start column of the specified glyph in the specified line. @@ -542,7 +542,7 @@ public: * @param glyphIdx index of the glyph in the line (starting from 0) * @return the column (starting from 1) */ - int glyphStartPostion(int line, int glyphIdx); + int glyphStartPostion(int line, int glyphIdx) const; /** * @brief get width (in columns) of the specified glyph in the specified line. @@ -553,7 +553,7 @@ public: * @param glyphIdx index of the glyph in the line (starting from 0) * @return */ - int glyphWidth(int line, int glyphIdx); + int glyphWidth(int line, int glyphIdx) const; int glyphWidth(const QString &glyph, int left) const { return mGlyphCalculator.glyphWidth(glyph,left); @@ -568,7 +568,7 @@ public: * @param charIdx position of the char in the line text (starting from 0) * @return glyph index in the line (starting from 0) */ - int charToGlyphIndex(int line, int charPos); + int charToGlyphIndex(int line, int charPos) const; /** * @brief get index of the glyph displayed on the specified column @@ -579,20 +579,20 @@ public: * @param column the column (starting from 1) * @return glyph index in the line (starting from 0) */ - int xposToGlyphIndex(int line, int xpos); + int xposToGlyphIndex(int line, int xpos) const; - int charToGlyphStartPosition(int line, int charPos); - int xposToGlyphStartChar(int line, int xpos); - int charToGlyphStartPosition(int line, const QString newStr, int charPos); - int xposToGlyphStartChar(int line, const QString newStr, int xpos); + int charToGlyphStartPosition(int line, int charPos) const; + int xposToGlyphStartChar(int line, int xpos) const; + int charToGlyphStartPosition(int line, const QString newStr, int charPos) const; + int xposToGlyphStartChar(int line, const QString newStr, int xpos) const; - bool getAppendNewLineAtEOF(); + bool getAppendNewLineAtEOF() const; void setAppendNewLineAtEOF(bool appendNewLineAtEOF); - NewlineType getNewlineType(); + NewlineType getNewlineType() const; void setNewlineType(const NewlineType &fileEndingType); - bool empty(); + bool empty() const; int tabSize() const { return mGlyphCalculator.tabSize(); } @@ -662,7 +662,7 @@ private: int mSetLineWidthLockCount; bool mMaxLineChangedInSetLinesWidth; - QRecursiveMutex mMutex; + mutable QRecursiveMutex mMutex; GlyphCalculator mGlyphCalculator;