Cppcheck
Public Types | Public Slots | Public Member Functions | Public Attributes | Private Slots | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
MainWindow Class Reference

Main window for cppcheck-gui. More...

#include <mainwindow.h>

Inheritance diagram for MainWindow:

Public Types

enum  { MaxRecentProjects = 5 }
 Maximum number of MRU project items in File-menu. More...
 

Public Slots

void analyzeFiles ()
 Slot for analyze files menu item. More...
 
void reAnalyzeAll ()
 Slot to reanalyze all files. More...
 
void checkLibrary ()
 Slot to reanalyze with checking library configuration. More...
 
void checkConfiguration ()
 Slot to check configuration. More...
 
void performSelectedFilesCheck (const QStringList &selectedFilesList)
 Slot to reanalyze selected files. More...
 
void reAnalyzeModified ()
 Slot to reanalyze modified files. More...
 
void clearResults ()
 Slot to clear all search results. More...
 
void openResults ()
 Slot to open XML report file. More...
 
void showStyle (bool checked)
 Show errors with type "style". More...
 
void showErrors (bool checked)
 Show errors with type "error". More...
 
void showWarnings (bool checked)
 Show errors with type "warning". More...
 
void showPortability (bool checked)
 Show errors with type "portability". More...
 
void showPerformance (bool checked)
 Show errors with type "performance". More...
 
void showInformation (bool checked)
 Show errors with type "information". More...
 
void checkAll ()
 Slot to check all "Show errors" menu items. More...
 
void uncheckAll ()
 Slot to uncheck all "Show errors" menu items. More...
 
void analyzeDirectory ()
 Slot for analyze directory menu item. More...
 
void programSettings ()
 Slot to open program's settings dialog. More...
 
void about ()
 Slot to open program's about dialog. More...
 
void showLicense ()
 Slot to to show license text. More...
 
void showAuthors ()
 Slot to to show authors list. More...
 
void save ()
 Slot to save results. More...
 
void complianceReport ()
 Slot to generate compliance report. More...
 
void newProjectFile ()
 Slot to create new project file. More...
 
void openProjectFile ()
 Slot to open project file and start analyzing contained paths. More...
 
void showScratchpad ()
 Slot to show scratchpad. More...
 
void closeProjectFile ()
 Slot to close open project file. More...
 
void editProjectFile ()
 Slot to edit project file. More...
 
void showStatistics ()
 Slot for showing the scan and project statistics. More...
 
void showLibraryEditor ()
 Slot for showing the library editor. More...
 

Public Member Functions

 MainWindow (TranslationHandler *th, QSettings *settings)
 
 MainWindow (const MainWindow &)=delete
 
 ~MainWindow () override
 
MainWindowoperator= (const MainWindow &)=delete
 
void analyzeCode (const QString &code, const QString &filename)
 Analyze given code. More...
 

Public Attributes

Platforms mPlatforms
 List of checked platforms. More...
 

Private Slots

void analysisDone ()
 Slot for checkthread's done signal. More...
 
void checkLockDownUI ()
 Lock down UI while analyzing. More...
 
void resultsAdded ()
 Slot for enabling save and clear button. More...
 
void toggleMainToolBar ()
 Slot for showing/hiding standard toolbar. More...
 
void toggleViewToolBar ()
 Slot for showing/hiding Categories toolbar. More...
 
void toggleFilterToolBar ()
 Slot for showing/hiding Filter toolbar. More...
 
void aboutToShowViewMenu ()
 Slot for updating View-menu before it is shown. More...
 
void stopAnalysis ()
 Slot when stop analysis button is pressed. More...
 
void openHelpContents ()
 Open help file contents. More...
 
void filterResults ()
 Filters the results in the result list. More...
 
void openRecentProject ()
 Opens recently opened project file. More...
 
void selectPlatform ()
 Selects the platform as analyzed platform. More...
 
void suppressIds (QStringList ids)
 Suppress error ids. More...
 
void replyFinished (QNetworkReply *reply)
 
void hideInformation ()
 

Private Member Functions

bool isCppcheckPremium () const
 
QString getLastResults () const
 Get filename for last results. More...
 
void reAnalyze (bool all)
 Reanalyzes files. More...
 
void reAnalyzeSelected (const QStringList &files)
 Reanalyze selected files. More...
 
void analyzeProject (const ProjectFile *projectFile, const bool checkLibrary=false, const bool checkConfiguration=false)
 Analyze the project. More...
 
void setLanguage (const QString &code)
 Set current language. More...
 
void closeEvent (QCloseEvent *event) override
 Event coming when application is about to close. More...
 
void toggleAllChecked (bool checked)
 Helper function to toggle all show error menu items. More...
 
void enableCheckButtons (bool enable)
 Helper function to enable/disable all check,recheck buttons. More...
 
void enableResultsButtons ()
 Helper function to enable/disable results buttons (clear,save,print) More...
 
QStringList selectFilesToAnalyze (QFileDialog::FileMode mode)
 Select files/or directory to analyze. More...
 
void doAnalyzeProject (ImportProject p, const bool checkLibrary=false, const bool checkConfiguration=false)
 Analyze project. More...
 
