GUI: Read include directories from project file.
This commit is contained in:
parent
3132041de3
commit
462117485d
|
@ -293,6 +293,13 @@ Settings MainWindow::GetCppcheckSettings()
|
|||
{
|
||||
result.addAutoAllocClass(classname.toStdString());
|
||||
}
|
||||
|
||||
QStringList dirs = pfile.GetIncludeDirs();
|
||||
QString dir;
|
||||
foreach(dir, dirs)
|
||||
{
|
||||
result._includePaths.push_back(dir.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ static const char ProjectElementName[] = "project";
|
|||
static const char AllocElementName[] = "autodealloc";
|
||||
static const char ClassElementName[] = "class";
|
||||
static const char ClassNameAttrib[] = "name";
|
||||
static const char IncludDirElementName[] = "includedir";
|
||||
static const char DirElementName[] = "dir";
|
||||
static const char DirNameAttrib[] = "name";
|
||||
|
||||
ProjectFile::ProjectFile(QObject *parent) :
|
||||
QObject(parent)
|
||||
|
@ -60,6 +63,9 @@ bool ProjectFile::Read(const QString &filename)
|
|||
// Find allocelement from inside project element
|
||||
if (insideProject && xmlReader.name() == AllocElementName)
|
||||
ReadAutoAllocClasses(xmlReader);
|
||||
|
||||
if (insideProject && xmlReader.name() == IncludDirElementName)
|
||||
ReadIncludeDirs(xmlReader);
|
||||
break;
|
||||
|
||||
case QXmlStreamReader::EndElement:
|
||||
|
@ -90,6 +96,11 @@ QStringList ProjectFile::GetDeAllocatedClasses() const
|
|||
return mDeAllocatedClasses;
|
||||
}
|
||||
|
||||
QStringList ProjectFile::GetIncludeDirs() const
|
||||
{
|
||||
return mIncludeDirs;
|
||||
}
|
||||
|
||||
void ProjectFile::ReadAutoAllocClasses(QXmlStreamReader &reader)
|
||||
{
|
||||
QXmlStreamReader::TokenType type;
|
||||
|
@ -131,3 +142,45 @@ void ProjectFile::ReadAutoAllocClasses(QXmlStreamReader &reader)
|
|||
}
|
||||
while (!allRead);
|
||||
}
|
||||
|
||||
void ProjectFile::ReadIncludeDirs(QXmlStreamReader &reader)
|
||||
{
|
||||
QXmlStreamReader::TokenType type;
|
||||
bool allRead = false;
|
||||
do
|
||||
{
|
||||
type = reader.readNext();
|
||||
switch (type)
|
||||
{
|
||||
case QXmlStreamReader::StartElement:
|
||||
|
||||
// Read dir-elements
|
||||
if (reader.name().toString() == DirElementName)
|
||||
{
|
||||
QXmlStreamAttributes attribs = reader.attributes();
|
||||
QString name = attribs.value("", DirNameAttrib).toString();
|
||||
if (!name.isEmpty())
|
||||
mIncludeDirs << name;
|
||||
}
|
||||
break;
|
||||
|
||||
case QXmlStreamReader::EndElement:
|
||||
if (reader.name().toString() == IncludDirElementName)
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -49,9 +49,25 @@ public:
|
|||
*/
|
||||
QStringList GetDeAllocatedClasses() const;
|
||||
|
||||
/**
|
||||
* @brief Get list of include directories.
|
||||
* @return list of directories.
|
||||
*/
|
||||
QStringList GetIncludeDirs() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Read list of automatically deallocated classes from XML.
|
||||
* @param reader XML stream reader.
|
||||
*/
|
||||
void ReadAutoAllocClasses(QXmlStreamReader &reader);
|
||||
|
||||
/**
|
||||
* @brief Read list of include directories from XML.
|
||||
* @param reader XML stream reader.
|
||||
*/
|
||||
void ReadIncludeDirs(QXmlStreamReader &reader);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -63,6 +79,11 @@ private:
|
|||
* @brief List of automatically deallocated classes.
|
||||
*/
|
||||
QStringList mDeAllocatedClasses;
|
||||
|
||||
/**
|
||||
* @brief List of include directories used to search include files.
|
||||
*/
|
||||
QStringList mIncludeDirs;
|
||||
};
|
||||
|
||||
#endif // PROJECT_FILE_H
|
||||
|
|
Loading…
Reference in New Issue