GUI: reopen project after restart. If build dir is specified the last results will also be shown.
This commit is contained in:
parent
f76ff9e7bf
commit
fcce43fb8d
|
@ -85,6 +85,7 @@
|
|||
#define SETTINGS_MRU_PROJECTS "MRU Projects"
|
||||
#define SETTINGS_SHOW_ERROR_ID "Show error Id"
|
||||
#define SETTINGS_SHOW_STATISTICS "Show statistics"
|
||||
#define SETTINGS_OPEN_PROJECT "Open Project"
|
||||
|
||||
// The maximum value for the progress bar
|
||||
#define PROGRESS_MAX 1024.0
|
||||
|
|
|
@ -139,7 +139,10 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
|
|||
loadSettings();
|
||||
|
||||
mThread->initialize(mUI.mResults);
|
||||
formatAndSetTitle();
|
||||
if (mProject)
|
||||
formatAndSetTitle(tr("Project:") + ' ' + mProject->getFilename());
|
||||
else
|
||||
formatAndSetTitle();
|
||||
|
||||
enableCheckButtons(true);
|
||||
|
||||
|
@ -172,6 +175,9 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
|
|||
handleCLIParams(args);
|
||||
}
|
||||
|
||||
mUI.mActionCloseProjectFile->setEnabled(mProject != nullptr);
|
||||
mUI.mActionEditProjectFile->setEnabled(mProject != nullptr);
|
||||
|
||||
for (int i = 0; i < mPlatforms.getCount(); i++) {
|
||||
Platform plat = mPlatforms.mPlatforms[i];
|
||||
QAction *act = new QAction(this);
|
||||
|
@ -310,9 +316,23 @@ void MainWindow::loadSettings()
|
|||
QMessageBox::Ok,
|
||||
this);
|
||||
msgBox.exec();
|
||||
|
||||
}
|
||||
|
||||
const QString project = mSettings->value(SETTINGS_OPEN_PROJECT, QString()).toString();
|
||||
if (!project.isEmpty() && QCoreApplication::arguments().size()==1) {
|
||||
QFileInfo inf(project);
|
||||
if (inf.exists() && inf.isReadable()) {
|
||||
delete mProject;
|
||||
mProject = new Project(project, this);
|
||||
mProject->open();
|
||||
if (!mProject->getProjectFile()->getBuildDir().isEmpty()) {
|
||||
const QString buildDir = QFileInfo(project).absolutePath() + '/' + mProject->getProjectFile()->getBuildDir();
|
||||
const QString lastResults = buildDir + "/lastResults.xml";
|
||||
if (QFileInfo(lastResults).exists())
|
||||
mUI.mResults->readErrorsXml(lastResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::saveSettings() const
|
||||
|
@ -352,6 +372,9 @@ void MainWindow::saveSettings() const
|
|||
mApplications->saveSettings();
|
||||
|
||||
mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->getCurrentLanguage());
|
||||
|
||||
mSettings->setValue(SETTINGS_OPEN_PROJECT, mProject ? mProject->getFilename() : QString());
|
||||
|
||||
mUI.mResults->saveSettings(mSettings);
|
||||
}
|
||||
|
||||
|
@ -852,6 +875,15 @@ void MainWindow::checkDone()
|
|||
if (mScratchPad)
|
||||
mScratchPad->setEnabled(true);
|
||||
|
||||
if (mProject && !mProject->getProjectFile()->getBuildDir().isEmpty()) {
|
||||
const QString prjpath = QFileInfo(mProject->getProjectFile()->getFilename()).absolutePath();
|
||||
const QString buildDir = prjpath + '/' + mProject->getProjectFile()->getBuildDir();
|
||||
if (QDir(buildDir).exists()) {
|
||||
mUI.mResults->saveStatistics(buildDir + "/statistics.txt");
|
||||
mUI.mResults->save(buildDir + "/lastResults.xml", Report::XMLV2);
|
||||
}
|
||||
}
|
||||
|
||||
if (mUI.mResults->hasResults()) {
|
||||
mUI.mActionClearResults->setEnabled(true);
|
||||
mUI.mActionSave->setEnabled(true);
|
||||
|
@ -1293,7 +1325,7 @@ void MainWindow::loadProjectFile(const QString &filePath)
|
|||
{
|
||||
QFileInfo inf(filePath);
|
||||
const QString filename = inf.fileName();
|
||||
formatAndSetTitle(tr("Project:") + QString(" ") + filename);
|
||||
formatAndSetTitle(tr("Project:") + ' ' + filename);
|
||||
addProjectMRU(filePath);
|
||||
|
||||
mIsLogfileLoaded = false;
|
||||
|
|
|
@ -968,8 +968,8 @@ void ResultsTree::saveResults(Report *report) const
|
|||
|
||||
for (int i = 0; i < mModel.rowCount(); i++) {
|
||||
QStandardItem *item = mModel.item(i, 0);
|
||||
if (!isRowHidden(i, QModelIndex()))
|
||||
saveErrors(report, item);
|
||||
//if (!isRowHidden(i, QModelIndex()))
|
||||
saveErrors(report, item);
|
||||
}
|
||||
|
||||
report->writeFooter();
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <QPrintPreviewDialog>
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QDate>
|
||||
#include "common.h"
|
||||
#include "erroritem.h"
|
||||
#include "resultsview.h"
|
||||
|
@ -134,6 +135,20 @@ void ResultsView::filterResults(const QString& filter)
|
|||
mUI.mTree->filterResults(filter);
|
||||
}
|
||||
|
||||
void ResultsView::saveStatistics(const QString &filename) const
|
||||
{
|
||||
QFile f(filename);
|
||||
if (!f.open(QIODevice::Text | QIODevice::Append))
|
||||
return;
|
||||
QTextStream ts(&f);
|
||||
ts << '[' << QDate::currentDate().toString("dd.MM.yyyy") << "]\n";
|
||||
ts << "error:" << mStatistics->getCount(ShowTypes::ShowErrors) << '\n';
|
||||
ts << "warning:" << mStatistics->getCount(ShowTypes::ShowWarnings) << '\n';
|
||||
ts << "style:" << mStatistics->getCount(ShowTypes::ShowStyle) << '\n';
|
||||
ts << "performance:" << mStatistics->getCount(ShowTypes::ShowPerformance) << '\n';
|
||||
ts << "portability:" << mStatistics->getCount(ShowTypes::ShowPortability) << '\n';
|
||||
}
|
||||
|
||||
void ResultsView::save(const QString &filename, Report::Type type) const
|
||||
{
|
||||
if (!hasResults()) {
|
||||
|
|
|
@ -73,6 +73,13 @@ public:
|
|||
*/
|
||||
void clearRecheckFile(const QString &filename);
|
||||
|
||||
/**
|
||||
* @brief Write statistics in file
|
||||
*
|
||||
* @param filename Filename to save statistics to
|
||||
*/
|
||||
void saveStatistics(const QString &filename) const;
|
||||
|
||||
/**
|
||||
* @brief Save results to a file
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue