use forward declarations for Ui:: objects / renamed *.ui files to mat… (#3796)

This commit is contained in:
Oliver Stöneberg 2022-03-19 19:54:20 +01:00 committed by GitHub
parent 8fc5c93803
commit 9d524616b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 3809 additions and 3732 deletions

View File

@ -18,22 +18,30 @@
#include "aboutdialog.h"
#include "ui_about.h"
#include <QDialogButtonBox>
#include <QLabel>
AboutDialog::AboutDialog(const QString &version, const QString &extraVersion, QWidget *parent)
: QDialog(parent)
, mUI(new Ui::About)
{
mUI.setupUi(this);
mUI->setupUi(this);
QString fmtVersion(version);
if (!extraVersion.isEmpty()) {
fmtVersion += " (" + extraVersion + ")";
}
mUI.mVersion->setText(mUI.mVersion->text().arg(fmtVersion));
mUI->mVersion->setText(mUI->mVersion->text().arg(fmtVersion));
QString date = __DATE__;
mUI.mCopyright->setText(mUI.mCopyright->text().arg(date.right(4)));
mUI->mCopyright->setText(mUI->mCopyright->text().arg(date.right(4)));
QString url = "<a href=\"https://cppcheck.sourceforge.io/\">https://cppcheck.sourceforge.io/</a>";
mUI.mHomepage->setText(mUI.mHomepage->text().arg(url));
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &AboutDialog::accept);
mUI->mHomepage->setText(mUI->mHomepage->text().arg(url));
connect(mUI->mButtons, &QDialogButtonBox::accepted, this, &AboutDialog::accept);
}
AboutDialog::~AboutDialog()
{
delete mUI;
}

View File

@ -19,12 +19,13 @@
#ifndef ABOUT_DIALOG_H
#define ABOUT_DIALOG_H
#include "ui_about.h"
#include <QDialog>
#include <QString>
class QWidget;
namespace Ui {
class About;
}
/// @addtogroup GUI
/// @{
@ -40,8 +41,10 @@ public:
const QString &extraVersion,
QWidget *parent = nullptr);
~AboutDialog() override;
private:
Ui::About mUI;
Ui::About* mUI;
};
/// @}
#endif // ABOUT_DIALOG_H

View File

