@@ -44,6 +44,8 @@ static const char IgnorePathNameAttrib[] = "name";
4444static const char ExcludeElementName[] = " exclude" ;
4545static const char ExcludePathName[] = " path" ;
4646static const char ExcludePathNameAttrib[] = " name" ;
47+ static const char LibrariesElementName[] = " libraries" ;
48+ static const char LibraryElementName[] = " library" ;
4749
4850ProjectFile::ProjectFile (QObject *parent) :
4951 QObject(parent)
@@ -100,6 +102,10 @@ bool ProjectFile::Read(const QString &filename)
100102 if (insideProject && xmlReader.name () == IgnoreElementName)
101103 ReadExcludes (xmlReader);
102104
105+ // Find libraries list from insid project element
106+ if (insideProject && xmlReader.name () == LibrariesElementName)
107+ ReadLibraries (xmlReader);
108+
103109 break ;
104110
105111 case QXmlStreamReader::EndElement:
@@ -160,6 +166,15 @@ QStringList ProjectFile::GetExcludedPaths() const
160166 return paths;
161167}
162168
169+ QStringList ProjectFile::GetLibraries () const
170+ {
171+ QStringList libraries;
172+ foreach (QString library, mLibraries ) {
173+ libraries << library;
174+ }
175+ return libraries;
176+ }
177+
163178void ProjectFile::ReadRootPath (QXmlStreamReader &reader)
164179{
165180 QXmlStreamAttributes attribs = reader.attributes ();
@@ -327,6 +342,45 @@ void ProjectFile::ReadExcludes(QXmlStreamReader &reader)
327342 } while (!allRead);
328343}
329344
345+
346+ void ProjectFile::ReadLibraries (QXmlStreamReader &reader)
347+ {
348+ QXmlStreamReader::TokenType type;
349+ bool allRead = false ;
350+ do {
351+ type = reader.readNext ();
352+ switch (type) {
353+ case QXmlStreamReader::StartElement:
354+ // Read library-elements
355+ if (reader.name ().toString () == LibraryElementName) {
356+ type = reader.readNext ();
357+ if (type == QXmlStreamReader::Characters) {
358+ QString library = reader.text ().toString ();
359+ mLibraries << library;
360+ }
361+ }
362+ break ;
363+
364+ case QXmlStreamReader::EndElement:
365+ if (reader.name ().toString () == LibrariesElementName)
366+ allRead = true ;
367+ break ;
368+
369+ // Not handled
370+ case QXmlStreamReader::NoToken:
371+ case QXmlStreamReader::Invalid:
372+ case QXmlStreamReader::StartDocument:
373+ case QXmlStreamReader::EndDocument:
374+ case QXmlStreamReader::Characters:
375+ case QXmlStreamReader::Comment:
376+ case QXmlStreamReader::DTD:
377+ case QXmlStreamReader::EntityReference:
378+ case QXmlStreamReader::ProcessingInstruction:
379+ break ;
380+ }
381+ } while (!allRead);
382+ }
383+
330384void ProjectFile::SetIncludes (const QStringList &includes)
331385{
332386 mIncludeDirs = includes;
@@ -347,6 +401,11 @@ void ProjectFile::SetExcludedPaths(const QStringList &paths)
347401 mExcludedPaths = paths;
348402}
349403
404+ void ProjectFile::SetLibraries (const QStringList &libraries)
405+ {
406+ mLibraries = libraries;
407+ }
408+
350409bool ProjectFile::Write (const QString &filename)
351410{
352411 if (!filename.isEmpty ())
@@ -408,6 +467,16 @@ bool ProjectFile::Write(const QString &filename)
408467 xmlWriter.writeEndElement ();
409468 }
410469
470+ if (!mLibraries .isEmpty ()) {
471+ xmlWriter.writeStartElement (LibrariesElementName);
472+ foreach (QString library, mLibraries ) {
473+ xmlWriter.writeStartElement (LibraryElementName);
474+ xmlWriter.writeCharacters (library);
475+ xmlWriter.writeEndElement ();
476+ }
477+ xmlWriter.writeEndElement ();
478+ }
479+
411480 xmlWriter.writeEndDocument ();
412481 file.close ();
413482 return true ;
0 commit comments