diff --git a/gui/main.ui b/gui/main.ui
index e07cdc726..11381be7e 100644
--- a/gui/main.ui
+++ b/gui/main.ui
@@ -1,369 +1,375 @@
-
-
- MainWindow
-
-
-
- 0
- 0
- 640
- 480
-
-
-
-
- 0
- 0
-
-
-
-
- 640
- 480
-
-
-
- Cppcheck
-
-
-
- 22
- 22
-
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 16777215
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
- Standard
-
-
- TopToolBarArea
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
- Categories
-
-
- TopToolBarArea
-
-
- false
-
-
-
-
-
-
- &License...
-
-
-
-
- A&uthors...
-
-
-
-
-
- :/images/help-browser.png:/images/help-browser.png
-
-
- &About...
-
-
-
-
- &Files...
-
-
- Ctrl+F
-
-
-
-
-
- :/icon.png:/icon.png
-
-
- &Directory...
-
-
- Ctrl+D
-
-
-
-
-
- :/images/view-refresh.png:/images/view-refresh.png
-
-
- &Recheck files
-
-
- Ctrl+R
-
-
-
-
-
- :/images/process-stop.png:/images/process-stop.png
-
-
- &Stop
-
-
- Esc
-
-
-
-
-
- :/images/media-floppy.png:/images/media-floppy.png
-
-
- &Save results to file...
-
-
- Ctrl+S
-
-
-
-
- &Quit
-
-
-
-
-
- :/images/edit-clear.png:/images/edit-clear.png
-
-
- &Clear results
-
-
-
-
-
- :/images/preferences-system.png:/images/preferences-system.png
-
-
- &Preferences
-
-
-
-
- true
-
-
-
- :/images/showstylewarnings.png:/images/showstylewarnings.png
-
-
- Show style errors
-
-
-
-
- true
-
-
-
- :/images/showerrors.png:/images/showerrors.png
-
-
- Show common errors
-
-
-
-
- &Check all
-
-
-
-
- &Uncheck all
-
-
-
-
- Collapse &all
-
-
-
-
- &Expand all
-
-
-
-
- true
-
-
- &Standard
-
-
- Standard items
-
-
-
-
- &Contents
-
-
- Open the help contents
-
-
- F1
-
-
-
-
- Toolbar
-
-
-
-
- true
-
-
- &Categories
-
-
- Error categories
-
-
-
-
- P&roject File...
-
-
-
-
-
- ResultsView
- QWidget
-
- 1
-
-
-
-
-
-
-
+
+
+ MainWindow
+
+
+
+ 0
+ 0
+ 640
+ 480
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 640
+ 480
+
+
+
+ Cppcheck
+
+
+
+ 22
+ 22
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ -
+
+
-
+
+
+
+
+
+
+
+
+
+ Standard
+
+
+ TopToolBarArea
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+ Categories
+
+
+ TopToolBarArea
+
+
+ false
+
+
+
+
+
+
+ &License...
+
+
+
+
+ A&uthors...
+
+
+
+
+
+ :/images/help-browser.png:/images/help-browser.png
+
+
+ &About...
+
+
+
+
+ &Files...
+
+
+ Ctrl+F
+
+
+
+
+
+ :/icon.png:/icon.png
+
+
+ &Directory...
+
+
+ Ctrl+D
+
+
+
+
+
+ :/images/view-refresh.png:/images/view-refresh.png
+
+
+ &Recheck files
+
+
+ Ctrl+R
+
+
+
+
+
+ :/images/process-stop.png:/images/process-stop.png
+
+
+ &Stop
+
+
+ Esc
+
+
+
+
+
+ :/images/media-floppy.png:/images/media-floppy.png
+
+
+ &Save results to file...
+
+
+ Ctrl+S
+
+
+
+
+ &Quit
+
+
+
+
+
+ :/images/edit-clear.png:/images/edit-clear.png
+
+
+ &Clear results
+
+
+
+
+
+ :/images/preferences-system.png:/images/preferences-system.png
+
+
+ &Preferences
+
+
+
+
+ true
+
+
+
+ :/images/showstylewarnings.png:/images/showstylewarnings.png
+
+
+ Show style errors
+
+
+
+
+ true
+
+
+
+ :/images/showerrors.png:/images/showerrors.png
+
+
+ Show common errors
+
+
+
+
+ &Check all
+
+
+
+
+ &Uncheck all
+
+
+
+
+ Collapse &all
+
+
+
+
+ &Expand all
+
+
+
+
+ true
+
+
+ &Standard
+
+
+ Standard items
+
+
+
+
+ &Contents
+
+
+ Open the help contents
+
+
+ F1
+
+
+
+
+ Toolbar
+
+
+
+
+ true
+
+
+ &Categories
+
+
+ Error categories
+
+
+
+
+ Open P&roject File...
+
+
+
+
+ &New Project File...
+
+
+
+
+
+ ResultsView
+ QWidget
+
+ 1
+
+
+
+
+
+
+
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 27d9e8ca8..379b3c367 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -80,7 +80,8 @@ MainWindow::MainWindow() :
connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded()));
connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu()));
- connect(mUI.mActionProjectFile, SIGNAL(triggered()), this, SLOT(ShowProjectFileDialog()));
+ connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFileDialog()));
+ connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(ShowProjectFileDialog()));
#ifdef WIN32
connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents()));
@@ -679,3 +680,9 @@ void MainWindow::ShowProjectFileDialog()
dlg.exec();
}
}
+
+void MainWindow::NewProjectFileDialog()
+{
+ ProjectFileDialog dlg(QString(), this);
+ dlg.exec();
+}
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index 7ee6e3225..431f8f730 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -125,6 +125,16 @@ public slots:
*/
void Save();
+ /**
+ * @brief Slot to shown project file dialog for new project file.
+ *
+ */
+ void NewProjectFileDialog();
+
+ /**
+ * @brief Slot to shown project file dialog for existing project file.
+ *
+ */
void ShowProjectFileDialog();
protected slots:
diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp
index ad8681f55..cf896782d 100644
--- a/gui/projectfiledialog.cpp
+++ b/gui/projectfiledialog.cpp
@@ -17,16 +17,30 @@
*/
#include
+#include
+#include
#include "projectfiledialog.h"
#include "projectfile.h"
ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
: QDialog(parent)
, mFileName(path)
+ , mDataSaved(false)
{
mUI.setupUi(this);
+ connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(this, SIGNAL(accepted()), this, SLOT(DialogAccepted()));
+
mPFile = new ProjectFile(path, this);
+ if (QFile::exists(path))
+ {
+ ReadProjectFile();
+ }
+}
+
+void ProjectFileDialog::ReadProjectFile()
+{
mPFile->Read();
QStringList includes = mPFile->GetIncludeDirs();
@@ -48,18 +62,32 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
definestr += ";";
}
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)
+void ProjectFileDialog::DialogAccepted()
{
- if (result == QDialog::Accepted)
+ if (mDataSaved)
+ return;
+
+ UpdateProjectFileData();
+ if (mFileName.isEmpty())
+ {
+ const QString filter = tr("Project files (*.cppcheck);;All files(*.*)");
+ QString filepath = QFileDialog::getSaveFileName(this,
+ tr("Save Project File"),
+ QString(),
+ filter);
+
+ if (!filepath.isEmpty())
+ {
+ mPFile->Write(filepath);
+ }
+ }
+ else
{
- UpdateProjectFileData();
mPFile->Write();
}
+ mDataSaved = true;
}
void ProjectFileDialog::UpdateProjectFileData()
diff --git a/gui/projectfiledialog.h b/gui/projectfiledialog.h
index df0fd74fb..ab04b6635 100644
--- a/gui/projectfiledialog.h
+++ b/gui/projectfiledialog.h
@@ -36,15 +36,17 @@ public:
ProjectFileDialog(const QString &path, QWidget *parent = 0);
protected slots:
- void DialogFinished(int result);
+ void DialogAccepted();
protected:
+ void ReadProjectFile();
void UpdateProjectFileData();
private:
Ui::ProjectFile mUI;
QString mFileName;
ProjectFile *mPFile;
+ bool mDataSaved;
};
/// @}