diff --git a/gui/common.h b/gui/common.h index c4fd7c070..132f6b3db 100644 --- a/gui/common.h +++ b/gui/common.h @@ -48,6 +48,7 @@ ShowTypes; #define SETTINGS_CHECK_THREADS "Check threads" #define SETTINGS_SHOW_FULL_PATH "Show full path" #define SETTINGS_SHOW_NO_ERRORS "Show no errors message" +#define SETTINGS_SHOW_DEBUG_WARNINGS "Show debug warnings" #define SETTINGS_SAVE_ALL_ERRORS "Save all errors" #define SETTINGS_SAVE_FULL_PATH "Save full path" #define SETTINGS_CHECK_DIALOG_WIDTH "Check dialog width" diff --git a/gui/erroritem.cpp b/gui/erroritem.cpp index bb2eb219b..280617494 100644 --- a/gui/erroritem.cpp +++ b/gui/erroritem.cpp @@ -37,3 +37,12 @@ ErrorItem::ErrorItem(const ErrorLine &line) severity = line.severity; msg = line.msg; } + +QString ErrorItem::ToString() const +{ + QString str = file + " - " + id + " - " + severity +"\n"; + str += " " + msg; + for (int i = 0; i < files.size(); i++) + str += " " + files[i] + ": " + lines[i] + "\n"; + return str; +} diff --git a/gui/erroritem.h b/gui/erroritem.h index 692e6d888..281f01bfb 100644 --- a/gui/erroritem.h +++ b/gui/erroritem.h @@ -39,6 +39,12 @@ public: ErrorItem(const ErrorLine &line); ~ErrorItem() { } + /** + * @brief Convert error item to string. + * @return Error item as string. + */ + QString ToString() const; + QString file; QStringList files; QList lines; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 7a7b9cea0..1f5a814b3 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -361,7 +361,7 @@ Settings MainWindow::GetCppcheckSettings() } result.debug = false; - result.debugwarnings = false; + result.debugwarnings = mSettings->value(SETTINGS_SHOW_DEBUG_WARNINGS, 0).toBool(); result._checkCodingStyle = true; result._errorsOnly = false; result._verbose = true; @@ -819,6 +819,14 @@ void MainWindow::Log(const QString &logline) } } +void MainWindow::DebugError(const ErrorItem &item) +{ + if (mLogView) + { + mLogView->AppendLine(item.ToString()); + } +} + void MainWindow::EnableProjectActions(bool enable) { mUI.mActionCloseProjectFile->setEnabled(enable); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index b166f71ae..23daa9a85 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -36,6 +36,7 @@ class ThreadHandler; class LogView; class HelpWindow; class Project; +class ErrorItem; /// @addtogroup GUI /// @{ @@ -218,6 +219,12 @@ protected slots: */ void Log(const QString &logline); + /** + * @brief Handle new debug error. + * + */ + void DebugError(const ErrorItem &item); + protected: /** diff --git a/gui/settings.ui b/gui/settings.ui index 315264fe3..97c831249 100644 --- a/gui/settings.ui +++ b/gui/settings.ui @@ -7,7 +7,7 @@ 0 0 589 - 274 + 281 @@ -17,7 +17,7 @@ - 1 + 0 @@ -61,6 +61,13 @@ + + + + Show internal warnings in log + + + @@ -164,6 +171,22 @@ + + tabWidget + mJobs + mForce + mShowFullPath + mShowNoErrorsMessage + mShowDebugWarnings + mListWidget + mButtonAdd + mButtonDelete + mButtonModify + mButtonDefault + mSaveAllErrors + mSaveFullPath + mButtons + diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index 713398cb6..93977beb3 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -46,7 +46,7 @@ SettingsDialog::SettingsDialog(QSettings *programSettings, mUI.mForce->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_CHECK_FORCE, false).toBool())); mUI.mShowFullPath->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool())); mUI.mShowNoErrorsMessage->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_NO_ERRORS, false).toBool())); - + mUI.mShowDebugWarnings->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_DEBUG_WARNINGS, false).toBool())); connect(mUI.mButtonAdd, SIGNAL(clicked()), this, SLOT(AddApplication())); @@ -122,6 +122,7 @@ void SettingsDialog::SaveCheckboxValues() SaveCheckboxValue(mUI.mSaveFullPath, SETTINGS_SAVE_FULL_PATH); SaveCheckboxValue(mUI.mShowFullPath, SETTINGS_SHOW_FULL_PATH); SaveCheckboxValue(mUI.mShowNoErrorsMessage, SETTINGS_SHOW_NO_ERRORS); + SaveCheckboxValue(mUI.mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS); } void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name) diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index 9b1bca96f..6a8c0196c 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -146,6 +146,9 @@ void ThreadHandler::Initialize(ResultsView *view) connect(&mResults, SIGNAL(Log(const QString &)), parent(), SLOT(Log(const QString &))); + + connect(&mResults, SIGNAL(Error(const ErrorItem &)), + parent(), SLOT(Error(const ErrorItem &))); } void ThreadHandler::LoadSettings(QSettings &settings) diff --git a/gui/threadresult.cpp b/gui/threadresult.cpp index ad249936b..428303d00 100644 --- a/gui/threadresult.cpp +++ b/gui/threadresult.cpp @@ -71,7 +71,10 @@ void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg) item.msg = QString(msg._msg.c_str()); item.severity = QString::fromStdString(Severity::toString(msg._severity)); - emit Error(item); + if (msg._severity != Severity::debug) + emit Error(item); + else + emit DebugError(item); } QString ThreadResult::GetNextFile() diff --git a/gui/threadresult.h b/gui/threadresult.h index 80133a90e..978b3a118 100644 --- a/gui/threadresult.h +++ b/gui/threadresult.h @@ -100,6 +100,13 @@ signals: */ void Log(const QString &logline); + /** + * @brief Signal of a debug error + * + * @param item Error data + */ + void DebugError(const ErrorItem &item); + protected: /**