Cppcheck
Public Types | Public Slots | Public Member Functions | Public Attributes | Protected Slots | Private Member Functions | Private Attributes
MainWindow Class Reference

Main window for cppcheck-gui. More...

#include <mainwindow.h>

List of all members.

Public Types

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

Public Slots

void CheckFiles ()
 Slot for check files menu item.
void ReCheck ()
 Slot to recheck files.
void ClearResults ()
 Slot to clear all search results.
void OpenResults ()
 Slot to open XML report file.
void ShowStyle (bool checked)
 Show errors with type "style".
void ShowErrors (bool checked)
 Show errors with type "error".
void ShowWarnings (bool checked)
 Show errors with type "warning".
void ShowPortability (bool checked)
 Show errors with type "portability".
void ShowPerformance (bool checked)
 Show errors with type "performance".
void ShowInformation (bool checked)
 Show errors with type "information".
void CheckAll ()
 Slot to check all "Show errors" menu items.
void UncheckAll ()
 Slot to uncheck all "Show errors" menu items.
void CheckDirectory ()
 Slot for check directory menu item.
void ProgramSettings ()
 Slot to open program's settings dialog.
void About ()
 Slot to open program's about dialog.
void ShowLicense ()
 Slot to to show license text.
void ShowAuthors ()
 Slot to to show authors list.
void Save ()
 Slot to stop processing files.
void NewProjectFile ()
 Slot to create new project file.
void OpenProjectFile ()
 Slot to open project file and start checking contained paths.
void ShowScratchpad ()
 Slot to open project file and start checking contained paths.
void CloseProjectFile ()
 Slot to close open project file.
void EditProjectFile ()
 Slot to edit project file.
void ShowLogView ()
 Slot for showing the log view.
void ShowStatistics ()
 Slot for showing the scan and project statistics.

Public Member Functions

 MainWindow (TranslationHandler *th, QSettings *settings)
virtual ~MainWindow ()
void CheckCode (const QString &code, const QString &filename)
 Checks given code.

Public Attributes

Platforms mPlatforms
 List of checked platforms.

Protected Slots

void CheckDone ()
 Slot for checkthread's done signal.
void CheckLockDownUI ()
 Lock down UI while checking.
void ResultsAdded ()
 Slot for enabling save and clear button.
void ToggleMainToolBar ()
 Slot for showing/hiding standard toolbar.
void ToggleViewToolBar ()
 Slot for showing/hiding Categories toolbar.
void ToggleFilterToolBar ()
 Slot for showing/hiding Filter toolbar.
void AboutToShowViewMenu ()
 Slot for updating View-menu before it is shown.
void StopChecking ()
 Slot when stop checking button is pressed.
void OpenHelpContents ()
 Open help file contents.
void Log (const QString &logline)
 Add new line to log.
void DebugError (const ErrorItem &item)
 Handle new debug error.
void FilterResults ()
 Filters the results in the result list.
void OpenRecentProject ()
 Opens recently opened project file.
void SelectPlatform ()
 Selects the platform as checked platform.

Private Member Functions

void CheckProject (Project *project)
 Check the project.
void SetLanguage (const QString &code)
 Set current language.
virtual void closeEvent (QCloseEvent *event)
 Event coming when application is about to close.
void ToggleAllChecked (bool checked)
 Helper function to toggle all show error menu items.
void EnableCheckButtons (bool enable)
 Helper function to enable/disable all check,recheck buttons.
QStringList SelectFilesToCheck (QFileDialog::FileMode mode)
 Select files/or directory to check.
void DoCheckFiles (const QStringList &files)
 Check all files specified in parameter files.
Settings GetCppcheckSettings ()
 Get our default cppcheck settings and read project file.
void LoadSettings ()
 Load program settings.
void SaveSettings () const
 Save program settings.
void FormatAndSetTitle (const QString &text=QString())
 Format main window title.
void OpenOnlineHelp ()
 Show help contents.
void EnableProjectActions (bool enable)
 Enable or disable project file actions.
void EnableProjectOpenActions (bool enable)
 Enable or disable project file actions.
void AddIncludeDirs (const QStringList &includeDirs, Settings &result)
 Add include directories.
void HandleCLIParams (const QStringList &params)
 Handle command line parameters given to GUI.
void LoadResults (const QString file)
 Load XML file to the GUI.
void LoadResults (const QString file, const QString checkedDirectory)
 Load XML file to the GUI.
