Skip to content

Commit fc78cac

Browse files
committed
Made several functions in GUI static or const
Fixed cppcheck message about wrong order in initializer list
1 parent c56170a commit fc78cac

16 files changed

Lines changed: 45 additions & 46 deletions

gui/applicationlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ bool ApplicationList::LoadSettings()
9797
return succeeded;
9898
}
9999

100-
void ApplicationList::SaveSettings()
100+
void ApplicationList::SaveSettings() const
101101
{
102102
QSettings settings;
103103
QStringList names;

gui/applicationlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ApplicationList : public QObject {
4848
/**
4949
* @brief Save all applications
5050
*/
51-
void SaveSettings();
51+
void SaveSettings() const;
5252

5353
/**
5454
* @brief Get the amount of applications in the list

gui/filelist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class FileList {
8080
* @brief Test if filename matches the filename extensions filtering.
8181
* @return true if filename matches filtering.
8282
*/
83-
bool FilterMatches(const QFileInfo &inf);
83+
static bool FilterMatches(const QFileInfo &inf);
8484

8585
/**
8686
* @brief Get filtered list of paths.

gui/projectfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ProjectFile : public QObject {
8282
* @brief Get filename for the project file.
8383
* @return file name.
8484
*/
85-
QString GetFilename() {
85+
QString GetFilename() const {
8686
return mFilename;
8787
}
8888

gui/projectfiledialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void ProjectFileDialog::LoadSettings()
6565
settings.value(SETTINGS_PROJECT_DIALOG_HEIGHT, 330).toInt());
6666
}
6767

68-
void ProjectFileDialog::SaveSettings()
68+
void ProjectFileDialog::SaveSettings() const
6969
{
7070
QSettings settings;
7171
settings.setValue(SETTINGS_PROJECT_DIALOG_WIDTH, size().width());

gui/projectfiledialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected slots:
167167
/**
168168
* @brief Load dialog settings.
169169
*/
170-
void SaveSettings();
170+
void SaveSettings() const;
171171

172172
/**
173173
* @brief Add new indlude directory.

gui/resultstree.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
ResultsTree::ResultsTree(QWidget * parent) :
4848
QTreeView(parent),
4949
mContextItem(0),
50-
mVisibleErrors(false),
5150
mShowErrorId(false),
51+
mVisibleErrors(false),
5252
mSelectionModel(0)
5353
{
5454
setModel(&mModel);
@@ -278,7 +278,7 @@ QString ResultsTree::SeverityToTranslatedString(Severity::SeverityType severity)
278278
}
279279
}
280280

281-
QStandardItem *ResultsTree::FindFileItem(const QString &name)
281+
QStandardItem *ResultsTree::FindFileItem(const QString &name) const
282282
{
283283
QList<QStandardItem *> list = mModel.findItems(name);
284284
if (list.size() > 0) {
@@ -325,7 +325,7 @@ void ResultsTree::LoadSettings()
325325
ShowIdColumn(mSettings->value(SETTINGS_SHOW_ERROR_ID, false).toBool());
326326
}
327327

328-
void ResultsTree::SaveSettings()
328+
void ResultsTree::SaveSettings() const
329329
{
330330
for (int i = 0; i < mModel.columnCount(); i++) {
331331
QString temp = QString(SETTINGS_RESULT_COLUMN_WIDTH).arg(i);
@@ -799,7 +799,7 @@ QString ResultsTree::SeverityToIcon(Severity::SeverityType severity) const
799799
}
800800
}
801801

802-
void ResultsTree::SaveResults(Report *report)
802+
void ResultsTree::SaveResults(Report *report) const
803803
{
804804
report->WriteHeader();
805805

@@ -812,7 +812,7 @@ void ResultsTree::SaveResults(Report *report)
812812
report->WriteFooter();
813813
}
814814

815-
void ResultsTree::SaveErrors(Report *report, QStandardItem *item)
815+
void ResultsTree::SaveErrors(Report *report, QStandardItem *item) const
816816
{
817817
if (!item) {
818818
return;
@@ -886,7 +886,7 @@ void ResultsTree::SetCheckDirectory(const QString &dir)
886886
mCheckPath = dir;
887887
}
888888

889-
QString ResultsTree::StripPath(const QString &path, bool saving)
889+
QString ResultsTree::StripPath(const QString &path, bool saving) const
890890
{
891891
if ((!saving && mShowFullPath) || (saving && mSaveFullPath)) {
892892
return QString(path);

gui/resultstree.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class ResultsTree : public QTreeView {
9595
* @brief Save results to a text stream
9696
*
9797
*/
98-
void SaveResults(Report *report);
98+
void SaveResults(Report *report) const;
9999

100100
/**
101101
* @brief Update tree settings
@@ -131,7 +131,7 @@ class ResultsTree : public QTreeView {
131131
* @brief Save all settings
132132
* Column widths
133133
*/
134-
void SaveSettings();
134+
void SaveSettings() const;
135135

136136
/**
137137
* @brief Change all visible texts language
@@ -241,15 +241,15 @@ protected slots:
241241
* @param saving are we saving? Check mSaveFullPath instead
242242
* @return Path that has checking directory removed
243243
*/
244-
QString StripPath(const QString &path, bool saving);
244+
QString StripPath(const QString &path, bool saving) const;
245245

246246

247247
/**
248248
* @brief Save all errors under specified item
249249
* @param report Report that errors are saved to
250250
* @param item Item whose errors to save
251251
*/
252-
void SaveErrors(Report *report, QStandardItem *item);
252+
void SaveErrors(Report *report, QStandardItem *item) const;
253253

254254
/**
255255
* @brief Convert a severity string to a icon filename
@@ -309,7 +309,7 @@ protected slots:
309309
* @param severity Severity to convert
310310
* @return Severity as translated string
311311
*/
312-
QString SeverityToTranslatedString(Severity::SeverityType severity);
312+
static QString SeverityToTranslatedString(Severity::SeverityType severity);
313313

314314
/**
315315
* @brief Load all settings
@@ -331,7 +331,7 @@ protected slots:
331331
* @param name name for the item
332332
* @return new QStandardItem
333333
*/
334-
QStandardItem *CreateNormalItem(const QString &name);
334+
static QStandardItem *CreateNormalItem(const QString &name);
335335

336336
/**
337337
* @brief Create new line number item.
@@ -340,15 +340,15 @@ protected slots:
340340
* @param linenumber name for the item
341341
* @return new QStandardItem
342342
*/
343-
QStandardItem *CreateLineNumberItem(const QString &linenumber);
343+
static QStandardItem *CreateLineNumberItem(const QString &linenumber);
344344

345345
/**
346346
* @brief Finds a file item
347347
*
348348
* @param name name of the file item to find
349349
* @return pointer to file item or null if none found
350350
*/
351-
QStandardItem *FindFileItem(const QString &name);
351+
QStandardItem *FindFileItem(const QString &name) const;
352352

353353

354354
/**

gui/settingsdialog.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ void SettingsDialog::InitTranslationsList()
125125
}
126126
}
127127

128-
Qt::CheckState SettingsDialog::BoolToCheckState(bool yes) const
128+
Qt::CheckState SettingsDialog::BoolToCheckState(bool yes)
129129
{
130130
if (yes) {
131131
return Qt::Checked;
132132
}
133133
return Qt::Unchecked;
134134
}
135135

136-
bool SettingsDialog::CheckStateToBool(Qt::CheckState state) const
136+
bool SettingsDialog::CheckStateToBool(Qt::CheckState state)
137137
{
138138
if (state == Qt::Checked) {
139139
return true;
@@ -149,14 +149,14 @@ void SettingsDialog::LoadSettings()
149149
settings.value(SETTINGS_CHECK_DIALOG_HEIGHT, 600).toInt());
150150
}
151151

152-
void SettingsDialog::SaveSettings()
152+
void SettingsDialog::SaveSettings() const
153153
{
154154
QSettings settings;
155155
settings.setValue(SETTINGS_CHECK_DIALOG_WIDTH, size().width());
156156
settings.setValue(SETTINGS_CHECK_DIALOG_HEIGHT, size().height());
157157
}
158158

159-
void SettingsDialog::SaveSettingValues()
159+
void SettingsDialog::SaveSettingValues() const
160160
{
161161
int jobs = mUI.mJobs->text().toInt();
162162
if (jobs <= 0) {
@@ -281,27 +281,27 @@ void SettingsDialog::Ok()
281281
accept();
282282
}
283283

284-
bool SettingsDialog::ShowFullPath()
284+
bool SettingsDialog::ShowFullPath() const
285285
{
286286
return CheckStateToBool(mUI.mShowFullPath->checkState());
287287
}
288288

289-
bool SettingsDialog::SaveFullPath()
289+
bool SettingsDialog::SaveFullPath() const
290290
{
291291
return CheckStateToBool(mUI.mSaveFullPath->checkState());
292292
}
293293

294-
bool SettingsDialog::SaveAllErrors()
294+
bool SettingsDialog::SaveAllErrors() const
295295
{
296296
return CheckStateToBool(mUI.mSaveAllErrors->checkState());
297297
}
298298

299-
bool SettingsDialog::ShowNoErrorsMessage()
299+
bool SettingsDialog::ShowNoErrorsMessage() const
300300
{
301301
return CheckStateToBool(mUI.mShowNoErrorsMessage->checkState());
302302
}
303303

304-
bool SettingsDialog::ShowErrorId()
304+
bool SettingsDialog::ShowErrorId() const
305305
{
306306
return CheckStateToBool(mUI.mShowErrorId->checkState());
307307
}

gui/settingsdialog.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,43 +47,43 @@ class SettingsDialog : public QDialog {
4747
* @brief Save all values to QSettings
4848
*
4949
*/
50-
void SaveSettingValues();
50+
void SaveSettingValues() const;
5151

5252
/**
5353
* @brief Get checkbox value for mShowFullPath
5454
*
5555
* @return should full path of errors be shown in the tree
5656
*/
57-
bool ShowFullPath();
57+
bool ShowFullPath() const;
5858

5959
/**
6060
* @brief Get checkbox value for mSaveFullPath
6161
*
6262
* @return should full path of files be saved when creating a report
6363
*/
64-
bool SaveFullPath();
64+
bool SaveFullPath() const;
6565

6666

6767
/**
6868
* @brief Get checkbox value for mNoErrorsMessage
6969
*
7070
* @return Should "no errors message" be hidden
7171
*/
72-
bool ShowNoErrorsMessage();
72+
bool ShowNoErrorsMessage() const;
7373

7474
/**
7575
* @brief Get checkbox value for mShowIdColumn
7676
*
7777
* @return Should error id column be displayed
7878
*/
79-
bool ShowErrorId();
79+
bool ShowErrorId() const;
8080

8181
/**
8282
* @brief Get checkbox value for mSaveAllErrors
8383
*
8484
* @return should all errors be saved to report
8585
*/
86-
bool SaveAllErrors();
86+
bool SaveAllErrors() const;
8787

8888
protected slots:
8989
/**
@@ -154,7 +154,7 @@ protected slots:
154154
* Loads dialog size and column widths.
155155
*
156156
*/
157-
void SaveSettings();
157+
void SaveSettings() const;
158158

159159
/**
160160
* @brief Save settings
@@ -170,23 +170,23 @@ protected slots:
170170
* @param box checkbox to save
171171
* @param name name for QSettings to store the value
172172
*/
173-
void SaveCheckboxValue(QSettings *settings, QCheckBox *box, const QString &name);
173+
static void SaveCheckboxValue(QSettings *settings, QCheckBox *box, const QString &name);
174174

175175
/**
176176
* @brief Convert bool to Qt::CheckState
177177
*
178178
* @param yes value to convert
179179
* @return value converted to Qt::CheckState
180180
*/
181-
Qt::CheckState BoolToCheckState(bool yes) const;
181+
static Qt::CheckState BoolToCheckState(bool yes);
182182

183183
/**
184184
* @brief Converts Qt::CheckState to bool
185185
*
186186
* @param state Qt::CheckState to convert
187187
* @return converted value
188188
*/
189-
bool CheckStateToBool(Qt::CheckState state) const;
189+
static bool CheckStateToBool(Qt::CheckState state);
190190

191191
/**
192192
* @brief Populate the include paths-list.

0 commit comments

Comments
 (0)