2009-03-01 08:38:21 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2009-05-30 07:48:12 +02:00
|
|
|
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
|
2009-03-01 08:38:21 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QAction>
|
2009-03-22 13:32:07 +01:00
|
|
|
#include <QFileDialog>
|
|
|
|
|
2009-06-20 18:55:23 +02:00
|
|
|
#include "resultsview.h"
|
2009-03-22 13:32:07 +01:00
|
|
|
#include "settingsdialog.h"
|
2009-03-01 08:38:21 +01:00
|
|
|
|
2009-06-20 18:55:23 +02:00
|
|
|
class ThreadHandler;
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Main window for cppcheck-gui
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
MainWindow();
|
|
|
|
virtual ~MainWindow();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
/**
|
2009-03-22 13:32:07 +01:00
|
|
|
* @brief Slot for check files menu item
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void CheckFiles();
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Slot to recheck files
|
|
|
|
*
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 16:42:00 +01:00
|
|
|
void ReCheck();
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Slot to clear all search results
|
|
|
|
*
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 16:42:00 +01:00
|
|
|
void ClearResults();
|
2009-03-22 13:32:07 +01:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Show errors with type "all"
|
|
|
|
* @param checked Should errors be shown (truw) or hidden (false)
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
void ShowAll(bool checked);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Show errors with type "security"
|
|
|
|
* @param checked Should errors be shown (truw) or hidden (false)
|
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
void ShowSecurity(bool checked);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Show errors with type "style"
|
|
|
|
* @param checked Should errors be shown (truw) or hidden (false)
|
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
void ShowStyle(bool checked);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Show errors with type "unused"
|
|
|
|
* @param checked Should errors be shown (truw) or hidden (false)
|
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
void ShowUnused(bool checked);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Show errors with type "error"
|
|
|
|
* @param checked Should errors be shown (truw) or hidden (false)
|
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
void ShowErrors(bool checked);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Slot to check all "Show errors" menu items
|
|
|
|
*/
|
2009-05-23 10:17:27 +02:00
|
|
|
void CheckAll();
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Slot to uncheck all "Show errors" menu items
|
|
|
|
*/
|
2009-05-23 10:17:27 +02:00
|
|
|
void UncheckAll();
|
2009-03-22 18:39:44 +01:00
|
|
|
|
2009-03-22 13:32:07 +01:00
|
|
|
/**
|
|
|
|
* @brief Slot for check directory menu item
|
2009-03-01 08:38:21 +01:00
|
|
|
*
|
|
|
|
*/
|
2009-03-22 13:32:07 +01:00
|
|
|
void CheckDirectory();
|
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Slot to open program's settings dialog
|
|
|
|
*
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 13:32:07 +01:00
|
|
|
void ProgramSettings();
|
2009-03-01 08:38:21 +01:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Slot to open program's about dialog
|
|
|
|
*
|
2009-05-24 10:53:29 +02:00
|
|
|
*/
|
|
|
|
void About();
|
|
|
|
|
2009-06-14 11:57:43 +02:00
|
|
|
/**
|
|
|
|
* @brief Slot to to show license text
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void ShowLicense();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Slot to to show authors list
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void ShowAuthors();
|
2009-05-26 17:21:39 +02:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Slot to stop processing files
|
|
|
|
*
|
2009-05-26 17:21:39 +02:00
|
|
|
*/
|
|
|
|
void Save();
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
protected slots:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Slot for checkthread's done signal
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void CheckDone();
|
2009-06-03 20:18:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Slot for enabling save and clear button
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void ResultsAdded();
|
2009-03-01 08:38:21 +01:00
|
|
|
protected:
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-14 23:48:16 +02:00
|
|
|
/**
|
|
|
|
* @brief Create main window menus.
|
|
|
|
*/
|
|
|
|
void CreateMenus();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Create main window toolbar.
|
|
|
|
*/
|
|
|
|
void CreateToolbar();
|
|
|
|
|
2009-06-04 16:02:35 +02:00
|
|
|
/**
|
|
|
|
* @brief Event coming when application is about to close.
|
|
|
|
*/
|
|
|
|
virtual void closeEvent(QCloseEvent *event);
|
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Helper function to toggle all show error menu items
|
|
|
|
* @param checked Should all errors be shown (true) or hidden (false)
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-05-23 10:17:27 +02:00
|
|
|
void ToggleAllChecked(bool checked);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Helper function to enable/disable all check,recheck buttons
|
|
|
|
*
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 16:42:00 +01:00
|
|
|
void EnableCheckButtons(bool enable);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
2009-06-17 21:35:24 +02:00
|
|
|
* @brief 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.
|
2009-06-01 23:54:21 +02:00
|
|
|
*
|
|
|
|
* @param mode Dialog open mode (files or directories)
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 13:32:07 +01:00
|
|
|
void DoCheckFiles(QFileDialog::FileMode mode);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Get all files recursively from given path
|
|
|
|
*
|
|
|
|
* @param path Path to get files from
|
|
|
|
* @return List of file paths
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 13:32:07 +01:00
|
|
|
QStringList GetFilesRecursively(const QString &path);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
2009-06-22 10:57:17 +02:00
|
|
|
* @brief Get our default cppcheck settings and read project file.
|
2009-06-01 23:54:21 +02:00
|
|
|
*
|
|
|
|
* @return Default cppcheck settings
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-05-24 10:53:29 +02:00
|
|
|
Settings GetCppcheckSettings();
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Removes all unaccepted (by cppcheck core) files from the list
|
|
|
|
*
|
|
|
|
* @param list List to remove unaccepted files from
|
|
|
|
* @return List of files that are all accepted by cppcheck core
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 13:32:07 +01:00
|
|
|
QStringList RemoveUnacceptedFiles(const QStringList &list);
|
2009-03-01 08:38:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Load program settings
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void LoadSettings();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Save program settings
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void SaveSettings();
|
|
|
|
|
2009-06-22 17:45:48 +02:00
|
|
|
/**
|
|
|
|
* @brief Format main window title.
|
|
|
|
* @param text Text added to end of the title.
|
|
|
|
*/
|
|
|
|
void FormatAndSetTitle(const QString &text = QString());
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Program settings
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QSettings mSettings;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Menu action to exit program
|
|
|
|
*
|
|
|
|
*/
|
2009-03-22 13:32:07 +01:00
|
|
|
QAction mActionExit;
|
2009-03-01 08:38:21 +01:00
|
|
|
|
|
|
|
/**
|
2009-03-22 13:32:07 +01:00
|
|
|
* @brief Menu action to check files
|
2009-03-01 08:38:21 +01:00
|
|
|
*
|
|
|
|
*/
|
2009-03-22 13:32:07 +01:00
|
|
|
QAction mActionCheckFiles;
|
|
|
|
|
2009-03-22 16:42:00 +01:00
|
|
|
/**
|
|
|
|
* @brief Menu action to clear results
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionClearResults;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Menu action to re check
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionReCheck;
|
|
|
|
|
2009-03-22 13:32:07 +01:00
|
|
|
/**
|
|
|
|
* @brief Menu action to check a directory
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionCheckDirectory;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Menu action to open settings dialog
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionSettings;
|
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Action to show errors with type "all"
|
|
|
|
*
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
QAction mActionShowAll;
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Action to show errors with type "security"
|
|
|
|
*
|
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
QAction mActionShowSecurity;
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Action to show errors with type "style"
|
|
|
|
*
|
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
QAction mActionShowStyle;
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Action to show errors with type "unused"
|
|
|
|
*
|
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
QAction mActionShowUnused;
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Action to show errors with type "error"
|
|
|
|
*
|
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
QAction mActionShowErrors;
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Action to check all "show error" menu items
|
|
|
|
*
|
|
|
|
*/
|
2009-05-23 10:17:27 +02:00
|
|
|
QAction mActionShowCheckAll;
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Action to uncheck all "show error" menu items
|
|
|
|
*
|
|
|
|
*/
|
2009-05-23 10:17:27 +02:00
|
|
|
QAction mActionShowUncheckAll;
|
2009-03-22 18:39:44 +01:00
|
|
|
|
2009-06-02 00:26:44 +02:00
|
|
|
/**
|
|
|
|
* @brief Action to collapse all items in the result tree.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionShowCollapseAll;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Action to expand all items in the result tree.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionShowExpandAll;
|
|
|
|
|
2009-05-24 10:53:29 +02:00
|
|
|
/**
|
2009-06-14 11:57:43 +02:00
|
|
|
* @brief Action to show about dialog
|
2009-05-24 10:53:29 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionAbout;
|
|
|
|
|
2009-06-14 11:57:43 +02:00
|
|
|
/**
|
|
|
|
* @brief Action to show license text
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionShowLicense;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Action to show authors list
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionShowAuthors;
|
|
|
|
|
2009-05-26 17:21:39 +02:00
|
|
|
/**
|
|
|
|
* @brief Action stop checking files
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionStop;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Action save found errors to a file
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QAction mActionSave;
|
2009-03-22 18:39:44 +01:00
|
|
|
|
2009-03-01 21:44:42 +01:00
|
|
|
/**
|
|
|
|
* @brief Results for checking
|
|
|
|
*
|
2009-03-01 08:38:21 +01:00
|
|
|
*/
|
|
|
|
ResultsView mResults;
|
|
|
|
|
2009-03-01 21:44:42 +01:00
|
|
|
/**
|
|
|
|
* @brief Thread to check files
|
|
|
|
*
|
2009-03-01 08:38:21 +01:00
|
|
|
*/
|
2009-06-20 18:55:23 +02:00
|
|
|
ThreadHandler *mThread;
|
2009-03-01 08:38:21 +01:00
|
|
|
|
2009-06-01 23:54:21 +02:00
|
|
|
/**
|
|
|
|
* @brief List of user defined applications to open errors with
|
|
|
|
*
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-05-23 12:37:30 +02:00
|
|
|
ApplicationList mApplications;
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
private:
|
2009-06-22 10:57:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Current checked directory.
|
|
|
|
*/
|
|
|
|
QString mCurrentDirectory;
|
2009-03-01 08:38:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|