diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index 9cf2cc7fb..857960cc4 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -32,6 +32,9 @@ static const char DirNameAttrib[] = "name"; static const char DefinesElementName[] = "defines"; static const char DefineName[] = "define"; static const char DefineNameAttrib[] = "name"; +static const char PathsElementName[] = "paths"; +static const char PathName[] = "dir"; +static const char PathNameAttrib[] = "name"; ProjectFile::ProjectFile(QObject *parent) : QObject(parent) @@ -66,6 +69,9 @@ bool ProjectFile::Read(const QString &filename) insideProject = true; projectTagFound = true; } + // Find paths to check from inside project element + if (insideProject && xmlReader.name() == PathsElementName) + ReadCheckPaths(xmlReader); // Find include directory from inside project element if (insideProject && xmlReader.name() == IncludDirElementName) @@ -113,6 +119,11 @@ QStringList ProjectFile::GetDefines() const return mDefines; } +QStringList ProjectFile::GetCheckPaths() const +{ + return mPaths; +} + void ProjectFile::ReadIncludeDirs(QXmlStreamReader &reader) { QXmlStreamReader::TokenType type; @@ -196,6 +207,48 @@ void ProjectFile::ReadDefines(QXmlStreamReader &reader) while (!allRead); } +void ProjectFile::ReadCheckPaths(QXmlStreamReader &reader) +{ + QXmlStreamReader::TokenType type; + bool allRead = false; + do + { + type = reader.readNext(); + switch (type) + { + case QXmlStreamReader::StartElement: + + // Read dir-elements + if (reader.name().toString() == PathName) + { + QXmlStreamAttributes attribs = reader.attributes(); + QString name = attribs.value("", PathNameAttrib).toString(); + if (!name.isEmpty()) + mPaths << name; + } + break; + + case QXmlStreamReader::EndElement: + if (reader.name().toString() == PathsElementName) + 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; @@ -206,6 +259,11 @@ void ProjectFile::SetDefines(QStringList defines) mDefines = defines; } +void ProjectFile::SetCheckPaths(QStringList paths) +{ + mPaths = paths; +} + bool ProjectFile::Write(const QString &filename) { if (!filename.isEmpty()) @@ -246,6 +304,20 @@ bool ProjectFile::Write(const QString &filename) } xmlWriter.writeEndElement(); } + + if (!mPaths.isEmpty()) + { + xmlWriter.writeStartElement(PathsElementName); + QString path; + foreach(path, mPaths) + { + xmlWriter.writeStartElement(PathName); + xmlWriter.writeAttribute(PathNameAttrib, path); + xmlWriter.writeEndElement(); + } + xmlWriter.writeEndElement(); + } + xmlWriter.writeEndDocument(); file.close(); return true; diff --git a/gui/projectfile.h b/gui/projectfile.h index afbcb8f85..be69a1b2b 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -59,6 +59,12 @@ public: */ QStringList GetDefines() const; + /** + * @brief Get list of paths to check. + * @return list of paths. + */ + QStringList GetCheckPaths() const; + /** * @brief Set list of includes. * @param includes List of defines. @@ -71,6 +77,12 @@ public: */ void SetDefines(QStringList defines); + /** + * @brief Set list of paths to check. + * @param defines List of paths. + */ + void SetCheckPaths(QStringList paths); + /** * @brief Write project file (to disk). * @param filename Filename to use. @@ -99,6 +111,12 @@ protected: */ void ReadDefines(QXmlStreamReader &reader); + /** + * @brief Read list paths to check. + * @param reader XML stream reader. + */ + void ReadCheckPaths(QXmlStreamReader &reader); + private: /** @@ -115,6 +133,11 @@ private: * @brief List of defines. */ QStringList mDefines; + + /** + * @brief List of paths to check. + */ + QStringList mPaths; }; /// @} #endif // PROJECT_FILE_H diff --git a/gui/projectfile.txt b/gui/projectfile.txt index f22c49a82..22944a97c 100644 --- a/gui/projectfile.txt +++ b/gui/projectfile.txt @@ -13,6 +13,9 @@ program. The format is: + + +