diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts
index 960f7dcff..9e28aaf2b 100644
--- a/gui/cppcheck_de.ts
+++ b/gui/cppcheck_de.ts
@@ -128,15 +128,15 @@ kate -l(line) (file)
MainWindow
-
-
-
-
+
+
+
+
-
+
@@ -146,265 +146,275 @@ kate -l(line) (file)
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
+
+
+
+
+
-
+
-
+
-
+
%1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -451,6 +477,51 @@ Stop the checking before exiting.
+
+ Project
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFileDialog
+
+
+
+
+
+
QObject
diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts
index a1292eba6..c42a0f1e1 100644
--- a/gui/cppcheck_en.ts
+++ b/gui/cppcheck_en.ts
@@ -141,15 +141,15 @@ kate -l(line) (file)
MainWindow
-
-
-
-
+
+
+
+
Cppcheck
-
+
Standard
@@ -159,217 +159,222 @@ kate -l(line) (file)
&File
-
+
&View
-
+
-
+
&Check
-
+
&Edit
-
+
&License...
-
+
A&uthors...
-
+
&About...
-
+
&Files...
-
+
Ctrl+F
-
+
&Directory...
-
+
Ctrl+D
-
+
&Recheck files
-
+
Ctrl+R
-
+
&Stop
-
+
Esc
-
+
&Save results to file...
-
+
Ctrl+S
-
+
&Quit
-
+
&Clear results
-
+
&Preferences
-
+
Show style errors
-
+
Show common errors
-
+
&Check all
-
+
&Uncheck all
-
+
Collapse &all
-
+
&Expand all
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
&Language
-
+
&Help
-
+
Select files to check
-
+
Select directory to check
-
+
No suitable files found to check!
-
-
-
-
-
-
+
@@ -378,48 +383,53 @@ Stop the checking before exiting.
Stop the checking before exiting.
-
+
License
-
+
Authors
-
+
XML files (*.xml);;Text files (*.txt);;CSV files (*.csv)
-
+
Save the report file
-
-
+
+
XML files (*.xml)
-
+
+
+
+
+
+
Text files (*.txt)
-
+
-
+
Cppcheck - %1
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -468,6 +494,51 @@ Stop the checking before exiting.
Polish
+
+ Project
+
+
+
+
+ Cppcheck
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFileDialog
+
+
+
+
+
+
QObject
diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts
index d962b2729..1e45bf547 100644
--- a/gui/cppcheck_fi.ts
+++ b/gui/cppcheck_fi.ts
@@ -143,15 +143,15 @@ kate -l(line) (file)
MainWindow
-
-
-
-
+
+
+
+
Cppcheck
-
+
Vakio
@@ -161,217 +161,222 @@ kate -l(line) (file)
&Tiedosto
-
+
&Näytä
-
+
-
+
&Tarkista
-
+
&Muokkaa
-
+
&Lisenssi...
-
+
&Tekijät...
-
+
&Tietoa ohjelmasta Cppcheck...
-
+
&Tiedostot...
-
+
Ctrl+F
-
+
&Hakemisto...
-
+
Ctrl+D
-
+
Tarkista tiedostot &uudelleen
-
+
Ctrl+R
-
+
&Pysäytä
-
+
Esc
-
+
&Tallenna tulokset tiedostoon...
-
+
Ctrl+S
-
+
&Lopeta
-
+
&Tyhjennä tulokset
-
+
&Asetukset
-
+
Näytä tyylivirheet
-
+
Näytä yleiset virheet
-
+
&Valitse kaikki
-
+
&Poista kaikista valinta
-
+
&Pienennä kaikki
-
+
&Laajenna kaikki
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
&Kieli
-
+
&Ohje
-
+
Valitse tarkistettavat tiedostot
-
+
Valitse tarkistettava hakemisto
-
+
Tarkistettavaksi sopivia tiedostoja ei löytynyt!
-
-
-
-
-
-
+
@@ -380,48 +385,53 @@ Stop the checking before exiting.
Lopeta tarkistus ennen ohjelman sammuttamista.
-
+
Lisenssi
-
+
Tekijät
-
+
XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv)
-
+
Tallenna raportti
-
-
+
+
XML-tiedostot (*xml)
-
+
+
+
+
+
+
Tekstitiedostot (*.txt)
-
+
-
+
Cppcheck - %1
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -472,6 +498,51 @@ Lopeta tarkistus ennen ohjelman sammuttamista.
Puola
+
+ Project
+
+
+
+
+ Cppcheck
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFileDialog
+
+
+
+
+
+
QObject
diff --git a/gui/cppcheck_nl.ts b/gui/cppcheck_nl.ts
index d52970c59..822e4ec5e 100644
--- a/gui/cppcheck_nl.ts
+++ b/gui/cppcheck_nl.ts
@@ -141,15 +141,15 @@ kate -l(line) (file)
MainWindow
-
-
-
-
+
+
+
+
Cppcheck
-
+
Standaard
@@ -159,217 +159,222 @@ kate -l(line) (file)
&Bestand
-
+
&Weergave
-
+
-
+
&Controleer
-
+
Be&werken
-
+
&Licentie...
-
+
A&uteurs...
-
+
&Over...
-
+
&Bestanden...
-
+
Ctrl+F
-
+
&Mappen...
-
+
Ctrl+D
-
+
&Opnieuw controleren
-
+
Ctrl+R
-
+
&Stop
-
+
Esc
-
+
&Resultaten opslaan...
-
+
Ctrl+S
-
+
&Afsluiten
-
+
&Resultaten wissen
-
+
&Voorkeuren
-
+
Toon stijl fouten
-
+
Toon gewone fouten
-
+
&Selecteer alles
-
+
Selecteer &niets
-
+
Alles Inkl&appen
-
+
Alles &Uitklappen
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
&Taal
-
+
&Help
-
+
Selecteer bestanden om te controleren
-
+
Selecteer een map om te controleren
-
+
Geen geschikte bestanden gevonden om te controleren!
-
-
-
-
-
-
+
@@ -378,48 +383,53 @@ Stop the checking before exiting.
Stop de controle alvorens te sluiten.
-
+
Licentie
-
+
Auteurs
-
+
XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv)
-
+
Rapport opslaan
-
-
+
+
XML bestanden (*.xml)
-
+
+
+
+
+
+
Tekst bestanden (*.txt)
-
+
-
+
Cppcheck - %1
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -468,6 +494,51 @@ Stop de controle alvorens te sluiten.
Pools
+
+ Project
+
+
+
+
+ Cppcheck
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFileDialog
+
+
+
+
+
+
QObject
diff --git a/gui/cppcheck_pl.ts b/gui/cppcheck_pl.ts
index 49c8a7820..328fbeed8 100644
--- a/gui/cppcheck_pl.ts
+++ b/gui/cppcheck_pl.ts
@@ -128,10 +128,10 @@ kate -l(line) (file)
MainWindow
-
-
-
-
+
+
+
+
@@ -141,270 +141,285 @@ kate -l(line) (file)
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -448,6 +474,51 @@ Stop the checking before exiting.
+
+ Project
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFileDialog
+
+
+
+
+
+
QObject
diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts
index 73a38de0d..02c1f88c0 100644
--- a/gui/cppcheck_ru.ts
+++ b/gui/cppcheck_ru.ts
@@ -131,15 +131,15 @@ kate -l(line) (file)
MainWindow
-
-
-
-
+
+
+
+
Cppcheck
-
+
@@ -149,265 +149,275 @@ kate -l(line) (file)
Файл
-
+
Вид
-
+
-
+
Проверить
-
+
Правка
-
+
Лицензия...
-
+
Авторы...
-
+
О программе...
-
+
Файлы...
-
+
Ctrl+F
-
+
Каталог...
-
+
Ctrl+D
-
+
-
+
Ctrl+R
-
+
Остановить
-
+
Esc
-
+
Сохранить отчёт в файл...
-
+
Ctrl+S
-
+
Выход
-
+
Очистить отчёт
-
+
Параметры
-
+
Показывать ошибки стиля
-
+
Показывать общие ошибки
-
+
Отметить все
-
+
Сбросить все
-
+
Свернуть все
-
+
Развернуть все
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
Язык
-
+
Помощь
-
+
Выберите файлы для проверки
-
+
Выберите каталог для проверки
-
+
-
-
-
-
-
-
+
-
+
Лицензия
-
+
Авторы
-
+
-
+
-
-
+
+
-
+
+
+
+
+
+
Текстовые файлы (*.txt)
-
+
-
+
Cppcheck - %1
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -458,6 +484,51 @@ Stop the checking before exiting.
+
+ Project
+
+
+
+
+ Cppcheck
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFileDialog
+
+
+
+
+
+
QObject
diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_se.ts
index 3a19447e8..f1e6f87e7 100644
--- a/gui/cppcheck_se.ts
+++ b/gui/cppcheck_se.ts
@@ -141,15 +141,15 @@ kate -l(line) (file)
MainWindow
-
-
-
-
+
+
+
+
Cppcheck
-
+
Standard
@@ -159,266 +159,276 @@ kate -l(line) (file)
&Arkiv
-
+
&Visa
-
+
Verktygsfält
-
+
&Check
-
+
&Redigera
-
+
&Licens...
-
+
&Utvecklat av...
-
+
&Om...
-
+
&Filer...
-
+
Ctrl+F
-
+
&Katalog...
-
+
Ctrl+D
-
+
Starta &om check
-
+
Ctrl+R
-
+
&Stoppa
-
+
Esc
-
+
&Spara resultat till fil...
-
+
Ctrl+S
-
+
&Avsluta
-
+
&Töm resultat
-
+
&Inställningar
-
+
Visa stilvarningar
-
+
Visa vanliga fel
-
+
&Kryssa alla
-
+
Kryssa &ur alla
-
+
Ingen bra översättning!
&Fäll ihop alla
-
+
&Expandera alla
-
+
&Standard
-
+
Standard poster
-
+
Verktygsfält
-
+
&Kategorier
-
+
Fel kategorier
-
+
-
+
+
+
+
+
+
+
+
+
+
+
&Innehåll
-
+
Kategorier
-
+
Öppna hjälp
-
+
F1
-
+
&Språk
-
+
&Hjälp
-
+
Välj filer att kontrollera
-
+
Välj katalog som skall kontrolleras
-
+
Inga lämpliga filer hittades!
-
-
-
-
-
-
+
Kan ej avsluta medans check pågår.
-
+
Licens
-
+
Utvecklare
-
+
XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv)
-
+
Spara rapport
-
-
+
+
XML filer (*.xml)
-
+
+
+
+
+
+
Text filer (*.txt)
-
+
CSV filer (*.csv)
-
+
Cppcheck - %1
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -469,6 +495,51 @@ Stop the checking before exiting.
Polska
+
+ Project
+
+
+
+
+ Cppcheck
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProjectFileDialog
+
+
+
+
+
+
QObject
diff --git a/gui/gui.cppcheck b/gui/gui.cppcheck
index 62d44c9d1..632b61115 100644
--- a/gui/gui.cppcheck
+++ b/gui/gui.cppcheck
@@ -1,9 +1,6 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/gui/gui.pro b/gui/gui.pro
index 84265f8ea..3e1de7f02 100644
--- a/gui/gui.pro
+++ b/gui/gui.pro
@@ -25,6 +25,7 @@ FORMS = main.ui \
application.ui \
settings.ui \
file.ui \
+ projectfile.ui \
about.ui
TRANSLATIONS = cppcheck_fi.ts \
@@ -52,7 +53,9 @@ HEADERS += mainwindow.h \
common.h \
erroritem.h \
fileviewdialog.h \
+ project.h \
projectfile.h \
+ projectfiledialog.h \
report.h \
txtreport.h \
xmlreport.h \
@@ -70,7 +73,9 @@ SOURCES += main.cpp \
applicationdialog.cpp \
aboutdialog.cpp \
fileviewdialog.cpp \
+ project.cpp \
projectfile.cpp \
+ projectfiledialog.cpp \
erroritem.cpp \
report.cpp \
txtreport.cpp \
diff --git a/gui/main.ui b/gui/main.ui
index 3317d4452..939106b55 100644
--- a/gui/main.ui
+++ b/gui/main.ui
@@ -74,6 +74,8 @@
&File
+
+
@@ -353,6 +355,16 @@
&Open XML...
+
+
+ Open P&roject File...
+
+
+
+
+ &New Project File...
+
+
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 34ec7c1de..e4e15e1ef 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -31,6 +31,7 @@
#include "threadhandler.h"
#include "fileviewdialog.h"
#include "projectfile.h"
+#include "project.h"
#include "report.h"
#include "../lib/filelister.h"
@@ -80,6 +81,9 @@ MainWindow::MainWindow() :
connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded()));
connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu()));
+ connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile()));
+ connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile()));
+
#ifdef WIN32
connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents()));
#else
@@ -231,6 +235,8 @@ void MainWindow::DoCheckFiles(const QStringList &files)
EnableCheckButtons(false);
mUI.mActionSettings->setEnabled(false);
mUI.mActionOpenXML->setEnabled(false);
+ mUI.mActionNewProjectFile->setEnabled(false);
+ mUI.mActionOpenProjectFile->setEnabled(false);
mUI.mResults->SetCheckDirectory(absDirectory);
@@ -392,6 +398,9 @@ void MainWindow::CheckDone()
EnableCheckButtons(true);
mUI.mActionSettings->setEnabled(true);
mUI.mActionOpenXML->setEnabled(true);
+ mUI.mActionNewProjectFile->setEnabled(false);
+ mUI.mActionOpenProjectFile->setEnabled(false);
+
if (mUI.mResults->HasResults())
{
mUI.mActionClearResults->setEnabled(true);
@@ -680,3 +689,35 @@ void MainWindow::OpenHtmlHelpContents()
HtmlHelp(NULL, exeFolder.utf16(), HH_DISPLAY_TOPIC, NULL);
#endif // WIN32
}
+
+void MainWindow::OpenProjectFile()
+{
+ const QString filter = tr("Project files (*.cppcheck);;All files(*.*)");
+ QString filepath = QFileDialog::getOpenFileName(this,
+ tr("Select Project File"),
+ QString(),
+ filter);
+
+ if (!filepath.isEmpty())
+ {
+ Project prj(filepath, this);
+ if (prj.Open())
+ prj.Edit();
+ }
+}
+
+void MainWindow::NewProjectFile()
+{
+ const QString filter = tr("Project files (*.cppcheck);;All files(*.*)");
+ QString filepath = QFileDialog::getSaveFileName(this,
+ tr("Select Project Filename"),
+ QString(),
+ filter);
+
+ if (!filepath.isEmpty())
+ {
+ Project prj(filepath, this);
+ prj.Create();
+ prj.Edit();
+ }
+}
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index 3142dccaa..1c8cae8b2 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -131,6 +131,18 @@ public slots:
*/
void Save();
+ /**
+ * @brief Slot to create new project file..
+ *
+ */
+ void NewProjectFile();
+
+ /**
+ * @brief Slot to edit existing project file.
+ *
+ */
+ void OpenProjectFile();
+
protected slots:
/**
diff --git a/gui/project.cpp b/gui/project.cpp
new file mode 100644
index 000000000..5d4f89661
--- /dev/null
+++ b/gui/project.cpp
@@ -0,0 +1,108 @@
+/*
+ * Cppcheck - A tool for static C/C++ code analysis
+ * Copyright (C) 2007-2010 Daniel Marjamki and Cppcheck team.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "project.h"
+#include "projectfile.h"
+#include "projectfiledialog.h"
+
+Project::Project(QWidget *parent) :
+ QObject(parent),
+ mPFile(NULL),
+ mParentWidget(parent)
+{
+}
+
+Project::Project(const QString &filename, QWidget *parent) :
+ QObject(parent),
+ mFilename(filename),
+ mPFile(NULL),
+ mParentWidget(parent)
+{
+}
+
+Project::~Project()
+{
+ delete mPFile;
+}
+
+void Project::SetFilename(const QString &filename)
+{
+ mFilename = filename;
+}
+
+bool Project::Open()
+{
+ mPFile = new ProjectFile(mFilename, this);
+ if (QFile::exists(mFilename))
+ {
+ if (!mPFile->Read())
+ {
+ QMessageBox msg(QMessageBox::Critical,
+ tr("Cppcheck"),
+ tr("Could not read the project file."),
+ QMessageBox::Ok,
+ mParentWidget);
+ msg.exec();
+ mFilename = QString();
+ mPFile->SetFilename(mFilename);
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+void Project::Edit()
+{
+ ProjectFileDialog dlg(mFilename, mParentWidget);
+
+ QStringList includes = mPFile->GetIncludeDirs();
+ dlg.SetIncludepaths(includes);
+ QStringList defines = mPFile->GetDefines();
+ dlg.SetDefines(defines);
+ int rv = dlg.exec();
+ if (rv == QDialog::Accepted)
+ {
+ QStringList includes = dlg.GetIncludePaths();
+ mPFile->SetIncludes(includes);
+ QStringList defines = dlg.GetDefines();
+ mPFile->SetDefines(defines);
+ bool writeSuccess = mPFile->Write();
+ if (!writeSuccess)
+ {
+ QMessageBox msg(QMessageBox::Critical,
+ tr("Cppcheck"),
+ tr("Could not write the project file."),
+ QMessageBox::Ok,
+ mParentWidget);
+ msg.exec();
+ }
+ }
+}
+
+void Project::Create()
+{
+ mPFile = new ProjectFile(mFilename, this);
+}
diff --git a/gui/project.h b/gui/project.h
new file mode 100644
index 000000000..146375d88
--- /dev/null
+++ b/gui/project.h
@@ -0,0 +1,74 @@
+/*
+ * Cppcheck - A tool for static C/C++ code analysis
+ * Copyright (C) 2007-2010 Daniel Marjamki and Cppcheck team.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef PROJECT_H
+#define PROJECT_H
+
+#include
+#include
+
+class QWidget;
+class ProjectFile;
+
+/// @addtogroup GUI
+/// @{
+
+/**
+* @brief A class that contains project data and manages projects.
+* Currently only project file creation and editing is implemented.
+*/
+class Project : public QObject
+{
+ Q_OBJECT
+
+public:
+ Project(QWidget *parent = 0);
+ Project(const QString &filename, QWidget *parent = 0);
+ ~Project();
+
+ /**
+ * @brief Set filename for the project file.
+ * @param filename Filename.
+ */
+ void SetFilename(const QString &filename);
+
+ /**
+ * @brief Open existing project file.
+ */
+ bool Open();
+
+ /**
+ * @brief Edit the project file.
+ */
+ void Edit();
+
+ /**
+ * @brief Create new project file.
+ */
+ void Create();
+
+private:
+
+ QString mFilename;
+ ProjectFile *mPFile;
+ QWidget *mParentWidget;
+};
+
+/// @}
+
+#endif // PROJECT_H
diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp
index 4d73bccaf..9cf2cc7fb 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";
@@ -52,13 +55,17 @@ bool ProjectFile::Read(const QString &filename)
QXmlStreamReader xmlReader(&file);
bool insideProject = false;
+ bool projectTagFound = false;
while (!xmlReader.atEnd())
{
switch (xmlReader.readNext())
{
case QXmlStreamReader::StartElement:
if (xmlReader.name() == ProjectElementName)
+ {
insideProject = true;
+ projectTagFound = true;
+ }
// Find include directory from inside project element
if (insideProject && xmlReader.name() == IncludDirElementName)
@@ -90,7 +97,10 @@ bool ProjectFile::Read(const QString &filename)
}
file.close();
- return true;
+ if (projectTagFound)
+ return true;
+ else
+ return false;
}
QStringList ProjectFile::GetIncludeDirs() const
@@ -185,3 +195,58 @@ 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)
+{
+ if (!filename.isEmpty())
+ mFilename = 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..afbcb8f85 100644
--- a/gui/projectfile.h
+++ b/gui/projectfile.h
@@ -31,7 +31,7 @@
/**
* @brief A class that reads and writes (TODO) project files.
* The project files contain project-specific settings for checking. For
-* example a list of automatically deallocated classes.
+* example a list of include paths.
*/
class ProjectFile : public QObject
{
@@ -59,6 +59,33 @@ 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());
+
+ /**
+ * @brief Set filename for the project file.
+ * @param filename Filename to use.
+ */
+ void SetFilename(const QString &filename)
+ {
+ mFilename = filename;
+ }
+
protected:
/**
* @brief Read list of include directories from XML.
diff --git a/gui/projectfile.txt b/gui/projectfile.txt
index c7069e3ff..f22c49a82 100644
--- a/gui/projectfile.txt
+++ b/gui/projectfile.txt
@@ -4,20 +4,15 @@ Project files
cppcheck GUI handles per-project settings in project files instead of global
program settings. This allows customizing cppcheck for each project's needs.
-Currently there is no GUI to edit the project file. The cppcheck automatically
-loads a project file which has same name than selected directory and extension
-".cppcheck". For example in "gui"-directory cppcheck loads "gui.cppcheck"
-project file.
+The cppcheck automatically loads a project file which has same name than
+selected directory and extension ".cppcheck". For example in "gui"-directory
+cppcheck loads "gui.cppcheck" project file.
The project file is simple XML file easy to edit with your favourite editor
program. The format is:
-
-
-
-
diff --git a/gui/projectfile.ui b/gui/projectfile.ui
new file mode 100644
index 000000000..fd005658e
--- /dev/null
+++ b/gui/projectfile.ui
@@ -0,0 +1,111 @@
+
+
+ ProjectFile
+
+
+
+ 0
+ 0
+ 400
+ 112
+
+
+
+ Project File
+
+
+ -
+
+
-
+
+
+ Include paths:
+
+
+ mEditIncludePaths
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ Defines:
+
+
+ mEditDefines
+
+
+
+ -
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+ mButtons
+ accepted()
+ ProjectFile
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ mButtons
+ rejected()
+ ProjectFile
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp
new file mode 100644
index 000000000..319505380
--- /dev/null
+++ b/gui/projectfiledialog.cpp
@@ -0,0 +1,94 @@
+/*
+ * Cppcheck - A tool for static C/C++ code analysis
+ * Copyright (C) 2007-2010 Daniel Marjamki and Cppcheck team.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+#include "projectfiledialog.h"
+
+ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
+ : QDialog(parent)
+{
+ mUI.setupUi(this);
+
+ QFileInfo inf(path);
+ QString filename = inf.fileName();
+ QString title = tr("Project file: %1").arg(filename);
+ setWindowTitle(title);
+
+ connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
+}
+
+QStringList ProjectFileDialog::GetIncludePaths() const
+{
+ QString include = mUI.mEditIncludePaths->text();
+ QStringList includes;
+ if (!include.isEmpty())
+ {
+ include = include.trimmed();
+ if (include.indexOf(';') != -1)
+ includes = include.split(";");
+ else
+ includes.append(include);
+ }
+ return includes;
+}
+
+QStringList ProjectFileDialog::GetDefines() const
+{
+ QString define = mUI.mEditDefines->text();
+ QStringList defines;
+ if (!define.isEmpty())
+ {
+ define = define.trimmed();
+ if (define.indexOf(';') != -1)
+ defines = define.split(";");
+ else
+ defines.append(define);
+ }
+ return defines;
+}
+
+void ProjectFileDialog::SetIncludepaths(const QStringList &includes)
+{
+ QString includestr;
+ QString dir;
+ foreach(dir, includes)
+ {
+ includestr += dir;
+ includestr += ";";
+ }
+ // Remove ; from the end of the string
+ if (includestr.endsWith(';'))
+ includestr = includestr.left(includestr.length() - 1);
+ mUI.mEditIncludePaths->setText(includestr);
+}
+
+void ProjectFileDialog::SetDefines(const QStringList &defines)
+{
+ QString definestr;
+ QString define;
+ foreach(define, defines)
+ {
+ definestr += define;
+ definestr += ";";
+ }
+ // Remove ; from the end of the string
+ if (definestr.endsWith(';'))
+ definestr = definestr.left(definestr.length() - 1);
+ mUI.mEditDefines->setText(definestr);
+}
diff --git a/gui/projectfiledialog.h b/gui/projectfiledialog.h
new file mode 100644
index 000000000..c3252fe35
--- /dev/null
+++ b/gui/projectfiledialog.h
@@ -0,0 +1,71 @@
+/*
+ * Cppcheck - A tool for static C/C++ code analysis
+ * Copyright (C) 2007-2010 Daniel Marjamki and Cppcheck team.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef PROJECTFILE_DIALOG_H
+#define PROJECTFILE_DIALOG_H
+
+#include
+#include
+
+#include "ui_projectfile.h"
+
+class ProjectFile;
+
+/// @addtogroup GUI
+/// @{
+
+
+/**
+* @brief A dialog for editing project file data.
+*/
+class ProjectFileDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ ProjectFileDialog(const QString &path, QWidget *parent = 0);
+
+ /**
+ * @brief Return include paths from the dialog control.
+ * @return List of include paths.
+ */
+ QStringList GetIncludePaths() const;
+
+ /**
+ * @brief Return define names from the dialog control.
+ * @return List of define names.
+ */
+ QStringList GetDefines() const;
+
+ /**
+ * @brief Set include paths to dialog control.
+ * @param includes List of include paths to set to dialog control.
+ */
+ void SetIncludepaths(const QStringList &includes);
+
+ /**
+ * @brief Set define names to dialog control.
+ * @param defines List of define names to set to dialog control.
+ */
+ void SetDefines(const QStringList &defines);
+
+private:
+ Ui::ProjectFile mUI;
+};
+
+/// @}
+#endif // PROJECTFILE_DIALOG_H