From e490852476d72892c653f03346613c8a02735f11 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Thu, 2 Aug 2012 15:09:08 +0300 Subject: [PATCH] GUI: Clear current results before opening XML. Currently if there were results in the GUI the results from XML file were imported to list of results. This is confusing and not what users usually want to do. This patch makes GUI to clear the results before opening new results from XML file. Ticket #3829 (Rename open xml to import xml) --- gui/mainwindow.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 1c9a061b7..1530bbad9 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -608,6 +608,23 @@ void MainWindow::ClearResults() void MainWindow::OpenXML() { + if (mUI.mResults->HasResults()) { + QMessageBox msgBox(this); + msgBox.setWindowTitle(tr("Cppcheck")); + const QString msg(tr("Current results will be cleared.\n\n" + "Opening a new XML file will clear current results." + "Do you want to proceed?")); + msgBox.setText(msg); + msgBox.setIcon(QMessageBox::Warning); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int dlgResult = msgBox.exec(); + if (dlgResult == QMessageBox::No) { + return; + } + } + QString selectedFilter; const QString filter(tr("XML files (*.xml)")); QString selectedFile = QFileDialog::getOpenFileName(this, @@ -617,6 +634,7 @@ void MainWindow::OpenXML() &selectedFilter); if (!selectedFile.isEmpty()) { + mUI.mResults->Clear(); mUI.mResults->ReadErrorsXml(selectedFile); } }