Made several functions in GUI static or const

Fixed cppcheck message about wrong order in initializer list
This commit is contained in:
PKEuS 2012-10-27 12:10:32 +02:00
parent c56170acfa
commit fc78cac797
16 changed files with 45 additions and 46 deletions

View File

@ -97,7 +97,7 @@ bool ApplicationList::LoadSettings()
return succeeded;
}
void ApplicationList::SaveSettings()
void ApplicationList::SaveSettings() const
{
QSettings settings;
QStringList names;

View File

@ -48,7 +48,7 @@ public:
/**
* @brief Save all applications
*/
void SaveSettings();
void SaveSettings() const;
/**
* @brief Get the amount of applications in the list

View File

@ -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.

View File

@ -82,7 +82,7 @@ public:
* @brief Get filename for the project file.
* @return file name.
*/
QString GetFilename() {
QString GetFilename() const {
return mFilename;
}

View File

@ -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());

View File

@ -167,7 +167,7 @@ protected:
/**
* @brief Load dialog settings.
*/
void SaveSettings();
void SaveSettings() const;
/**
* @brief Add new indlude directory.

View File

@ -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<QStandardItem *> 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);

View File

@ -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;
/**

View File

@ -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());
}

View File

@ -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.

View File

@ -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]);

View File

@ -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?

View File

@ -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());
}

View File

@ -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

View File

@ -123,7 +123,7 @@ void ThreadResult::ClearFiles()
mTotalFiles = 0;
}
int ThreadResult::GetFileCount()
int ThreadResult::GetFileCount() const
{
QMutexLocker locker(&mutex);
return mFiles.size();

View File

@ -62,7 +62,7 @@ public:
* @brief Get the number of files to check
*
*/
int GetFileCount();
int GetFileCount() const;
/**
* ErrorLogger methods