From 0f4d067926d51f63146743e8fcdaa704ba520691 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sun, 15 Aug 2010 16:12:32 +0300 Subject: [PATCH] GUI: Add menuitem to edit open project file. Earlier we opened project file only for editing. But now that we really use project files we need separate feature for editing them. --- gui/main.ui | 11 +++++++++++ gui/mainwindow.cpp | 19 +++++++++++++++++++ gui/mainwindow.h | 6 ++++++ 3 files changed, 36 insertions(+) diff --git a/gui/main.ui b/gui/main.ui index 728a42c61..f0de6a8fa 100644 --- a/gui/main.ui +++ b/gui/main.ui @@ -74,9 +74,12 @@ &File + + + @@ -383,6 +386,14 @@ C&lose Project File + + + false + + + &Edit Project File... + + diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index d33c1bfc5..3ae1e396c 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -90,6 +90,7 @@ MainWindow::MainWindow() : connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); + connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); #ifdef WIN32 connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); @@ -692,6 +693,7 @@ void MainWindow::OpenProjectFile() if (!filepath.isEmpty()) { mUI.mActionCloseProjectFile->setEnabled(true); + mUI.mActionEditProjectFile->setEnabled(true); mProject = new Project(filepath, this); mProject->Open(); QStringList paths = mProject->GetProjectFile()->GetCheckPaths(); @@ -714,6 +716,7 @@ void MainWindow::NewProjectFile() Project prj(filepath, this); prj.Create(); prj.Edit(); + mUI.mActionEditProjectFile->setEnabled(true); } } @@ -722,6 +725,22 @@ void MainWindow::CloseProjectFile() delete mProject; mProject = NULL; mUI.mActionCloseProjectFile->setEnabled(false); + mUI.mActionEditProjectFile->setEnabled(false); +} + +void MainWindow::EditProjectFile() +{ + if (!mProject) + { + QMessageBox msg(QMessageBox::Critical, + tr("Cppcheck"), + QString(tr("No project file loaded")), + QMessageBox::Ok, + this); + msg.exec(); + return; + } + mProject->Edit(); } void MainWindow::ShowLogView() diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 66f80e087..5c1b6ec76 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -152,6 +152,12 @@ public slots: */ void CloseProjectFile(); + /** + * @brief Slot to edit project file. + * + */ + void EditProjectFile(); + /** * @brief Slot for showing the log view. *