Added more comments to class members and methods.

This commit is contained in:
Vesa Pikki 2009-05-23 19:29:24 +03:00
parent 2b7bf671d7
commit 2d8b08d4ab
11 changed files with 504 additions and 33 deletions

View File

@ -25,6 +25,7 @@
#include <QFileDialog>
#include <QDebug>
ApplicationDialog::ApplicationDialog(const QString &name,
const QString &path,
const QString &title)

View File

@ -23,21 +23,62 @@
#include <QDialog>
#include <QLineEdit>
/**
* @brief Dialog to edit a startable application.
* User can open errors with user specified applications. This is a dialog
* to modify/add an application to open errors with.
*
*/
class ApplicationDialog : public QDialog
{
Q_OBJECT
public:
/**
* @brief Constructor
*
* @param name Default name for the application to start
* @param path Path for the application
* @param title Title for the dialog
*/
ApplicationDialog(const QString &name,
const QString &path,
const QString &title);
virtual ~ApplicationDialog();
/**
* @brief Get modified name
* This is just a name to display the application. This has nothing to do
* with executing the application.
*
* @return Modified name
*/
QString GetName();
/**
* @brief Get modified path
* This also contains all parameters user wants to specify.
* @return Modified path
*/
QString GetPath();
protected slots:
/**
* @brief Slot to browse for an application
*
*/
void Browse();
protected:
/**
* @brief Editbox for the application's name
* This is just a name to display the application. This has nothing to do
* with executing the application.
*/
QLineEdit *mName;
/**
* @brief Editbox for the application's path
* This also contains all parameters user wants to specify.
*/
QLineEdit *mPath;
private:
};

View File