@ -21,6 +21,8 @@
#include "application.h"
#include "common.h"
#include "ui_applicationdialog.h"
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QMessageBox>
@ -31,16 +33,17 @@ ApplicationDialog::ApplicationDialog(const QString &title,
Application &app,
QWidget *parent) :
QDialog(parent),
mUI(new Ui::ApplicationDialog),
mApplication(app)
{
mUI.setupUi(this);
mUI->setupUi(this);
connect(mUI.mButtonBrowse, &QPushButton::clicked, this, &ApplicationDialog::browse);
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &ApplicationDialog::ok);
connect(mUI.mButtons, &QDialogButtonBox::rejected, this, &ApplicationDialog::reject);
mUI.mPath->setText(app.getPath());
mUI.mName->setText(app.getName());
mUI.mParameters->setText(app.getParameters());
connect(mUI->mButtonBrowse, &QPushButton::clicked, this, &ApplicationDialog::browse);
connect(mUI->mButtons, &QDialogButtonBox::accepted, this, &ApplicationDialog::ok);
connect(mUI->mButtons, &QDialogButtonBox::rejected, this, &ApplicationDialog::reject);
mUI->mPath->setText(app.getPath());
mUI->mName->setText(app.getName());
mUI->mParameters->setText(app.getParameters());
setWindowTitle(title);
adjustSize();
}
@ -48,7 +51,7 @@ ApplicationDialog::ApplicationDialog(const QString &title,
ApplicationDialog::~ApplicationDialog()
{
//dtor
delete mUI;
}
void ApplicationDialog::browse()
@ -67,13 +70,13 @@ void ApplicationDialog::browse()
if (!selectedFile.isEmpty()) {
setPath(SETTINGS_LAST_APP_PATH, selectedFile);
QString path(QDir::toNativeSeparators(selectedFile));
mUI.mPath->setText(path);
mUI->mPath->setText(path);
}
}
void ApplicationDialog::ok()
{
if (mUI.mName->text().isEmpty() || mUI.mPath->text().isEmpty()) {
if (mUI->mName->text().isEmpty() || mUI->mPath->text().isEmpty()) {
QMessageBox msg(QMessageBox::Warning,
tr("Cppcheck"),
tr("You must specify a name, a path and optionally parameters for the application!"),
@ -85,9 +88,9 @@ void ApplicationDialog::ok()
reject();
} else {
// Convert possible native (Windows) path to internal presentation format
mApplication.setName(mUI.mName->text());
mApplication.setPath(QDir::fromNativeSeparators(mUI.mPath->text()));
mApplication.setParameters(mUI.mParameters->text());
mApplication.setName(mUI->mName->text());
mApplication.setPath(QDir::fromNativeSeparators(mUI->mPath->text()));
mApplication.setParameters(mUI->mParameters->text());
accept();
}

View File

@ -19,13 +19,14 @@
#ifndef APPLICATIONDIALOG_H
#define APPLICATIONDIALOG_H
#include "ui_application.h"
#include <QDialog>
#include <QString>
class QWidget;
class Application;
namespace Ui {
class ApplicationDialog;
}
/// @addtogroup GUI
/// @{
@ -67,7 +68,7 @@ protected:
* @brief UI from the Qt designer
*
*/
Ui::ApplicationDialog mUI;
Ui::ApplicationDialog* mUI;
private:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,17 +23,25 @@
#include <QMessageBox>
#include <QTextEdit>
#include "ui_fileview.h"
FileViewDialog::FileViewDialog(const QString &file,
const QString &title,
QWidget *parent)
: QDialog(parent)
, mUI(new Ui::Fileview)
{
mUI.setupUi(this);
mUI->setupUi(this);
setWindowTitle(title);
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
loadTextFile(file, mUI.mText);
connect(mUI->mButtons, SIGNAL(accepted()), this, SLOT(accept()));
loadTextFile(file, mUI->mText);
}
FileViewDialog::~FileViewDialog()
{
delete mUI;
}
void FileViewDialog::loadTextFile(const QString &filename, QTextEdit *edit)

View File

@ -19,13 +19,14 @@
#ifndef FILEVIEW_DIALOG_H
#define FILEVIEW_DIALOG_H
#include "ui_file.h"
#include <QDialog>
#include <QString>
class QWidget;
class QTextEdit;
namespace Ui {
class Fileview;
}
/// @addtogroup GUI
/// @{
@ -44,6 +45,7 @@ public:
const QString &title,
QWidget *parent = nullptr);
~FileViewDialog() override;
protected:
@ -55,7 +57,7 @@ protected:
*/
void loadTextFile(const QString &filename, QTextEdit *edit);
Ui::Fileview mUI;
Ui::Fileview* mUI;
};
/// @}
#endif // FILEVIEW_DIALOG_H

View File

@ -70,16 +70,16 @@ win32 {
RESOURCES = gui.qrc
FORMS = about.ui \
application.ui \
file.ui \
applicationdialog.ui \
fileview.ui \
functioncontractdialog.ui \
helpdialog.ui \
mainwindow.ui \
projectfiledialog.ui \
projectfile.ui \
resultsview.ui \
scratchpad.ui \
settings.ui \
stats.ui \
statsdialog.ui \
librarydialog.ui \
libraryaddfunctiondialog.ui \
libraryeditargdialog.ui \

View File

@ -18,10 +18,10 @@
#include "helpdialog.h"
#include "ui_helpdialog.h"
#include "common.h"
#include "ui_helpdialog.h"
#include <QFileInfo>
#include <QHelpEngine>
#include <QHelpContentWidget>

View File

@ -18,13 +18,13 @@
#include "librarydialog.h"
#include "ui_librarydialog.h"
#include "common.h"
#include "libraryaddfunctiondialog.h"
#include "libraryeditargdialog.h"
#include "path.h"
#include "ui_librarydialog.h"
#include <QFile>
#include <QFileDialog>
#include <QMessageBox>

View File

@ -39,9 +39,12 @@
#include "translationhandler.h"
#include "variablecontractsdialog.h"
#include "ui_mainwindow.h"
#include <QApplication>
#include <QAction>
#include <QActionGroup>
#include <QCloseEvent>
#include <QDebug>
#include <QDir>
#include <QFile>
@ -58,6 +61,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
mSettings(settings),
mApplications(new ApplicationList(this)),
mTranslation(th),
mUI(new Ui::MainWindow),
mScratchPad(nullptr),
mProjectFile(nullptr),
mPlatformActions(new QActionGroup(this)),
@ -67,9 +71,9 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
mExiting(false),
mIsLogfileLoaded(false)
{
mUI.setupUi(this);
mUI->setupUi(this);
mThread = new ThreadHandler(this);
mUI.mResults->initialize(mSettings, mApplications, mThread);
mUI->mResults->initialize(mSettings, mApplications, mThread);
// Filter timer to delay filtering results slightly while typing
mFilterTimer = new QTimer(this);
@ -78,82 +82,82 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
connect(mFilterTimer, &QTimer::timeout, this, &MainWindow::filterResults);
// "Filter" toolbar
mLineEditFilter = new QLineEdit(mUI.mToolBarFilter);
mLineEditFilter = new QLineEdit(mUI->mToolBarFilter);
mLineEditFilter->setPlaceholderText(tr("Quick Filter:"));
mLineEditFilter->setClearButtonEnabled(true);
mUI.mToolBarFilter->addWidget(mLineEditFilter);
mUI->mToolBarFilter->addWidget(mLineEditFilter);
connect(mLineEditFilter, SIGNAL(textChanged(const QString&)), mFilterTimer, SLOT(start()));
connect(mLineEditFilter, &QLineEdit::returnPressed, this, &MainWindow::filterResults);
connect(mUI.mActionPrint, SIGNAL(triggered()), mUI.mResults, SLOT(print()));
connect(mUI.mActionPrintPreview, SIGNAL(triggered()), mUI.mResults, SLOT(printPreview()));
connect(mUI.mActionQuit, &QAction::triggered, this, &MainWindow::close);
connect(mUI.mActionAnalyzeFiles, &QAction::triggered, this, &MainWindow::analyzeFiles);
connect(mUI.mActionAnalyzeDirectory, &QAction::triggered, this, &MainWindow::analyzeDirectory);
connect(mUI.mActionSettings, &QAction::triggered, this, &MainWindow::programSettings);
connect(mUI.mActionClearResults, &QAction::triggered, this, &MainWindow::clearResults);
connect(mUI.mActionOpenXML, &QAction::triggered, this, &MainWindow::openResults);
connect(mUI->mActionPrint, SIGNAL(triggered()), mUI->mResults, SLOT(print()));
connect(mUI->mActionPrintPreview, SIGNAL(triggered()), mUI->mResults, SLOT(printPreview()));
connect(mUI->mActionQuit, &QAction::triggered, this, &MainWindow::close);
connect(mUI->mActionAnalyzeFiles, &QAction::triggered, this, &MainWindow::analyzeFiles);
connect(mUI->mActionAnalyzeDirectory, &QAction::triggered, this, &MainWindow::analyzeDirectory);
connect(mUI->mActionSettings, &QAction::triggered, this, &MainWindow::programSettings);
connect(mUI->mActionClearResults, &QAction::triggered, this, &MainWindow::clearResults);
connect(mUI->mActionOpenXML, &QAction::triggered, this, &MainWindow::openResults);
connect(mUI.mActionShowStyle, &QAction::toggled, this, &MainWindow::showStyle);
connect(mUI.mActionShowErrors, &QAction::toggled, this, &MainWindow::showErrors);
connect(mUI.mActionShowWarnings, &QAction::toggled, this, &MainWindow::showWarnings);
connect(mUI.mActionShowPortability, &QAction::toggled, this, &MainWindow::showPortability);
connect(mUI.mActionShowPerformance, &QAction::toggled, this, &MainWindow::showPerformance);
connect(mUI.mActionShowInformation, &QAction::toggled, this, &MainWindow::showInformation);
connect(mUI.mActionShowCppcheck, &QAction::toggled, mUI.mResults, &ResultsView::showCppcheckResults);
connect(mUI.mActionShowClang, &QAction::toggled, mUI.mResults, &ResultsView::showClangResults);
connect(mUI.mActionCheckAll, &QAction::triggered, this, &MainWindow::checkAll);
connect(mUI.mActionUncheckAll, &QAction::triggered, this, &MainWindow::uncheckAll);
connect(mUI.mActionCollapseAll, &QAction::triggered, mUI.mResults, &ResultsView::collapseAllResults);
connect(mUI.mActionExpandAll, &QAction::triggered, mUI.mResults, &ResultsView::expandAllResults);
connect(mUI.mActionShowHidden, &QAction::triggered, mUI.mResults, &ResultsView::showHiddenResults);
connect(mUI.mActionViewStats, &QAction::triggered, this, &MainWindow::showStatistics);
connect(mUI.mActionLibraryEditor, &QAction::triggered, this, &MainWindow::showLibraryEditor);
connect(mUI->mActionShowStyle, &QAction::toggled, this, &MainWindow::showStyle);
connect(mUI->mActionShowErrors, &QAction::toggled, this, &MainWindow::showErrors);
connect(mUI->mActionShowWarnings, &QAction::toggled, this, &MainWindow::showWarnings);
connect(mUI->mActionShowPortability, &QAction::toggled, this, &MainWindow::showPortability);
connect(mUI->mActionShowPerformance, &QAction::toggled, this, &MainWindow::showPerformance);
connect(mUI->mActionShowInformation, &QAction::toggled, this, &MainWindow::showInformation);
connect(mUI->mActionShowCppcheck, &QAction::toggled, mUI->mResults, &ResultsView::showCppcheckResults);
connect(mUI->mActionShowClang, &QAction::toggled, mUI->mResults, &ResultsView::showClangResults);
connect(mUI->mActionCheckAll, &QAction::triggered, this, &MainWindow::checkAll);
connect(mUI->mActionUncheckAll, &QAction::triggered, this, &MainWindow::uncheckAll);
connect(mUI->mActionCollapseAll, &QAction::triggered, mUI->mResults, &ResultsView::collapseAllResults);
connect(mUI->mActionExpandAll, &QAction::triggered, mUI->mResults, &ResultsView::expandAllResults);
connect(mUI->mActionShowHidden, &QAction::triggered, mUI->mResults, &ResultsView::showHiddenResults);
connect(mUI->mActionViewStats, &QAction::triggered, this, &MainWindow::showStatistics);
connect(mUI->mActionLibraryEditor, &QAction::triggered, this, &MainWindow::showLibraryEditor);
connect(mUI.mActionReanalyzeModified, &QAction::triggered, this, &MainWindow::reAnalyzeModified);
connect(mUI.mActionReanalyzeAll, &QAction::triggered, this, &MainWindow::reAnalyzeAll);
connect(mUI.mActionCheckLibrary, &QAction::triggered, this, &MainWindow::checkLibrary);
connect(mUI.mActionCheckConfiguration, &QAction::triggered, this, &MainWindow::checkConfiguration);
connect(mUI->mActionReanalyzeModified, &QAction::triggered, this, &MainWindow::reAnalyzeModified);
connect(mUI->mActionReanalyzeAll, &QAction::triggered, this, &MainWindow::reAnalyzeAll);
connect(mUI->mActionCheckLibrary, &QAction::triggered, this, &MainWindow::checkLibrary);
connect(mUI->mActionCheckConfiguration, &QAction::triggered, this, &MainWindow::checkConfiguration);
connect(mUI.mActionStop, &QAction::triggered, this, &MainWindow::stopAnalysis);
connect(mUI.mActionSave, &QAction::triggered, this, &MainWindow::save);
connect(mUI->mActionStop, &QAction::triggered, this, &MainWindow::stopAnalysis);
connect(mUI->mActionSave, &QAction::triggered, this, &MainWindow::save);
// About menu
connect(mUI.mActionAbout, &QAction::triggered, this, &MainWindow::about);
connect(mUI.mActionLicense, &QAction::triggered, this, &MainWindow::showLicense);
connect(mUI->mActionAbout, &QAction::triggered, this, &MainWindow::about);
connect(mUI->mActionLicense, &QAction::triggered, this, &MainWindow::showLicense);
// View > Toolbar menu
connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(toggleMainToolBar()));
connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(toggleViewToolBar()));
connect(mUI.mActionToolBarFilter, SIGNAL(toggled(bool)), this, SLOT(toggleFilterToolBar()));
connect(mUI->mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(toggleMainToolBar()));
connect(mUI->mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(toggleViewToolBar()));
connect(mUI->mActionToolBarFilter, SIGNAL(toggled(bool)), this, SLOT(toggleFilterToolBar()));
connect(mUI.mActionAuthors, &QAction::triggered, this, &MainWindow::showAuthors);
connect(mUI->mActionAuthors, &QAction::triggered, this, &MainWindow::showAuthors);
connect(mThread, &ThreadHandler::done, this, &MainWindow::analysisDone);
connect(mThread, &ThreadHandler::log, mUI.mResults, &ResultsView::log);
connect(mThread, &ThreadHandler::debugError, mUI.mResults, &ResultsView::debugError);
connect(mThread, &ThreadHandler::bughuntingReportLine, mUI.mResults, &ResultsView::bughuntingReportLine);
connect(mUI.mResults, &ResultsView::gotResults, this, &MainWindow::resultsAdded);
connect(mUI.mResults, &ResultsView::resultsHidden, mUI.mActionShowHidden, &QAction::setEnabled);
connect(mUI.mResults, &ResultsView::checkSelected, this, &MainWindow::performSelectedFilesCheck);
connect(mUI.mResults, &ResultsView::suppressIds, this, &MainWindow::suppressIds);
connect(mUI.mResults, &ResultsView::editFunctionContract, this, &MainWindow::editFunctionContract);
connect(mUI.mResults, &ResultsView::editVariableContract, this, &MainWindow::editVariableContract);
connect(mUI.mResults, &ResultsView::deleteFunctionContract, this, &MainWindow::deleteFunctionContract);
connect(mUI.mResults, &ResultsView::deleteVariableContract, this, &MainWindow::deleteVariableContract);
connect(mUI.mMenuView, &QMenu::aboutToShow, this, &MainWindow::aboutToShowViewMenu);
connect(mThread, &ThreadHandler::log, mUI->mResults, &ResultsView::log);
connect(mThread, &ThreadHandler::debugError, mUI->mResults, &ResultsView::debugError);
connect(mThread, &ThreadHandler::bughuntingReportLine, mUI->mResults, &ResultsView::bughuntingReportLine);
connect(mUI->mResults, &ResultsView::gotResults, this, &MainWindow::resultsAdded);
connect(mUI->mResults, &ResultsView::resultsHidden, mUI->mActionShowHidden, &QAction::setEnabled);
connect(mUI->mResults, &ResultsView::checkSelected, this, &MainWindow::performSelectedFilesCheck);
connect(mUI->mResults, &ResultsView::suppressIds, this, &MainWindow::suppressIds);
connect(mUI->mResults, &ResultsView::editFunctionContract, this, &MainWindow::editFunctionContract);
connect(mUI->mResults, &ResultsView::editVariableContract, this, &MainWindow::editVariableContract);
connect(mUI->mResults, &ResultsView::deleteFunctionContract, this, &MainWindow::deleteFunctionContract);
connect(mUI->mResults, &ResultsView::deleteVariableContract, this, &MainWindow::deleteVariableContract);
connect(mUI->mMenuView, &QMenu::aboutToShow, this, &MainWindow::aboutToShowViewMenu);
// File menu
connect(mUI.mActionNewProjectFile, &QAction::triggered, this, &MainWindow::newProjectFile);
connect(mUI.mActionOpenProjectFile, &QAction::triggered, this, &MainWindow::openProjectFile);
connect(mUI.mActionShowScratchpad, &QAction::triggered, this, &MainWindow::showScratchpad);
connect(mUI.mActionCloseProjectFile, &QAction::triggered, this, &MainWindow::closeProjectFile);
connect(mUI.mActionEditProjectFile, &QAction::triggered, this, &MainWindow::editProjectFile);
connect(mUI->mActionNewProjectFile, &QAction::triggered, this, &MainWindow::newProjectFile);
connect(mUI->mActionOpenProjectFile, &QAction::triggered, this, &MainWindow::openProjectFile);
connect(mUI->mActionShowScratchpad, &QAction::triggered, this, &MainWindow::showScratchpad);
connect(mUI->mActionCloseProjectFile, &QAction::triggered, this, &MainWindow::closeProjectFile);
connect(mUI->mActionEditProjectFile, &QAction::triggered, this, &MainWindow::editProjectFile);
connect(mUI.mActionHelpContents, &QAction::triggered, this, &MainWindow::openHelpContents);
connect(mUI->mActionHelpContents, &QAction::triggered, this, &MainWindow::openHelpContents);
loadSettings();
mThread->initialize(mUI.mResults);
mThread->initialize(mUI->mResults);
if (mProjectFile)
formatAndSetTitle(tr("Project:") + ' ' + mProjectFile->getFilename());
else
@ -161,7 +165,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
enableCheckButtons(true);
mUI.mActionPrint->setShortcut(QKeySequence::Print);
mUI->mActionPrint->setShortcut(QKeySequence::Print);
enableResultsButtons();
enableProjectOpenActions(true);
enableProjectActions(false);
@ -175,7 +179,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
this, SLOT(openRecentProject()));
}
mRecentProjectActs[MaxRecentProjects] = nullptr; // The separator
mUI.mActionProjectMRU->setVisible(false);
mUI->mActionProjectMRU->setVisible(false);
updateMRUMenuItems();
QStringList args = QCoreApplication::arguments();
@ -185,8 +189,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
handleCLIParams(args);
}
mUI.mActionCloseProjectFile->setEnabled(mProjectFile != nullptr);
mUI.mActionEditProjectFile->setEnabled(mProjectFile != nullptr);
mUI->mActionCloseProjectFile->setEnabled(mProjectFile != nullptr);
mUI->mActionEditProjectFile->setEnabled(mProjectFile != nullptr);
for (int i = 0; i < mPlatforms.getCount(); i++) {
Platform platform = mPlatforms.mPlatforms[i];
@ -197,23 +201,23 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
action->setData(platform.mType);
action->setCheckable(true);
action->setActionGroup(mPlatformActions);
mUI.mMenuAnalyze->insertAction(mUI.mActionPlatforms, action);
mUI->mMenuAnalyze->insertAction(mUI->mActionPlatforms, action);
connect(action, SIGNAL(triggered()), this, SLOT(selectPlatform()));
}
mUI.mActionC89->setActionGroup(mCStandardActions);
mUI.mActionC99->setActionGroup(mCStandardActions);
mUI.mActionC11->setActionGroup(mCStandardActions);
mUI->mActionC89->setActionGroup(mCStandardActions);
mUI->mActionC99->setActionGroup(mCStandardActions);
mUI->mActionC11->setActionGroup(mCStandardActions);
mUI.mActionCpp03->setActionGroup(mCppStandardActions);
mUI.mActionCpp11->setActionGroup(mCppStandardActions);
mUI.mActionCpp14->setActionGroup(mCppStandardActions);
mUI.mActionCpp17->setActionGroup(mCppStandardActions);
mUI.mActionCpp20->setActionGroup(mCppStandardActions);
mUI->mActionCpp03->setActionGroup(mCppStandardActions);
mUI->mActionCpp11->setActionGroup(mCppStandardActions);
mUI->mActionCpp14->setActionGroup(mCppStandardActions);
mUI->mActionCpp17->setActionGroup(mCppStandardActions);
mUI->mActionCpp20->setActionGroup(mCppStandardActions);
mUI.mActionEnforceC->setActionGroup(mSelectLanguageActions);
mUI.mActionEnforceCpp->setActionGroup(mSelectLanguageActions);
mUI.mActionAutoDetectLanguage->setActionGroup(mSelectLanguageActions);
mUI->mActionEnforceC->setActionGroup(mSelectLanguageActions);
mUI->mActionEnforceCpp->setActionGroup(mSelectLanguageActions);
mUI->mActionAutoDetectLanguage->setActionGroup(mSelectLanguageActions);
// For Windows platforms default to Win32 checked platform.
// For other platforms default to unspecified/default which means the
@ -231,6 +235,7 @@ MainWindow::~MainWindow()
{
delete mProjectFile;
delete mScratchPad;
delete mUI;
}
void MainWindow::handleCLIParams(const QStringList &params)
@ -274,48 +279,48 @@ void MainWindow::loadSettings()
mSettings->value(SETTINGS_WINDOW_HEIGHT, 600).toInt());
}
ShowTypes *types = mUI.mResults->getShowTypes();
mUI.mActionShowStyle->setChecked(types->isShown(ShowTypes::ShowStyle));
mUI.mActionShowErrors->setChecked(types->isShown(ShowTypes::ShowErrors));
mUI.mActionShowWarnings->setChecked(types->isShown(ShowTypes::ShowWarnings));
mUI.mActionShowPortability->setChecked(types->isShown(ShowTypes::ShowPortability));
mUI.mActionShowPerformance->setChecked(types->isShown(ShowTypes::ShowPerformance));
mUI.mActionShowInformation->setChecked(types->isShown(ShowTypes::ShowInformation));
mUI.mActionShowCppcheck->setChecked(true);
mUI.mActionShowClang->setChecked(true);
ShowTypes *types = mUI->mResults->getShowTypes();
mUI->mActionShowStyle->setChecked(types->isShown(ShowTypes::ShowStyle));
mUI->mActionShowErrors->setChecked(types->isShown(ShowTypes::ShowErrors));
mUI->mActionShowWarnings->setChecked(types->isShown(ShowTypes::ShowWarnings));
mUI->mActionShowPortability->setChecked(types->isShown(ShowTypes::ShowPortability));
mUI->mActionShowPerformance->setChecked(types->isShown(ShowTypes::ShowPerformance));
mUI->mActionShowInformation->setChecked(types->isShown(ShowTypes::ShowInformation));
mUI->mActionShowCppcheck->setChecked(true);
mUI->mActionShowClang->setChecked(true);
Standards standards;
standards.setC(mSettings->value(SETTINGS_STD_C, QString()).toString().toStdString());
mUI.mActionC89->setChecked(standards.c == Standards::C89);
mUI.mActionC99->setChecked(standards.c == Standards::C99);
mUI.mActionC11->setChecked(standards.c == Standards::C11);
mUI->mActionC89->setChecked(standards.c == Standards::C89);
mUI->mActionC99->setChecked(standards.c == Standards::C99);
mUI->mActionC11->setChecked(standards.c == Standards::C11);
standards.setCPP(mSettings->value(SETTINGS_STD_CPP, QString()).toString().toStdString());
mUI.mActionCpp03->setChecked(standards.cpp == Standards::CPP03);
mUI.mActionCpp11->setChecked(standards.cpp == Standards::CPP11);
mUI.mActionCpp14->setChecked(standards.cpp == Standards::CPP14);
mUI.mActionCpp17->setChecked(standards.cpp == Standards::CPP17);
mUI.mActionCpp20->setChecked(standards.cpp == Standards::CPP20);
mUI->mActionCpp03->setChecked(standards.cpp == Standards::CPP03);
mUI->mActionCpp11->setChecked(standards.cpp == Standards::CPP11);
mUI->mActionCpp14->setChecked(standards.cpp == Standards::CPP14);
mUI->mActionCpp17->setChecked(standards.cpp == Standards::CPP17);
mUI->mActionCpp20->setChecked(standards.cpp == Standards::CPP20);
// Main window settings
const bool showMainToolbar = mSettings->value(SETTINGS_TOOLBARS_MAIN_SHOW, true).toBool();
mUI.mActionToolBarMain->setChecked(showMainToolbar);
mUI.mToolBarMain->setVisible(showMainToolbar);
mUI->mActionToolBarMain->setChecked(showMainToolbar);
mUI->mToolBarMain->setVisible(showMainToolbar);
const bool showViewToolbar = mSettings->value(SETTINGS_TOOLBARS_VIEW_SHOW, true).toBool();
mUI.mActionToolBarView->setChecked(showViewToolbar);
mUI.mToolBarView->setVisible(showViewToolbar);
mUI->mActionToolBarView->setChecked(showViewToolbar);
mUI->mToolBarView->setVisible(showViewToolbar);
const bool showFilterToolbar = mSettings->value(SETTINGS_TOOLBARS_FILTER_SHOW, true).toBool();
mUI.mActionToolBarFilter->setChecked(showFilterToolbar);
mUI.mToolBarFilter->setVisible(showFilterToolbar);
mUI->mActionToolBarFilter->setChecked(showFilterToolbar);
mUI->mToolBarFilter->setVisible(showFilterToolbar);
Settings::Language enforcedLanguage = (Settings::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt();
if (enforcedLanguage == Settings::CPP)
mUI.mActionEnforceCpp->setChecked(true);
mUI->mActionEnforceCpp->setChecked(true);
else if (enforcedLanguage == Settings::C)
mUI.mActionEnforceC->setChecked(true);
mUI->mActionEnforceC->setChecked(true);
else
mUI.mActionAutoDetectLanguage->setChecked(true);
mUI->mActionAutoDetectLanguage->setChecked(true);
bool succeeded = mApplications->loadSettings();
if (!succeeded) {
@ -356,39 +361,39 @@ void MainWindow::saveSettings() const
mSettings->setValue(SETTINGS_WINDOW_MAXIMIZED, isMaximized());
// Show * states
mSettings->setValue(SETTINGS_SHOW_STYLE, mUI.mActionShowStyle->isChecked());
mSettings->setValue(SETTINGS_SHOW_ERRORS, mUI.mActionShowErrors->isChecked());
mSettings->setValue(SETTINGS_SHOW_WARNINGS, mUI.mActionShowWarnings->isChecked());
mSettings->setValue(SETTINGS_SHOW_PORTABILITY, mUI.mActionShowPortability->isChecked());
mSettings->setValue(SETTINGS_SHOW_PERFORMANCE, mUI.mActionShowPerformance->isChecked());
mSettings->setValue(SETTINGS_SHOW_INFORMATION, mUI.mActionShowInformation->isChecked());
mSettings->setValue(SETTINGS_SHOW_STYLE, mUI->mActionShowStyle->isChecked());
mSettings->setValue(SETTINGS_SHOW_ERRORS, mUI->mActionShowErrors->isChecked());
mSettings->setValue(SETTINGS_SHOW_WARNINGS, mUI->mActionShowWarnings->isChecked());
mSettings->setValue(SETTINGS_SHOW_PORTABILITY, mUI->mActionShowPortability->isChecked());
mSettings->setValue(SETTINGS_SHOW_PERFORMANCE, mUI->mActionShowPerformance->isChecked());
mSettings->setValue(SETTINGS_SHOW_INFORMATION, mUI->mActionShowInformation->isChecked());
if (mUI.mActionC89->isChecked())
if (mUI->mActionC89->isChecked())
mSettings->setValue(SETTINGS_STD_C, "C89");
if (mUI.mActionC99->isChecked())
if (mUI->mActionC99->isChecked())
mSettings->setValue(SETTINGS_STD_C, "C99");
if (mUI.mActionC11->isChecked())
if (mUI->mActionC11->isChecked())
mSettings->setValue(SETTINGS_STD_C, "C11");
if (mUI.mActionCpp03->isChecked())
if (mUI->mActionCpp03->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++03");
if (mUI.mActionCpp11->isChecked())
if (mUI->mActionCpp11->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++11");
if (mUI.mActionCpp14->isChecked())
if (mUI->mActionCpp14->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++14");
if (mUI.mActionCpp17->isChecked())
if (mUI->mActionCpp17->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++17");
if (mUI.mActionCpp20->isChecked())
if (mUI->mActionCpp20->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++20");
// Main window settings
mSettings->setValue(SETTINGS_TOOLBARS_MAIN_SHOW, mUI.mToolBarMain->isVisible());
mSettings->setValue(SETTINGS_TOOLBARS_VIEW_SHOW, mUI.mToolBarView->isVisible());
mSettings->setValue(SETTINGS_TOOLBARS_FILTER_SHOW, mUI.mToolBarFilter->isVisible());
mSettings->setValue(SETTINGS_TOOLBARS_MAIN_SHOW, mUI->mToolBarMain->isVisible());
mSettings->setValue(SETTINGS_TOOLBARS_VIEW_SHOW, mUI->mToolBarView->isVisible());
mSettings->setValue(SETTINGS_TOOLBARS_FILTER_SHOW, mUI->mToolBarFilter->isVisible());
if (mUI.mActionEnforceCpp->isChecked())
if (mUI->mActionEnforceCpp->isChecked())
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::CPP);
else if (mUI.mActionEnforceC->isChecked())
else if (mUI->mActionEnforceC->isChecked())
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::C);
else
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::None);
@ -399,7 +404,7 @@ void MainWindow::saveSettings() const
mSettings->setValue(SETTINGS_OPEN_PROJECT, mProjectFile ? mProjectFile->getFilename() : QString());
mUI.mResults->saveSettings(mSettings);
mUI->mResults->saveSettings(mSettings);
}
void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, const bool checkConfiguration)
@ -422,10 +427,10 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
enableProjectActions(false);
}
mUI.mResults->clear(true);
mUI->mResults->clear(true);
mThread->clearFiles();
mUI.mResults->checkingStarted(p.fileSettings.size());
mUI->mResults->checkingStarted(p.fileSettings.size());
QDir inf(mCurrentDirectory);
const QString checkPath = inf.canonicalPath();
@ -433,7 +438,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
checkLockDownUI(); // lock UI while checking
mUI.mResults->setCheckDirectory(checkPath);
mUI->mResults->setCheckDirectory(checkPath);
Settings checkSettings = getCppcheckSettings();
checkSettings.force = false;
checkSettings.checkLibrary = checkLibrary;
@ -476,7 +481,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
}
QStringList fileNames = pathList.getFileList();
mUI.mResults->clear(true);
mUI->mResults->clear(true);
mThread->clearFiles();
if (fileNames.isEmpty()) {
@ -489,7 +494,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
return;
}
mUI.mResults->checkingStarted(fileNames.count());
mUI->mResults->checkingStarted(fileNames.count());
mThread->setFiles(fileNames);
if (mProjectFile && !checkConfiguration)
@ -501,7 +506,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
checkLockDownUI(); // lock UI while checking
mUI.mResults->setCheckDirectory(checkPath);
mUI->mResults->setCheckDirectory(checkPath);
Settings checkSettings = getCppcheckSettings();
checkSettings.checkLibrary = checkLibrary;
checkSettings.checkConfiguration = checkConfiguration;
@ -529,13 +534,13 @@ void MainWindow::analyzeCode(const QString& code, const QString& filename)
ThreadResult result;
result.setFiles(QStringList(filename));
connect(&result, SIGNAL(progress(int,const QString&)),
mUI.mResults, SLOT(progress(int,const QString&)));
mUI->mResults, SLOT(progress(int,const QString&)));
connect(&result, SIGNAL(error(const ErrorItem&)),
mUI.mResults, SLOT(error(const ErrorItem&)));
mUI->mResults, SLOT(error(const ErrorItem&)));
connect(&result, SIGNAL(log(const QString&)),
mUI.mResults, SLOT(log(const QString&)));
mUI->mResults, SLOT(log(const QString&)));
connect(&result, SIGNAL(debugError(const ErrorItem&)),
mUI.mResults, SLOT(debugError(const ErrorItem&)));
mUI->mResults, SLOT(debugError(const ErrorItem&)));
// Create CppCheck instance
CppCheck cppcheck(result, true, nullptr);
@ -544,13 +549,13 @@ void MainWindow::analyzeCode(const QString& code, const QString& filename)
// Check
checkLockDownUI();
clearResults();
mUI.mResults->checkingStarted(1);
mUI->mResults->checkingStarted(1);
cppcheck.check(filename.toStdString(), code.toStdString());
analysisDone();
// Expand results
if (mUI.mResults->hasVisibleResults())
mUI.mResults->expandAllResults();
if (mUI->mResults->hasVisibleResults())
mUI->mResults->expandAllResults();
}
QStringList MainWindow::selectFilesToAnalyze(QFileDialog::FileMode mode)
@ -617,7 +622,7 @@ void MainWindow::updateFunctionContractsTab()
addedContracts << QString::fromStdString(it.first);
}
}
mUI.mResults->setAddedFunctionContracts(addedContracts);
mUI->mResults->setAddedFunctionContracts(addedContracts);
}
void MainWindow::updateVariableContractsTab()
@ -633,7 +638,7 @@ void MainWindow::updateVariableContractsTab()
added << line;
}
}
mUI.mResults->setAddedVariableContracts(added);
mUI->mResults->setAddedVariableContracts(added);
}
void MainWindow::analyzeFiles()
@ -1016,33 +1021,33 @@ void MainWindow::analysisDone()
return;
}
mUI.mResults->checkingFinished();
mUI->mResults->checkingFinished();
enableCheckButtons(true);
mUI.mActionSettings->setEnabled(true);
mUI.mActionOpenXML->setEnabled(true);
mUI->mActionSettings->setEnabled(true);
mUI->mActionOpenXML->setEnabled(true);
if (mProjectFile) {
enableProjectActions(true);
} else if (mIsLogfileLoaded) {
mUI.mActionReanalyzeModified->setEnabled(false);
mUI.mActionReanalyzeAll->setEnabled(false);
mUI->mActionReanalyzeModified->setEnabled(false);
mUI->mActionReanalyzeAll->setEnabled(false);
}
enableProjectOpenActions(true);
mPlatformActions->setEnabled(true);
mCStandardActions->setEnabled(true);
mCppStandardActions->setEnabled(true);
mSelectLanguageActions->setEnabled(true);
mUI.mActionPosix->setEnabled(true);
mUI->mActionPosix->setEnabled(true);
if (mScratchPad)
mScratchPad->setEnabled(true);
mUI.mActionViewStats->setEnabled(true);
mUI->mActionViewStats->setEnabled(true);
if (mProjectFile && !mProjectFile->getBuildDir().isEmpty()) {
const QString prjpath = QFileInfo(mProjectFile->getFilename()).absolutePath();
const QString buildDir = prjpath + '/' + mProjectFile->getBuildDir();
if (QDir(buildDir).exists()) {
mUI.mResults->saveStatistics(buildDir + "/statistics.txt");
mUI.mResults->updateFromOldReport(buildDir + "/lastResults.xml");
mUI.mResults->save(buildDir + "/lastResults.xml", Report::XMLV2);
mUI->mResults->saveStatistics(buildDir + "/statistics.txt");
mUI->mResults->updateFromOldReport(buildDir + "/lastResults.xml");
mUI->mResults->save(buildDir + "/lastResults.xml", Report::XMLV2);
}
}
@ -1062,15 +1067,15 @@ void MainWindow::analysisDone()
void MainWindow::checkLockDownUI()
{
enableCheckButtons(false);
mUI.mActionSettings->setEnabled(false);
mUI.mActionOpenXML->setEnabled(false);
mUI->mActionSettings->setEnabled(false);
mUI->mActionOpenXML->setEnabled(false);
enableProjectActions(false);
enableProjectOpenActions(false);
mPlatformActions->setEnabled(false);
mCStandardActions->setEnabled(false);
mCppStandardActions->setEnabled(false);
mSelectLanguageActions->setEnabled(false);
mUI.mActionPosix->setEnabled(false);
mUI->mActionPosix->setEnabled(false);
if (mScratchPad)
mScratchPad->setEnabled(false);
@ -1086,13 +1091,13 @@ void MainWindow::programSettings()
if (dialog.exec() == QDialog::Accepted) {
dialog.saveSettingValues();
mSettings->sync();
mUI.mResults->updateSettings(dialog.showFullPath(),
dialog.saveFullPath(),
dialog.saveAllErrors(),
dialog.showNoErrorsMessage(),
dialog.showErrorId(),
dialog.showInconclusive());
mUI.mResults->updateStyleSetting(mSettings);
mUI->mResults->updateSettings(dialog.showFullPath(),
dialog.saveFullPath(),
dialog.saveAllErrors(),
dialog.showNoErrorsMessage(),
dialog.showErrorId(),
dialog.showInconclusive());
mUI->mResults->updateStyleSetting(mSettings);
const QString newLang = mSettings->value(SETTINGS_LANGUAGE, "en").toString();
setLanguage(newLang);
}
@ -1131,18 +1136,18 @@ void MainWindow::reAnalyzeSelected(QStringList files)
return;
// Clear details, statistics and progress
mUI.mResults->clear(false);
mUI->mResults->clear(false);
for (int i = 0; i < files.size(); ++i)
mUI.mResults->clearRecheckFile(files[i]);
mUI->mResults->clearRecheckFile(files[i]);
mCurrentDirectory = mUI.mResults->getCheckDirectory();
mCurrentDirectory = mUI->mResults->getCheckDirectory();
FileList pathList;
pathList.addPathList(files);
if (mProjectFile)
pathList.addExcludeList(mProjectFile->getExcludedPaths());
QStringList fileNames = pathList.getFileList();
checkLockDownUI(); // lock UI while checking
mUI.mResults->checkingStarted(fileNames.size());
mUI->mResults->checkingStarted(fileNames.size());
mThread->setCheckFiles(fileNames);
// Saving last check start time, otherwise unchecked modified files will not be
@ -1160,14 +1165,14 @@ void MainWindow::reAnalyze(bool all)
return;
// Clear details, statistics and progress
mUI.mResults->clear(all);
mUI->mResults->clear(all);
// Clear results for changed files
for (int i = 0; i < files.size(); ++i)
mUI.mResults->clear(files[i]);
mUI->mResults->clear(files[i]);
checkLockDownUI(); // lock UI while checking
mUI.mResults->checkingStarted(files.size());
mUI->mResults->checkingStarted(files.size());
if (mProjectFile)
qDebug() << "Rechecking project file" << mProjectFile->getFilename();
@ -1185,14 +1190,14 @@ void MainWindow::clearResults()
dir.remove(f);
}
}
mUI.mResults->clear(true);
Q_ASSERT(false == mUI.mResults->hasResults());
mUI->mResults->clear(true);
Q_ASSERT(false == mUI->mResults->hasResults());
enableResultsButtons();
}
void MainWindow::openResults()
{
if (mUI.mResults->hasResults()) {
if (mUI->mResults->hasResults()) {
QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("Cppcheck"));
const QString msg(tr("Current results will be cleared.\n\n"
@ -1229,10 +1234,10 @@ void MainWindow::loadResults(const QString &selectedFile)
if (mProjectFile)
closeProjectFile();
mIsLogfileLoaded = true;
mUI.mResults->clear(true);
mUI.mActionReanalyzeModified->setEnabled(false);
mUI.mActionReanalyzeAll->setEnabled(false);
mUI.mResults->readErrorsXml(selectedFile);
mUI->mResults->clear(true);
mUI->mActionReanalyzeModified->setEnabled(false);
mUI->mActionReanalyzeAll->setEnabled(false);
mUI->mResults->readErrorsXml(selectedFile);
setPath(SETTINGS_LAST_RESULT_PATH, selectedFile);
formatAndSetTitle(selectedFile);
}
@ -1240,62 +1245,62 @@ void MainWindow::loadResults(const QString &selectedFile)
void MainWindow::loadResults(const QString &selectedFile, const QString &sourceDirectory)
{
loadResults(selectedFile);
mUI.mResults->setCheckDirectory(sourceDirectory);
mUI->mResults->setCheckDirectory(sourceDirectory);
}
void MainWindow::enableCheckButtons(bool enable)
{
mUI.mActionStop->setEnabled(!enable);
mUI.mActionAnalyzeFiles->setEnabled(enable);
mUI->mActionStop->setEnabled(!enable);
mUI->mActionAnalyzeFiles->setEnabled(enable);
if (mProjectFile) {
mUI.mActionReanalyzeModified->setEnabled(false);
mUI.mActionReanalyzeAll->setEnabled(enable);
mUI->mActionReanalyzeModified->setEnabled(false);
mUI->mActionReanalyzeAll->setEnabled(enable);
} else if (!enable || mThread->hasPreviousFiles()) {
mUI.mActionReanalyzeModified->setEnabled(enable);
mUI.mActionReanalyzeAll->setEnabled(enable);
mUI->mActionReanalyzeModified->setEnabled(enable);
mUI->mActionReanalyzeAll->setEnabled(enable);
}
mUI.mActionAnalyzeDirectory->setEnabled(enable);
mUI->mActionAnalyzeDirectory->setEnabled(enable);
}
void MainWindow::enableResultsButtons()
{
bool enabled = mUI.mResults->hasResults();
mUI.mActionClearResults->setEnabled(enabled);
mUI.mActionSave->setEnabled(enabled);
mUI.mActionPrint->setEnabled(enabled);
mUI.mActionPrintPreview->setEnabled(enabled);
bool enabled = mUI->mResults->hasResults();
mUI->mActionClearResults->setEnabled(enabled);
mUI->mActionSave->setEnabled(enabled);
mUI->mActionPrint->setEnabled(enabled);
mUI->mActionPrintPreview->setEnabled(enabled);
}
void MainWindow::showStyle(bool checked)
{
mUI.mResults->showResults(ShowTypes::ShowStyle, checked);
mUI->mResults->showResults(ShowTypes::ShowStyle, checked);
}
void MainWindow::showErrors(bool checked)
{
mUI.mResults->showResults(ShowTypes::ShowErrors, checked);
mUI->mResults->showResults(ShowTypes::ShowErrors, checked);
}
void MainWindow::showWarnings(bool checked)
{
mUI.mResults->showResults(ShowTypes::ShowWarnings, checked);
mUI->mResults->showResults(ShowTypes::ShowWarnings, checked);
}
void MainWindow::showPortability(bool checked)
{
mUI.mResults->showResults(ShowTypes::ShowPortability, checked);
mUI->mResults->showResults(ShowTypes::ShowPortability, checked);
}
void MainWindow::showPerformance(bool checked)
{
mUI.mResults->showResults(ShowTypes::ShowPerformance, checked);
mUI->mResults->showResults(ShowTypes::ShowPerformance, checked);
}
void MainWindow::showInformation(bool checked)
{
mUI.mResults->showResults(ShowTypes::ShowInformation, checked);
mUI->mResults->showResults(ShowTypes::ShowInformation, checked);
}
void MainWindow::checkAll()
@ -1339,17 +1344,17 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::toggleAllChecked(bool checked)
{
mUI.mActionShowStyle->setChecked(checked);
mUI->mActionShowStyle->setChecked(checked);
showStyle(checked);
mUI.mActionShowErrors->setChecked(checked);
mUI->mActionShowErrors->setChecked(checked);
showErrors(checked);
mUI.mActionShowWarnings->setChecked(checked);
mUI->mActionShowWarnings->setChecked(checked);
showWarnings(checked);
mUI.mActionShowPortability->setChecked(checked);
mUI->mActionShowPortability->setChecked(checked);
showPortability(checked);
mUI.mActionShowPerformance->setChecked(checked);
mUI->mActionShowPerformance->setChecked(checked);
showPerformance(checked);
mUI.mActionShowInformation->setChecked(checked);
mUI->mActionShowInformation->setChecked(checked);
showInformation(checked);
}
@ -1411,7 +1416,7 @@ void MainWindow::save()
type = Report::CSV;
}
mUI.mResults->save(selectedFile, type);
mUI->mResults->save(selectedFile, type);
setPath(SETTINGS_LAST_RESULT_PATH, selectedFile);
}
}
@ -1421,17 +1426,17 @@ void MainWindow::resultsAdded()
void MainWindow::toggleMainToolBar()
{
mUI.mToolBarMain->setVisible(mUI.mActionToolBarMain->isChecked());
mUI->mToolBarMain->setVisible(mUI->mActionToolBarMain->isChecked());
}
void MainWindow::toggleViewToolBar()
{
mUI.mToolBarView->setVisible(mUI.mActionToolBarView->isChecked());
mUI->mToolBarView->setVisible(mUI->mActionToolBarView->isChecked());
}
void MainWindow::toggleFilterToolBar()
{
mUI.mToolBarFilter->setVisible(mUI.mActionToolBarFilter->isChecked());
mUI->mToolBarFilter->setVisible(mUI->mActionToolBarFilter->isChecked());
mLineEditFilter->clear(); // Clearing the filter also disables filtering
}
@ -1460,8 +1465,8 @@ void MainWindow::setLanguage(const QString &code)
if (mTranslation->setLanguage(code)) {
//Translate everything that is visible here
mUI.retranslateUi(this);
mUI.mResults->translate();
mUI->retranslateUi(this);
mUI->mResults->translate();
mLineEditFilter->setPlaceholderText(QCoreApplication::translate("MainWindow", "Quick Filter:"));
if (mProjectFile)
formatAndSetTitle(tr("Project:") + ' ' + mProjectFile->getFilename());
@ -1472,18 +1477,18 @@ void MainWindow::setLanguage(const QString &code)
void MainWindow::aboutToShowViewMenu()
{
mUI.mActionToolBarMain->setChecked(mUI.mToolBarMain->isVisible());
mUI.mActionToolBarView->setChecked(mUI.mToolBarView->isVisible());
mUI.mActionToolBarFilter->setChecked(mUI.mToolBarFilter->isVisible());
mUI->mActionToolBarMain->setChecked(mUI->mToolBarMain->isVisible());
mUI->mActionToolBarView->setChecked(mUI->mToolBarView->isVisible());
mUI->mActionToolBarFilter->setChecked(mUI->mToolBarFilter->isVisible());
}
void MainWindow::stopAnalysis()
{
mThread->stop();
mUI.mResults->disableProgressbar();
mUI->mResults->disableProgressbar();
const QString &lastResults = getLastResults();
if (!lastResults.isEmpty()) {
mUI.mResults->updateFromOldReport(lastResults);
mUI->mResults->updateFromOldReport(lastResults);
}
}
@ -1534,12 +1539,12 @@ void MainWindow::loadProjectFile(const QString &filePath)
addProjectMRU(filePath);
mIsLogfileLoaded = false;
mUI.mActionCloseProjectFile->setEnabled(true);
mUI.mActionEditProjectFile->setEnabled(true);
mUI->mActionCloseProjectFile->setEnabled(true);
mUI->mActionEditProjectFile->setEnabled(true);
delete mProjectFile;
mProjectFile = new ProjectFile(filePath, this);
mProjectFile->setActiveProject();
mUI.mResults->showContracts(mProjectFile->bugHunting);
mUI->mResults->showContracts(mProjectFile->bugHunting);
updateFunctionContractsTab();
updateVariableContractsTab();
if (!loadLastResults())
@ -1560,9 +1565,9 @@ bool MainWindow::loadLastResults()
return false;
if (!QFileInfo(lastResults).exists())
return false;
mUI.mResults->readErrorsXml(lastResults);
mUI.mResults->setCheckDirectory(mSettings->value(SETTINGS_LAST_CHECK_PATH,QString()).toString());
mUI.mActionViewStats->setEnabled(true);
mUI->mResults->readErrorsXml(lastResults);
mUI->mResults->setCheckDirectory(mSettings->value(SETTINGS_LAST_CHECK_PATH,QString()).toString());
mUI->mActionViewStats->setEnabled(true);
enableResultsButtons();
return true;
}
@ -1675,7 +1680,7 @@ void MainWindow::newProjectFile()
ProjectFileDialog dlg(mProjectFile, this);
if (dlg.exec() == QDialog::Accepted) {
addProjectMRU(filepath);
mUI.mResults->showContracts(mProjectFile->bugHunting);
mUI->mResults->showContracts(mProjectFile->bugHunting);
analyzeProject(mProjectFile);
} else {
closeProjectFile();
@ -1689,9 +1694,9 @@ void MainWindow::closeProjectFile()
{
delete mProjectFile;
mProjectFile = nullptr;
mUI.mResults->clear(true);
mUI.mResults->clearContracts();
mUI.mResults->showContracts(false);
mUI->mResults->clear(true);
mUI->mResults->clearContracts();
mUI->mResults->showContracts(false);
enableProjectActions(false);
enableProjectOpenActions(true);
formatAndSetTitle();
@ -1712,7 +1717,7 @@ void MainWindow::editProjectFile()
ProjectFileDialog dlg(mProjectFile, this);
if (dlg.exec() == QDialog::Accepted) {
mProjectFile->write();
mUI.mResults->showContracts(mProjectFile->bugHunting);
mUI->mResults->showContracts(mProjectFile->bugHunting);
analyzeProject(mProjectFile);
}
}
@ -1726,7 +1731,7 @@ void MainWindow::showStatistics()
statsDialog.setPathSelected(mCurrentDirectory);
statsDialog.setNumberOfFilesScanned(mThread->getPreviousFilesCount());
statsDialog.setScanDuration(mThread->getPreviousScanDuration() / 1000.0);
statsDialog.setStatistics(mUI.mResults->getStatistics());
statsDialog.setStatistics(mUI->mResults->getStatistics());
statsDialog.exec();
}
@ -1739,21 +1744,21 @@ void MainWindow::showLibraryEditor()
void MainWindow::filterResults()
{
mUI.mResults->filterResults(mLineEditFilter->text());
mUI->mResults->filterResults(mLineEditFilter->text());
}
void MainWindow::enableProjectActions(bool enable)
{
mUI.mActionCloseProjectFile->setEnabled(enable);
mUI.mActionEditProjectFile->setEnabled(enable);
mUI.mActionCheckLibrary->setEnabled(enable);
mUI.mActionCheckConfiguration->setEnabled(enable);
mUI->mActionCloseProjectFile->setEnabled(enable);
mUI->mActionEditProjectFile->setEnabled(enable);
mUI->mActionCheckLibrary->setEnabled(enable);
mUI->mActionCheckConfiguration->setEnabled(enable);
}
void MainWindow::enableProjectOpenActions(bool enable)
{
mUI.mActionNewProjectFile->setEnabled(enable);
mUI.mActionOpenProjectFile->setEnabled(enable);
mUI->mActionNewProjectFile->setEnabled(enable);
mUI->mActionOpenProjectFile->setEnabled(enable);
}
void MainWindow::openRecentProject()
@ -1793,7 +1798,7 @@ void MainWindow::updateMRUMenuItems()
{
for (QAction* recentProjectAct : mRecentProjectActs) {
if (recentProjectAct != nullptr)
mUI.mMenuFile->removeAction(recentProjectAct);
mUI->mMenuFile->removeAction(recentProjectAct);
}
QStringList projects = mSettings->value(SETTINGS_MRU_PROJECTS).toStringList();
@ -1817,11 +1822,11 @@ void MainWindow::updateMRUMenuItems()
mRecentProjectActs[i]->setText(text);
mRecentProjectActs[i]->setData(projects[i]);
mRecentProjectActs[i]->setVisible(true);
mUI.mMenuFile->insertAction(mUI.mActionProjectMRU, mRecentProjectActs[i]);
mUI->mMenuFile->insertAction(mUI->mActionProjectMRU, mRecentProjectActs[i]);
}
if (numRecentProjects > 1)
mRecentProjectActs[numRecentProjects] = mUI.mMenuFile->insertSeparator(mUI.mActionProjectMRU);
mRecentProjectActs[numRecentProjects] = mUI->mMenuFile->insertSeparator(mUI->mActionProjectMRU);
}
void MainWindow::addProjectMRU(const QString &project)