void doAnalyzeFiles (const QStringList &files, const bool checkLibrary=false, const bool checkConfiguration=false)
 Analyze all files specified in parameter files. More...
 
QPair< bool, SettingsgetCppcheckSettings ()
 Get our default cppcheck settings and read project file. More...
 
void loadSettings ()
 Load program settings. More...
 
void saveSettings () const
 Save program settings. More...
 
void formatAndSetTitle (const QString &text=QString())
 Format main window title. More...
 
void enableProjectActions (bool enable)
 Enable or disable project file actions. More...
 
void enableProjectOpenActions (bool enable)
 Enable or disable project file actions. More...
 
void addIncludeDirs (const QStringList &includeDirs, Settings &result)
 Add include directories. More...
 
void handleCLIParams (const QStringList &params)
 Handle command line parameters given to GUI. More...
 
void loadResults (const QString &selectedFile)
 Load XML file to the GUI. More...
 
void loadResults (const QString &selectedFile, const QString &sourceDirectory)
 Load XML file to the GUI. More...
 
bool loadLastResults ()
 Load last project results to the GUI. More...
 
void loadProjectFile (const QString &filePath)
 Load project file to the GUI. More...
 
Library::Error loadLibrary (Library &library, const QString &filename)
 Load library file. More...
 
bool tryLoadLibrary (Library &library, const QString &filename)
 Tries to load library file, prints message on error. More...
 
QString loadAddon (Settings &settings, const QString &filesDir, const QString &pythonCmd, const QString &addon)
 
void updateMRUMenuItems ()
 Update project MRU items in File-menu. More...
 
void addProjectMRU (const QString &project)
 Add project file (path) to the MRU list. More...
 
void removeProjectMRU (const QString &project)
 Remove project file (path) from the MRU list. More...
 

Static Private Member Functions

static void openOnlineHelp ()
 Show help contents. More...
 

Private Attributes

QSettings * mSettings
 Program settings. More...
 
ThreadHandlermThread
 Thread to analyze files. More...
 
ApplicationListmApplications
 List of user defined applications to open errors with. More...
 
TranslationHandlermTranslation
 Class to handle translation changes. More...
 
Ui::MainWindow * mUI
 Class holding all UI components. More...
 
QString mCurrentDirectory
 Current analyzed directory. More...
 
ScratchPadmScratchPad {}
 Scratchpad. More...
 
ProjectFilemProjectFile {}
 Project (file). More...
 
QLineEdit * mLineEditFilter
 Filter field in the Filter toolbar. More...
 
QTimer * mFilterTimer
 Timer to delay filtering while typing. More...
 
QActionGroup * mPlatformActions
 GUI actions for selecting the analyzed platform. More...
 
QActionGroup * mCStandardActions
 GUI actions for selecting the coding standard. More...
 
QActionGroup * mCppStandardActions
 
QActionGroup * mSelectLanguageActions
 GUI actions for selecting language. More...
 
bool mExiting {}
 Are we exiting the cppcheck? If this is true then the cppcheck is waiting for check threads to exit so that the application can be closed. More...
 
bool mIsLogfileLoaded {}
 Set to true in case of loading log file. More...
 
QAction * mRecentProjectActs [MaxRecentProjects+1]
 Project MRU menu actions. More...
 
QString mCppcheckCfgAbout
 
QString mCppcheckCfgProductName
 
QNetworkAccessManager * mNetworkAccessManager = nullptr
 

Detailed Description

Main window for cppcheck-gui.

Definition at line 58 of file mainwindow.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Maximum number of MRU project items in File-menu.

Enumerator
MaxRecentProjects 

Definition at line 65 of file mainwindow.h.

Constructor & Destructor Documentation

◆ MainWindow() [1/2]

MainWindow::MainWindow ( TranslationHandler th,
QSettings *  settings 
)

Definition at line 113 of file mainwindow.cpp.

References about(), aboutToShowViewMenu(), analysisDone(), analyzeDirectory(), analyzeFiles(), checkAll(), checkConfiguration(), checkLibrary(), ResultsView::checkSelected(), clearResults(), closeProjectFile(), ResultsView::collapseAllResults(), complianceReport(), Settings::cppcheckCfgAbout, Settings::cppcheckCfgProductName, ResultsView::debugError(), ThreadHandler::debugError(), ThreadHandler::done(), editProjectFile(), enableCheckButtons(), enableProjectActions(), enableProjectOpenActions(), enableResultsButtons(), Settings::exename, ResultsView::expandAllResults(), filterResults(), formatAndSetTitle(), Platforms::get(), Platforms::getCount(), ProjectFile::getFilename(), ResultsView::gotResults(), handleCLIParams(), hideInformation(), ThreadHandler::initialize(), isCppcheckPremium(), Settings::loadCppcheckCfg(), loadSettings(), ThreadHandler::log(), ResultsView::log(), PlatformData::mActMainWindow, mApplications, MaxRecentProjects, mCppcheckCfgAbout, mCppcheckCfgProductName, mCppStandardActions, mCStandardActions, mFilterTimer, mLineEditFilter, mNetworkAccessManager, mPlatformActions, mPlatforms, Platforms::mPlatforms, mProjectFile, mRecentProjectActs, mSelectLanguageActions, mSettings, mThread, PlatformData::mTitle, PlatformData::mType, mUI, newProjectFile(), openHelpContents(), openProjectFile(), openRecentProject(), openResults(), performSelectedFilesCheck(), programSettings(), reAnalyzeAll(), reAnalyzeModified(), replyFinished(), resultsAdded(), ResultsView::resultsHidden(), save(), selectPlatform(), SETTINGS_CHECK_FOR_UPDATES, SETTINGS_CHECKED_PLATFORM, showAuthors(), ResultsView::showClangResults(), ResultsView::showCppcheckResults(), showErrors(), ResultsView::showHiddenResults(), showInformation(), showLibraryEditor(), showLicense(), showPerformance(), showPortability(), showScratchpad(), showStatistics(), showStyle(), showWarnings(), stopAnalysis(), suppressIds(), ResultsView::suppressIds(), Settings::supprs, toggleFilterToolBar(), toggleMainToolBar(), toggleViewToolBar(), uncheckAll(), and updateMRUMenuItems().