@ -24,40 +24,126 @@
#include <QSettings>
/**
* @brief List of applications user has specified to open errors with
* Each application has a name and a path. Name is displayed to the user
* and has no other meaning. It isn't used to start the application.
* Path contains the path to the application as well as the executable itself and
* any possible argument user might want to specify.
*
* User can also specify certain predefined strings to path. These strings
* will be replaced with appropriate values concerning the error. Strings are:
* (file) - Filename containing the error
* (line) - Line number containing the error
* (message) - Error message
* (severity) - Error severity
*
* Example opening a file with Kate and make Kate scroll to the corret line:
* kate -l(line) (file)
*
*/
class ApplicationList : public QObject
{
public:
/**
* @brief Struct containing information of the application
*
*/
typedef struct
{
/**
* @brief Applicaton's name
*
*/
QString Name;
/**
* @brief Application's path and commandline arguments
*
*/
QString Path;
}ApplicationType;
ApplicationList();
virtual ~ApplicationList();
/**
* @brief Load all applications
*
* @param programSettings QSettings to load application list from
*/
void LoadSettings(QSettings &programSettings);
/**
* @brief Save all applications
* @param programSettings QSettings to save applications to
*/
void SaveSettings(QSettings &programSettings);
/**
* @brief Get the amount of applications in the list
* @return The count of applications
*/
int GetApplicationCount();
QString GetApplicationName(const int index);
/**
* @brief Get spesific application's name
*
* @param index Index of the application whose name to get
* @return Name of the application
*/
QString GetApplicationName(const int index);
QString GetApplicationPath(const int index);
/**
* @brief Get Application's path
*
* @param index of the application whose path to get
* @return Application's path
*/
QString GetApplicationPath(const int index);
void SetApplicationType(const int index,
/**
* @brief Modify an application
*
* @param index Index of the application to modify
* @param name New name for the application
* @param path New path for the application
*/
void SetApplicationType(const int index,
const QString &name,
const QString &path);
/**
* @brief Add a new application
*
* @param name Name of the application
* @param path Path to the application
*/
void AddApplicationType(const QString &name, const QString &path);
/**
* @brief Remove an application from the list
*
* @param index Index of the application to remove.
*/
void RemoveApplication(const int index);
/**
* @brief Move certain application as first.
* Position of the application is used by the application to determine
* which of the applications is the default application. First application
* (index 0) is the default application.
*
* @param index Index of the application to make the default one
*/
void MoveFirst(const int index);
protected:
/**
* @brief List of applications
*
*/
QList<ApplicationType> mApplications;
private:
};

View File

@ -20,7 +20,10 @@
#ifndef COMMON_H
#define COMMON_H
/**
* @brief List of error types to show
*
*/
typedef enum
{
SHOW_ALL = 0,

View File

@ -49,15 +49,57 @@ public slots:
*
*/
void CheckFiles();
/**
* @brief Slot to recheck files
*
*/
void ReCheck();
/**
* @brief Slot to clear all search results
*
*/
void ClearResults();
/**
* @brief Show errors with type "all"
* @param checked Should errors be shown (truw) or hidden (false)
*/
void ShowAll(bool checked);
/**
* @brief Show errors with type "security"
* @param checked Should errors be shown (truw) or hidden (false)
*/
void ShowSecurity(bool checked);
/**
* @brief Show errors with type "style"
* @param checked Should errors be shown (truw) or hidden (false)
*/
void ShowStyle(bool checked);
/**
* @brief Show errors with type "unused"
* @param checked Should errors be shown (truw) or hidden (false)
*/
void ShowUnused(bool checked);
/**
* @brief Show errors with type "error"
* @param checked Should errors be shown (truw) or hidden (false)
*/
void ShowErrors(bool checked);
/**
* @brief Slot to check all "Show errors" menu items
*/
void CheckAll();
/**
* @brief Slot to uncheck all "Show errors" menu items
*/
void UncheckAll();
/**
@ -66,6 +108,10 @@ public slots:
*/
void CheckDirectory();
/**
* @brief Slot to open program's settings dialog
*
*/
void ProgramSettings();
protected slots:
@ -76,11 +122,47 @@ protected slots:
*/
void CheckDone();
protected:
/**
* @brief Helper function to toggle all show error menu items
* @param checked Should all errors be shown (true) or hidden (false)
*/
void ToggleAllChecked(bool checked);
/**
* @brief Helper function to enable/disable all check,recheck buttons
*
*/
void EnableCheckButtons(bool enable);
/**
* @brief Helper function to open a dialog to ask user to select files to check
*
* @param mode Dialog open mode (files or directories)
*/
void DoCheckFiles(QFileDialog::FileMode mode);
/**
* @brief Get all files recursively from given path
*
* @param path Path to get files from
* @return List of file paths
*/
QStringList GetFilesRecursively(const QString &path);
/**
* @brief Get our default cppcheck settings
*
* @return Default cppcheck settings
*/
Settings GetCppCheckSettings();
/**
* @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
*/
QStringList RemoveUnacceptedFiles(const QStringList &list);
/**
@ -138,12 +220,46 @@ protected:
*/
QAction mActionSettings;
/**
* @brief Action to show errors with type "all"
*
*/
QAction mActionShowAll;
/**
* @brief Action to show errors with type "security"
*
*/
QAction mActionShowSecurity;
/**
* @brief Action to show errors with type "style"
*
*/
QAction mActionShowStyle;
/**
* @brief Action to show errors with type "unused"
*
*/
QAction mActionShowUnused;
/**
* @brief Action to show errors with type "error"
*
*/
QAction mActionShowErrors;
/**
* @brief Action to check all "show error" menu items
*
*/
QAction mActionShowCheckAll;
/**
* @brief Action to uncheck all "show error" menu items
*
*/
QAction mActionShowUncheckAll;
@ -160,6 +276,10 @@ protected:
*/
ThreadHandler mThread;
/**
* @brief List of user defined applications to open errors with
*
*/
ApplicationList mApplications;
private:

View File

@ -204,7 +204,6 @@ void ResultsTree::ShowResults(ShowTypes type, bool show)
{
mShowTypes[type] = show;
RefreshTree();
}
}
@ -261,26 +260,6 @@ void ResultsTree::RefreshTree()
}
}
QString ResultsTree::ShowTypeToString(ShowTypes type)
{
switch (type)
{
case SHOW_ALL:
return "all";
case SHOW_ERRORS:
return "error";
case SHOW_STYLE:
return "style";
case SHOW_SECURITY:
return "security";
case SHOW_UNUSED:
return "unused";
case SHOW_NONE:
return "none";
}
return "";
}
QStandardItem *ResultsTree::EnsureFileItem(const QString &name)
{
@ -350,7 +329,6 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
//Start the menu
menu.exec(e->globalPos());
//Disconnect all signals
for (int i = 0;i < actions.size();i++)
{

View File

@ -46,7 +46,9 @@ public:
*
* @param file filename
* @param severity error severity
* @param error error message
* @param message error message
* @param files list of files affected by the error
* @param lines list of file line numers affected by the error
*/
void AddErrorItem(const QString &file,
const QString &severity,
@ -60,9 +62,22 @@ public:
*/
void Clear();
/**
* @brief Function to show/hide certain type of errors
* Refreshes the tree.
*
* @param type Type of error to show/hide
* @param Should specified errors be shown (true) or hidden (false)
*/
void ShowResults(ShowTypes type, bool show);
protected slots:
/**
* @brief Slot to quickstart an error with default application
*
* @param index Model index to specify which error item to open
*/
void QuickStartApplication(const QModelIndex &index);
/**
* @brief Slot for context menu item to open an error with specified application
*
@ -70,9 +85,34 @@ protected slots:
*/
void Context(int application);
protected:
/**
* @brief Helper function to open an error within target with application
*
*
* @param target Error tree item to open
* @param application Index of the application to open with
*/
void StartApplication(QStandardItem *target, int application);
/**
* @brief Context menu event (user right clicked on the tree)
*
* @param e Event
*/
void contextMenuEvent(QContextMenuEvent * e);
/**
* @brief Add a new error item beneath a file or a backtrace item beneath an error
*
* @param parent Parent for the item. Either a file item or an error item
* @param file Filename of the error
* @param line Line numer
* @param severity Error severity
* @param message Error message
* @param hide Should this be hidden (true) or shown (false)
* @return newly created QStandardItem *
*/
QStandardItem *AddBacktraceFiles(QStandardItem *parent,
const QString &file,
const int line,
@ -80,11 +120,28 @@ protected:
const QString &message,
const bool hide);
void AddItem(int index);
/**
* @brief Refresh tree by checking which of the items should be shown
* and which should be hidden
*
*/
void RefreshTree();
/**
* @brief Convert QVariant (that contains an int) to Showtypes value
*
* @param data QVariant (that contains an int) to be converted
* @return data converted to ShowTypes
*/
ShowTypes VariantToShowType(const QVariant &data);
/**
* @brief Convert severity string to ShowTypes value
* @param severity Error severity string
* @return Severity converted to ShowTypes value
*/
ShowTypes SeverityToShowType(const QString &severity);
QString ShowTypeToString(ShowTypes type);
/**
* @brief Load all settings
@ -142,8 +199,17 @@ protected:
*/
QSettings &mSettings;
/**
* @brief List of bools to determine which of ShowTypes to display on the tree
* (true) and which of them should be hidden (false)
*
*/
bool mShowTypes[SHOW_NONE];
/**
* @brief List of applications to open errors with
*
*/
ApplicationList &mApplications;
/**

View File

@ -41,6 +41,13 @@ public:
ResultsView(QSettings &settings, ApplicationList &list);
virtual ~ResultsView();
/**
* @brief Function to show/hide certain type of errors
* Refreshes the tree.
*
* @param type Type of error to show/hide
* @param Should specified errors be shown (true) or hidden (false)
*/
void ShowResults(ShowTypes type, bool show);
/**
@ -49,10 +56,24 @@ public:
*/
void Clear();
public slots:
/**
* Slots for CheckThread's signals
/**
* @brief Slot for updating the checking progress
*
* @param value Current progress value
* @param max Maximum progress value
*/
void Progress(int value, int max);
/**
* @brief Slot for new error to be displayed
*
* @param file filename
* @param severity error severity
* @param message error message
* @param files list of files affected by the error
* @param lines list of file line numers affected by the error
*/
void Error(const QString &file,
const QString &severity,
const QString &message,

View File

@ -44,12 +44,37 @@ class SettingsDialog : public QDialog
public:
SettingsDialog(QSettings &programSettings, ApplicationList &list);
virtual ~SettingsDialog();
/**
* @brief Save all values to QSettings
*
*/
void SaveCheckboxValues();
protected slots:
/**
* @brief Slot for adding a new application to the list
*
*/
void AddApplication();
/**
* @brief Slot for deleting an application from the list
*
*/
void DeleteApplication();
/**
* @brief Slot for modifying an application in the list
*
*/
void ModifyApplication();
/**
* @brief Slot for making the selected application as the default (first)
*
*/
void DefaultApplication();
protected:
void PopulateListWidget();
@ -129,6 +154,11 @@ protected:
*
*/
QSettings &mSettings;
/**
* @brief List of applications user has specified
*
*/
ApplicationList &mApplications;
private:
};

View File

@ -39,9 +39,30 @@ class ThreadHandler : public QObject
public:
ThreadHandler();
virtual ~ThreadHandler();
/**
* @brief Set the number of threads to use
* @param count The number of threads to use
*/
void SetThreadCount(const int count);
/**
* @brief Initialize the threads (connect all signals to resultsview's slots)
*
* @param view View to show error results
*/
void Initialize(ResultsView *view);
/**
* @brief Load settings
* @param settings QSettings to load settings from
*/
void LoadSettings(QSettings &settings);
/**
* @brief Save settings
* @param settings QSettings to save settings to
*/
void SaveSettings(QSettings &settings);
/**
@ -57,19 +78,63 @@ public:
*/
void SetFiles(const QStringList &files);
/**
* @brief Start the threads to check the files
*
* @param settings Settings for checking
* @param recheck Should we reuse the files we checked earleir
*/
void Check(Settings settings, bool recheck);
signals:
/**
* @brief Signal that all threads are done
*
*/
void Done();
protected slots:
/**
* @brief Slot to stop all threads
*
*/
void Stop();
/**
* @brief Slot that a single thread is done
*
*/
void ThreadDone();
protected:
/**
* @brief List of files checked last time (used when rechecking)
*
*/
QStringList mLastFiles;
/**
* @brief Function to delete all threads
*
*/
void RemoveThreads();
/**
* @brief Thread results are stored here
*
*/
ThreadResult mResults;
/**
* @brief List of threads currently in use
*
*/
QList<CheckThread *> mThreads;
/**
* @brief The amount of threads currently running
*
*/
int mRunningThreadCount;
private:
};

View File

@ -37,9 +37,29 @@ class ThreadResult : public QObject, public ErrorLogger
public:
ThreadResult();
virtual ~ThreadResult();
/**
* @brief Get next unprocessed file
* @return File path
*/
QString GetNextFile();
/**
* @brief Set list of files to check
* @param files List of files to check
*/
void SetFiles(const QStringList &files);
/**
* @brief Clear files to check
*
*/
void ClearFiles();
/**
* @brief Get the number of files to check
*
*/
int GetFileCount();
/**
@ -49,9 +69,29 @@ public:
void reportErr(const ErrorLogger::ErrorMessage &msg);
void reportStatus(unsigned int index, unsigned int max);
public slots:
/**
* @brief Slot threads use to signal this class that a spesific file is checked
* @param file File taht is checked
*/
void FileChecked(const QString &file);
signals:
/**
* @brief Progress signal
* @param value Current progress
* @param max Maximum progress
*/
void Progress(int value, int max);
/**
* @brief Signal of a new error
*
* @param file filename
* @param severity error severity
* @param message error message
* @param files list of files affected by the error
* @param lines list of file line numers affected by the error
*/
void Error(const QString &file,
const QString &severity,
const QString &message,
@ -59,9 +99,29 @@ signals:
const QVariantList &lines);
protected:
/**
* @brief Mutex
*
*/
mutable QMutex mutex;
/**
* @brief List of files to check
*
*/
QStringList mFiles;
/**
* @brief Max progress
*
*/
int mMaxProgress;
/**
* @brief Current progress
*
*/
int mProgress;
private:
};