Added messagebox to inform user about not found/non visible errors.
This commit is contained in:
parent
de0bea3479
commit
b67424785f
|
@ -123,9 +123,14 @@ void ApplicationDialog::Ok()
|
|||
{
|
||||
if (mName->text().isEmpty() || mPath->text().isEmpty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("You must specify a name and a path for the application!");
|
||||
msgBox.exec();
|
||||
QMessageBox msg(QMessageBox::Warning,
|
||||
tr("Cppcheck"),
|
||||
tr("You must specify a name and a path for the application!"),
|
||||
QMessageBox::Ok,
|
||||
this);
|
||||
|
||||
msg.exec();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QToolBar>
|
||||
#include <QKeySequence>
|
||||
#include "aboutdialog.h"
|
||||
#include "../src/filelister.h"
|
||||
#include "../src/cppcheckexecutor.h"
|
||||
|
@ -132,6 +133,11 @@ MainWindow::MainWindow() :
|
|||
toolbar->addAction(&mActionSettings);
|
||||
toolbar->addAction(&mActionAbout);
|
||||
|
||||
mActionReCheck.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
|
||||
mActionCheckDirectory.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
|
||||
mActionSave.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
|
||||
mActionAbout.setShortcut(QKeySequence(Qt::Key_F1));
|
||||
|
||||
LoadSettings();
|
||||
mThread.Initialize(&mResults);
|
||||
setWindowTitle(tr("Cppcheck"));
|
||||
|
@ -209,9 +215,15 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
|
|||
|
||||
if (fileNames.isEmpty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("No suitable files found to check!");
|
||||
msgBox.exec();
|
||||
|
||||
QMessageBox msg(QMessageBox::Warning,
|
||||
tr("Cppcheck"),
|
||||
tr("No suitable files found to check!"),
|
||||
QMessageBox::Ok,
|
||||
this);
|
||||
|
||||
msg.exec();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -306,7 +318,8 @@ void MainWindow::ProgramSettings()
|
|||
dialog.SaveCheckboxValues();
|
||||
mResults.UpdateSettings(dialog.ShowFullPath(),
|
||||
dialog.SaveFullPath(),
|
||||
dialog.SaveAllErrors());
|
||||
dialog.SaveAllErrors(),
|
||||
dialog.ShowNoErrorsMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,11 +388,18 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
event->accept();
|
||||
else
|
||||
{
|
||||
QString msg(tr("Cannot exit while checking.\n\n" \
|
||||
"Stop the checking before exiting."));
|
||||
QMessageBox *box = new QMessageBox(QMessageBox::Warning,
|
||||
tr("cppcheck"), msg);
|
||||
box->show();
|
||||
QString text(tr("Cannot exit while checking.\n\n" \
|
||||
"Stop the checking before exiting."));
|
||||
|
||||
QMessageBox msg(QMessageBox::Warning,
|
||||
tr("Cppcheck"),
|
||||
text,
|
||||
QMessageBox::Ok,
|
||||
this);
|
||||
|
||||
msg.exec();
|
||||
|
||||
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ ResultsTree::ResultsTree(QSettings &settings, ApplicationList &list) :
|
|||
mSettings(settings),
|
||||
mApplications(list),
|
||||
mContextItem(0),
|
||||
mCheckPath("")
|
||||
mCheckPath(""),
|
||||
mVisibleErrors(false)
|
||||
{
|
||||
setModel(&mModel);
|
||||
QStringList labels;
|
||||
|
@ -76,6 +77,13 @@ void ResultsTree::AddErrorItem(const QString &file,
|
|||
}
|
||||
|
||||
bool hide = !mShowTypes[SeverityToShowType(severity)];
|
||||
|
||||
//if there is at least on error that is not hidden, we have a visible error
|
||||
if (!hide)
|
||||
{
|
||||
mVisibleErrors = true;
|
||||
}
|
||||
|
||||
//Create the base item for the error and ensure it has a proper
|
||||
//file item as a parent
|
||||
QStandardItem *item = AddBacktraceFiles(EnsureFileItem(realfile, hide),
|
||||
|
@ -226,6 +234,7 @@ void ResultsTree::ShowResults(ShowTypes type, bool show)
|
|||
|
||||
void ResultsTree::RefreshTree()
|
||||
{
|
||||
mVisibleErrors = false;
|
||||
//Get the amount of files in the tree
|
||||
int filecount = mModel.rowCount();
|
||||
|
||||
|
@ -261,6 +270,11 @@ void ResultsTree::RefreshTree()
|
|||
//Check if this error should be hidden
|
||||
bool hide = !mShowTypes[VariantToShowType(data["severity"])];
|
||||
|
||||
if (!hide)
|
||||
{
|
||||
mVisibleErrors = true;
|
||||
}
|
||||
|
||||
//Hide/show accordingly
|
||||
setRowHidden(j, file->index(), hide);
|
||||
|
||||
|
@ -370,9 +384,10 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
|
|||
//If there are now application's specified, tell the user about it
|
||||
if (mApplications.GetApplicationCount() == 0)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("You can open this error by specifying applications in program's settings.");
|
||||
msgBox.exec();
|
||||
QMessageBox msg(QMessageBox::Warning,
|
||||
tr("Cppcheck"),
|
||||
tr("You can open this error by specifying applications in program's settings."));
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -421,6 +436,7 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
|
|||
msgbox.setWindowTitle("Cppcheck");
|
||||
msgbox.setText(text);
|
||||
msgbox.setIcon(QMessageBox::Critical);
|
||||
|
||||
msgbox.exec();
|
||||
}
|
||||
}
|
||||
|
@ -689,3 +705,8 @@ void ResultsTree::RefreshFilePaths()
|
|||
RefreshFilePaths(mModel.item(i, 0));
|
||||
}
|
||||
}
|
||||
|
||||
bool ResultsTree::VisibleErrors()
|
||||
{
|
||||
return mVisibleErrors;
|
||||
}
|
||||
|
|
|
@ -93,6 +93,13 @@ public:
|
|||
* @param dir Directory we are checking
|
||||
*/
|
||||
void SetCheckDirectory(const QString &dir);
|
||||
|
||||
/**
|
||||
* @brief Check if there are any visible errors
|
||||
* @return true if there is at least one visible error
|
||||
*/
|
||||
bool VisibleErrors();
|
||||
|
||||
protected slots:
|
||||
/**
|
||||
* @brief Slot to quickstart an error with default application
|
||||
|
@ -107,6 +114,7 @@ protected slots:
|
|||
* @param application Index of the application to open the error
|
||||
*/
|
||||
void Context(int application);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
@ -313,6 +321,13 @@ protected:
|
|||
*
|
||||
*/
|
||||
QString mCheckPath;
|
||||
|
||||
/**
|
||||
* @brief Are there any visible errors
|
||||
*
|
||||
*/
|
||||
bool mVisibleErrors;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
#include <QDebug>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
|
||||
ResultsView::ResultsView(QSettings &settings, ApplicationList &list)
|
||||
ResultsView::ResultsView(QSettings &settings, ApplicationList &list) :
|
||||
mErrorsFound(false),
|
||||
mShowNoErrorsMessage(true)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
setLayout(layout);
|
||||
|
@ -35,6 +38,8 @@ ResultsView::ResultsView(QSettings &settings, ApplicationList &list)
|
|||
mTree = new ResultsTree(settings, list);
|
||||
layout->addWidget(mTree);
|
||||
|
||||
mShowNoErrorsMessage = settings.value(tr("Show no errors message"), true).toBool();
|
||||
|
||||
}
|
||||
|
||||
ResultsView::~ResultsView()
|
||||
|
@ -46,6 +51,11 @@ ResultsView::~ResultsView()
|
|||
void ResultsView::Clear()
|
||||
{
|
||||
mTree->Clear();
|
||||
mErrorsFound = false;
|
||||
|
||||
//Clear the progressbar
|
||||
mProgress->setMaximum(100);
|
||||
mProgress->setValue(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,6 +67,32 @@ void ResultsView::Progress(int value, int max)
|
|||
if (value >= max)
|
||||
{
|
||||
mProgress->setVisible(false);
|
||||
//Should we inform user of non visible/not found errors?
|
||||
if (mShowNoErrorsMessage)
|
||||
{ //Tell user that we found no errors
|
||||
if (!mErrorsFound)
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Information,
|
||||
tr("Cppcheck"),
|
||||
tr("No errors found."),
|
||||
QMessageBox::Ok,
|
||||
this);
|
||||
|
||||
msg.exec();
|
||||
} //If we have errors but they aren't visible, tell user about it
|
||||
else if (!mTree->VisibleErrors())
|
||||
{
|
||||
QString text = tr("Errors found from the file, but they are configured to be hidden.\n"\
|
||||
"To toggle what kind of errors are shown, open view menu.");
|
||||
QMessageBox msg(QMessageBox::Information,
|
||||
tr("Cppcheck"),
|
||||
text,
|
||||
QMessageBox::Ok,
|
||||
this);
|
||||
|
||||
msg.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -71,6 +107,7 @@ void ResultsView::Error(const QString &file,
|
|||
const QVariantList &lines,
|
||||
const QString &id)
|
||||
{
|
||||
mErrorsFound = true;
|
||||
mTree->AddErrorItem(file, severity, message, files, lines, id);
|
||||
emit GotResults();
|
||||
}
|
||||
|
@ -92,6 +129,13 @@ void ResultsView::ExpandAllResults()
|
|||
|
||||
void ResultsView::Save(const QString &filename, bool xml)
|
||||
{
|
||||
if (!mErrorsFound)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("No errors found, nothing to save.");
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
|
@ -105,9 +149,11 @@ void ResultsView::Save(const QString &filename, bool xml)
|
|||
|
||||
void ResultsView::UpdateSettings(bool showFullPath,
|
||||
bool saveFullPath,
|
||||
bool saveAllErrors)
|
||||
bool saveAllErrors,
|
||||
bool showNoErrorsMessage)
|
||||
{
|
||||
mTree->UpdateSettings(showFullPath, saveFullPath, saveAllErrors);
|
||||
mShowNoErrorsMessage = showNoErrorsMessage;
|
||||
}
|
||||
|
||||
void ResultsView::SetCheckDirectory(const QString &dir)
|
||||
|
|
|
@ -70,7 +70,10 @@ public:
|
|||
* @param saveFullPath Save full path of files in reports
|
||||
* @param saveAllErrors Save all visible errors
|
||||
*/
|
||||
void UpdateSettings(bool showFullPath, bool saveFullPath, bool saveAllErrors);
|
||||
void UpdateSettings(bool showFullPath,
|
||||
bool saveFullPath,
|
||||
bool saveAllErrors,
|
||||
bool showNoErrorsMessage);
|
||||
|
||||
/**
|
||||
* @brief Set the directory we are checking
|
||||
|
@ -138,6 +141,16 @@ protected:
|
|||
*/
|
||||
QProgressBar *mProgress;
|
||||
|
||||
/**
|
||||
* @brief Have any errors been found
|
||||
*/
|
||||
bool mErrorsFound;
|
||||
|
||||
/**
|
||||
* @brief Should we show a "No errors found dialog" everytime no errors were found?
|
||||
*/
|
||||
bool mShowNoErrorsMessage;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list
|
|||
|
||||
//Force
|
||||
mForce = AddCheckbox(layout,
|
||||
tr("Force checking on files that have \"too many\" configurations"),
|
||||
tr("Check all #ifdef configurations"),
|
||||
tr("Check force"),
|
||||
false);
|
||||
|
||||
|
@ -88,6 +88,11 @@ SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list
|
|||
tr("Show full path"),
|
||||
false);
|
||||
|
||||
mShowNoErrorsMessage = AddCheckbox(layout,
|
||||
tr("Show \"No errors found\" message when no errors found"),
|
||||
tr("Show no errors message"),
|
||||
true);
|
||||
|
||||
layout->addStretch();
|
||||
general->setLayout(layout);
|
||||
|
||||
|
@ -115,7 +120,7 @@ SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list
|
|||
connect(modify, SIGNAL(clicked()),
|
||||
this, SLOT(ModifyApplication()));
|
||||
|
||||
QPushButton *def = new QPushButton(tr("Make default application"));
|
||||
QPushButton *def = new QPushButton(tr("Set as default application"));
|
||||
appslayout->addWidget(def);
|
||||
connect(def, SIGNAL(clicked()),
|
||||
this, SLOT(DefaultApplication()));
|
||||
|
@ -205,6 +210,7 @@ void SettingsDialog::SaveCheckboxValues()
|
|||
SaveCheckboxValue(mSaveAllErrors, tr("Save all errors"));
|
||||
SaveCheckboxValue(mSaveFullPath, tr("Save full path"));
|
||||
SaveCheckboxValue(mShowFullPath, tr("Show full path"));
|
||||
SaveCheckboxValue(mShowNoErrorsMessage, tr("Show no errors message"));
|
||||
}
|
||||
|
||||
void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name)
|
||||
|
@ -303,3 +309,11 @@ bool SettingsDialog::SaveAllErrors()
|
|||
{
|
||||
return CheckStateToBool(mSaveAllErrors->checkState());
|
||||
}
|
||||
|
||||
bool SettingsDialog::ShowNoErrorsMessage()
|
||||
{
|
||||
return CheckStateToBool(mShowNoErrorsMessage->checkState());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -64,6 +64,14 @@ public:
|
|||
*/
|
||||
bool SaveFullPath();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get checkbox value for mNoErrorsMessage
|
||||
*
|
||||
* @return Should "no errors message" be hidden
|
||||
*/
|
||||
bool ShowNoErrorsMessage();
|
||||
|
||||
/**
|
||||
* @brief Get checkbox value for mSaveAllErrors
|
||||
*
|
||||
|
@ -191,6 +199,12 @@ protected:
|
|||
*/
|
||||
QCheckBox *mShowFullPath;
|
||||
|
||||
/**
|
||||
* @brief Show a message dialog when no errors are found (false)
|
||||
*
|
||||
*/
|
||||
QCheckBox *mShowNoErrorsMessage;
|
||||
|
||||
/**
|
||||
* @brief List of all applications that can be started when right clicking
|
||||
* an error
|
||||
|
|
Loading…
Reference in New Issue