◆ MainWindow() [2/2]

MainWindow::MainWindow ( const MainWindow )
delete

◆ ~MainWindow()

MainWindow::~MainWindow ( )
override

Definition at line 313 of file mainwindow.cpp.

References mProjectFile, mScratchPad, and mUI.

Member Function Documentation

◆ about

void MainWindow::about ( )
slot

Slot to open program's about dialog.

Definition at line 1505 of file mainwindow.cpp.

References CppCheck::extraVersion(), mCppcheckCfgAbout, and CppCheck::version().

Referenced by MainWindow().

◆ aboutToShowViewMenu

void MainWindow::aboutToShowViewMenu ( )
privateslot

Slot for updating View-menu before it is shown.

Definition at line 1657 of file mainwindow.cpp.

References mUI.

Referenced by MainWindow().

◆ addIncludeDirs()

void MainWindow::addIncludeDirs ( const QStringList &  includeDirs,
Settings result 
)
private

Add include directories.

Parameters
includeDirsList of include directories to add.
resultSettings class where include directories are added.

Definition at line 810 of file mainwindow.cpp.

References Settings::includePaths, and mCurrentDirectory.

Referenced by getCppcheckSettings().

◆ addProjectMRU()

void MainWindow::addProjectMRU ( const QString &  project)
private

Add project file (path) to the MRU list.

Parameters
projectFull path to the project file to add.

Definition at line 2037 of file mainwindow.cpp.

References MaxRecentProjects, mSettings, SETTINGS_MRU_PROJECTS, and updateMRUMenuItems().

Referenced by loadProjectFile(), and newProjectFile().

◆ analysisDone

void MainWindow::analysisDone ( )
privateslot

◆ analyzeCode()

void MainWindow::analyzeCode ( const QString &  code,
const QString &  filename 
)

Analyze given code.

Parameters
codeContent of the (virtual) file to be analyzed
filenameName of the (virtual) file to be analyzed - determines language.

Definition at line 625 of file mainwindow.cpp.

References analysisDone(), checkLockDownUI(), clearResults(), error, getCppcheckSettings(), mUI, and ThreadResult::setFiles().

Referenced by ScratchPad::checkButtonClicked().

◆ analyzeDirectory

void MainWindow::analyzeDirectory ( )
slot

Slot for analyze directory menu item.

Definition at line 753 of file mainwindow.cpp.

References doAnalyzeFiles(), loadProjectFile(), and selectFilesToAnalyze().

Referenced by MainWindow().

◆ analyzeFiles

void MainWindow::analyzeFiles ( )
slot

◆ analyzeProject()

void MainWindow::analyzeProject ( const ProjectFile projectFile,
const bool  checkLibrary = false,
const bool  checkConfiguration = false 
)
private

◆ checkAll

void MainWindow::checkAll ( )
slot

Slot to check all "Show errors" menu items.

Definition at line 1450 of file mainwindow.cpp.

References toggleAllChecked().

Referenced by MainWindow().

◆ checkConfiguration

void MainWindow::checkConfiguration ( )
slot

Slot to check configuration.

Definition at line 1250 of file mainwindow.cpp.

References analyzeProject(), and mProjectFile.

Referenced by analyzeProject(), doAnalyzeFiles(), doAnalyzeProject(), and MainWindow().

◆ checkLibrary

void MainWindow::checkLibrary ( )
slot

Slot to reanalyze with checking library configuration.

Definition at line 1244 of file mainwindow.cpp.

References analyzeProject(), and mProjectFile.

Referenced by analyzeProject(), doAnalyzeFiles(), doAnalyzeProject(), and MainWindow().

◆ checkLockDownUI

void MainWindow::checkLockDownUI ( )
privateslot

◆ clearResults

void MainWindow::clearResults ( )
slot

Slot to clear all search results.

Definition at line 1321 of file mainwindow.cpp.

References enableResultsButtons(), ProjectFile::getBuildDir(), ProjectFile::getFilename(), mProjectFile, and mUI.

Referenced by analyzeCode(), doAnalyzeFiles(), doAnalyzeProject(), and MainWindow().

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent *  event)
overrideprivate