void LoadProjectFile (const QString &filePath)
 Load project file to the GUI.
void UpdateMRUMenuItems ()
 Update project MRU items in File-menu.
void AddProjectMRU (const QString &project)
 Add project file (path) to the MRU list.
void RemoveProjectMRU (const QString &project)
 Remove project file (path) from the MRU list.

Private Attributes

QSettings * mSettings
 Program settings.
ThreadHandlermThread
 Thread to check files.
ApplicationListmApplications
 List of user defined applications to open errors with.
TranslationHandlermTranslation
 Class to handle translation changes.
Ui::MainWindow mUI
 Class holding all UI components.
QString mCurrentDirectory
 Current checked directory.
LogViewmLogView
 Log view.
ScratchPadmScratchPad
 Scratchpad.
ProjectmProject
 Project (file).
QLineEdit * mLineEditFilter
 Filter field in the Filter toolbar.
QTimer * mFilterTimer
 Timer to delay filtering while typing.
QActionGroup * mPlatformActions
 GUI actions for selecting the checked platform.
QActionGroup * mCStandardActions
 GUI actions for selecting the coding standard.
QActionGroup * mCppStandardActions
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.
QAction * mRecentProjectActs [MaxRecentProjects+1]
 Project MRU menu actions.

Detailed Description

Main window for cppcheck-gui.

Definition at line 48 of file mainwindow.h.


Member Enumeration Documentation

anonymous enum

Maximum number of MRU project items in File-menu.

Enumerator:
MaxRecentProjects 

Definition at line 55 of file mainwindow.h.


Constructor & Destructor Documentation

MainWindow::MainWindow ( TranslationHandler th,
QSettings *  settings 
)
MainWindow::~MainWindow ( ) [virtual]

Definition at line 193 of file mainwindow.cpp.

References mLogView, mProject, and mScratchPad.


Member Function Documentation

void MainWindow::About ( ) [slot]

Slot to open program's about dialog.

Definition at line 811 of file mainwindow.cpp.

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

Referenced by MainWindow().

void MainWindow::AboutToShowViewMenu ( ) [protected, slot]

Slot for updating View-menu before it is shown.

Definition at line 918 of file mainwindow.cpp.

References mUI.

Referenced by MainWindow().

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 498 of file mainwindow.cpp.

References Settings::_includePaths, and mCurrentDirectory.

Referenced by GetCppcheckSettings().

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 1197 of file mainwindow.cpp.

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

Referenced by LoadProjectFile(), and NewProjectFile().

void MainWindow::CheckAll ( ) [slot]

Slot to check all "Show errors" menu items.

Definition at line 756 of file mainwindow.cpp.

References ToggleAllChecked().

Referenced by MainWindow().

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

Checks given code.

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

Definition at line 364 of file mainwindow.cpp.

References CppCheck::check(), CheckDone(), CheckLockDownUI(), ClearResults(), DebugError(), GetCppcheckSettings(), Log(), mUI, ThreadResult::SetFiles(), and CppCheck::settings().

Referenced by ScratchPad::CheckButtonClicked().

void MainWindow::CheckDirectory ( ) [slot]

Slot for check directory menu item.

Definition at line 441 of file mainwindow.cpp.

References DoCheckFiles(), LoadProjectFile(), and SelectFilesToCheck().

Referenced by MainWindow().

void MainWindow::CheckDone ( ) [protected, slot]
void MainWindow::CheckFiles ( ) [slot]

Slot for check files menu item.

Definition at line 436 of file mainwindow.cpp.

References DoCheckFiles(), and SelectFilesToCheck().

Referenced by MainWindow().

void MainWindow::CheckLockDownUI ( ) [protected, slot]
void MainWindow::CheckProject ( Project project) [private]

Check the project.

Parameters:
projectPointer to the project to check.

Definition at line 984 of file mainwindow.cpp.

References DoCheckFiles(), Project::Filename(), ProjectFile::GetCheckPaths(), Project::GetProjectFile(), ProjectFile::GetRootPath(), Project::IsOpen(), mCurrentDirectory, mProject, and Project::Open().

Referenced by LoadProjectFile(), and NewProjectFile().

void MainWindow::ClearResults ( ) [slot]

Slot to clear all search results.

Definition at line 661 of file mainwindow.cpp.

References mUI.

Referenced by CheckCode(), DoCheckFiles(), and MainWindow().

void MainWindow::closeEvent ( QCloseEvent *  event) [private, virtual]

Event coming when application is about to close.

