From fc78cac79787e35f7b8ada75430219c8225815da Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 27 Oct 2012 12:10:32 +0200 Subject: [PATCH] Made several functions in GUI static or const Fixed cppcheck message about wrong order in initializer list --- gui/applicationlist.cpp | 2 +- gui/applicationlist.h | 2 +- gui/filelist.h | 2 +- gui/projectfile.h | 2 +- gui/projectfiledialog.cpp | 2 +- gui/projectfiledialog.h | 2 +- gui/resultstree.cpp | 12 ++++++------ gui/resultstree.h | 16 ++++++++-------- gui/settingsdialog.cpp | 18 +++++++++--------- gui/settingsdialog.h | 20 ++++++++++---------- gui/showtypes.cpp | 2 +- gui/showtypes.h | 2 +- gui/threadhandler.cpp | 3 +-- gui/threadhandler.h | 2 +- gui/threadresult.cpp | 2 +- gui/threadresult.h | 2 +- 16 files changed, 45 insertions(+), 46 deletions(-) diff --git a/gui/applicationlist.cpp b/gui/applicationlist.cpp index a08ab25ac..a8541cb0c 100644 --- a/gui/applicationlist.cpp +++ b/gui/applicationlist.cpp @@ -97,7 +97,7 @@ bool ApplicationList::LoadSettings() return succeeded; } -void ApplicationList::SaveSettings() +void ApplicationList::SaveSettings() const { QSettings settings; QStringList names; diff --git a/gui/applicationlist.h b/gui/applicationlist.h index 5b86f97af..57ffff412 100644 --- a/gui/applicationlist.h +++ b/gui/applicationlist.h @@ -48,7 +48,7 @@ public: /** * @brief Save all applications */ - void SaveSettings(); + void SaveSettings() const; /** * @brief Get the amount of applications in the list diff --git a/gui/filelist.h b/gui/filelist.h index 8e3e03c13..fddf4a43e 100644 --- a/gui/filelist.h +++ b/gui/filelist.h @@ -80,7 +80,7 @@ protected: * @brief Test if filename matches the filename extensions filtering. * @return true if filename matches filtering. */ - bool FilterMatches(const QFileInfo &inf); + static bool FilterMatches(const QFileInfo &inf); /** * @brief Get filtered list of paths. diff --git a/gui/projectfile.h b/gui/projectfile.h index ca2be76f2..2384948e8 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -82,7 +82,7 @@ public: * @brief Get filename for the project file. * @return file name. */ - QString GetFilename() { + QString GetFilename() const { return mFilename; } diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index ea9007c2a..208e09b5d 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -65,7 +65,7 @@ void ProjectFileDialog::LoadSettings() settings.value(SETTINGS_PROJECT_DIALOG_HEIGHT, 330).toInt()); } -void ProjectFileDialog::SaveSettings() +void ProjectFileDialog::SaveSettings() const { QSettings settings; settings.setValue(SETTINGS_PROJECT_DIALOG_WIDTH, size().width()); diff --git a/gui/projectfiledialog.h b/gui/projectfiledialog.h index 702b434da..573e2156c 100644 --- a/gui/projectfiledialog.h +++ b/gui/projectfiledialog.h @@ -167,7 +167,7 @@ protected: /** * @brief Load dialog settings. */ - void SaveSettings(); + void SaveSettings() const; /** * @brief Add new indlude directory. diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index f50c3d866..4a294d838 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -47,8 +47,8 @@ ResultsTree::ResultsTree(QWidget * parent) : QTreeView(parent), mContextItem(0), - mVisibleErrors(false), mShowErrorId(false), + mVisibleErrors(false), mSelectionModel(0) { setModel(&mModel); @@ -278,7 +278,7 @@ QString ResultsTree::SeverityToTranslatedString(Severity::SeverityType severity) } } -QStandardItem *ResultsTree::FindFileItem(const QString &name) +QStandardItem *ResultsTree::FindFileItem(const QString &name) const { QList list = mModel.findItems(name); if (list.size() > 0) { @@ -325,7 +325,7 @@ void ResultsTree::LoadSettings() ShowIdColumn(mSettings->value(SETTINGS_SHOW_ERROR_ID, false).toBool()); } -void ResultsTree::SaveSettings() +void ResultsTree::SaveSettings() const { for (int i = 0; i < mModel.columnCount(); i++) { QString temp = QString(SETTINGS_RESULT_COLUMN_WIDTH).arg(i); @@ -799,7 +799,7 @@ QString ResultsTree::SeverityToIcon(Severity::SeverityType severity) const } } -void ResultsTree::SaveResults(Report *report) +void ResultsTree::SaveResults(Report *report) const { report->WriteHeader(); @@ -812,7 +812,7 @@ void ResultsTree::SaveResults(Report *report) report->WriteFooter(); } -void ResultsTree::SaveErrors(Report *report, QStandardItem *item) +void ResultsTree::SaveErrors(Report *report, QStandardItem *item) const { if (!item) { return; @@ -886,7 +886,7 @@ void ResultsTree::SetCheckDirectory(const QString &dir) mCheckPath = dir; } -QString ResultsTree::StripPath(const QString &path, bool saving) +QString ResultsTree::StripPath(const QString &path, bool saving) const { if ((!saving && mShowFullPath) || (saving && mSaveFullPath)) { return QString(path); diff --git a/gui/resultstree.h b/gui/resultstree.h index c9e2ca929..48693210e 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -95,7 +95,7 @@ public: * @brief Save results to a text stream * */ - void SaveResults(Report *report); + void SaveResults(Report *report) const; /** * @brief Update tree settings @@ -131,7 +131,7 @@ public: * @brief Save all settings * Column widths */ - void SaveSettings(); + void SaveSettings() const; /** * @brief Change all visible texts language @@ -241,7 +241,7 @@ protected: * @param saving are we saving? Check mSaveFullPath instead * @return Path that has checking directory removed */ - QString StripPath(const QString &path, bool saving); + QString StripPath(const QString &path, bool saving) const; /** @@ -249,7 +249,7 @@ protected: * @param report Report that errors are saved to * @param item Item whose errors to save */ - void SaveErrors(Report *report, QStandardItem *item); + void SaveErrors(Report *report, QStandardItem *item) const; /** * @brief Convert a severity string to a icon filename @@ -309,7 +309,7 @@ protected: * @param severity Severity to convert * @return Severity as translated string */ - QString SeverityToTranslatedString(Severity::SeverityType severity); + static QString SeverityToTranslatedString(Severity::SeverityType severity); /** * @brief Load all settings @@ -331,7 +331,7 @@ protected: * @param name name for the item * @return new QStandardItem */ - QStandardItem *CreateNormalItem(const QString &name); + static QStandardItem *CreateNormalItem(const QString &name); /** * @brief Create new line number item. @@ -340,7 +340,7 @@ protected: * @param linenumber name for the item * @return new QStandardItem */ - QStandardItem *CreateLineNumberItem(const QString &linenumber); + static QStandardItem *CreateLineNumberItem(const QString &linenumber); /** * @brief Finds a file item @@ -348,7 +348,7 @@ protected: * @param name name of the file item to find * @return pointer to file item or null if none found */ - QStandardItem *FindFileItem(const QString &name); + QStandardItem *FindFileItem(const QString &name) const; /** diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index 62dac5074..71632dc10 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -125,7 +125,7 @@ void SettingsDialog::InitTranslationsList() } } -Qt::CheckState SettingsDialog::BoolToCheckState(bool yes) const +Qt::CheckState SettingsDialog::BoolToCheckState(bool yes) { if (yes) { return Qt::Checked; @@ -133,7 +133,7 @@ Qt::CheckState SettingsDialog::BoolToCheckState(bool yes) const return Qt::Unchecked; } -bool SettingsDialog::CheckStateToBool(Qt::CheckState state) const +bool SettingsDialog::CheckStateToBool(Qt::CheckState state) { if (state == Qt::Checked) { return true; @@ -149,14 +149,14 @@ void SettingsDialog::LoadSettings() settings.value(SETTINGS_CHECK_DIALOG_HEIGHT, 600).toInt()); } -void SettingsDialog::SaveSettings() +void SettingsDialog::SaveSettings() const { QSettings settings; settings.setValue(SETTINGS_CHECK_DIALOG_WIDTH, size().width()); settings.setValue(SETTINGS_CHECK_DIALOG_HEIGHT, size().height()); } -void SettingsDialog::SaveSettingValues() +void SettingsDialog::SaveSettingValues() const { int jobs = mUI.mJobs->text().toInt(); if (jobs <= 0) { @@ -281,27 +281,27 @@ void SettingsDialog::Ok() accept(); } -bool SettingsDialog::ShowFullPath() +bool SettingsDialog::ShowFullPath() const { return CheckStateToBool(mUI.mShowFullPath->checkState()); } -bool SettingsDialog::SaveFullPath() +bool SettingsDialog::SaveFullPath() const { return CheckStateToBool(mUI.mSaveFullPath->checkState()); } -bool SettingsDialog::SaveAllErrors() +bool SettingsDialog::SaveAllErrors() const { return CheckStateToBool(mUI.mSaveAllErrors->checkState()); } -bool SettingsDialog::ShowNoErrorsMessage() +bool SettingsDialog::ShowNoErrorsMessage() const { return CheckStateToBool(mUI.mShowNoErrorsMessage->checkState()); } -bool SettingsDialog::ShowErrorId() +bool SettingsDialog::ShowErrorId() const { return CheckStateToBool(mUI.mShowErrorId->checkState()); } diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h index bfd5e1873..42fae86f3 100644 --- a/gui/settingsdialog.h +++ b/gui/settingsdialog.h @@ -47,21 +47,21 @@ public: * @brief Save all values to QSettings * */ - void SaveSettingValues(); + void SaveSettingValues() const; /** * @brief Get checkbox value for mShowFullPath * * @return should full path of errors be shown in the tree */ - bool ShowFullPath(); + bool ShowFullPath() const; /** * @brief Get checkbox value for mSaveFullPath * * @return should full path of files be saved when creating a report */ - bool SaveFullPath(); + bool SaveFullPath() const; /** @@ -69,21 +69,21 @@ public: * * @return Should "no errors message" be hidden */ - bool ShowNoErrorsMessage(); + bool ShowNoErrorsMessage() const; /** * @brief Get checkbox value for mShowIdColumn * * @return Should error id column be displayed */ - bool ShowErrorId(); + bool ShowErrorId() const; /** * @brief Get checkbox value for mSaveAllErrors * * @return should all errors be saved to report */ - bool SaveAllErrors(); + bool SaveAllErrors() const; protected slots: /** @@ -154,7 +154,7 @@ protected: * Loads dialog size and column widths. * */ - void SaveSettings(); + void SaveSettings() const; /** * @brief Save settings @@ -170,7 +170,7 @@ protected: * @param box checkbox to save * @param name name for QSettings to store the value */ - void SaveCheckboxValue(QSettings *settings, QCheckBox *box, const QString &name); + static void SaveCheckboxValue(QSettings *settings, QCheckBox *box, const QString &name); /** * @brief Convert bool to Qt::CheckState @@ -178,7 +178,7 @@ protected: * @param yes value to convert * @return value converted to Qt::CheckState */ - Qt::CheckState BoolToCheckState(bool yes) const; + static Qt::CheckState BoolToCheckState(bool yes); /** * @brief Converts Qt::CheckState to bool @@ -186,7 +186,7 @@ protected: * @param state Qt::CheckState to convert * @return converted value */ - bool CheckStateToBool(Qt::CheckState state) const; + static bool CheckStateToBool(Qt::CheckState state); /** * @brief Populate the include paths-list. diff --git a/gui/showtypes.cpp b/gui/showtypes.cpp index de06c3450..08db152b1 100644 --- a/gui/showtypes.cpp +++ b/gui/showtypes.cpp @@ -100,7 +100,7 @@ void ShowTypes::load() mVisible[ShowInformation] = settings.value(SETTINGS_SHOW_INFORMATION, true).toBool(); } -void ShowTypes::save() +void ShowTypes::save() const { QSettings settings; settings.setValue(SETTINGS_SHOW_STYLE, mVisible[ShowStyle]); diff --git a/gui/showtypes.h b/gui/showtypes.h index ba24e7073..6066ef284 100644 --- a/gui/showtypes.h +++ b/gui/showtypes.h @@ -70,7 +70,7 @@ public: /** * @brief Save visibility settings to the platform's settings storage. */ - void save(); + void save() const; /** * @brief Is the showtype visible in the GUI? diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index cf56eb717..95b55a76f 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -150,7 +150,6 @@ void ThreadHandler::Stop() void ThreadHandler::Initialize(ResultsView *view) { - connect(&mResults, SIGNAL(Progress(int, const QString&)), view, SLOT(Progress(int, const QString&))); @@ -169,7 +168,7 @@ void ThreadHandler::LoadSettings(QSettings &settings) SetThreadCount(settings.value(SETTINGS_CHECK_THREADS, 1).toInt()); } -void ThreadHandler::SaveSettings(QSettings &settings) +void ThreadHandler::SaveSettings(QSettings &settings) const { settings.setValue(SETTINGS_CHECK_THREADS, mThreads.size()); } diff --git a/gui/threadhandler.h b/gui/threadhandler.h index 646a38cef..8125cccba 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -68,7 +68,7 @@ public: * @brief Save settings * @param settings QSettings to save settings to */ - void SaveSettings(QSettings &settings); + void SaveSettings(QSettings &settings) const; /** * @brief Clear all files from cppcheck diff --git a/gui/threadresult.cpp b/gui/threadresult.cpp index 670fddf3b..117624c41 100644 --- a/gui/threadresult.cpp +++ b/gui/threadresult.cpp @@ -123,7 +123,7 @@ void ThreadResult::ClearFiles() mTotalFiles = 0; } -int ThreadResult::GetFileCount() +int ThreadResult::GetFileCount() const { QMutexLocker locker(&mutex); return mFiles.size(); diff --git a/gui/threadresult.h b/gui/threadresult.h index 945d258da..3daf42702 100644 --- a/gui/threadresult.h +++ b/gui/threadresult.h @@ -62,7 +62,7 @@ public: * @brief Get the number of files to check * */ - int GetFileCount(); + int GetFileCount() const; /** * ErrorLogger methods