Event coming when application is about to close.

Definition at line 1460 of file mainwindow.cpp.

References ThreadHandler::isChecking(), mExiting, mThread, saveSettings(), and ThreadHandler::stop().

◆ closeProjectFile

void MainWindow::closeProjectFile ( )
slot

Slot to close open project file.

Definition at line 1901 of file mainwindow.cpp.

References enableProjectActions(), enableProjectOpenActions(), formatAndSetTitle(), mProjectFile, and mUI.

Referenced by loadResults(), MainWindow(), and newProjectFile().

◆ complianceReport

void MainWindow::complianceReport ( )
slot

Slot to generate compliance report.

Definition at line 1578 of file mainwindow.cpp.

References mCppcheckCfgProductName, mProjectFile, mUI, and Report::XMLV2.

Referenced by MainWindow().

◆ doAnalyzeFiles()

void MainWindow::doAnalyzeFiles ( const QStringList &  files,
const bool  checkLibrary = false,
const bool  checkConfiguration = false 
)
private

◆ doAnalyzeProject()

void MainWindow::doAnalyzeProject ( ImportProject  p,
const bool  checkLibrary = false,
const bool  checkConfiguration = false 
)
private

◆ editProjectFile

void MainWindow::editProjectFile ( )
slot

Slot to edit project file.

Definition at line 1911 of file mainwindow.cpp.

References analyzeProject(), isCppcheckPremium(), mProjectFile, and ProjectFile::write().

Referenced by MainWindow().

◆ enableCheckButtons()

void MainWindow::enableCheckButtons ( bool  enable)
private

Helper function to enable/disable all check,recheck buttons.

Definition at line 1391 of file mainwindow.cpp.

References ProjectFile::getAddons(), ProjectFile::getCodingStandards(), ThreadHandler::hasPreviousFiles(), isCppcheckPremium(), mProjectFile, mThread, and mUI.

Referenced by analysisDone(), checkLockDownUI(), and MainWindow().

◆ enableProjectActions()

void MainWindow::enableProjectActions ( bool  enable)
private

Enable or disable project file actions.

Project editing and closing actions should be only enabled when project is open and we are not analyzing files.

Parameters
enableIf true then actions are enabled.

Definition at line 1955 of file mainwindow.cpp.

References mUI.

Referenced by analysisDone(), checkLockDownUI(), closeProjectFile(), doAnalyzeFiles(), doAnalyzeProject(), and MainWindow().

◆ enableProjectOpenActions()

void MainWindow::enableProjectOpenActions ( bool  enable)
private

Enable or disable project file actions.

Project opening and creating actions should be disabled when analyzing.

Parameters
enableIf true then actions are enabled.

Definition at line 1963 of file mainwindow.cpp.

References mUI.

Referenced by analysisDone(), checkLockDownUI(), closeProjectFile(), and MainWindow().

◆ enableResultsButtons()

void MainWindow::enableResultsButtons ( )
private

Helper function to enable/disable results buttons (clear,save,print)

Definition at line 1411 of file mainwindow.cpp.

References mUI.

Referenced by analysisDone(), clearResults(), loadLastResults(), and MainWindow().

◆ filterResults

void MainWindow::filterResults ( )
privateslot

Filters the results in the result list.

Definition at line 1950 of file mainwindow.cpp.

References mLineEditFilter, and mUI.

Referenced by MainWindow().

◆ formatAndSetTitle()

void MainWindow::formatAndSetTitle ( const QString &  text = QString())
private

Format main window title.

Parameters
textText added to end of the title.

Definition at line 1619 of file mainwindow.cpp.

References CppCheck::extraVersion(), mCppcheckCfgProductName, and CppCheck::version().

Referenced by closeProjectFile(), loadProjectFile(), loadResults(), MainWindow(), newProjectFile(), selectFilesToAnalyze(), and setLanguage().

◆ getCppcheckSettings()

QPair< bool, Settings > MainWindow::getCppcheckSettings ( )
private

Get our default cppcheck settings and read project file.

Returns
Default cppcheck settings

Definition at line 963 of file mainwindow.cpp.