View File

@ -19,8 +19,6 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "ui_mainwindow.h"
#include "settings.h"
#include "platforms.h"
@ -32,10 +30,15 @@ class ThreadHandler;
class TranslationHandler;
class ScratchPad;
class ProjectFile;
class ApplicationList;
class QAction;
class QActionGroup;
class QSettings;
class QTimer;
class QLineEdit;
namespace Ui {
class MainWindow;
};
/// @addtogroup GUI
/// @{
@ -431,7 +434,7 @@ private:
TranslationHandler *mTranslation;
/** @brief Class holding all UI components */
Ui::MainWindow mUI;
Ui::MainWindow *mUI;
/** @brief Current analyzed directory. */
QString mCurrentDirectory;

View File

@ -18,13 +18,13 @@
#include "newsuppressiondialog.h"
#include "ui_newsuppressiondialog.h"
#include "cppcheck.h"
#include "color.h"
#include "errorlogger.h"
#include "suppressions.h"
#include "ui_newsuppressiondialog.h"
NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
QDialog(parent),
mUI(new Ui::NewSuppressionDialog)

View File

@ -26,6 +26,8 @@
#include "platforms.h"
#include "projectfile.h"
#include "ui_projectfile.h"
#include <QDir>
#include <QFileDialog>
#include <QFileInfo>
@ -70,11 +72,12 @@ QStringList ProjectFileDialog::getProjectConfigs(const QString &fileName)
ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, QWidget *parent)
: QDialog(parent)
, mUI(new Ui::ProjectFile)
, mProjectFile(projectFile)
{
mUI.setupUi(this);
mUI->setupUi(this);
mUI.mToolClangAnalyzer->hide();
mUI->mToolClangAnalyzer->hide();
const QFileInfo inf(projectFile->getFilename());
QString filename = inf.fileName();
@ -146,9 +149,9 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, QWidget *parent)
}
}
libs.sort();
mUI.mLibraries->clear();
mUI->mLibraries->clear();
for (const QString &lib : libs) {
QListWidgetItem* item = new QListWidgetItem(lib, mUI.mLibraries);
QListWidgetItem* item = new QListWidgetItem(lib, mUI->mLibraries);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
item->setCheckState(Qt::Unchecked); // AND initialize check state
}
@ -156,7 +159,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, QWidget *parent)
// Platforms..
Platforms platforms;
for (cppcheck::Platform::PlatformType builtinPlatform : builtinPlatforms)
mUI.mComboBoxPlatform->addItem(platforms.get(builtinPlatform).mTitle);
mUI->mComboBoxPlatform->addItem(platforms.get(builtinPlatform).mTitle);
QStringList platformFiles;
foreach (QString sp, searchPaths) {
if (sp.endsWith("/cfg"))
@ -177,41 +180,42 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, QWidget *parent)
}
}
platformFiles.sort();
mUI.mComboBoxPlatform->addItems(platformFiles);
mUI->mComboBoxPlatform->addItems(platformFiles);
mUI.mEditTags->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9 ;]*"),this));
mUI->mEditTags->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9 ;]*"),this));
const QRegExp undefRegExp("\\s*([a-zA-Z_][a-zA-Z0-9_]*[; ]*)*");
mUI.mEditUndefines->setValidator(new QRegExpValidator(undefRegExp, this));
mUI->mEditUndefines->setValidator(new QRegExpValidator(undefRegExp, this));
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &ProjectFileDialog::ok);
connect(mUI.mBtnBrowseBuildDir, &QPushButton::clicked, this, &ProjectFileDialog::browseBuildDir);
connect(mUI.mBtnClearImportProject, &QPushButton::clicked, this, &ProjectFileDialog::clearImportProject);
connect(mUI.mBtnBrowseImportProject, &QPushButton::clicked, this, &ProjectFileDialog::browseImportProject);
connect(mUI.mBtnAddCheckPath, SIGNAL(clicked()), this, SLOT(addCheckPath()));
connect(mUI.mBtnEditCheckPath, &QPushButton::clicked, this, &ProjectFileDialog::editCheckPath);
connect(mUI.mBtnRemoveCheckPath, &QPushButton::clicked, this, &ProjectFileDialog::removeCheckPath);
connect(mUI.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(addIncludeDir()));
connect(mUI.mBtnEditInclude, &QPushButton::clicked, this, &ProjectFileDialog::editIncludeDir);
connect(mUI.mBtnRemoveInclude, &QPushButton::clicked, this, &ProjectFileDialog::removeIncludeDir);
connect(mUI.mBtnAddIgnorePath, SIGNAL(clicked()), this, SLOT(addExcludePath()));
connect(mUI.mBtnAddIgnoreFile, SIGNAL(clicked()), this, SLOT(addExcludeFile()));
connect(mUI.mBtnEditIgnorePath, &QPushButton::clicked, this, &ProjectFileDialog::editExcludePath);
connect(mUI.mBtnRemoveIgnorePath, &QPushButton::clicked, this, &ProjectFileDialog::removeExcludePath);
connect(mUI.mBtnIncludeUp, &QPushButton::clicked, this, &ProjectFileDialog::moveIncludePathUp);
connect(mUI.mBtnIncludeDown, &QPushButton::clicked, this, &ProjectFileDialog::moveIncludePathDown);
connect(mUI.mBtnAddSuppression, &QPushButton::clicked, this, &ProjectFileDialog::addSuppression);
connect(mUI.mBtnRemoveSuppression, &QPushButton::clicked, this, &ProjectFileDialog::removeSuppression);
connect(mUI.mListSuppressions, &QListWidget::doubleClicked, this, &ProjectFileDialog::editSuppression);
connect(mUI.mBtnBrowseMisraFile, &QPushButton::clicked, this, &ProjectFileDialog::browseMisraFile);
connect(mUI.mChkAllVsConfigs, &QCheckBox::clicked, this, &ProjectFileDialog::checkAllVSConfigs);
connect(mUI.mBtnNormalAnalysis, &QCheckBox::toggled, mUI.mBtnSafeClasses, &QCheckBox::setEnabled);
connect(mUI->mButtons, &QDialogButtonBox::accepted, this, &ProjectFileDialog::ok);
connect(mUI->mBtnBrowseBuildDir, &QPushButton::clicked, this, &ProjectFileDialog::browseBuildDir);
connect(mUI->mBtnClearImportProject, &QPushButton::clicked, this, &ProjectFileDialog::clearImportProject);
connect(mUI->mBtnBrowseImportProject, &QPushButton::clicked, this, &ProjectFileDialog::browseImportProject);
connect(mUI->mBtnAddCheckPath, SIGNAL(clicked()), this, SLOT(addCheckPath()));
connect(mUI->mBtnEditCheckPath, &QPushButton::clicked, this, &ProjectFileDialog::editCheckPath);
connect(mUI->mBtnRemoveCheckPath, &QPushButton::clicked, this, &ProjectFileDialog::removeCheckPath);
connect(mUI->mBtnAddInclude, SIGNAL(clicked()), this, SLOT(addIncludeDir()));
connect(mUI->mBtnEditInclude, &QPushButton::clicked, this, &ProjectFileDialog::editIncludeDir);
connect(mUI->mBtnRemoveInclude, &QPushButton::clicked, this, &ProjectFileDialog::removeIncludeDir);
connect(mUI->mBtnAddIgnorePath, SIGNAL(clicked()), this, SLOT(addExcludePath()));
connect(mUI->mBtnAddIgnoreFile, SIGNAL(clicked()), this, SLOT(addExcludeFile()));
connect(mUI->mBtnEditIgnorePath, &QPushButton::clicked, this, &ProjectFileDialog::editExcludePath);
connect(mUI->mBtnRemoveIgnorePath, &QPushButton::clicked, this, &ProjectFileDialog::removeExcludePath);
connect(mUI->mBtnIncludeUp, &QPushButton::clicked, this, &ProjectFileDialog::moveIncludePathUp);
connect(mUI->mBtnIncludeDown, &QPushButton::clicked, this, &ProjectFileDialog::moveIncludePathDown);
connect(mUI->mBtnAddSuppression, &QPushButton::clicked, this, &ProjectFileDialog::addSuppression);
connect(mUI->mBtnRemoveSuppression, &QPushButton::clicked, this, &ProjectFileDialog::removeSuppression);
connect(mUI->mListSuppressions, &QListWidget::doubleClicked, this, &ProjectFileDialog::editSuppression);
connect(mUI->mBtnBrowseMisraFile, &QPushButton::clicked, this, &ProjectFileDialog::browseMisraFile);
connect(mUI->mChkAllVsConfigs, &QCheckBox::clicked, this, &ProjectFileDialog::checkAllVSConfigs);
connect(mUI->mBtnNormalAnalysis, &QCheckBox::toggled, mUI->mBtnSafeClasses, &QCheckBox::setEnabled);
loadFromProjectFile(projectFile);
}
ProjectFileDialog::~ProjectFileDialog()
{
saveSettings();
delete mUI;
}
void ProjectFileDialog::loadSettings()
@ -240,13 +244,13 @@ static void updateAddonCheckBox(QCheckBox *cb, const ProjectFile *projectFile, c
void ProjectFileDialog::checkAllVSConfigs()
{
if (mUI.mChkAllVsConfigs->isChecked()) {
for (int row = 0; row < mUI.mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI.mListVsConfigs->item(row);
if (mUI->mChkAllVsConfigs->isChecked()) {
for (int row = 0; row < mUI->mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI->mListVsConfigs->item(row);
item->setCheckState(Qt::Checked);
}
}
mUI.mListVsConfigs->setEnabled(!mUI.mChkAllVsConfigs->isChecked());
mUI->mListVsConfigs->setEnabled(!mUI->mChkAllVsConfigs->isChecked());
}
void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
@ -258,39 +262,39 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
setUndefines(projectFile->getUndefines());
setCheckPaths(projectFile->getCheckPaths());
setImportProject(projectFile->getImportProject());
mUI.mChkAllVsConfigs->setChecked(projectFile->getAnalyzeAllVsConfigs());
setProjectConfigurations(getProjectConfigs(mUI.mEditImportProject->text()));
for (int row = 0; row < mUI.mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI.mListVsConfigs->item(row);
mUI->mChkAllVsConfigs->setChecked(projectFile->getAnalyzeAllVsConfigs());
setProjectConfigurations(getProjectConfigs(mUI->mEditImportProject->text()));
for (int row = 0; row < mUI->mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI->mListVsConfigs->item(row);
if (projectFile->getAnalyzeAllVsConfigs() || projectFile->getVsConfigurations().contains(item->text()))
item->setCheckState(Qt::Checked);
else
item->setCheckState(Qt::Unchecked);
}
mUI.mCheckHeaders->setChecked(projectFile->getCheckHeaders());
mUI.mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates());
mUI.mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth());
mUI.mMaxTemplateRecursion->setValue(projectFile->getMaxTemplateRecursion());
mUI->mCheckHeaders->setChecked(projectFile->getCheckHeaders());
mUI->mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates());
mUI->mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth());
mUI->mMaxTemplateRecursion->setValue(projectFile->getMaxTemplateRecursion());
if (projectFile->clangParser)
mUI.mBtnClangParser->setChecked(true);
mUI->mBtnClangParser->setChecked(true);
else
mUI.mBtnCppcheckParser->setChecked(true);
mUI.mBtnSafeClasses->setChecked(projectFile->safeChecks.classes);
mUI.mBtnBugHunting->setChecked(projectFile->bugHunting);
mUI->mBtnCppcheckParser->setChecked(true);
mUI->mBtnSafeClasses->setChecked(projectFile->safeChecks.classes);
mUI->mBtnBugHunting->setChecked(projectFile->bugHunting);
setExcludedPaths(projectFile->getExcludedPaths());
setLibraries(projectFile->getLibraries());
const QString platform = projectFile->getPlatform();
if (platform.endsWith(".xml")) {
int i;
for (i = numberOfBuiltinPlatforms; i < mUI.mComboBoxPlatform->count(); ++i) {
if (mUI.mComboBoxPlatform->itemText(i) == platform)
for (i = numberOfBuiltinPlatforms; i < mUI->mComboBoxPlatform->count(); ++i) {
if (mUI->mComboBoxPlatform->itemText(i) == platform)
break;
}
if (i < mUI.mComboBoxPlatform->count())
mUI.mComboBoxPlatform->setCurrentIndex(i);
if (i < mUI->mComboBoxPlatform->count())
mUI->mComboBoxPlatform->setCurrentIndex(i);
else {
mUI.mComboBoxPlatform->addItem(platform);
mUI.mComboBoxPlatform->setCurrentIndex(i);
mUI->mComboBoxPlatform->addItem(platform);
mUI->mComboBoxPlatform->setCurrentIndex(i);
}
} else {
int i;
@ -300,55 +304,55 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
break;
}
if (i < numberOfBuiltinPlatforms)
mUI.mComboBoxPlatform->setCurrentIndex(i);
mUI->mComboBoxPlatform->setCurrentIndex(i);
else
mUI.mComboBoxPlatform->setCurrentIndex(-1);
mUI->mComboBoxPlatform->setCurrentIndex(-1);
}
mUI.mComboBoxPlatform->setCurrentText(projectFile->getPlatform());
mUI->mComboBoxPlatform->setCurrentText(projectFile->getPlatform());
setSuppressions(projectFile->getSuppressions());
// Human knowledge..
/*
mUI.mListUnknownFunctionReturn->clear();
mUI.mListUnknownFunctionReturn->addItem("rand()");
for (int row = 0; row < mUI.mListUnknownFunctionReturn->count(); ++row) {
QListWidgetItem *item = mUI.mListUnknownFunctionReturn->item(row);
mUI->mListUnknownFunctionReturn->clear();
mUI->mListUnknownFunctionReturn->addItem("rand()");
for (int row = 0; row < mUI->mListUnknownFunctionReturn->count(); ++row) {
QListWidgetItem *item = mUI->mListUnknownFunctionReturn->item(row);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
const bool unknownValues = projectFile->getCheckUnknownFunctionReturn().contains(item->text());
item->setCheckState(unknownValues ? Qt::Checked : Qt::Unchecked); // AND initialize check state
}
mUI.mCheckSafeClasses->setChecked(projectFile->getSafeChecks().classes);
mUI.mCheckSafeExternalFunctions->setChecked(projectFile->getSafeChecks().externalFunctions);
mUI.mCheckSafeInternalFunctions->setChecked(projectFile->getSafeChecks().internalFunctions);
mUI.mCheckSafeExternalVariables->setChecked(projectFile->getSafeChecks().externalVariables);
mUI->mCheckSafeClasses->setChecked(projectFile->getSafeChecks().classes);
mUI->mCheckSafeExternalFunctions->setChecked(projectFile->getSafeChecks().externalFunctions);
mUI->mCheckSafeInternalFunctions->setChecked(projectFile->getSafeChecks().internalFunctions);
mUI->mCheckSafeExternalVariables->setChecked(projectFile->getSafeChecks().externalVariables);
*/
// Addons..
QSettings settings;
const QString dataDir = getDataDir();
updateAddonCheckBox(mUI.mAddonThreadSafety, projectFile, dataDir, "threadsafety");
updateAddonCheckBox(mUI.mAddonY2038, projectFile, dataDir, "y2038");
updateAddonCheckBox(mUI.mAddonCert, projectFile, dataDir, "cert");
updateAddonCheckBox(mUI.mAddonMisra, projectFile, dataDir, "misra");
updateAddonCheckBox(mUI->mAddonThreadSafety, projectFile, dataDir, "threadsafety");
updateAddonCheckBox(mUI->mAddonY2038, projectFile, dataDir, "y2038");
updateAddonCheckBox(mUI->mAddonCert, projectFile, dataDir, "cert");
updateAddonCheckBox(mUI->mAddonMisra, projectFile, dataDir, "misra");
const QString &misraFile = settings.value(SETTINGS_MISRA_FILE, QString()).toString();
mUI.mEditMisraFile->setText(misraFile);
if (!mUI.mAddonMisra->isEnabled()) {
mUI.mEditMisraFile->setEnabled(false);
mUI.mBtnBrowseMisraFile->setEnabled(false);
mUI->mEditMisraFile->setText(misraFile);
if (!mUI->mAddonMisra->isEnabled()) {
mUI->mEditMisraFile->setEnabled(false);
mUI->mBtnBrowseMisraFile->setEnabled(false);
} else if (misraFile.isEmpty()) {
mUI.mAddonMisra->setEnabled(false);
mUI.mAddonMisra->setText(mUI.mAddonMisra->text() + ' ' + tr("(no rule texts file)"));
mUI->mAddonMisra->setEnabled(false);
mUI->mAddonMisra->setText(mUI->mAddonMisra->text() + ' ' + tr("(no rule texts file)"));
}
mUI.mToolClangAnalyzer->setChecked(projectFile->getClangAnalyzer());
mUI.mToolClangTidy->setChecked(projectFile->getClangTidy());
mUI->mToolClangAnalyzer->setChecked(projectFile->getClangAnalyzer());
mUI->mToolClangTidy->setChecked(projectFile->getClangTidy());
if (CheckThread::clangTidyCmd().isEmpty()) {
mUI.mToolClangTidy->setText(tr("Clang-tidy (not found)"));
mUI.mToolClangTidy->setEnabled(false);
mUI->mToolClangTidy->setText(tr("Clang-tidy (not found)"));
mUI->mToolClangTidy->setEnabled(false);
}
mUI.mEditTags->setText(projectFile->getTags().join(';'));
mUI->mEditTags->setText(projectFile->getTags().join(';'));
updatePathsAndDefines();
}
@ -357,25 +361,25 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
projectFile->setRootPath(getRootPath());
projectFile->setBuildDir(getBuildDir());
projectFile->setImportProject(getImportProject());
projectFile->setAnalyzeAllVsConfigs(mUI.mChkAllVsConfigs->isChecked());
projectFile->setAnalyzeAllVsConfigs(mUI->mChkAllVsConfigs->isChecked());
projectFile->setVSConfigurations(getProjectConfigurations());
projectFile->setCheckHeaders(mUI.mCheckHeaders->isChecked());
projectFile->setCheckUnusedTemplates(mUI.mCheckUnusedTemplates->isChecked());
projectFile->setMaxCtuDepth(mUI.mMaxCtuDepth->value());
projectFile->setMaxTemplateRecursion(mUI.mMaxTemplateRecursion->value());
projectFile->setCheckHeaders(mUI->mCheckHeaders->isChecked());
projectFile->setCheckUnusedTemplates(mUI->mCheckUnusedTemplates->isChecked());
projectFile->setMaxCtuDepth(mUI->mMaxCtuDepth->value());
projectFile->setMaxTemplateRecursion(mUI->mMaxTemplateRecursion->value());
projectFile->setIncludes(getIncludePaths());
projectFile->setDefines(getDefines());
projectFile->setUndefines(getUndefines());
projectFile->setCheckPaths(getCheckPaths());
projectFile->setExcludedPaths(getExcludedPaths());
projectFile->setLibraries(getLibraries());
projectFile->clangParser = mUI.mBtnClangParser->isChecked();
projectFile->safeChecks.classes = mUI.mBtnSafeClasses->isChecked();
projectFile->bugHunting = mUI.mBtnBugHunting->isChecked();
if (mUI.mComboBoxPlatform->currentText().endsWith(".xml"))
projectFile->setPlatform(mUI.mComboBoxPlatform->currentText());
projectFile->clangParser = mUI->mBtnClangParser->isChecked();
projectFile->safeChecks.classes = mUI->mBtnSafeClasses->isChecked();
projectFile->bugHunting = mUI->mBtnBugHunting->isChecked();
if (mUI->mComboBoxPlatform->currentText().endsWith(".xml"))
projectFile->setPlatform(mUI->mComboBoxPlatform->currentText());
else {
int i = mUI.mComboBoxPlatform->currentIndex();
int i = mUI->mComboBoxPlatform->currentIndex();
if (i < numberOfBuiltinPlatforms)
projectFile->setPlatform(cppcheck::Platform::platformString(builtinPlatforms[i]));
else
@ -385,36 +389,36 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
// Human knowledge
/*
QStringList unknownReturnValues;
for (int row = 0; row < mUI.mListUnknownFunctionReturn->count(); ++row) {
QListWidgetItem *item = mUI.mListUnknownFunctionReturn->item(row);
for (int row = 0; row < mUI->mListUnknownFunctionReturn->count(); ++row) {
QListWidgetItem *item = mUI->mListUnknownFunctionReturn->item(row);
if (item->checkState() == Qt::Checked)
unknownReturnValues << item->text();
}
projectFile->setCheckUnknownFunctionReturn(unknownReturnValues);
ProjectFile::SafeChecks safeChecks;
safeChecks.classes = mUI.mCheckSafeClasses->isChecked();
safeChecks.externalFunctions = mUI.mCheckSafeExternalFunctions->isChecked();
safeChecks.internalFunctions = mUI.mCheckSafeInternalFunctions->isChecked();
safeChecks.externalVariables = mUI.mCheckSafeExternalVariables->isChecked();
safeChecks.classes = mUI->mCheckSafeClasses->isChecked();
safeChecks.externalFunctions = mUI->mCheckSafeExternalFunctions->isChecked();
safeChecks.internalFunctions = mUI->mCheckSafeInternalFunctions->isChecked();
safeChecks.externalVariables = mUI->mCheckSafeExternalVariables->isChecked();
projectFile->setSafeChecks(safeChecks);
*/
// Addons
QStringList list;
if (mUI.mAddonThreadSafety->isChecked())
if (mUI->mAddonThreadSafety->isChecked())
list << "threadsafety";
if (mUI.mAddonY2038->isChecked())
if (mUI->mAddonY2038->isChecked())
list << "y2038";
if (mUI.mAddonCert->isChecked())
if (mUI->mAddonCert->isChecked())
list << "cert";
if (mUI.mAddonMisra->isChecked())
if (mUI->mAddonMisra->isChecked())
list << "misra";
projectFile->setAddons(list);
projectFile->setClangAnalyzer(mUI.mToolClangAnalyzer->isChecked());
projectFile->setClangTidy(mUI.mToolClangTidy->isChecked());
projectFile->setClangAnalyzer(mUI->mToolClangAnalyzer->isChecked());
projectFile->setClangTidy(mUI->mToolClangTidy->isChecked());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
projectFile->setTags(mUI.mEditTags->text().split(";", Qt::SkipEmptyParts));
projectFile->setTags(mUI->mEditTags->text().split(";", Qt::SkipEmptyParts));
#else
projectFile->setTags(mUI.mEditTags->text().split(";", QString::SkipEmptyParts));
projectFile->setTags(mUI->mEditTags->text().split(";", QString::SkipEmptyParts));
#endif
}
@ -454,36 +458,36 @@ void ProjectFileDialog::browseBuildDir()
{
const QString dir(getExistingDirectory(tr("Select Cppcheck build dir"), false));
if (!dir.isEmpty())
mUI.mEditBuildDir->setText(dir);
mUI->mEditBuildDir->setText(dir);
}
void ProjectFileDialog::updatePathsAndDefines()
{
const QString &fileName = mUI.mEditImportProject->text();
const QString &fileName = mUI->mEditImportProject->text();
bool importProject = !fileName.isEmpty();
bool hasConfigs = fileName.endsWith(".sln") || fileName.endsWith(".vcxproj");
mUI.mBtnClearImportProject->setEnabled(importProject);
mUI.mListCheckPaths->setEnabled(!importProject);
mUI.mListIncludeDirs->setEnabled(!importProject);
mUI.mBtnAddCheckPath->setEnabled(!importProject);
mUI.mBtnEditCheckPath->setEnabled(!importProject);
mUI.mBtnRemoveCheckPath->setEnabled(!importProject);
mUI.mEditDefines->setEnabled(!importProject);
mUI.mEditUndefines->setEnabled(!importProject);
mUI.mBtnAddInclude->setEnabled(!importProject);
mUI.mBtnEditInclude->setEnabled(!importProject);
mUI.mBtnRemoveInclude->setEnabled(!importProject);
mUI.mBtnIncludeUp->setEnabled(!importProject);
mUI.mBtnIncludeDown->setEnabled(!importProject);
mUI.mChkAllVsConfigs->setEnabled(hasConfigs);
mUI.mListVsConfigs->setEnabled(hasConfigs && !mUI.mChkAllVsConfigs->isChecked());
mUI->mBtnClearImportProject->setEnabled(importProject);
mUI->mListCheckPaths->setEnabled(!importProject);
mUI->mListIncludeDirs->setEnabled(!importProject);
mUI->mBtnAddCheckPath->setEnabled(!importProject);
mUI->mBtnEditCheckPath->setEnabled(!importProject);
mUI->mBtnRemoveCheckPath->setEnabled(!importProject);
mUI->mEditDefines->setEnabled(!importProject);
mUI->mEditUndefines->setEnabled(!importProject);
mUI->mBtnAddInclude->setEnabled(!importProject);
mUI->mBtnEditInclude->setEnabled(!importProject);
mUI->mBtnRemoveInclude->setEnabled(!importProject);
mUI->mBtnIncludeUp->setEnabled(!importProject);
mUI->mBtnIncludeDown->setEnabled(!importProject);
mUI->mChkAllVsConfigs->setEnabled(hasConfigs);
mUI->mListVsConfigs->setEnabled(hasConfigs && !mUI->mChkAllVsConfigs->isChecked());
if (!hasConfigs)
mUI.mListVsConfigs->clear();
mUI->mListVsConfigs->clear();
}
void ProjectFileDialog::clearImportProject()
{
mUI.mEditImportProject->clear();
mUI->mEditImportProject->clear();
updatePathsAndDefines();
}
@ -499,11 +503,11 @@ void ProjectFileDialog::browseImportProject()
dir.canonicalPath(),
toFilterString(filters));
if (!fileName.isEmpty()) {
mUI.mEditImportProject->setText(dir.relativeFilePath(fileName));
mUI->mEditImportProject->setText(dir.relativeFilePath(fileName));
updatePathsAndDefines();
setProjectConfigurations(getProjectConfigs(fileName));
for (int row = 0; row < mUI.mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI.mListVsConfigs->item(row);
for (int row = 0; row < mUI->mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI->mListVsConfigs->item(row);
item->setCheckState(Qt::Checked);
}
}
@ -512,8 +516,8 @@ void ProjectFileDialog::browseImportProject()
QStringList ProjectFileDialog::getProjectConfigurations() const
{
QStringList configs;
for (int row = 0; row < mUI.mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI.mListVsConfigs->item(row);
for (int row = 0; row < mUI->mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI->mListVsConfigs->item(row);
if (item->checkState() == Qt::Checked)
configs << item->text();
}
@ -522,10 +526,10 @@ QStringList ProjectFileDialog::getProjectConfigurations() const
void ProjectFileDialog::setProjectConfigurations(const QStringList &configs)
{
mUI.mListVsConfigs->clear();
mUI.mListVsConfigs->setEnabled(!configs.isEmpty() && !mUI.mChkAllVsConfigs->isChecked());
mUI->mListVsConfigs->clear();
mUI->mListVsConfigs->setEnabled(!configs.isEmpty() && !mUI->mChkAllVsConfigs->isChecked());
foreach (const QString &cfg, configs) {
QListWidgetItem* item = new QListWidgetItem(cfg, mUI.mListVsConfigs);
QListWidgetItem* item = new QListWidgetItem(cfg, mUI->mListVsConfigs);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
item->setCheckState(Qt::Unchecked);
}
@ -533,7 +537,7 @@ void ProjectFileDialog::setProjectConfigurations(const QStringList &configs)
QString ProjectFileDialog::getImportProject() const
{
return mUI.mEditImportProject->text();
return mUI->mEditImportProject->text();
}
void ProjectFileDialog::addIncludeDir(const QString &dir)
@ -544,7 +548,7 @@ void ProjectFileDialog::addIncludeDir(const QString &dir)
const QString newdir = QDir::toNativeSeparators(dir);
QListWidgetItem *item = new QListWidgetItem(newdir);
item->setFlags(item->flags() | Qt::ItemIsEditable);
mUI.mListIncludeDirs->addItem(item);
mUI->mListIncludeDirs->addItem(item);
}
void ProjectFileDialog::addCheckPath(const QString &path)
@ -555,7 +559,7 @@ void ProjectFileDialog::addCheckPath(const QString &path)
const QString newpath = QDir::toNativeSeparators(path);
QListWidgetItem *item = new QListWidgetItem(newpath);
item->setFlags(item->flags() | Qt::ItemIsEditable);
mUI.mListCheckPaths->addItem(item);
mUI->mListCheckPaths->addItem(item);
}
void ProjectFileDialog::addExcludePath(const QString &path)
@ -566,12 +570,12 @@ void ProjectFileDialog::addExcludePath(const QString &path)
const QString newpath = QDir::toNativeSeparators(path);
QListWidgetItem *item = new QListWidgetItem(newpath);
item->setFlags(item->flags() | Qt::ItemIsEditable);
mUI.mListExcludedPaths->addItem(item);
mUI->mListExcludedPaths->addItem(item);
}
QString ProjectFileDialog::getRootPath() const
{
QString root = mUI.mEditProjectRoot->text();
QString root = mUI->mEditProjectRoot->text();
root = root.trimmed();
root = QDir::fromNativeSeparators(root);
return root;
@ -579,26 +583,26 @@ QString ProjectFileDialog::getRootPath() const
QString ProjectFileDialog::getBuildDir() const
{
return mUI.mEditBuildDir->text();
return mUI->mEditBuildDir->text();
}
QStringList ProjectFileDialog::getIncludePaths() const
{
return getPaths(mUI.mListIncludeDirs);
return getPaths(mUI->mListIncludeDirs);
}
QStringList ProjectFileDialog::getDefines() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return mUI.mEditDefines->text().trimmed().split(QRegExp("\\s*;\\s*"), Qt::SkipEmptyParts);
return mUI->mEditDefines->text().trimmed().split(QRegExp("\\s*;\\s*"), Qt::SkipEmptyParts);
#else
return mUI.mEditDefines->text().trimmed().split(QRegExp("\\s*;\\s*"), QString::SkipEmptyParts);
return mUI->mEditDefines->text().trimmed().split(QRegExp("\\s*;\\s*"), QString::SkipEmptyParts);
#endif
}
QStringList ProjectFileDialog::getUndefines() const
{
const QString undefine = mUI.mEditUndefines->text().trimmed();
const QString undefine = mUI->mEditUndefines->text().trimmed();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList undefines = undefine.split(QRegExp("\\s*;\\s*"), Qt::SkipEmptyParts);
#else
@ -610,19 +614,19 @@ QStringList ProjectFileDialog::getUndefines() const
QStringList ProjectFileDialog::getCheckPaths() const
{
return getPaths(mUI.mListCheckPaths);
return getPaths(mUI->mListCheckPaths);
}
QStringList ProjectFileDialog::getExcludedPaths() const
{
return getPaths(mUI.mListExcludedPaths);
return getPaths(mUI->mListExcludedPaths);
}
QStringList ProjectFileDialog::getLibraries() const
{
QStringList libraries;
for (int row = 0; row < mUI.mLibraries->count(); ++row) {
QListWidgetItem *item = mUI.mLibraries->item(row);
for (int row = 0; row < mUI->mLibraries->count(); ++row) {
QListWidgetItem *item = mUI->mLibraries->item(row);
if (item->checkState() == Qt::Checked)
libraries << item->text();
}
@ -631,17 +635,17 @@ QStringList ProjectFileDialog::getLibraries() const
void ProjectFileDialog::setRootPath(const QString &root)
{
mUI.mEditProjectRoot->setText(QDir::toNativeSeparators(root));
mUI->mEditProjectRoot->setText(QDir::toNativeSeparators(root));
}
void ProjectFileDialog::setBuildDir(const QString &buildDir)
{
mUI.mEditBuildDir->setText(buildDir);
mUI->mEditBuildDir->setText(buildDir);
}
void ProjectFileDialog::setImportProject(const QString &importProject)
{
mUI.mEditImportProject->setText(importProject);
mUI->mEditImportProject->setText(importProject);
}
void ProjectFileDialog::setIncludepaths(const QStringList &includes)
@ -653,12 +657,12 @@ void ProjectFileDialog::setIncludepaths(const QStringList &includes)
void ProjectFileDialog::setDefines(const QStringList &defines)
{
mUI.mEditDefines->setText(defines.join(";"));
mUI->mEditDefines->setText(defines.join(";"));
}
void ProjectFileDialog::setUndefines(const QStringList &undefines)
{
mUI.mEditUndefines->setText(undefines.join(";"));
mUI->mEditUndefines->setText(undefines.join(";"));
}
void ProjectFileDialog::setCheckPaths(const QStringList &paths)
@ -677,8 +681,8 @@ void ProjectFileDialog::setExcludedPaths(const QStringList &paths)
void ProjectFileDialog::setLibraries(const QStringList &libraries)
{
for (int row = 0; row < mUI.mLibraries->count(); ++row) {
QListWidgetItem *item = mUI.mLibraries->item(row);
for (int row = 0; row < mUI->mLibraries->count(); ++row) {
QListWidgetItem *item = mUI->mLibraries->item(row);
item->setCheckState(libraries.contains(item->text()) ? Qt::Checked : Qt::Unchecked);
}
}
@ -712,18 +716,18 @@ void ProjectFileDialog::addSingleSuppression(const Suppressions::Suppression &su
suppression_name = QString::fromStdString(suppression.getText());
}
mUI.mListSuppressions->addItem(suppression_name);
mUI->mListSuppressions->addItem(suppression_name);
}
void ProjectFileDialog::setSuppressions(const QList<Suppressions::Suppression> &suppressions)
{
mUI.mListSuppressions->clear();
mUI->mListSuppressions->clear();
QList<Suppressions::Suppression> new_suppressions = suppressions;
mSuppressions.clear();
foreach (const Suppressions::Suppression &suppression, new_suppressions) {
addSingleSuppression(suppression);
}
mUI.mListSuppressions->sortItems();
mUI->mListSuppressions->sortItems();
}
void ProjectFileDialog::addCheckPath()
@ -735,14 +739,14 @@ void ProjectFileDialog::addCheckPath()
void ProjectFileDialog::editCheckPath()
{
QListWidgetItem *item = mUI.mListCheckPaths->currentItem();
mUI.mListCheckPaths->editItem(item);
QListWidgetItem *item = mUI->mListCheckPaths->currentItem();
mUI->mListCheckPaths->editItem(item);
}
void ProjectFileDialog::removeCheckPath()
{
const int row = mUI.mListCheckPaths->currentRow();
QListWidgetItem *item = mUI.mListCheckPaths->takeItem(row);
const int row = mUI->mListCheckPaths->currentRow();
QListWidgetItem *item = mUI->mListCheckPaths->takeItem(row);
delete item;
}
@ -755,15 +759,15 @@ void ProjectFileDialog::addIncludeDir()
void ProjectFileDialog::removeIncludeDir()
{
const int row = mUI.mListIncludeDirs->currentRow();
QListWidgetItem *item = mUI.mListIncludeDirs->takeItem(row);
const int row = mUI->mListIncludeDirs->currentRow();
QListWidgetItem *item = mUI->mListIncludeDirs->takeItem(row);
delete item;
}
void ProjectFileDialog::editIncludeDir()
{
QListWidgetItem *item = mUI.mListIncludeDirs->currentItem();
mUI.mListIncludeDirs->editItem(item);
QListWidgetItem *item = mUI->mListIncludeDirs->currentItem();
mUI->mListIncludeDirs->editItem(item);
}
void ProjectFileDialog::addExcludePath()
@ -783,34 +787,34 @@ void ProjectFileDialog::addExcludeFile()
void ProjectFileDialog::editExcludePath()
{
QListWidgetItem *item = mUI.mListExcludedPaths->currentItem();
mUI.mListExcludedPaths->editItem(item);
QListWidgetItem *item = mUI->mListExcludedPaths->currentItem();
mUI->mListExcludedPaths->editItem(item);
}
void ProjectFileDialog::removeExcludePath()
{
const int row = mUI.mListExcludedPaths->currentRow();
QListWidgetItem *item = mUI.mListExcludedPaths->takeItem(row);
const int row = mUI->mListExcludedPaths->currentRow();
QListWidgetItem *item = mUI->mListExcludedPaths->takeItem(row);
delete item;
}
void ProjectFileDialog::moveIncludePathUp()
{
int row = mUI.mListIncludeDirs->currentRow();
QListWidgetItem *item = mUI.mListIncludeDirs->takeItem(row);
int row = mUI->mListIncludeDirs->currentRow();
QListWidgetItem *item = mUI->mListIncludeDirs->takeItem(row);
row = row > 0 ? row - 1 : 0;
mUI.mListIncludeDirs->insertItem(row, item);
mUI.mListIncludeDirs->setCurrentItem(item);
mUI->mListIncludeDirs->insertItem(row, item);
mUI->mListIncludeDirs->setCurrentItem(item);
}
void ProjectFileDialog::moveIncludePathDown()
{
int row = mUI.mListIncludeDirs->currentRow();
QListWidgetItem *item = mUI.mListIncludeDirs->takeItem(row);
const int count = mUI.mListIncludeDirs->count();
int row = mUI->mListIncludeDirs->currentRow();
QListWidgetItem *item = mUI->mListIncludeDirs->takeItem(row);
const int count = mUI->mListIncludeDirs->count();
row = row < count ? row + 1 : count;
mUI.mListIncludeDirs->insertItem(row, item);
mUI.mListIncludeDirs->setCurrentItem(item);
mUI->mListIncludeDirs->insertItem(row, item);
mUI->mListIncludeDirs->setCurrentItem(item);
}
void ProjectFileDialog::addSuppression()
@ -823,8 +827,8 @@ void ProjectFileDialog::addSuppression()
void ProjectFileDialog::removeSuppression()
{
const int row = mUI.mListSuppressions->currentRow();
QListWidgetItem *item = mUI.mListSuppressions->takeItem(row);
const int row = mUI->mListSuppressions->currentRow();
QListWidgetItem *item = mUI->mListSuppressions->takeItem(row);
if (!item)
return;
@ -836,8 +840,8 @@ void ProjectFileDialog::removeSuppression()
void ProjectFileDialog::editSuppression(const QModelIndex &)
{
const int row = mUI.mListSuppressions->currentRow();
QListWidgetItem *item = mUI.mListSuppressions->item(row);
const int row = mUI->mListSuppressions->currentRow();
QListWidgetItem *item = mUI->mListSuppressions->item(row);
int suppressionIndex = getSuppressionIndex(item->text());
if (suppressionIndex >= 0) { // TODO what if suppression is not found?
NewSuppressionDialog dlg;
@ -867,11 +871,11 @@ void ProjectFileDialog::browseMisraFile()
tr("MISRA rule texts file (%1)").arg("*.txt"));
if (!fileName.isEmpty()) {
QSettings settings;
mUI.mEditMisraFile->setText(fileName);
mUI->mEditMisraFile->setText(fileName);
settings.setValue(SETTINGS_MISRA_FILE, fileName);
mUI.mAddonMisra->setText("MISRA C 2012");
mUI.mAddonMisra->setEnabled(true);
updateAddonCheckBox(mUI.mAddonMisra, nullptr, getDataDir(), "misra");
mUI->mAddonMisra->setText("MISRA C 2012");
mUI->mAddonMisra->setEnabled(true);
updateAddonCheckBox(mUI->mAddonMisra, nullptr, getDataDir(), "misra");
}
}

View File

@ -19,8 +19,6 @@
#ifndef PROJECTFILE_DIALOG_H
#define PROJECTFILE_DIALOG_H
#include "ui_projectfiledialog.h"
#include "suppressions.h"
#include <QDialog>
@ -28,6 +26,9 @@
#include <QStringList>
class QWidget;
namespace Ui {
class ProjectFile;
}
/// @addtogroup GUI
/// @{
@ -315,7 +316,7 @@ protected:
private:
QStringList getProjectConfigs(const QString &fileName);
Ui::ProjectFile mUI;
Ui::ProjectFile *mUI;
/**
* @brief Projectfile path.

View File

@ -29,6 +29,8 @@
#include "xmlreport.h"
#include "xmlreportv2.h"
#include "ui_resultsview.h"
#include <QClipboard>
#include <QDate>
#include <QDir>
@ -44,65 +46,66 @@
ResultsView::ResultsView(QWidget * parent) :
QWidget(parent),
mShowNoErrorsMessage(true),
mUI(new Ui::ResultsView),
mStatistics(new CheckStatistics(this))
{
mUI.setupUi(this);
mUI->setupUi(this);
connect(mUI.mTree, &ResultsTree::resultsHidden, this, &ResultsView::resultsHidden);
connect(mUI.mTree, &ResultsTree::checkSelected, this, &ResultsView::checkSelected);
connect(mUI.mTree, &ResultsTree::treeSelectionChanged, this, &ResultsView::updateDetails);
connect(mUI.mTree, &ResultsTree::suppressIds, this, &ResultsView::suppressIds);
connect(mUI.mTree, &ResultsTree::editFunctionContract, this, &ResultsView::editFunctionContract);
connect(this, &ResultsView::showResults, mUI.mTree, &ResultsTree::showResults);
connect(this, &ResultsView::showCppcheckResults, mUI.mTree, &ResultsTree::showCppcheckResults);
connect(this, &ResultsView::showClangResults, mUI.mTree, &ResultsTree::showClangResults);
connect(this, &ResultsView::collapseAllResults, mUI.mTree, &ResultsTree::collapseAll);
connect(this, &ResultsView::expandAllResults, mUI.mTree, &ResultsTree::expandAll);
connect(this, &ResultsView::showHiddenResults, mUI.mTree, &ResultsTree::showHiddenResults);
connect(mUI->mTree, &ResultsTree::resultsHidden, this, &ResultsView::resultsHidden);
connect(mUI->mTree, &ResultsTree::checkSelected, this, &ResultsView::checkSelected);
connect(mUI->mTree, &ResultsTree::treeSelectionChanged, this, &ResultsView::updateDetails);
connect(mUI->mTree, &ResultsTree::suppressIds, this, &ResultsView::suppressIds);
connect(mUI->mTree, &ResultsTree::editFunctionContract, this, &ResultsView::editFunctionContract);
connect(this, &ResultsView::showResults, mUI->mTree, &ResultsTree::showResults);
connect(this, &ResultsView::showCppcheckResults, mUI->mTree, &ResultsTree::showCppcheckResults);
connect(this, &ResultsView::showClangResults, mUI->mTree, &ResultsTree::showClangResults);
connect(this, &ResultsView::collapseAllResults, mUI->mTree, &ResultsTree::collapseAll);
connect(this, &ResultsView::expandAllResults, mUI->mTree, &ResultsTree::expandAll);
connect(this, &ResultsView::showHiddenResults, mUI->mTree, &ResultsTree::showHiddenResults);
// Function contracts
connect(mUI.mListAddedContracts, &QListWidget::itemDoubleClicked, this, &ResultsView::contractDoubleClicked);
connect(mUI.mListMissingContracts, &QListWidget::itemDoubleClicked, this, &ResultsView::contractDoubleClicked);
mUI.mListAddedContracts->installEventFilter(this);
connect(mUI->mListAddedContracts, &QListWidget::itemDoubleClicked, this, &ResultsView::contractDoubleClicked);
connect(mUI->mListMissingContracts, &QListWidget::itemDoubleClicked, this, &ResultsView::contractDoubleClicked);
mUI->mListAddedContracts->installEventFilter(this);
// Variable contracts
connect(mUI.mListAddedVariables, &QListWidget::itemDoubleClicked, this, &ResultsView::variableDoubleClicked);
connect(mUI.mListMissingVariables, &QListWidget::itemDoubleClicked, this, &ResultsView::variableDoubleClicked);
connect(mUI.mEditVariablesFilter, &QLineEdit::textChanged, this, &ResultsView::editVariablesFilter);
mUI.mListAddedVariables->installEventFilter(this);
connect(mUI->mListAddedVariables, &QListWidget::itemDoubleClicked, this, &ResultsView::variableDoubleClicked);
connect(mUI->mListMissingVariables, &QListWidget::itemDoubleClicked, this, &ResultsView::variableDoubleClicked);
connect(mUI->mEditVariablesFilter, &QLineEdit::textChanged, this, &ResultsView::editVariablesFilter);
mUI->mListAddedVariables->installEventFilter(this);
mUI.mListLog->setContextMenuPolicy(Qt::CustomContextMenu);
mUI->mListLog->setContextMenuPolicy(Qt::CustomContextMenu);
mUI.mListAddedContracts->setSortingEnabled(true);
mUI.mListMissingContracts->setSortingEnabled(true);
mUI->mListAddedContracts->setSortingEnabled(true);
mUI->mListMissingContracts->setSortingEnabled(true);
}
void ResultsView::initialize(QSettings *settings, ApplicationList *list, ThreadHandler *checkThreadHandler)
{
mUI.mProgress->setMinimum(0);
mUI.mProgress->setVisible(false);
mUI->mProgress->setMinimum(0);
mUI->mProgress->setVisible(false);
CodeEditorStyle theStyle(CodeEditorStyle::loadSettings(settings));
mUI.mCode->setStyle(theStyle);
mUI->mCode->setStyle(theStyle);
QByteArray state = settings->value(SETTINGS_MAINWND_SPLITTER_STATE).toByteArray();
mUI.mVerticalSplitter->restoreState(state);
mUI->mVerticalSplitter->restoreState(state);
mShowNoErrorsMessage = settings->value(SETTINGS_SHOW_NO_ERRORS, true).toBool();
mUI.mTree->initialize(settings, list, checkThreadHandler);
mUI->mTree->initialize(settings, list, checkThreadHandler);
}
ResultsView::~ResultsView()
{
//dtor
delete mUI;
}
void ResultsView::setAddedFunctionContracts(const QStringList &addedContracts)
{
mUI.mListAddedContracts->clear();
mUI.mListAddedContracts->addItems(addedContracts);
mUI->mListAddedContracts->clear();
mUI->mListAddedContracts->addItems(addedContracts);
for (const QString& f: addedContracts) {
auto res = mUI.mListMissingContracts->findItems(f, Qt::MatchExactly);
auto res = mUI->mListMissingContracts->findItems(f, Qt::MatchExactly);
if (!res.empty())
delete res.front();
}
@ -110,10 +113,10 @@ void ResultsView::setAddedFunctionContracts(const QStringList &addedContracts)
void ResultsView::setAddedVariableContracts(const QStringList &added)
{
mUI.mListAddedVariables->clear();
mUI.mListAddedVariables->addItems(added);
mUI->mListAddedVariables->clear();
mUI->mListAddedVariables->addItems(added);
for (const QString& var: added) {
for (auto *item: mUI.mListMissingVariables->findItems(var, Qt::MatchExactly))
for (auto *item: mUI->mListMissingVariables->findItems(var, Qt::MatchExactly))
delete item;
mVariableContracts.insert(var);
}
@ -122,54 +125,59 @@ void ResultsView::setAddedVariableContracts(const QStringList &added)
void ResultsView::clear(bool results)
{
if (results) {
mUI.mTree->clear();
mUI->mTree->clear();
}
mUI.mDetails->setText(QString());
mUI->mDetails->setText(QString());
mStatistics->clear();
//Clear the progressbar
mUI.mProgress->setMaximum(PROGRESS_MAX);
mUI.mProgress->setValue(0);
mUI.mProgress->setFormat("%p%");
mUI->mProgress->setMaximum(PROGRESS_MAX);
mUI->mProgress->setValue(0);
mUI->mProgress->setFormat("%p%");
}
void ResultsView::clear(const QString &filename)
{
mUI.mTree->clear(filename);
mUI->mTree->clear(filename);
}
void ResultsView::clearRecheckFile(const QString &filename)
{
mUI.mTree->clearRecheckFile(filename);
mUI->mTree->clearRecheckFile(filename);
}
void ResultsView::clearContracts()
{
mUI.mListAddedContracts->clear();
mUI.mListAddedVariables->clear();
mUI.mListMissingContracts->clear();
mUI.mListMissingVariables->clear();
mUI->mListAddedContracts->clear();
mUI->mListAddedVariables->clear();
mUI->mListMissingContracts->clear();
mUI->mListMissingVariables->clear();
mFunctionContracts.clear();
mVariableContracts.clear();
}
ShowTypes * ResultsView::getShowTypes() const
{
return &mUI->mTree->mShowSeverities;
}
void ResultsView::showContracts(bool visible)
{
mUI.mTabFunctionContracts->setVisible(visible);
mUI.mTabVariableContracts->setVisible(visible);
mUI->mTabFunctionContracts->setVisible(visible);
mUI->mTabVariableContracts->setVisible(visible);
}
void ResultsView::progress(int value, const QString& description)
{
mUI.mProgress->setValue(value);
mUI.mProgress->setFormat(QString("%p% (%1)").arg(description));
mUI->mProgress->setValue(value);
mUI->mProgress->setFormat(QString("%p% (%1)").arg(description));
}
void ResultsView::error(const ErrorItem &item)
{
if (mUI.mTree->addErrorItem(item)) {
if (mUI->mTree->addErrorItem(item)) {
emit gotResults();
mStatistics->addItem(item.tool(), ShowTypes::SeverityToShowType(item.severity));
}
@ -177,7 +185,7 @@ void ResultsView::error(const ErrorItem &item)
void ResultsView::filterResults(const QString& filter)
{
mUI.mTree->filterResults(filter);
mUI->mTree->filterResults(filter);
}
void ResultsView::saveStatistics(const QString &filename) const
@ -199,7 +207,7 @@ void ResultsView::saveStatistics(const QString &filename) const
void ResultsView::updateFromOldReport(const QString &filename) const
{
mUI.mTree->updateFromOldReport(filename);
mUI->mTree->updateFromOldReport(filename);
}
void ResultsView::save(const QString &filename, Report::Type type) const
@ -220,7 +228,7 @@ void ResultsView::save(const QString &filename, Report::Type type) const
if (report) {
if (report->create())
mUI.mTree->saveResults(report);
mUI->mTree->saveResults(report);
else {
QMessageBox msgBox;
msgBox.setText(tr("Failed to save the report."));
@ -267,7 +275,7 @@ void ResultsView::print(QPrinter* printer)
}
PrintableReport report;
mUI.mTree->saveResults(&report);
mUI->mTree->saveResults(&report);
QTextDocument doc(report.getFormattedReportText());
doc.print(printer);
}
@ -279,42 +287,42 @@ void ResultsView::updateSettings(bool showFullPath,
bool showErrorId,
bool showInconclusive)
{
mUI.mTree->updateSettings(showFullPath, saveFullPath, saveAllErrors, showErrorId, showInconclusive);
mUI->mTree->updateSettings(showFullPath, saveFullPath, saveAllErrors, showErrorId, showInconclusive);
mShowNoErrorsMessage = showNoErrorsMessage;
}
void ResultsView::updateStyleSetting(QSettings *settings)
{
CodeEditorStyle theStyle(CodeEditorStyle::loadSettings(settings));
mUI.mCode->setStyle(theStyle);
mUI->mCode->setStyle(theStyle);
}
void ResultsView::setCheckDirectory(const QString &dir)
{
mUI.mTree->setCheckDirectory(dir);
mUI->mTree->setCheckDirectory(dir);
}
QString ResultsView::getCheckDirectory()
{
return mUI.mTree->getCheckDirectory();
return mUI->mTree->getCheckDirectory();
}
void ResultsView::checkingStarted(int count)
{
mUI.mProgress->setVisible(true);
mUI.mProgress->setMaximum(PROGRESS_MAX);
mUI.mProgress->setValue(0);
mUI.mProgress->setFormat(tr("%p% (%1 of %2 files checked)").arg(0).arg(count));
mUI->mProgress->setVisible(true);
mUI->mProgress->setMaximum(PROGRESS_MAX);
mUI->mProgress->setValue(0);
mUI->mProgress->setFormat(tr("%p% (%1 of %2 files checked)").arg(0).arg(count));
}
void ResultsView::checkingFinished()
{
mUI.mProgress->setVisible(false);
mUI.mProgress->setFormat("%p%");
mUI->mProgress->setVisible(false);
mUI->mProgress->setFormat("%p%");
// TODO: Items can be mysteriously hidden when checking is finished, this function
// call should be redundant but it "unhides" the wrongly hidden items.
mUI.mTree->refreshTree();
mUI->mTree->refreshTree();
//Should we inform user of non visible/not found errors?
if (mShowNoErrorsMessage) {
@ -328,7 +336,7 @@ void ResultsView::checkingFinished()
msg.exec();
} //If we have errors but they aren't visible, tell user about it
else if (!mUI.mTree->hasVisibleResults()) {
else if (!mUI->mTree->hasVisibleResults()) {
QString text = tr("Errors were found, but they are configured to be hidden.\n" \
"To toggle what kind of errors are shown, open view menu.");
QMessageBox msg(QMessageBox::Information,
@ -344,31 +352,31 @@ void ResultsView::checkingFinished()
bool ResultsView::hasVisibleResults() const
{
return mUI.mTree->hasVisibleResults();
return mUI->mTree->hasVisibleResults();
}
bool ResultsView::hasResults() const
{
return mUI.mTree->hasResults();
return mUI->mTree->hasResults();
}
void ResultsView::saveSettings(QSettings *settings)
{
mUI.mTree->saveSettings();
QByteArray state = mUI.mVerticalSplitter->saveState();
mUI->mTree->saveSettings();
QByteArray state = mUI->mVerticalSplitter->saveState();
settings->setValue(SETTINGS_MAINWND_SPLITTER_STATE, state);
mUI.mVerticalSplitter->restoreState(state);
mUI->mVerticalSplitter->restoreState(state);
}
void ResultsView::translate()
{
mUI.retranslateUi(this);
mUI.mTree->translate();
mUI->retranslateUi(this);
mUI->mTree->translate();
}
void ResultsView::disableProgressbar()
{
mUI.mProgress->setEnabled(false);
mUI->mProgress->setEnabled(false);
}
void ResultsView::readErrorsXml(const QString &filename)
@ -402,7 +410,7 @@ void ResultsView::readErrorsXml(const QString &filename)
ErrorItem item;
foreach (item, errors) {
mUI.mTree->addErrorItem(item);
mUI->mTree->addErrorItem(item);
}
QString dir;
@ -412,17 +420,17 @@ void ResultsView::readErrorsXml(const QString &filename)
dir = relativePath;
}
mUI.mTree->setCheckDirectory(dir);
mUI->mTree->setCheckDirectory(dir);
}
void ResultsView::updateDetails(const QModelIndex &index)
{
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(mUI.mTree->model());
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(mUI->mTree->model());
QStandardItem *item = model->itemFromIndex(index);
if (!item) {
mUI.mCode->clear();
mUI.mDetails->setText(QString());
mUI->mCode->clear();
mUI->mDetails->setText(QString());
return;
}
@ -434,8 +442,8 @@ void ResultsView::updateDetails(const QModelIndex &index)
// If there is no severity data then it is a parent item without summary and message
if (!data.contains("severity")) {
mUI.mCode->clear();
mUI.mDetails->setText(QString());
mUI->mCode->clear();
mUI->mDetails->setText(QString());
return;
}
@ -448,46 +456,46 @@ void ResultsView::updateDetails(const QModelIndex &index)
if (data["cwe"].toInt() > 0)
formattedMsg.prepend("CWE: " + QString::number(data["cwe"].toInt()) + "\n");
if (mUI.mTree->showIdColumn())
if (mUI->mTree->showIdColumn())
formattedMsg.prepend(tr("Id") + ": " + data["id"].toString() + "\n");
if (data["incomplete"].toBool())
formattedMsg += "\n" + tr("Bug hunting analysis is incomplete");
mUI.mDetails->setText(formattedMsg);
mUI->mDetails->setText(formattedMsg);
const int lineNumber = data["line"].toInt();
QString filepath = data["file"].toString();
if (!QFileInfo(filepath).exists() && QFileInfo(mUI.mTree->getCheckDirectory() + '/' + filepath).exists())
filepath = mUI.mTree->getCheckDirectory() + '/' + filepath;
if (!QFileInfo(filepath).exists() && QFileInfo(mUI->mTree->getCheckDirectory() + '/' + filepath).exists())
filepath = mUI->mTree->getCheckDirectory() + '/' + filepath;
QStringList symbols;
if (data.contains("symbolNames"))
symbols = data["symbolNames"].toString().split("\n");
if (filepath == mUI.mCode->getFileName()) {
mUI.mCode->setError(lineNumber, symbols);
if (filepath == mUI->mCode->getFileName()) {
mUI->mCode->setError(lineNumber, symbols);
return;
}
QFile file(filepath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
mUI.mCode->clear();
mUI->mCode->clear();
return;
}
QTextStream in(&file);
mUI.mCode->setError(in.readAll(), lineNumber, symbols);
mUI.mCode->setFileName(filepath);
mUI->mCode->setError(in.readAll(), lineNumber, symbols);
mUI->mCode->setFileName(filepath);
}
void ResultsView::log(const QString &str)
{
mUI.mListLog->addItem(str);
mUI->mListLog->addItem(str);
}
void ResultsView::debugError(const ErrorItem &item)
{
mUI.mListLog->addItem(item.toString());
mUI->mListLog->addItem(item.toString());
}
void ResultsView::bughuntingReportLine(const QString& line)
@ -497,13 +505,13 @@ void ResultsView::bughuntingReportLine(const QString& line)
const QString varname = s.mid(9);
if (!mVariableContracts.contains(varname)) {
mVariableContracts.insert(varname);
mUI.mListMissingVariables->addItem(varname);
mUI->mListMissingVariables->addItem(varname);
}
} else if (s.startsWith("[missing contract] ")) {
const QString functionName = s.mid(19);
if (!mFunctionContracts.contains(functionName)) {
mFunctionContracts.insert(functionName);
mUI.mListMissingContracts->addItem(functionName);
mUI->mListMissingContracts->addItem(functionName);
}
}
}
@ -511,12 +519,12 @@ void ResultsView::bughuntingReportLine(const QString& line)
void ResultsView::logClear()
{
mUI.mListLog->clear();
mUI->mListLog->clear();
}
void ResultsView::logCopyEntry()
{
const QListWidgetItem * item = mUI.mListLog->currentItem();
const QListWidgetItem * item = mUI->mListLog->currentItem();
if (nullptr != item) {
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(item->text());
@ -526,8 +534,8 @@ void ResultsView::logCopyEntry()
void ResultsView::logCopyComplete()
{
QString logText;
for (int i=0; i < mUI.mListLog->count(); ++i) {
const QListWidgetItem * item = mUI.mListLog->item(i);
for (int i=0; i < mUI->mListLog->count(); ++i) {
const QListWidgetItem * item = mUI->mListLog->item(i);
if (nullptr != item) {
logText += item->text();
}
@ -548,20 +556,20 @@ void ResultsView::variableDoubleClicked(QListWidgetItem* item)
void ResultsView::editVariablesFilter(const QString &text)
{
for (auto *item: mUI.mListAddedVariables->findItems(".*", Qt::MatchRegExp)) {
for (auto *item: mUI->mListAddedVariables->findItems(".*", Qt::MatchRegExp)) {
QString varname = item->text().mid(0, item->text().indexOf(" "));
item->setHidden(!varname.contains(text));
}
for (auto *item: mUI.mListMissingVariables->findItems(".*", Qt::MatchRegExp))
for (auto *item: mUI->mListMissingVariables->findItems(".*", Qt::MatchRegExp))
item->setHidden(!item->text().contains(text));
}
void ResultsView::on_mListLog_customContextMenuRequested(const QPoint &pos)
{
if (mUI.mListLog->count() <= 0)
if (mUI->mListLog->count() <= 0)
return;
const QPoint globalPos = mUI.mListLog->mapToGlobal(pos);
const QPoint globalPos = mUI->mListLog->mapToGlobal(pos);
QMenu contextMenu;
contextMenu.addAction(tr("Clear Log"), this, SLOT(logClear()));
@ -574,10 +582,10 @@ void ResultsView::on_mListLog_customContextMenuRequested(const QPoint &pos)
bool ResultsView::eventFilter(QObject *target, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
if (target == mUI.mListAddedVariables) {
if (target == mUI->mListAddedVariables) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Delete) {
for (auto *i: mUI.mListAddedVariables->selectedItems()) {
for (auto *i: mUI->mListAddedVariables->selectedItems()) {
emit deleteVariableContract(i->text().mid(0, i->text().indexOf(" ")));
delete i;
}
@ -585,10 +593,10 @@ bool ResultsView::eventFilter(QObject *target, QEvent *event)
}
}
if (target == mUI.mListAddedContracts) {
if (target == mUI->mListAddedContracts) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Delete) {
for (auto *i: mUI.mListAddedContracts->selectedItems()) {
for (auto *i: mUI->mListAddedContracts->selectedItems()) {
emit deleteFunctionContract(i->text());
delete i;
}

View File

@ -20,17 +20,24 @@
#ifndef RESULTSVIEW_H
#define RESULTSVIEW_H
#include "ui_resultsview.h"
#include "report.h"
#include "showtypes.h"
#include <QSet>
#include <QString>
#include <QWidget>
class ErrorItem;
class ApplicationList;
class ThreadHandler;
class QModelIndex;
class QPrinter;
class QSettings;
class CheckStatistics;
class QListWidgetItem;
namespace Ui {
class ResultsView;
}
/// @addtogroup GUI
/// @{
@ -195,9 +202,7 @@ public:
* @brief Return Showtypes.
* @return Pointer to Showtypes.
*/
ShowTypes * getShowTypes() const {
return &mUI.mTree->mShowSeverities;
}
ShowTypes * getShowTypes() const;
/** Show/hide the contract tabs */
void showContracts(bool visible);
@ -368,7 +373,7 @@ protected:
*/
bool mShowNoErrorsMessage;
Ui::ResultsView mUI;
Ui::ResultsView *mUI;
CheckStatistics *mStatistics;

View File

@ -20,24 +20,32 @@
#include "mainwindow.h"
#include "ui_scratchpad.h"
ScratchPad::ScratchPad(MainWindow& mainWindow)
: QDialog(&mainWindow)
, mUI(new Ui::ScratchPad)
, mMainWindow(mainWindow)
{
mUI.setupUi(this);
mUI->setupUi(this);
connect(mUI.mCheckButton, &QPushButton::clicked, this, &ScratchPad::checkButtonClicked);
connect(mUI->mCheckButton, &QPushButton::clicked, this, &ScratchPad::checkButtonClicked);
}
ScratchPad::~ScratchPad()
{
delete mUI;
}
void ScratchPad::translate()
{
mUI.retranslateUi(this);
mUI->retranslateUi(this);
}
void ScratchPad::checkButtonClicked()
{
QString filename = mUI.lineEdit->text();
QString filename = mUI->lineEdit->text();
if (filename.isEmpty())
filename = "test.cpp";
mMainWindow.analyzeCode(mUI.plainTextEdit->toPlainText(), filename);
mMainWindow.analyzeCode(mUI->plainTextEdit->toPlainText(), filename);
}

View File

@ -19,11 +19,12 @@
#ifndef SCRATCHPAD_H
#define SCRATCHPAD_H
#include "ui_scratchpad.h"
#include <QDialog>
class MainWindow;
namespace Ui {
class ScratchPad;
}
/// @addtogroup GUI
/// @{
@ -35,6 +36,7 @@ class ScratchPad : public QDialog {
Q_OBJECT
public:
explicit ScratchPad(MainWindow& mainWindow);
~ScratchPad();
/**
* @brief Translate dialog
@ -48,7 +50,7 @@ private slots:
void checkButtonClicked();
private:
Ui::ScratchPad mUI;
Ui::ScratchPad *mUI;
MainWindow& mMainWindow;
};

View File

@ -25,6 +25,8 @@
#include "common.h"
#include "translationhandler.h"
#include "ui_settings.h"
#include <QFileDialog>
#include <QFileInfo>
#include <QList>
@ -38,71 +40,72 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
QDialog(parent),
mApplications(list),
mTempApplications(new ApplicationList(this)),
mTranslator(translator)
mTranslator(translator),
mUI(new Ui::Settings)
{
mUI.setupUi(this);
mUI.mPythonPathWarning->setStyleSheet("color: red");
mUI->setupUi(this);
mUI->mPythonPathWarning->setStyleSheet("color: red");
QSettings settings;
mTempApplications->copy(list);
mUI.mJobs->setText(settings.value(SETTINGS_CHECK_THREADS, 1).toString());
mUI.mForce->setCheckState(boolToCheckState(settings.value(SETTINGS_CHECK_FORCE, false).toBool()));
mUI.mShowFullPath->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_FULL_PATH, false).toBool()));
mUI.mShowNoErrorsMessage->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_NO_ERRORS, false).toBool()));
mUI.mShowDebugWarnings->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_DEBUG_WARNINGS, false).toBool()));
mUI.mSaveAllErrors->setCheckState(boolToCheckState(settings.value(SETTINGS_SAVE_ALL_ERRORS, false).toBool()));
mUI.mSaveFullPath->setCheckState(boolToCheckState(settings.value(SETTINGS_SAVE_FULL_PATH, false).toBool()));
mUI.mInlineSuppressions->setCheckState(boolToCheckState(settings.value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool()));
mUI.mEnableInconclusive->setCheckState(boolToCheckState(settings.value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool()));
mUI.mShowStatistics->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_STATISTICS, false).toBool()));
mUI.mShowErrorId->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool()));
mUI.mEditPythonPath->setText(settings.value(SETTINGS_PYTHON_PATH, QString()).toString());
mUI->mJobs->setText(settings.value(SETTINGS_CHECK_THREADS, 1).toString());
mUI->mForce->setCheckState(boolToCheckState(settings.value(SETTINGS_CHECK_FORCE, false).toBool()));
mUI->mShowFullPath->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_FULL_PATH, false).toBool()));
mUI->mShowNoErrorsMessage->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_NO_ERRORS, false).toBool()));
mUI->mShowDebugWarnings->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_DEBUG_WARNINGS, false).toBool()));
mUI->mSaveAllErrors->setCheckState(boolToCheckState(settings.value(SETTINGS_SAVE_ALL_ERRORS, false).toBool()));
mUI->mSaveFullPath->setCheckState(boolToCheckState(settings.value(SETTINGS_SAVE_FULL_PATH, false).toBool()));
mUI->mInlineSuppressions->setCheckState(boolToCheckState(settings.value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool()));
mUI->mEnableInconclusive->setCheckState(boolToCheckState(settings.value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool()));
mUI->mShowStatistics->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_STATISTICS, false).toBool()));
mUI->mShowErrorId->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool()));
mUI->mEditPythonPath->setText(settings.value(SETTINGS_PYTHON_PATH, QString()).toString());
validateEditPythonPath();
mUI.mEditMisraFile->setText(settings.value(SETTINGS_MISRA_FILE, QString()).toString());
mUI->mEditMisraFile->setText(settings.value(SETTINGS_MISRA_FILE, QString()).toString());
#ifdef Q_OS_WIN
//mUI.mTabClang->setVisible(true);
mUI.mEditClangPath->setText(settings.value(SETTINGS_CLANG_PATH, QString()).toString());
mUI.mEditVsIncludePaths->setText(settings.value(SETTINGS_VS_INCLUDE_PATHS, QString()).toString());
connect(mUI.mBtnBrowseClangPath, &QPushButton::released, this, &SettingsDialog::browseClangPath);
//mUI->mTabClang->setVisible(true);
mUI->mEditClangPath->setText(settings.value(SETTINGS_CLANG_PATH, QString()).toString());
mUI->mEditVsIncludePaths->setText(settings.value(SETTINGS_VS_INCLUDE_PATHS, QString()).toString());
connect(mUI->mBtnBrowseClangPath, &QPushButton::released, this, &SettingsDialog::browseClangPath);
#else
mUI.mTabClang->setVisible(false);
mUI->mTabClang->setVisible(false);
#endif
mCurrentStyle = new CodeEditorStyle(CodeEditorStyle::loadSettings(&settings));
manageStyleControls();
connect(mUI.mEditPythonPath, SIGNAL(textEdited(const QString&)),
connect(mUI->mEditPythonPath, SIGNAL(textEdited(const QString&)),
this, SLOT(validateEditPythonPath()));
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &SettingsDialog::ok);
connect(mUI.mButtons, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
connect(mUI.mBtnAddApplication, SIGNAL(clicked()),
connect(mUI->mButtons, &QDialogButtonBox::accepted, this, &SettingsDialog::ok);
connect(mUI->mButtons, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
connect(mUI->mBtnAddApplication, SIGNAL(clicked()),
this, SLOT(addApplication()));
connect(mUI.mBtnRemoveApplication, SIGNAL(clicked()),
connect(mUI->mBtnRemoveApplication, SIGNAL(clicked()),
this, SLOT(removeApplication()));
connect(mUI.mBtnEditApplication, SIGNAL(clicked()),
connect(mUI->mBtnEditApplication, SIGNAL(clicked()),
this, SLOT(editApplication()));
connect(mUI.mBtnDefaultApplication, SIGNAL(clicked()),
connect(mUI->mBtnDefaultApplication, SIGNAL(clicked()),
this, SLOT(defaultApplication()));
connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
connect(mUI->mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(editApplication()));
connect(mUI.mBtnBrowsePythonPath, &QPushButton::clicked, this, &SettingsDialog::browsePythonPath);
connect(mUI.mBtnBrowseMisraFile, &QPushButton::clicked, this, &SettingsDialog::browseMisraFile);
connect(mUI.mBtnEditTheme, SIGNAL(clicked()), this, SLOT(editCodeEditorStyle()));
connect(mUI.mThemeSystem, SIGNAL(released()), this, SLOT(setCodeEditorStyleDefault()));
connect(mUI.mThemeDark, SIGNAL(released()), this, SLOT(setCodeEditorStyleDefault()));
connect(mUI.mThemeLight, SIGNAL(released()), this, SLOT(setCodeEditorStyleDefault()));
connect(mUI.mThemeCustom, SIGNAL(toggled(bool)), mUI.mBtnEditTheme, SLOT(setEnabled(bool)));
connect(mUI->mBtnBrowsePythonPath, &QPushButton::clicked, this, &SettingsDialog::browsePythonPath);
connect(mUI->mBtnBrowseMisraFile, &QPushButton::clicked, this, &SettingsDialog::browseMisraFile);
connect(mUI->mBtnEditTheme, SIGNAL(clicked()), this, SLOT(editCodeEditorStyle()));
connect(mUI->mThemeSystem, SIGNAL(released()), this, SLOT(setCodeEditorStyleDefault()));
connect(mUI->mThemeDark, SIGNAL(released()), this, SLOT(setCodeEditorStyleDefault()));
connect(mUI->mThemeLight, SIGNAL(released()), this, SLOT(setCodeEditorStyleDefault()));
connect(mUI->mThemeCustom, SIGNAL(toggled(bool)), mUI->mBtnEditTheme, SLOT(setEnabled(bool)));
mUI.mListWidget->setSortingEnabled(false);
mUI->mListWidget->setSortingEnabled(false);
populateApplicationList();
const int count = QThread::idealThreadCount();
if (count != -1)
mUI.mLblIdealThreads->setText(QString::number(count));
mUI->mLblIdealThreads->setText(QString::number(count));
else
mUI.mLblIdealThreads->setText(tr("N/A"));
mUI->mLblIdealThreads->setText(tr("N/A"));
loadSettings();
initTranslationsList();
@ -111,6 +114,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
SettingsDialog::~SettingsDialog()
{
saveSettings();
delete mUI;
}
void SettingsDialog::initTranslationsList()
@ -121,9 +125,9 @@ void SettingsDialog::initTranslationsList()
QListWidgetItem *item = new QListWidgetItem;
item->setText(translation.mName);
item->setData(mLangCodeRole, QVariant(translation.mCode));
mUI.mListLanguages->addItem(item);
mUI->mListLanguages->addItem(item);
if (translation.mCode == current || translation.mCode == current.mid(0, 2))
mUI.mListLanguages->setCurrentItem(item);
mUI->mListLanguages->setCurrentItem(item);
}
}
@ -160,32 +164,32 @@ void SettingsDialog::saveSettings() const
void SettingsDialog::saveSettingValues() const
{
int jobs = mUI.mJobs->text().toInt();
int jobs = mUI->mJobs->text().toInt();
if (jobs <= 0) {
jobs = 1;
}
QSettings settings;
settings.setValue(SETTINGS_CHECK_THREADS, jobs);
saveCheckboxValue(&settings, mUI.mForce, SETTINGS_CHECK_FORCE);
saveCheckboxValue(&settings, mUI.mSaveAllErrors, SETTINGS_SAVE_ALL_ERRORS);
saveCheckboxValue(&settings, mUI.mSaveFullPath, SETTINGS_SAVE_FULL_PATH);
saveCheckboxValue(&settings, mUI.mShowFullPath, SETTINGS_SHOW_FULL_PATH);
saveCheckboxValue(&settings, mUI.mShowNoErrorsMessage, SETTINGS_SHOW_NO_ERRORS);
saveCheckboxValue(&settings, mUI.mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS);
saveCheckboxValue(&settings, mUI.mInlineSuppressions, SETTINGS_INLINE_SUPPRESSIONS);
saveCheckboxValue(&settings, mUI.mEnableInconclusive, SETTINGS_INCONCLUSIVE_ERRORS);
saveCheckboxValue(&settings, mUI.mShowStatistics, SETTINGS_SHOW_STATISTICS);
saveCheckboxValue(&settings, mUI.mShowErrorId, SETTINGS_SHOW_ERROR_ID);
settings.setValue(SETTINGS_PYTHON_PATH, mUI.mEditPythonPath->text());
settings.setValue(SETTINGS_MISRA_FILE, mUI.mEditMisraFile->text());
saveCheckboxValue(&settings, mUI->mForce, SETTINGS_CHECK_FORCE);
saveCheckboxValue(&settings, mUI->mSaveAllErrors, SETTINGS_SAVE_ALL_ERRORS);
saveCheckboxValue(&settings, mUI->mSaveFullPath, SETTINGS_SAVE_FULL_PATH);
saveCheckboxValue(&settings, mUI->mShowFullPath, SETTINGS_SHOW_FULL_PATH);
saveCheckboxValue(&settings, mUI->mShowNoErrorsMessage, SETTINGS_SHOW_NO_ERRORS);
saveCheckboxValue(&settings, mUI->mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS);
saveCheckboxValue(&settings, mUI->mInlineSuppressions, SETTINGS_INLINE_SUPPRESSIONS);
saveCheckboxValue(&settings, mUI->mEnableInconclusive, SETTINGS_INCONCLUSIVE_ERRORS);
saveCheckboxValue(&settings, mUI->mShowStatistics, SETTINGS_SHOW_STATISTICS);
saveCheckboxValue(&settings, mUI->mShowErrorId, SETTINGS_SHOW_ERROR_ID);
settings.setValue(SETTINGS_PYTHON_PATH, mUI->mEditPythonPath->text());
settings.setValue(SETTINGS_MISRA_FILE, mUI->mEditMisraFile->text());
#ifdef Q_OS_WIN
settings.setValue(SETTINGS_CLANG_PATH, mUI.mEditClangPath->text());
settings.setValue(SETTINGS_VS_INCLUDE_PATHS, mUI.mEditVsIncludePaths->text());
settings.setValue(SETTINGS_CLANG_PATH, mUI->mEditClangPath->text());
settings.setValue(SETTINGS_VS_INCLUDE_PATHS, mUI->mEditVsIncludePaths->text());
#endif
const QListWidgetItem *currentLang = mUI.mListLanguages->currentItem();
const QListWidgetItem *currentLang = mUI->mListLanguages->currentItem();
if (currentLang) {
const QString langcode = currentLang->data(mLangCodeRole).toString();
settings.setValue(SETTINGS_LANGUAGE, langcode);
@ -201,10 +205,10 @@ void SettingsDialog::saveCheckboxValue(QSettings *settings, QCheckBox *box,
void SettingsDialog::validateEditPythonPath()
{
const auto pythonPath = mUI.mEditPythonPath->text();
const auto pythonPath = mUI->mEditPythonPath->text();
if (pythonPath.isEmpty()) {
mUI.mEditPythonPath->setStyleSheet("");
mUI.mPythonPathWarning->hide();
mUI->mEditPythonPath->setStyleSheet("");
mUI->mPythonPathWarning->hide();
return;
}
@ -212,12 +216,12 @@ void SettingsDialog::validateEditPythonPath()
if (!pythonPathInfo.exists() ||
!pythonPathInfo.isFile() ||
!pythonPathInfo.isExecutable()) {
mUI.mEditPythonPath->setStyleSheet("QLineEdit {border: 1px solid red}");
mUI.mPythonPathWarning->setText(tr("The executable file \"%1\" is not available").arg(pythonPath));
mUI.mPythonPathWarning->show();
mUI->mEditPythonPath->setStyleSheet("QLineEdit {border: 1px solid red}");
mUI->mPythonPathWarning->setText(tr("The executable file \"%1\" is not available").arg(pythonPath));
mUI->mPythonPathWarning->show();
} else {
mUI.mEditPythonPath->setStyleSheet("");
mUI.mPythonPathWarning->hide();
mUI->mEditPythonPath->setStyleSheet("");
mUI->mPythonPathWarning->hide();
}
}
@ -228,15 +232,15 @@ void SettingsDialog::addApplication()
if (dialog.exec() == QDialog::Accepted) {
mTempApplications->addApplication(app);
mUI.mListWidget->addItem(app.getName());
mUI->mListWidget->addItem(app.getName());
}
}
void SettingsDialog::removeApplication()
{
QList<QListWidgetItem *> selected = mUI.mListWidget->selectedItems();
QList<QListWidgetItem *> selected = mUI->mListWidget->selectedItems();
foreach (QListWidgetItem *item, selected) {
const int removeIndex = mUI.mListWidget->row(item);
const int removeIndex = mUI->mListWidget->row(item);
const int currentDefault = mTempApplications->getDefaultApplication();
mTempApplications->removeApplication(removeIndex);
if (removeIndex == currentDefault)
@ -246,16 +250,16 @@ void SettingsDialog::removeApplication()
// Move default app one up if earlier app was removed
mTempApplications->setDefault(currentDefault - 1);
}
mUI.mListWidget->clear();
mUI->mListWidget->clear();
populateApplicationList();
}
void SettingsDialog::editApplication()
{
QList<QListWidgetItem *> selected = mUI.mListWidget->selectedItems();
QList<QListWidgetItem *> selected = mUI->mListWidget->selectedItems();
QListWidgetItem *item = nullptr;
foreach (item, selected) {
int row = mUI.mListWidget->row(item);
int row = mUI->mListWidget->row(item);
Application& app = mTempApplications->getApplication(row);
ApplicationDialog dialog(tr("Modify an application"), app, this);
@ -270,11 +274,11 @@ void SettingsDialog::editApplication()
void SettingsDialog::defaultApplication()
{
QList<QListWidgetItem *> selected = mUI.mListWidget->selectedItems();
QList<QListWidgetItem *> selected = mUI->mListWidget->selectedItems();
if (!selected.isEmpty()) {
int index = mUI.mListWidget->row(selected[0]);
int index = mUI->mListWidget->row(selected[0]);
mTempApplications->setDefault(index);
mUI.mListWidget->clear();
mUI->mListWidget->clear();
populateApplicationList();
}
}
@ -289,18 +293,18 @@ void SettingsDialog::populateApplicationList()
name += " ";
name += tr("[Default]");
}
mUI.mListWidget->addItem(name);
mUI->mListWidget->addItem(name);
}
// Select default application, or if there is no default app then the
// first item.
if (defapp == -1)
mUI.mListWidget->setCurrentRow(0);
mUI->mListWidget->setCurrentRow(0);
else {
if (mTempApplications->getApplicationCount() > defapp)
mUI.mListWidget->setCurrentRow(defapp);
mUI->mListWidget->setCurrentRow(defapp);
else
mUI.mListWidget->setCurrentRow(0);
mUI->mListWidget->setCurrentRow(0);
}
}
@ -312,56 +316,56 @@ void SettingsDialog::ok()
bool SettingsDialog::showFullPath() const
{
return checkStateToBool(mUI.mShowFullPath->checkState());
return checkStateToBool(mUI->mShowFullPath->checkState());
}
bool SettingsDialog::saveFullPath() const
{
return checkStateToBool(mUI.mSaveFullPath->checkState());
return checkStateToBool(mUI->mSaveFullPath->checkState());
}
bool SettingsDialog::saveAllErrors() const
{
return checkStateToBool(mUI.mSaveAllErrors->checkState());
return checkStateToBool(mUI->mSaveAllErrors->checkState());
}
bool SettingsDialog::showNoErrorsMessage() const
{
return checkStateToBool(mUI.mShowNoErrorsMessage->checkState());
return checkStateToBool(mUI->mShowNoErrorsMessage->checkState());
}
bool SettingsDialog::showErrorId() const
{
return checkStateToBool(mUI.mShowErrorId->checkState());
return checkStateToBool(mUI->mShowErrorId->checkState());
}
bool SettingsDialog::showInconclusive() const
{
return checkStateToBool(mUI.mEnableInconclusive->checkState());
return checkStateToBool(mUI->mEnableInconclusive->checkState());
}
void SettingsDialog::browsePythonPath()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Select python binary"), QDir::rootPath());
if (fileName.contains("python", Qt::CaseInsensitive))
mUI.mEditPythonPath->setText(fileName);
mUI->mEditPythonPath->setText(fileName);
}
void SettingsDialog::browseMisraFile()
{
const QString fileName = QFileDialog::getOpenFileName(this, tr("Select MISRA File"), QDir::homePath(), "Misra File (*.pdf *.txt)");
if (!fileName.isEmpty())
mUI.mEditMisraFile->setText(fileName);
mUI->mEditMisraFile->setText(fileName);
}
// Slot to set default light style
void SettingsDialog::setCodeEditorStyleDefault()
{
if (mUI.mThemeSystem->isChecked())
if (mUI->mThemeSystem->isChecked())
*mCurrentStyle = CodeEditorStyle::getSystemTheme();
if (mUI.mThemeLight->isChecked())
if (mUI->mThemeLight->isChecked())
*mCurrentStyle = defaultStyleLight;
if (mUI.mThemeDark->isChecked())
if (mUI->mThemeDark->isChecked())
*mCurrentStyle = defaultStyleDark;
manageStyleControls();
}
@ -384,7 +388,7 @@ void SettingsDialog::browseClangPath()
QDir::rootPath());
if (!selectedDir.isEmpty()) {
mUI.mEditClangPath->setText(selectedDir);
mUI->mEditClangPath->setText(selectedDir);
}
}
@ -393,10 +397,10 @@ void SettingsDialog::manageStyleControls()
bool isSystemTheme = mCurrentStyle->isSystemTheme();
bool isDefaultLight = !isSystemTheme && *mCurrentStyle == defaultStyleLight;
bool isDefaultDark = !isSystemTheme && *mCurrentStyle == defaultStyleDark;
mUI.mThemeSystem->setChecked(isSystemTheme);
mUI.mThemeLight->setChecked(isDefaultLight && !isDefaultDark);
mUI.mThemeDark->setChecked(!isDefaultLight && isDefaultDark);
mUI.mThemeCustom->setChecked(!isSystemTheme && !isDefaultLight && !isDefaultDark);
mUI.mBtnEditTheme->setEnabled(!isSystemTheme && !isDefaultLight && !isDefaultDark);
mUI->mThemeSystem->setChecked(isSystemTheme);
mUI->mThemeLight->setChecked(isDefaultLight && !isDefaultDark);
mUI->mThemeDark->setChecked(!isDefaultLight && isDefaultDark);
mUI->mThemeCustom->setChecked(!isSystemTheme && !isDefaultLight && !isDefaultDark);
mUI->mBtnEditTheme->setEnabled(!isSystemTheme && !isDefaultLight && !isDefaultDark);
}

View File

@ -20,8 +20,6 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include "ui_settings.h"
#include <QDialog>
class QSettings;
@ -29,6 +27,10 @@ class QWidget;
class ApplicationList;
class TranslationHandler;
class CodeEditorStyle;
class QCheckBox;
namespace Ui {
class Settings;
}
/// @addtogroup GUI
/// @{
@ -230,7 +232,7 @@ protected:
* @brief Dialog from UI designer
*
*/
Ui::Settings mUI;
Ui::Settings *mUI;
private:
void manageStyleControls();

View File

@ -22,6 +22,8 @@
#include "common.h"
#include "projectfile.h"
#include "ui_statsdialog.h"
#include <QClipboard>
#include <QDate>
#include <QFileDialog>
@ -46,26 +48,32 @@ static const QString CPPCHECK("cppcheck");
StatsDialog::StatsDialog(QWidget *parent)
: QDialog(parent),
mUI(new Ui::StatsDialog),
mStatistics(nullptr)
{
mUI.setupUi(this);
mUI->setupUi(this);
setWindowFlags(Qt::Window);
connect(mUI.mCopyToClipboard, &QPushButton::pressed, this, &StatsDialog::copyToClipboard);
connect(mUI.mPDFexport, &QPushButton::pressed, this, &StatsDialog::pdfExport);
connect(mUI->mCopyToClipboard, &QPushButton::pressed, this, &StatsDialog::copyToClipboard);
connect(mUI->mPDFexport, &QPushButton::pressed, this, &StatsDialog::pdfExport);
}
StatsDialog::~StatsDialog()
{
delete mUI;
}
void StatsDialog::setProject(const ProjectFile* projectFile)
{
if (projectFile) {
mUI.mProject->setText(projectFile->getRootPath());
mUI.mPaths->setText(projectFile->getCheckPaths().join(";"));
mUI.mIncludePaths->setText(projectFile->getIncludeDirs().join(";"));
mUI.mDefines->setText(projectFile->getDefines().join(";"));
mUI.mUndefines->setText(projectFile->getUndefines().join(";"));
mUI->mProject->setText(projectFile->getRootPath());
mUI->mPaths->setText(projectFile->getCheckPaths().join(";"));
mUI->mIncludePaths->setText(projectFile->getIncludeDirs().join(";"));
mUI->mDefines->setText(projectFile->getDefines().join(";"));
mUI->mUndefines->setText(projectFile->getUndefines().join(";"));
#ifndef HAVE_QCHART
mUI.mTabHistory->setVisible(false);
mUI->mTabHistory->setVisible(false);
#else
QString statsFile;
if (!projectFile->getBuildDir().isEmpty()) {
@ -75,38 +83,38 @@ void StatsDialog::setProject(const ProjectFile* projectFile)
statsFile = buildDir + "/statistics.txt";
}
}
mUI.mLblHistoryFile->setText(tr("File: ") + (statsFile.isEmpty() ? tr("No cppcheck build dir") : statsFile));
mUI->mLblHistoryFile->setText(tr("File: ") + (statsFile.isEmpty() ? tr("No cppcheck build dir") : statsFile));
if (!statsFile.isEmpty()) {
QChartView *chartView;
chartView = createChart(statsFile, "cppcheck");
mUI.mTabHistory->layout()->addWidget(chartView);
mUI->mTabHistory->layout()->addWidget(chartView);
if (projectFile->getClangAnalyzer()) {
chartView = createChart(statsFile, CLANG_ANALYZER);
mUI.mTabHistory->layout()->addWidget(chartView);
mUI->mTabHistory->layout()->addWidget(chartView);
}
if (projectFile->getClangTidy()) {
chartView = createChart(statsFile, CLANG_TIDY);
mUI.mTabHistory->layout()->addWidget(chartView);
mUI->mTabHistory->layout()->addWidget(chartView);
}
}
#endif
} else {
mUI.mProject->setText(QString());
mUI.mPaths->setText(QString());
mUI.mIncludePaths->setText(QString());
mUI.mDefines->setText(QString());
mUI.mUndefines->setText(QString());
mUI->mProject->setText(QString());
mUI->mPaths->setText(QString());
mUI->mIncludePaths->setText(QString());
mUI->mDefines->setText(QString());
mUI->mUndefines->setText(QString());
}
}
void StatsDialog::setPathSelected(const QString& path)
{
mUI.mPath->setText(path);
mUI->mPath->setText(path);
}
void StatsDialog::setNumberOfFilesScanned(int num)
{
mUI.mNumberOfFilesScanned->setText(QString::number(num));
mUI->mNumberOfFilesScanned->setText(QString::number(num));
}
void StatsDialog::setScanDuration(double seconds)
@ -135,7 +143,7 @@ void StatsDialog::setScanDuration(double seconds)
if (parts.isEmpty())
parts << tr("0.%1 seconds").arg(int(10.0 *(seconds - secs)));
mUI.mScanDuration->setText(parts.join(tr(" and ")));
mUI->mScanDuration->setText(parts.join(tr(" and ")));
}
void StatsDialog::pdfExport()
{
@ -213,15 +221,15 @@ void StatsDialog::copyToClipboard()
)
.arg(projSettings)
.arg(project)
.arg(mUI.mProject->text())
.arg(mUI->mProject->text())
.arg(paths)
.arg(mUI.mPaths->text())
.arg(mUI->mPaths->text())
.arg(incPaths)
.arg(mUI.mIncludePaths->text())
.arg(mUI->mIncludePaths->text())
.arg(defines)
.arg(mUI.mDefines->text())
.arg(mUI->mDefines->text())
.arg(undefines)
.arg(mUI.mUndefines->text());
.arg(mUI->mUndefines->text());
const QString previous = QString(
"%1\n"
@ -231,11 +239,11 @@ void StatsDialog::copyToClipboard()
)
.arg(prevScan)
.arg(selPath)
.arg(mUI.mPath->text())
.arg(mUI->mPath->text())
.arg(numFiles)
.arg(mUI.mNumberOfFilesScanned->text())
.arg(mUI->mNumberOfFilesScanned->text())
.arg(duration)
.arg(mUI.mScanDuration->text());
.arg(mUI->mScanDuration->text());
const QString statistics = QString(
"%1\n"
@ -275,15 +283,15 @@ void StatsDialog::copyToClipboard()
)
.arg(projSettings)
.arg(project)
.arg(mUI.mProject->text())
.arg(mUI->mProject->text())
.arg(paths)
.arg(mUI.mPaths->text())
.arg(mUI->mPaths->text())
.arg(incPaths)
.arg(mUI.mIncludePaths->text())
.arg(mUI->mIncludePaths->text())
.arg(defines)
.arg(mUI.mDefines->text())
.arg(mUI->mDefines->text())
.arg(undefines)
.arg(mUI.mUndefines->text());
.arg(mUI->mUndefines->text());
const QString htmlPrevious = QString(
"<h3>%1</h3>\n"
@ -295,11 +303,11 @@ void StatsDialog::copyToClipboard()
)
.arg(prevScan)
.arg(selPath)
.arg(mUI.mPath->text())
.arg(mUI->mPath->text())
.arg(numFiles)
.arg(mUI.mNumberOfFilesScanned->text())
.arg(mUI->mNumberOfFilesScanned->text())
.arg(duration)
.arg(mUI.mScanDuration->text());
.arg(mUI->mScanDuration->text());
const QString htmlStatistics = QString(
"<h3>%1</h3>\n"
@ -336,12 +344,12 @@ void StatsDialog::copyToClipboard()
void StatsDialog::setStatistics(const CheckStatistics *stats)
{
mStatistics = stats;
mUI.mLblErrors->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowErrors)));
mUI.mLblWarnings->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowWarnings)));
mUI.mLblStyle->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowStyle)));
mUI.mLblPortability->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowPortability)));
mUI.mLblPerformance->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowPerformance)));
mUI.mLblInformation->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowInformation)));
mUI->mLblErrors->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowErrors)));
mUI->mLblWarnings->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowWarnings)));
mUI->mLblStyle->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowStyle)));
mUI->mLblPortability->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowPortability)));
mUI->mLblPerformance->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowPerformance)));
mUI->mLblInformation->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowInformation)));
}
#ifdef HAVE_QCHART

View File

@ -19,12 +19,13 @@
#ifndef STATSDIALOG_H
#define STATSDIALOG_H
#include "ui_stats.h"
#include <QDialog>
class ProjectFile;
class CheckStatistics;
namespace Ui {
class StatsDialog;
}
#ifdef HAVE_QCHART
namespace QtCharts {
@ -44,6 +45,7 @@ class StatsDialog : public QDialog {
Q_OBJECT
public:
explicit StatsDialog(QWidget *parent = nullptr);
~StatsDialog() override;
/**
* @brief Sets the project to extract statistics from
@ -78,7 +80,7 @@ private slots:
QtCharts::QLineSeries *numberOfReports(const QString &fileName, const QString &severity) const;
#endif
private:
Ui::StatsDialog mUI;
Ui::StatsDialog *mUI;
const CheckStatistics *mStatistics;
};