Skip to content

Commit a330e9c

Browse files
committed
Added the initial version of saving results to a file.
1 parent 2a7470e commit a330e9c

File tree

11 files changed

+546
-16
lines changed

11 files changed

+546
-16
lines changed

gui/mainwindow.cpp

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ MainWindow::MainWindow() :
110110

111111
connect(&mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
112112
connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
113+
connect(&mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded()));
113114

114115
//Toolbar
115116
QToolBar *toolbar = addToolBar("Toolbar");
@@ -140,6 +141,9 @@ MainWindow::MainWindow() :
140141
setWindowTitle(tr("Cppcheck"));
141142

142143
EnableCheckButtons(true);
144+
145+
mActionClearResults.setEnabled(false);
146+
mActionSave.setEnabled(false);
143147
}
144148

145149
MainWindow::~MainWindow()
@@ -210,6 +214,7 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
210214
mThread.SetFiles(RemoveUnacceptedFiles(fileNames));
211215
mSettings.setValue(tr("Check path"), dialog.directory().absolutePath());
212216
EnableCheckButtons(false);
217+
mResults.SetCheckDirectory(dialog.directory().absolutePath());
213218
mThread.Check(GetCppcheckSettings(), false);
214219
}
215220
}
@@ -295,6 +300,9 @@ void MainWindow::ProgramSettings()
295300
if (dialog.exec() == QDialog::Accepted)
296301
{
297302
dialog.SaveCheckboxValues();
303+
mResults.UpdateSettings(dialog.ShowFullPath(),
304+
dialog.SaveFullPath(),
305+
dialog.SaveAllErrors());
298306
}
299307
}
300308

@@ -309,6 +317,8 @@ void MainWindow::ReCheck()
309317
void MainWindow::ClearResults()
310318
{
311319
mResults.Clear();
320+
mActionClearResults.setEnabled(false);
321+
mActionSave.setEnabled(false);
312322
}
313323

314324
void MainWindow::EnableCheckButtons(bool enable)
@@ -396,9 +406,30 @@ void MainWindow::About()
396406

397407
void MainWindow::Save()
398408
{
399-
QMessageBox msgBox;
400-
msgBox.setWindowTitle(tr("Not implemented yet..."));
401-
msgBox.setText(tr("Not implemented yet..."));
402-
msgBox.exec();
409+
QFileDialog dialog(this);
410+
dialog.setFileMode(QFileDialog::AnyFile);
411+
dialog.setAcceptMode(QFileDialog::AcceptSave);
412+
413+
QStringList filters;
414+
filters << tr("XML files (*.xml)") << tr("Text files (*.txt)");
415+
dialog.setNameFilters(filters);
416+
417+
if (dialog.exec())
418+
{
419+
QStringList list = dialog.selectedFiles();
420+
421+
if (list.size() > 0)
422+
{
423+
bool xml = (dialog.selectedNameFilter() == filters[0] && list[0].endsWith(".xml", Qt::CaseInsensitive));
424+
mResults.Save(list[0], xml);
425+
}
426+
}
403427
}
404428

429+
void MainWindow::ResultsAdded()
430+
{
431+
mActionClearResults.setEnabled(true);
432+
mActionSave.setEnabled(true);
433+
}
434+
435+

gui/mainwindow.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ protected slots:
133133
*
134134
*/
135135
void CheckDone();
136+
137+
/**
138+
* @brief Slot for enabling save and clear button
139+
*
140+
*/
141+
void ResultsAdded();
136142
protected:
137143

138144
/**

0 commit comments

Comments
 (0)