diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index abd82ebcd..611848c79 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -37,6 +37,9 @@ static const char PathName[] = "dir"; static const char PathNameAttrib[] = "name"; static const char RootPathName[] = "root"; static const char RootPathNameAttrib[] = "name"; +static const char IgnoreElementName[] = "defines"; +static const char IgnorePathName[] = "path"; +static const char IgnorePathNameAttrib[] = "name"; ProjectFile::ProjectFile(QObject *parent) : QObject(parent) @@ -87,6 +90,10 @@ bool ProjectFile::Read(const QString &filename) if (insideProject && xmlReader.name() == DefinesElementName) ReadDefines(xmlReader); + // Find ignore list from inside project element + if (insideProject && xmlReader.name() == IgnoreElementName) + ReadIgnores(xmlReader); + break; case QXmlStreamReader::EndElement: @@ -130,6 +137,11 @@ QStringList ProjectFile::GetCheckPaths() const return mPaths; } +QStringList ProjectFile::GetIgnoredPaths() const +{ + return mIgnoredPaths; +} + void ProjectFile::ReadRootPath(QXmlStreamReader &reader) { QXmlStreamAttributes attribs = reader.attributes(); @@ -263,6 +275,47 @@ void ProjectFile::ReadCheckPaths(QXmlStreamReader &reader) while (!allRead); } +void ProjectFile::ReadIgnores(QXmlStreamReader &reader) +{ + QXmlStreamReader::TokenType type; + bool allRead = false; + do + { + type = reader.readNext(); + switch (type) + { + case QXmlStreamReader::StartElement: + // Read define-elements + if (reader.name().toString() == IgnorePathName) + { + QXmlStreamAttributes attribs = reader.attributes(); + QString name = attribs.value("", IgnorePathNameAttrib).toString(); + if (!name.isEmpty()) + mIgnoredPaths << name; + } + break; + + case QXmlStreamReader::EndElement: + if (reader.name().toString() == IgnoreElementName) + allRead = true; + break; + + // Not handled + case QXmlStreamReader::NoToken: + case QXmlStreamReader::Invalid: + case QXmlStreamReader::StartDocument: + case QXmlStreamReader::EndDocument: + case QXmlStreamReader::Characters: + case QXmlStreamReader::Comment: + case QXmlStreamReader::DTD: + case QXmlStreamReader::EntityReference: + case QXmlStreamReader::ProcessingInstruction: + break; + } + } + while (!allRead); +} + void ProjectFile::SetIncludes(QStringList includes) { mIncludeDirs = includes; @@ -278,6 +331,11 @@ void ProjectFile::SetCheckPaths(QStringList paths) mPaths = paths; } +void ProjectFile::SetIgnoredPaths(QStringList paths) +{ + mIgnoredPaths = paths; +} + bool ProjectFile::Write(const QString &filename) { if (!filename.isEmpty()) diff --git a/gui/projectfile.h b/gui/projectfile.h index 23496c90c..8fe2efb93 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -74,6 +74,12 @@ public: */ QStringList GetCheckPaths() const; + /** + * @brief Get list of paths to ignore. + * @return list of paths. + */ + QStringList GetIgnoredPaths() const; + /** * @brief Set project root path. * @param rootpath new project root path. @@ -101,6 +107,12 @@ public: */ void SetCheckPaths(QStringList paths); + /** + * @brief Set list of paths to ignore. + * @param defines List of paths. + */ + void SetIgnoredPaths(QStringList paths); + /** * @brief Write project file (to disk). * @param filename Filename to use. @@ -142,6 +154,12 @@ protected: */ void ReadCheckPaths(QXmlStreamReader &reader); + /** + * @brief Read lists of ignores. + * @param reader XML stream reader. + */ + void ReadIgnores(QXmlStreamReader &reader); + private: /** @@ -171,6 +189,11 @@ private: * @brief List of paths to check. */ QStringList mPaths; + + /** + * @brief Paths ignored from the check. + */ + QStringList mIgnoredPaths; }; /// @} #endif // PROJECT_FILE_H