GUI: When loading project, try to load last results

This commit is contained in:
Daniel Marjamäki 2017-07-30 13:42:34 +02:00
parent 0b509e9e35
commit abcabba88e
2 changed files with 29 additions and 13 deletions

View File

@ -318,19 +318,12 @@ void MainWindow::loadSettings()
msgBox.exec(); msgBox.exec();
} }
const QString project = mSettings->value(SETTINGS_OPEN_PROJECT, QString()).toString(); const QString projectFile = mSettings->value(SETTINGS_OPEN_PROJECT, QString()).toString();
if (!project.isEmpty() && QCoreApplication::arguments().size()==1) { if (!projectFile.isEmpty() && QCoreApplication::arguments().size()==1) {
QFileInfo inf(project); QFileInfo inf(projectFile);
if (inf.exists() && inf.isReadable()) { if (inf.exists() && inf.isReadable()) {
delete mProject; mProject = new Project(projectFile, this);
mProject = new Project(project, this); loadLastResults();
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);
}
} }
} }
} }
@ -1333,7 +1326,24 @@ void MainWindow::loadProjectFile(const QString &filePath)
mUI.mActionEditProjectFile->setEnabled(true); mUI.mActionEditProjectFile->setEnabled(true);
delete mProject; delete mProject;
mProject = new Project(filePath, this); mProject = new Project(filePath, this);
analyzeProject(mProject); if (!loadLastResults())
analyzeProject(mProject);
}
bool MainWindow::loadLastResults()
{
if (!mProject)
return false;
if (!mProject->isOpen() && !mProject->open())
return false;
if (mProject->getProjectFile()->getBuildDir().isEmpty())
return false;
const QString buildDir = QFileInfo(mProject->getFilename()).absolutePath() + '/' + mProject->getProjectFile()->getBuildDir();
const QString lastResults = buildDir + "/lastResults.xml";
if (!QFileInfo(lastResults).exists())
return false;
mUI.mResults->readErrorsXml(lastResults);
return true;
} }
void MainWindow::analyzeProject(Project *project) void MainWindow::analyzeProject(Project *project)

View File

@ -343,6 +343,12 @@ private:
*/ */
void loadResults(const QString selectedFile, const QString sourceDirectory); void loadResults(const QString selectedFile, const QString sourceDirectory);
/**
* @brief Load last project results to the GUI.
* @return Returns true if last results was loaded
*/
bool loadLastResults();
/** /**
* @brief Load project file to the GUI. * @brief Load project file to the GUI.
* @param filePath Filename (inc. path) of project file to load. * @param filePath Filename (inc. path) of project file to load.