References addIncludeDirs(), Settings::addons, SuppressionList::addSuppression(), Settings::buildDir, Settings::certainty, Settings::checkAllConfigurations, Settings::checkHeaders, Settings::checks, Settings::checkUnknownFunctionReturn, Settings::checkUnusedTemplates, Settings::clang, ProjectFile::clangParser, Settings::SafeChecks::classes, Settings::debugwarnings, SimpleEnableGroup< T >::enable(), Settings::enforcedLang, CheckThread::executeCommand(), Settings::exename, Settings::exhaustive, Settings::SafeChecks::externalFunctions, Settings::SafeChecks::externalVariables, Settings::force, fromNativePath(), ProjectFile::getAddons(), ProjectFile::getBughunting(), ProjectFile::getBuildDir(), ProjectFile::getCertIntPrecision(), ProjectFile::getCheckHeaders(), ProjectFile::getCheckingSuppressions(), ProjectFile::getCheckUnknownFunctionReturn(), ProjectFile::getCheckUnusedTemplates(), ProjectFile::getCodingStandards(), getDataDir(), ProjectFile::getDefines(), ProjectFile::getFilename(), ProjectFile::getImportProject(), ProjectFile::getIncludeDirs(), ProjectFile::getLibraries(), ProjectFile::getMaxCtuDepth(), ProjectFile::getMaxTemplateRecursion(), ProjectFile::getPlatform(), ProjectFile::getUndefines(), inconclusive, information, Settings::inlineSuppressions, Settings::SafeChecks::internalFunctions, ProjectFile::isCheckLevelExhaustive(), isCppcheckPremium(), Settings::jobs, Settings::libraries, Settings::library, loadAddon(), Settings::loadCppcheckCfg(), Platform::loadFromFile(), Settings::maxConfigs, Settings::maxCtuDepth, Settings::maxTemplateRecursion, missingInclude, mProjectFile, mSettings, Suppressions::nomsg, Settings::normal, performance, Settings::platform, portability, Settings::premiumArgs, Settings::quiet, ProjectFile::safeChecks, Settings::safeChecks, saveSettings(), Platform::set(), Standards::setC(), Settings::setCheckLevel(), Standards::setCPP(), SimpleEnableGroup< T >::setEnabled(), Settings::setMisraRuleTexts(), SETTINGS_CHECK_FORCE, SETTINGS_CHECK_THREADS, SETTINGS_CHECKED_PLATFORM, SETTINGS_ENFORCED_LANGUAGE, SETTINGS_GLOBAL_INCLUDE_PATHS, SETTINGS_INCONCLUSIVE_ERRORS, SETTINGS_INLINE_SUPPRESSIONS, SETTINGS_PYTHON_PATH, SETTINGS_SHOW_DEBUG_WARNINGS, SETTINGS_STD_C, SETTINGS_STD_CPP, Settings::severity, Settings::standards, style, Settings::supprs, Settings::terminate(), Platform::toString(), toString(), tryLoadLibrary(), Platform::type, unusedFunction, Settings::userDefines, Settings::userUndefs, Settings::verbose, warning, and Settings::xml.

Referenced by analyzeCode(), doAnalyzeFiles(), doAnalyzeProject(), reAnalyze(), and reAnalyzeSelected().

◆ getLastResults()

QString MainWindow::getLastResults ( ) const
private

Get filename for last results.

Definition at line 1731 of file mainwindow.cpp.

References ProjectFile::getBuildDir(), ProjectFile::getFilename(), and mProjectFile.

Referenced by loadLastResults(), and stopAnalysis().

◆ handleCLIParams()

void MainWindow::handleCLIParams ( const QStringList &  params)
private

Handle command line parameters given to GUI.

Parameters
paramsList of string given to command line.

Definition at line 320 of file mainwindow.cpp.

References doAnalyzeFiles(), loadProjectFile(), and loadResults().

Referenced by MainWindow().

◆ hideInformation

void MainWindow::hideInformation ( )
privateslot

Definition at line 2157 of file mainwindow.cpp.

References getVersion(), mSettings, mUI, and SETTINGS_CHECK_VERSION.

Referenced by MainWindow().

◆ isCppcheckPremium()

bool MainWindow::isCppcheckPremium ( ) const
private

◆ loadAddon()

QString MainWindow::loadAddon ( Settings settings,
const QString &  filesDir,
const QString &  pythonCmd,
const QString &  addon 
)
private

◆ loadLastResults()

bool MainWindow::loadLastResults ( )
private

Load last project results to the GUI.

Returns
Returns true if last results was loaded

Definition at line 1738 of file mainwindow.cpp.

References enableResultsButtons(), getLastResults(), mSettings, mUI, SETTINGS_LAST_CHECK_PATH, and toString().

Referenced by loadProjectFile(), loadSettings(), and openRecentProject().

◆ loadLibrary()

Library::Error MainWindow::loadLibrary ( Library library,
const QString &  filename 
)
private

Load library file.

Parameters
librarylibrary to use
filenamefilename (no path)
Returns
error code

Definition at line 826 of file mainwindow.cpp.

References Library::Error::errorcode, Library::FILE_NOT_FOUND, getDataDir(), ProjectFile::getFilename(), Library::load(), and mProjectFile.

Referenced by tryLoadLibrary().

◆ loadProjectFile()

void MainWindow::loadProjectFile ( const QString &  filePath)
private

Load project file to the GUI.

Parameters
filePathFilename (inc. path) of project file to load.

Definition at line 1714 of file mainwindow.cpp.

References addProjectMRU(), analyzeProject(), formatAndSetTitle(), loadLastResults(), mIsLogfileLoaded, mProjectFile, mUI, and ProjectFile::setActiveProject().

Referenced by analyzeDirectory(), handleCLIParams(), openProjectFile(), and openRecentProject().

◆ loadResults() [1/2]

void MainWindow::loadResults ( const QString &  selectedFile)
private

Load XML file to the GUI.

Parameters
selectedFileFilename (inc. path) of XML file to load.

Definition at line 1370 of file mainwindow.cpp.

References closeProjectFile(), formatAndSetTitle(), mIsLogfileLoaded, mProjectFile, mUI, setPath(), and SETTINGS_LAST_RESULT_PATH.

Referenced by handleCLIParams(), loadResults(), openRecentProject(), and openResults().

◆ loadResults() [2/2]

void MainWindow::loadResults ( const QString &  selectedFile,
const QString &  sourceDirectory 
)
private

Load XML file to the GUI.

Parameters
selectedFileFilename (inc. path) of XML file to load.
sourceDirectoryPath to the directory that the results were generated for.

Definition at line 1385 of file mainwindow.cpp.

References loadResults(), and mUI.

◆ loadSettings()

void MainWindow::loadSettings ( )
private

◆ newProjectFile

void MainWindow::newProjectFile ( )
slot

◆ openHelpContents

void MainWindow::openHelpContents ( )
privateslot

Open help file contents.

Definition at line 1675 of file mainwindow.cpp.

References openOnlineHelp().

Referenced by MainWindow().

◆ openOnlineHelp()

void MainWindow::openOnlineHelp ( )
staticprivate

Show help contents.

Definition at line 1680 of file mainwindow.cpp.

Referenced by openHelpContents().

◆ openProjectFile

void MainWindow::openProjectFile ( )
slot

Slot to open project file and start analyzing contained paths.

Definition at line 1686 of file mainwindow.cpp.

References getPath(), loadProjectFile(), setPath(), and SETTINGS_LAST_PROJECT_PATH.

Referenced by MainWindow().

◆ openRecentProject

void MainWindow::openRecentProject ( )
privateslot

Opens recently opened project file.

Definition at line 1969 of file mainwindow.cpp.

References loadLastResults(), loadProjectFile(), loadResults(), and removeProjectMRU().

Referenced by MainWindow().

◆ openResults

void MainWindow::openResults ( )
slot

Slot to open XML report file.

Definition at line 1338 of file mainwindow.cpp.

References getPath(), loadResults(), mUI, and SETTINGS_LAST_RESULT_PATH.

Referenced by MainWindow().

◆ operator=()

MainWindow& MainWindow::operator= ( const MainWindow )
delete

◆ performSelectedFilesCheck

void MainWindow::performSelectedFilesCheck ( const QStringList &  selectedFilesList)
slot

Slot to reanalyze selected files.

Parameters
selectedFilesListlist of selected files

Definition at line 1535 of file mainwindow.cpp.

References reAnalyzeSelected().

Referenced by MainWindow().

◆ programSettings

void MainWindow::programSettings ( )
slot

◆ reAnalyze()

void MainWindow::reAnalyze ( bool  all)
private

◆ reAnalyzeAll

void MainWindow::reAnalyzeAll ( )
slot

Slot to reanalyze all files.

Definition at line 1236 of file mainwindow.cpp.

References analyzeProject(), mProjectFile, and reAnalyze().

Referenced by MainWindow().

◆ reAnalyzeModified

void MainWindow::reAnalyzeModified ( )
slot

Slot to reanalyze modified files.

Definition at line 1231 of file mainwindow.cpp.

References reAnalyze().

Referenced by MainWindow().

◆ reAnalyzeSelected()

void MainWindow::reAnalyzeSelected ( const QStringList &  files)
private

◆ removeProjectMRU()

void MainWindow::removeProjectMRU ( const QString &  project)
private

Remove project file (path) from the MRU list.

Parameters
projectFull path of the project file to remove.

Definition at line 2049 of file mainwindow.cpp.

References mSettings, SETTINGS_MRU_PROJECTS, and updateMRUMenuItems().

Referenced by openRecentProject().

◆ replyFinished

void MainWindow::replyFinished ( QNetworkReply *  reply)
privateslot

◆ resultsAdded

void MainWindow::resultsAdded ( )
privateslot

Slot for enabling save and clear button.

Definition at line 1600 of file mainwindow.cpp.

Referenced by MainWindow().

◆ save

void MainWindow::save ( )
slot

Slot to save results.

Definition at line 1540 of file mainwindow.cpp.

References Report::CSV, getPath(), mCppcheckCfgProductName, mUI, setPath(), SETTINGS_LAST_RESULT_PATH, Report::TXT, and Report::XMLV2.

Referenced by MainWindow().

◆ saveSettings()

void MainWindow::saveSettings ( ) const
private

◆ selectFilesToAnalyze()

QStringList MainWindow::selectFilesToAnalyze ( QFileDialog::FileMode  mode)
private

Select files/or directory to analyze.

Helper function to open a dialog to ask user to select files or directory to analyze. Use native dialogs instead of Qt:s own dialogs.

Parameters
modeDialog open mode (files or directories)
Returns
QStringList of files or directories that were selected to analyze

Definition at line 660 of file mainwindow.cpp.

References compile_commands_json(), formatAndSetTitle(), FileList::getDefaultFilters(), getPath(), mCurrentDirectory, mProjectFile, mSettings, setPath(), SETTINGS_LAST_ANALYZE_FILES_FILTER, SETTINGS_LAST_CHECK_PATH, and toFilterString().

Referenced by analyzeDirectory(), and analyzeFiles().

◆ selectPlatform

void MainWindow::selectPlatform ( )
privateslot

Selects the platform as analyzed platform.

Definition at line 2058 of file mainwindow.cpp.

References mSettings, and SETTINGS_CHECKED_PLATFORM.

Referenced by MainWindow().

◆ setLanguage()

void MainWindow::setLanguage ( const QString &  code)
private

Set current language.

Parameters
codeLanguage code of the language to set (e.g. "en").

Definition at line 1639 of file mainwindow.cpp.

References formatAndSetTitle(), TranslationHandler::getCurrentLanguage(), ProjectFile::getFilename(), mLineEditFilter, mProjectFile, mScratchPad, mTranslation, mUI, TranslationHandler::setLanguage(), and ScratchPad::translate().

Referenced by programSettings().

◆ showAuthors

void MainWindow::showAuthors ( )
slot

Slot to to show authors list.

Definition at line 1528 of file mainwindow.cpp.

Referenced by MainWindow().

◆ showErrors

void MainWindow::showErrors ( bool  checked)
slot

Show errors with type "error".

Parameters
checkedShould errors be shown (true) or hidden (false)

Definition at line 1425 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowErrors.

Referenced by MainWindow(), and toggleAllChecked().

◆ showInformation

void MainWindow::showInformation ( bool  checked)
slot

Show errors with type "information".

Parameters
checkedShould errors be shown (true) or hidden (false)

Definition at line 1445 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowInformation.

Referenced by MainWindow(), and toggleAllChecked().

◆ showLibraryEditor

void MainWindow::showLibraryEditor ( )
slot

Slot for showing the library editor.

Definition at line 1944 of file mainwindow.cpp.

Referenced by MainWindow().

◆ showLicense

void MainWindow::showLicense ( )
slot

Slot to to show license text.

Definition at line 1521 of file mainwindow.cpp.

Referenced by MainWindow().

◆ showPerformance

void MainWindow::showPerformance ( bool  checked)
slot

Show errors with type "performance".

Parameters
checkedShould errors be shown (true) or hidden (false)

Definition at line 1440 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowPerformance.

Referenced by MainWindow(), and toggleAllChecked().

◆ showPortability

void MainWindow::showPortability ( bool  checked)
slot

Show errors with type "portability".

Parameters
checkedShould errors be shown (true) or hidden (false)

Definition at line 1435 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowPortability.

Referenced by MainWindow(), and toggleAllChecked().

◆ showScratchpad

void MainWindow::showScratchpad ( )
slot

Slot to show scratchpad.

Definition at line 1703 of file mainwindow.cpp.

References mScratchPad.

Referenced by MainWindow().

◆ showStatistics

void MainWindow::showStatistics ( )
slot

◆ showStyle

void MainWindow::showStyle ( bool  checked)
slot

Show errors with type "style".

Parameters
checkedShould errors be shown (true) or hidden (false)

Definition at line 1420 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowStyle.

Referenced by MainWindow(), and toggleAllChecked().

◆ showWarnings

void MainWindow::showWarnings ( bool  checked)
slot

Show errors with type "warning".

Parameters
checkedShould errors be shown (true) or hidden (false)

Definition at line 1430 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowWarnings.

Referenced by MainWindow(), and toggleAllChecked().

◆ stopAnalysis

void MainWindow::stopAnalysis ( )
privateslot

Slot when stop analysis button is pressed.

Definition at line 1664 of file mainwindow.cpp.

References getLastResults(), mThread, mUI, and ThreadHandler::stop().

Referenced by MainWindow().

◆ suppressIds

void MainWindow::suppressIds ( QStringList  ids)
privateslot

◆ toggleAllChecked()

void MainWindow::toggleAllChecked ( bool  checked)
private

Helper function to toggle all show error menu items.

Parameters
checkedShould all errors be shown (true) or hidden (false)

Definition at line 1489 of file mainwindow.cpp.

References mUI, showErrors(), showInformation(), showPerformance(), showPortability(), showStyle(), and showWarnings().

Referenced by checkAll(), and uncheckAll().

◆ toggleFilterToolBar

void MainWindow::toggleFilterToolBar ( )
privateslot

Slot for showing/hiding Filter toolbar.

Definition at line 1613 of file mainwindow.cpp.

References mLineEditFilter, and mUI.

Referenced by MainWindow().

◆ toggleMainToolBar

void MainWindow::toggleMainToolBar ( )
privateslot

Slot for showing/hiding standard toolbar.

Definition at line 1603 of file mainwindow.cpp.

References mUI.

Referenced by MainWindow().

◆ toggleViewToolBar

void MainWindow::toggleViewToolBar ( )
privateslot

Slot for showing/hiding Categories toolbar.

Definition at line 1608 of file mainwindow.cpp.

References mUI.

Referenced by MainWindow().

◆ tryLoadLibrary()

bool MainWindow::tryLoadLibrary ( Library library,
const QString &  filename 
)
private

Tries to load library file, prints message on error.

Parameters
librarylibrary to use
filenamefilename (no path)
Returns
True if no error

Definition at line 874 of file mainwindow.cpp.

