diff --git a/gui/gui.cppcheck b/gui/gui.cppcheck
index 62d44c9d1..b83d366a0 100644
--- a/gui/gui.cppcheck
+++ b/gui/gui.cppcheck
@@ -1,9 +1,12 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp
index 4d73bccaf..2beb7f1bf 100644
--- a/gui/projectfile.cpp
+++ b/gui/projectfile.cpp
@@ -19,10 +19,13 @@
#include
#include
#include
+#include
#include
#include "projectfile.h"
static const char ProjectElementName[] = "project";
+static const char ProjectVersionAttrib[] = "version";
+static const char ProjectFileVersion[] = "1";
static const char IncludDirElementName[] = "includedir";
static const char DirElementName[] = "dir";
static const char DirNameAttrib[] = "name";
@@ -185,3 +188,55 @@ void ProjectFile::ReadDefines(QXmlStreamReader &reader)
}
while (!allRead);
}
+
+void ProjectFile::SetIncludes(QStringList includes)
+{
+ mIncludeDirs = includes;
+}
+
+void ProjectFile::SetDefines(QStringList defines)
+{
+ mDefines = defines;
+}
+
+bool ProjectFile::Write(const QString &filename)
+{
+ QFile file(mFilename);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ return false;
+
+ QXmlStreamWriter xmlWriter(&file);
+ xmlWriter.setAutoFormatting(true);
+ xmlWriter.writeStartDocument("1.0");
+ xmlWriter.writeStartElement(ProjectElementName);
+ xmlWriter.writeAttribute(ProjectVersionAttrib, ProjectFileVersion);
+
+ if (!mIncludeDirs.isEmpty())
+ {
+ xmlWriter.writeStartElement(IncludDirElementName);
+ QString incdir;
+ foreach(incdir, mIncludeDirs)
+ {
+ xmlWriter.writeStartElement(DirElementName);
+ xmlWriter.writeAttribute(DirNameAttrib, incdir);
+ xmlWriter.writeEndElement();
+ }
+ xmlWriter.writeEndElement();
+ }
+
+ if (!mDefines.isEmpty())
+ {
+ xmlWriter.writeStartElement(DefinesElementName);
+ QString define;
+ foreach(define, mDefines)
+ {
+ xmlWriter.writeStartElement(DefineName);
+ xmlWriter.writeAttribute(DefineNameAttrib, define);
+ xmlWriter.writeEndElement();
+ }
+ xmlWriter.writeEndElement();
+ }
+ xmlWriter.writeEndDocument();
+ file.close();
+ return true;
+}
diff --git a/gui/projectfile.h b/gui/projectfile.h
index 09e82a9ce..dc58fa3e2 100644
--- a/gui/projectfile.h
+++ b/gui/projectfile.h
@@ -59,6 +59,24 @@ public:
*/
QStringList GetDefines() const;
+ /**
+ * @brief Set list of includes.
+ * @param includes List of defines.
+ */
+ void SetIncludes(QStringList includes);
+
+ /**
+ * @brief Set list of defines.
+ * @param defines List of defines.
+ */
+ void SetDefines(QStringList defines);
+
+ /**
+ * @brief Write project file (to disk).
+ * @param filename Filename to use.
+ */
+ bool Write(const QString &filename = QString());
+
protected:
/**
* @brief Read list of include directories from XML.
diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp
index ef6be75b2..ad8681f55 100644
--- a/gui/projectfiledialog.cpp
+++ b/gui/projectfiledialog.cpp
@@ -50,4 +50,23 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
mUI.mEditDefines->setText(definestr);
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(this, SIGNAL(finished(int)), this, SLOT(DialogFinished(int)));
+}
+
+void ProjectFileDialog::DialogFinished(int result)
+{
+ if (result == QDialog::Accepted)
+ {
+ UpdateProjectFileData();
+ mPFile->Write();
+ }
+}
+
+void ProjectFileDialog::UpdateProjectFileData()
+{
+ QStringList includes = mUI.mEditIncludePaths->text().split(";");
+ mPFile->SetIncludes(includes);
+
+ QStringList defines = mUI.mEditDefines->text().split(";");
+ mPFile->SetDefines(defines);
}
diff --git a/gui/projectfiledialog.h b/gui/projectfiledialog.h
index 49cc2193c..df0fd74fb 100644
--- a/gui/projectfiledialog.h
+++ b/gui/projectfiledialog.h
@@ -35,6 +35,12 @@ class ProjectFileDialog : public QDialog
public:
ProjectFileDialog(const QString &path, QWidget *parent = 0);
+protected slots:
+ void DialogFinished(int result);
+
+protected:
+ void UpdateProjectFileData();
+
private:
Ui::ProjectFile mUI;
QString mFileName;