Definition at line 766 of file mainwindow.cpp.

References ThreadHandler::IsChecking(), mExiting, mThread, SaveSettings(), and ThreadHandler::Stop().

Slot to close open project file.

Definition at line 1052 of file mainwindow.cpp.

References EnableProjectActions(), EnableProjectOpenActions(), FormatAndSetTitle(), and mProject.

Referenced by MainWindow().

void MainWindow::DebugError ( const ErrorItem item) [protected, slot]

Handle new debug error.

Definition at line 1108 of file mainwindow.cpp.

References LogView::AppendLine(), mLogView, and ErrorItem::ToString().

Referenced by CheckCode().

void MainWindow::DoCheckFiles ( const QStringList &  files) [private]
void MainWindow::EditProjectFile ( ) [slot]

Slot to edit project file.

Definition at line 1061 of file mainwindow.cpp.

References Project::Edit(), and mProject.

Referenced by MainWindow().

void MainWindow::EnableCheckButtons ( bool  enable) [private]

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

Definition at line 715 of file mainwindow.cpp.

References ThreadHandler::HasPreviousFiles(), mThread, and mUI.

Referenced by CheckDone(), CheckLockDownUI(), and MainWindow().

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 checking files.

Parameters:
enableIf true then actions are enabled.

Definition at line 1120 of file mainwindow.cpp.

References mUI.

Referenced by CheckDone(), CheckLockDownUI(), CloseProjectFile(), MainWindow(), and NewProjectFile().

void MainWindow::EnableProjectOpenActions ( bool  enable) [private]

Enable or disable project file actions.

Project opening and creating actions should be disabled when checking.

Parameters:
enableIf true then actions are enabled.

Definition at line 1126 of file mainwindow.cpp.

References mUI.

Referenced by CheckDone(), CheckLockDownUI(), CloseProjectFile(), and MainWindow().

void MainWindow::FilterResults ( ) [protected, slot]

Filters the results in the result list.

Definition at line 1115 of file mainwindow.cpp.

References mLineEditFilter, and mUI.

Referenced by MainWindow().

void MainWindow::FormatAndSetTitle ( const QString &  text = QString()) [private]

Format main window title.

Parameters:
textText added to end of the title.

Definition at line 893 of file mainwindow.cpp.

Referenced by CloseProjectFile(), LoadProjectFile(), MainWindow(), NewProjectFile(), and SelectFilesToCheck().

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 200 of file mainwindow.cpp.

References DoCheckFiles(), LoadProjectFile(), and LoadResults().

Referenced by MainWindow().

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 970 of file mainwindow.cpp.

References AddProjectMRU(), CheckProject(), FormatAndSetTitle(), mProject, and mUI.

Referenced by CheckDirectory(), HandleCLIParams(), OpenProjectFile(), and OpenRecentProject().

void MainWindow::LoadResults ( const QString  file) [private]

Load XML file to the GUI.

Parameters:
fileFilename (inc. path) of XML file to load.

Definition at line 700 of file mainwindow.cpp.

References mUI, SetPath(), and SETTINGS_LAST_RESULT_PATH.

Referenced by HandleCLIParams(), LoadResults(), and OpenResults().

void MainWindow::LoadResults ( const QString  file,
const QString  checkedDirectory 
) [private]

Load XML file to the GUI.

Parameters:
fileFilename (inc. path) of XML file to load.
checkedDirectoryPath to the directory that the results were generated for.

Definition at line 709 of file mainwindow.cpp.

References LoadResults(), and mUI.

void MainWindow::LoadSettings ( ) [private]
void MainWindow::Log ( const QString &  logline) [protected, slot]

Add new line to log.

Definition at line 1101 of file mainwindow.cpp.

References LogView::AppendLine(), and mLogView.

Referenced by CheckCode().

void MainWindow::NewProjectFile ( ) [slot]
void MainWindow::OpenHelpContents ( ) [protected, slot]

Open help file contents.

Definition at line 931 of file mainwindow.cpp.

References OpenOnlineHelp().

Referenced by MainWindow().

void MainWindow::OpenOnlineHelp ( ) [private]

Show help contents.

Definition at line 936 of file mainwindow.cpp.

References OnlineHelpURL().

Referenced by OpenHelpContents().

void MainWindow::OpenProjectFile ( ) [slot]

Slot to open project file and start checking contained paths.

Definition at line 941 of file mainwindow.cpp.

