GUI: Add ignored paths support to project file.
This patch adds support for ignored paths in the project file. There is new <ignore> element which can contain one or more <path> elements with name attribute containing the path to ignore.
This commit is contained in:
parent
e3f779a41c
commit
d6f6da10fa
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue