Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "projectfile.h"
#include "projectfiledialog.h"
#include "report.h"
#include "resultstree.h"
#include "resultsview.h"
#include "scratchpad.h"
#include "settings.h"
Expand Down Expand Up @@ -230,10 +231,13 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
loadSettings();

mThread->initialize(mUI->mResults);
if (mProjectFile)
if (mProjectFile) {
enableProjectActions(true);
formatAndSetTitle(tr("Project:") + ' ' + mProjectFile->getFilename());
else
} else {
enableProjectActions(false);
formatAndSetTitle();
}

mUI->mActionComplianceReport->setVisible(isCppcheckPremium());

Expand All @@ -242,7 +246,6 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
mUI->mActionPrint->setShortcut(QKeySequence::Print);
enableResultsButtons();
enableProjectOpenActions(true);
enableProjectActions(false);

// Must setup MRU menu before CLI param handling as it can load a
// project file and update MRU menu.
Expand All @@ -263,9 +266,6 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
handleCLIParams(args);
}

mUI->mActionCloseProjectFile->setEnabled(mProjectFile != nullptr);
mUI->mActionEditProjectFile->setEnabled(mProjectFile != nullptr);

for (int i = 0; i < mPlatforms.getCount(); i++) {
PlatformData platform = mPlatforms.mPlatforms[i];
auto *action = new QAction(this);
Expand Down Expand Up @@ -588,6 +588,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
}

mUI->mResults->clear(true);
mUI->mResults->setResultsSource(ResultsTree::ResultsSource::Analysis);
mThread->clearFiles();

mUI->mResults->checkingStarted(p.fileSettings.size());
Expand Down Expand Up @@ -651,6 +652,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
QStringList fileNames = pathList.getFileList();

mUI->mResults->clear(true);
mUI->mResults->setResultsSource(ResultsTree::ResultsSource::Analysis);
mThread->clearFiles();

if (fileNames.isEmpty()) {
Expand Down Expand Up @@ -1486,6 +1488,7 @@ void MainWindow::loadResults(const QString &selectedFile)
closeProjectFile();
mIsLogfileLoaded = true;
mUI->mResults->clear(true);
mUI->mResults->setResultsSource(ResultsTree::ResultsSource::Log);
mUI->mActionReanalyzeModified->setEnabled(false);
mUI->mActionReanalyzeAll->setEnabled(false);
mUI->mResults->readErrorsXml(selectedFile);
Expand Down Expand Up @@ -1776,7 +1779,6 @@ void MainWindow::stopAnalysis()
{
mThread->stop();
mUI->mResults->stopAnalysis();
mUI->mResults->disableProgressbar();
const QString &lastResults = getLastResults();
if (!lastResults.isEmpty()) {
mUI->mResults->updateFromOldReport(lastResults);
Expand Down Expand Up @@ -1830,8 +1832,10 @@ void MainWindow::loadProjectFile(const QString &filePath)
addProjectMRU(filePath);

mIsLogfileLoaded = false;
mUI->mActionCloseProjectFile->setEnabled(true);
mUI->mActionEditProjectFile->setEnabled(true);
mUI->mResults->setResultsSource(ResultsTree::ResultsSource::Analysis);
mUI->mActionReanalyzeModified->setEnabled(true);
mUI->mActionReanalyzeAll->setEnabled(true);
enableProjectActions(true);
delete mProjectFile;
mProjectFile = new ProjectFile(filePath, this);
mProjectFile->setActiveProject();
Expand Down
10 changes: 7 additions & 3 deletions gui/resultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
auto *hideallid = new QAction(tr("Hide all with id"), &menu);
auto *opencontainingfolder = new QAction(tr("Open containing folder"), &menu);

if (selectedFiles == 0 || mThread->isChecking())
if (selectedFiles == 0 || mThread->isChecking() || mResultsSource == ResultsSource::Log)
recheckAction->setDisabled(true);

if (selectedResults == 0)
Expand All @@ -774,7 +774,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
if (selectedResults == 0 || multipleSelection)
hideallid->setDisabled(true);

if (multipleSelection)
if (multipleSelection || mResultsSource == ResultsSource::Log)
opencontainingfolder->setDisabled(true);

menu.addAction(recheckAction);
Expand Down Expand Up @@ -1424,12 +1424,16 @@ void ResultsTree::setCheckDirectory(const QString &dir)
mCheckPath = dir;
}


const QString& ResultsTree::getCheckDirectory() const
{
return mCheckPath;
}

void ResultsTree::setResultsSource(ResultsSource source)
{
mResultsSource = source;
}

QString ResultsTree::stripPath(const QString &path, bool saving) const
{
if ((!saving && mShowFullPath) || (saving && mSaveFullPath)) {
Expand Down
25 changes: 24 additions & 1 deletion gui/resultstree.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ enum class Severity : std::uint8_t;
/// @addtogroup GUI
/// @{


/**
* @brief Cppcheck's results are shown in this tree
*
Expand Down Expand Up @@ -139,6 +138,24 @@ class ResultsTree : public QTreeView {

const QString& getCheckDirectory() const;

/**
* @brief Results source for analysis results in the results tree.
*/
enum class ResultsSource : std::uint8_t {
/** Results from a project, files, or directory check */
Analysis,
/** Saved results from a log file */
Log,
};

/**
* @brief Set the source type of the current results. This
* affects the actions that are allowed on them.
*
* @param source The results source type.
*/
void setResultsSource(ResultsSource source);

/**
* @brief Check if there are any visible results in view.
* @return true if there is at least one visible warning/error.
Expand Down Expand Up @@ -508,6 +525,12 @@ protected slots:
*/
QString mCheckPath;

/**
* @brief The type of source of the current results
*
*/
ResultsSource mResultsSource{ResultsSource::Analysis};

/**
* @brief Are there any visible errors
*
Expand Down
10 changes: 5 additions & 5 deletions gui/resultsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ void ResultsView::setReportType(ReportType reportType) {
mUI->mTree->setReportType(reportType);
}

void ResultsView::setResultsSource(ResultsTree::ResultsSource source)
{
mUI->mTree->setResultsSource(source);
}

void ResultsView::progress(int value, const QString& description)
{
mUI->mProgress->setValue(value);
Expand Down Expand Up @@ -389,11 +394,6 @@ void ResultsView::translate()
mUI->mTree->translate();
}

void ResultsView::disableProgressbar()
{
mUI->mProgress->setEnabled(false);
}

void ResultsView::readErrorsXml(const QString &filename)
{
mSuccess = false; // Don't know if results come from an aborted analysis
Expand Down
10 changes: 8 additions & 2 deletions gui/resultsview.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define RESULTSVIEW_H

#include "report.h"
#include "resultstree.h"
#include "showtypes.h"

#include <cstdint>
Expand Down Expand Up @@ -197,8 +198,6 @@ class ResultsView : public QWidget {
*/
bool isSuccess() const;

void disableProgressbar();

/**
* @brief Read errors from report XML file.
* @param filename Report file to read.
Expand All @@ -222,6 +221,13 @@ class ResultsView : public QWidget {

void setReportType(ReportType reportType);

/**
* @brief Set the results source type for the results tree.
*
* @param source The results source type.
*/
void setResultsSource(ResultsTree::ResultsSource source);

signals:

/**
Expand Down