References GetPath(), LoadProjectFile(), mSettings, SetPath(), and SETTINGS_LAST_PROJECT_PATH.

Referenced by MainWindow().

void MainWindow::OpenRecentProject ( ) [protected, slot]

Opens recently opened project file.

Definition at line 1132 of file mainwindow.cpp.

References LoadProjectFile(), and RemoveProjectMRU().

Referenced by MainWindow().

void MainWindow::OpenResults ( ) [slot]

Slot to open XML report file.

Definition at line 668 of file mainwindow.cpp.

References GetPath(), LoadResults(), mUI, and SETTINGS_LAST_RESULT_PATH.

Referenced by MainWindow().

void MainWindow::ProgramSettings ( ) [slot]
void MainWindow::ReCheck ( ) [slot]
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 1209 of file mainwindow.cpp.

References mSettings, SETTINGS_MRU_PROJECTS, and UpdateMRUMenuItems().

Referenced by OpenRecentProject().

void MainWindow::ResultsAdded ( ) [protected, slot]

Slot for enabling save and clear button.

Definition at line 873 of file mainwindow.cpp.

Referenced by MainWindow().

void MainWindow::Save ( ) [slot]

Slot to stop processing files.

Definition at line 831 of file mainwindow.cpp.

References Report::CSV, GetPath(), mUI, SetPath(), SETTINGS_LAST_RESULT_PATH, Report::TXT, Report::XML, and Report::XMLV2.

Referenced by MainWindow().

void MainWindow::SaveSettings ( ) const [private]
QStringList MainWindow::SelectFilesToCheck ( QFileDialog::FileMode  mode) [private]

Select files/or directory to check.

Helper function to open a dialog to ask user to select files or directory to check. 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 check

Definition at line 390 of file mainwindow.cpp.

References FormatAndSetTitle(), GetPath(), mCurrentDirectory, mProject, SetPath(), and SETTINGS_LAST_CHECK_PATH.

Referenced by CheckDirectory(), and CheckFiles().

void MainWindow::SelectPlatform ( ) [protected, slot]

Selects the platform as checked platform.

Definition at line 1218 of file mainwindow.cpp.

References mSettings, and SETTINGS_CHECKED_PLATFORM.

Referenced by MainWindow().

void MainWindow::SetLanguage ( const QString &  code) [private]

Set current language.

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

Definition at line 903 of file mainwindow.cpp.

References TranslationHandler::GetCurrentLanguage(), mLogView, mTranslation, mUI, and TranslationHandler::SetLanguage().

Referenced by ProgramSettings().

void MainWindow::ShowAuthors ( ) [slot]

Slot to to show authors list.

Definition at line 824 of file mainwindow.cpp.

Referenced by MainWindow().

void MainWindow::ShowErrors ( bool  checked) [slot]

Show errors with type "error".

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

Definition at line 731 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowErrors.

Referenced by MainWindow(), and ToggleAllChecked().

void MainWindow::ShowInformation ( bool  checked) [slot]

Show errors with type "information".

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

Definition at line 751 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowInformation.

Referenced by MainWindow(), and ToggleAllChecked().

void MainWindow::ShowLicense ( ) [slot]

Slot to to show license text.

Definition at line 817 of file mainwindow.cpp.

Referenced by MainWindow().

void MainWindow::ShowLogView ( ) [slot]

Slot for showing the log view.

Definition at line 1075 of file mainwindow.cpp.

References mLogView.

Referenced by MainWindow().

void MainWindow::ShowPerformance ( bool  checked) [slot]

Show errors with type "performance".

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

Definition at line 746 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowPerformance.

Referenced by MainWindow(), and ToggleAllChecked().

void MainWindow::ShowPortability ( bool  checked) [slot]

Show errors with type "portability".

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

Definition at line 741 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowPortability.

Referenced by MainWindow(), and ToggleAllChecked().

void MainWindow::ShowScratchpad ( ) [slot]

Slot to open project file and start checking contained paths.

Definition at line 959 of file mainwindow.cpp.

References mScratchPad.

Referenced by MainWindow().

void MainWindow::ShowStatistics ( ) [slot]
void MainWindow::ShowStyle ( bool  checked) [slot]

Show errors with type "style".

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

Definition at line 726 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowStyle.

Referenced by MainWindow(), and ToggleAllChecked().

void MainWindow::ShowWarnings ( bool  checked) [slot]

Show errors with type "warning".

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

Definition at line 736 of file mainwindow.cpp.

References mUI, and ShowTypes::ShowWarnings.

Referenced by MainWindow(), and ToggleAllChecked().

void MainWindow::StopChecking ( ) [protected, slot]

Slot when stop checking button is pressed.

Definition at line 925 of file mainwindow.cpp.

References mThread, mUI, and ThreadHandler::Stop().

Referenced by MainWindow().

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 795 of file mainwindow.cpp.

References mUI, ShowErrors(), ShowInformation(), ShowPerformance(), ShowPortability(), ShowStyle(), and ShowWarnings().

Referenced by CheckAll(), and UncheckAll().

void MainWindow::ToggleFilterToolBar ( ) [protected, slot]

Slot for showing/hiding Filter toolbar.

Definition at line 887 of file mainwindow.cpp.

References mLineEditFilter, and mUI.

Referenced by MainWindow().

void MainWindow::ToggleMainToolBar ( ) [protected, slot]

Slot for showing/hiding standard toolbar.

Definition at line 877 of file mainwindow.cpp.

References mUI.

Referenced by MainWindow().

void MainWindow::ToggleViewToolBar ( ) [protected, slot]

Slot for showing/hiding Categories toolbar.

Definition at line 882 of file mainwindow.cpp.

References mUI.

Referenced by MainWindow().

void MainWindow::UncheckAll ( ) [slot]

Slot to uncheck all "Show errors" menu items.

Definition at line 761 of file mainwindow.cpp.

References ToggleAllChecked().

Referenced by MainWindow().

void MainWindow::UpdateMRUMenuItems ( ) [private]

Update project MRU items in File-menu.

Definition at line 1161 of file mainwindow.cpp.

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

Referenced by AddProjectMRU(), MainWindow(), and RemoveProjectMRU().


Member Data Documentation

List of user defined applications to open errors with.

Definition at line 460 of file mainwindow.h.

Referenced by LoadSettings(), MainWindow(), ProgramSettings(), and SaveSettings().

QActionGroup * MainWindow::mCppStandardActions [private]

Definition at line 512 of file mainwindow.h.

Referenced by CheckDone(), CheckLockDownUI(), and MainWindow().

QActionGroup* MainWindow::mCStandardActions [private]

GUI actions for selecting the coding standard.

Definition at line 512 of file mainwindow.h.

Referenced by CheckDone(), CheckLockDownUI(), and MainWindow().

QString MainWindow::mCurrentDirectory [private]

Current checked directory.

Definition at line 477 of file mainwindow.h.

Referenced by AddIncludeDirs(), CheckProject(), DoCheckFiles(), SelectFilesToCheck(), and ShowStatistics().

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 519 of file mainwindow.h.

Referenced by CheckDone(), and closeEvent().

QTimer* MainWindow::mFilterTimer [private]

Timer to delay filtering while typing.

Definition at line 502 of file mainwindow.h.

Referenced by MainWindow().

QLineEdit* MainWindow::mLineEditFilter [private]

Filter field in the Filter toolbar.

Definition at line 497 of file mainwindow.h.

Referenced by FilterResults(), MainWindow(), and ToggleFilterToolBar().

Log view.

Definition at line 482 of file mainwindow.h.

Referenced by DebugError(), Log(), SetLanguage(), ShowLogView(), and ~MainWindow().

QActionGroup* MainWindow::mPlatformActions [private]

GUI actions for selecting the checked platform.

Definition at line 507 of file mainwindow.h.

Referenced by CheckDone(), CheckLockDownUI(), and MainWindow().

List of checked platforms.

Definition at line 63 of file mainwindow.h.

Referenced by MainWindow().

Project MRU menu actions.

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

Definition at line 525 of file mainwindow.h.

Referenced by CheckDone(), CheckLockDownUI(), MainWindow(), and UpdateMRUMenuItems().

Scratchpad.

Definition at line 487 of file mainwindow.h.

Referenced by CheckDone(), CheckLockDownUI(), ShowScratchpad(), and ~MainWindow().

QSettings* MainWindow::mSettings [private]

Thread to check files.

Definition at line 454 of file mainwindow.h.

Referenced by closeEvent(), DoCheckFiles(), EnableCheckButtons(), MainWindow(), ReCheck(), ShowStatistics(), and StopChecking().

Class to handle translation changes.

Definition at line 466 of file mainwindow.h.

Referenced by ProgramSettings(), SaveSettings(), and SetLanguage().

Ui::MainWindow MainWindow::mUI [private]

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