References Library::BAD_ATTRIBUTE_VALUE, Library::BAD_XML, Library::DUPLICATE_DEFINE, Library::DUPLICATE_PLATFORM_TYPE, error, Library::FILE_NOT_FOUND, loadLibrary(), Library::MISSING_ATTRIBUTE, Library::OK, Library::PLATFORM_TYPE_REDEFINED, Library::UNKNOWN_ELEMENT, and Library::UNSUPPORTED_FORMAT.

Referenced by getCppcheckSettings().

◆ uncheckAll

void MainWindow::uncheckAll ( )
slot

Slot to uncheck all "Show errors" menu items.

Definition at line 1455 of file mainwindow.cpp.

References toggleAllChecked().

Referenced by MainWindow().

◆ updateMRUMenuItems()

void MainWindow::updateMRUMenuItems ( )
private

Update project MRU items in File-menu.

Definition at line 2002 of file mainwindow.cpp.

References MaxRecentProjects, mRecentProjectActs, mSettings, mUI, and SETTINGS_MRU_PROJECTS.

Referenced by addProjectMRU(), MainWindow(), and removeProjectMRU().

Member Data Documentation

◆ mApplications

ApplicationList* MainWindow::mApplications
private

List of user defined applications to open errors with.

Definition at line 431 of file mainwindow.h.

Referenced by loadSettings(), MainWindow(), programSettings(), and saveSettings().

◆ mCppcheckCfgAbout

QString MainWindow::mCppcheckCfgAbout
private

Definition at line 479 of file mainwindow.h.

Referenced by about(), and MainWindow().

◆ mCppcheckCfgProductName

QString MainWindow::mCppcheckCfgProductName
private

◆ mCppStandardActions

QActionGroup * MainWindow::mCppStandardActions
private

Definition at line 458 of file mainwindow.h.

Referenced by analysisDone(), checkLockDownUI(), and MainWindow().

◆ mCStandardActions

QActionGroup* MainWindow::mCStandardActions
private

GUI actions for selecting the coding standard.

Definition at line 458 of file mainwindow.h.

Referenced by analysisDone(), checkLockDownUI(), and MainWindow().

◆ mCurrentDirectory

QString MainWindow::mCurrentDirectory
private

◆ mExiting

bool MainWindow::mExiting {}
private

Are we exiting the cppcheck? If this is true then the cppcheck is waiting for check threads to exit so that the application can be closed.

Definition at line 468 of file mainwindow.h.

Referenced by analysisDone(), and closeEvent().

◆ mFilterTimer

QTimer* MainWindow::mFilterTimer
private

Timer to delay filtering while typing.

Definition at line 452 of file mainwindow.h.

Referenced by MainWindow().

◆ mIsLogfileLoaded

bool MainWindow::mIsLogfileLoaded {}
private

Set to true in case of loading log file.

Definition at line 471 of file mainwindow.h.

Referenced by analysisDone(), doAnalyzeFiles(), doAnalyzeProject(), loadProjectFile(), and loadResults().

◆ mLineEditFilter

QLineEdit* MainWindow::mLineEditFilter
private

Filter field in the Filter toolbar.

Definition at line 449 of file mainwindow.h.

Referenced by filterResults(), MainWindow(), setLanguage(), and toggleFilterToolBar().

◆ mNetworkAccessManager

QNetworkAccessManager* MainWindow::mNetworkAccessManager = nullptr
private

Definition at line 482 of file mainwindow.h.

Referenced by MainWindow().

◆ mPlatformActions

QActionGroup* MainWindow::mPlatformActions
private

GUI actions for selecting the analyzed platform.

Definition at line 455 of file mainwindow.h.

Referenced by analysisDone(), checkLockDownUI(), and MainWindow().

◆ mPlatforms

Platforms MainWindow::mPlatforms

List of checked platforms.

Definition at line 75 of file mainwindow.h.

Referenced by MainWindow().

◆ mProjectFile

ProjectFile* MainWindow::mProjectFile {}
private

◆ mRecentProjectActs

QAction* MainWindow::mRecentProjectActs[MaxRecentProjects+1]
private

Project MRU menu actions.

List of MRU menu actions. Needs also to store the separator.

Definition at line 477 of file mainwindow.h.

Referenced by analysisDone(), checkLockDownUI(), MainWindow(), and updateMRUMenuItems().

◆ mScratchPad

ScratchPad* MainWindow::mScratchPad {}
private

Scratchpad.

Definition at line 443 of file mainwindow.h.

Referenced by analysisDone(), checkLockDownUI(), setLanguage(), showScratchpad(), and ~MainWindow().

◆ mSelectLanguageActions

QActionGroup* MainWindow::mSelectLanguageActions
private

GUI actions for selecting language.

Definition at line 461 of file mainwindow.h.

Referenced by analysisDone(), checkLockDownUI(), and MainWindow().

◆ mSettings

QSettings* MainWindow::mSettings
private

◆ mThread

ThreadHandler* MainWindow::mThread
private

◆ mTranslation

TranslationHandler* MainWindow::mTranslation
private

Class to handle translation changes.

Definition at line 434 of file mainwindow.h.

Referenced by programSettings(), saveSettings(), and setLanguage().

◆ mUI

Ui::MainWindow* MainWindow::mUI
private

The documentation for this class was generated from the following files: