diff --git a/gui/common.h b/gui/common.h index 802d7178b..7d0a395d8 100644 --- a/gui/common.h +++ b/gui/common.h @@ -76,6 +76,7 @@ #define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions" #define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors" #define SETTINGS_MRU_PROJECTS "MRU Projects" +#define SETTINGS_DISPLAY_ERROR_ID "Show error Id" // The maximum value for the progress bar #define PROGRESS_MAX 1024.0 diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 30ede824f..85dc241d7 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -604,7 +604,8 @@ void MainWindow::ProgramSettings() mUI.mResults->UpdateSettings(dialog.ShowFullPath(), dialog.SaveFullPath(), dialog.SaveAllErrors(), - dialog.ShowNoErrorsMessage()); + dialog.ShowNoErrorsMessage(), + dialog.ShowErrorId()); const QString newLang = mSettings->value(SETTINGS_LANGUAGE, "en").toString(); SetLanguage(newLang); } diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index f3f76d990..303abe76b 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -48,12 +48,11 @@ ResultsTree::ResultsTree(QWidget * parent) : QTreeView(parent), mContextItem(0), mVisibleErrors(false), + mShowErrorId(false), mSelectionModel(0) { setModel(&mModel); - QStringList labels; - labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary"); - mModel.setHorizontalHeaderLabels(labels); + Translate(); // Adds columns to grid setExpandsOnDoubleClick(false); setSortingEnabled(true); @@ -198,6 +197,7 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent, const QString severity = SeverityToTranslatedString(item.severity); list << CreateNormalItem(severity); list << CreateLineNumberItem(QString("%1").arg(item.line)); + list << CreateNormalItem(item.errorId); //TODO message has parameter names so we'll need changes to the core //cppcheck so we can get proper translations QString summary; @@ -314,14 +314,15 @@ void ResultsTree::Clear(const QString &filename) void ResultsTree::LoadSettings() { for (int i = 0; i < mModel.columnCount(); i++) { - //mFileTree.columnWidth(i); QString temp = QString(SETTINGS_RESULT_COLUMN_WIDTH).arg(i); - setColumnWidth(i, mSettings->value(temp, 800 / mModel.columnCount()).toInt()); + setColumnWidth(i, qMax(20, mSettings->value(temp, 800 / mModel.columnCount()).toInt())); } mSaveFullPath = mSettings->value(SETTINGS_SAVE_FULL_PATH, false).toBool(); mSaveAllErrors = mSettings->value(SETTINGS_SAVE_ALL_ERRORS, false).toBool(); mShowFullPath = mSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool(); + + ShowIdColumn(mSettings->value(SETTINGS_SHOW_ERROR_ID, false).toBool()); } void ResultsTree::SaveSettings() @@ -866,7 +867,8 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) void ResultsTree::UpdateSettings(bool showFullPath, bool saveFullPath, - bool saveAllErrors) + bool saveAllErrors, + bool showErrorId) { if (mShowFullPath != showFullPath) { mShowFullPath = showFullPath; @@ -875,6 +877,8 @@ void ResultsTree::UpdateSettings(bool showFullPath, mSaveFullPath = saveFullPath; mSaveAllErrors = saveAllErrors; + + ShowIdColumn(showErrorId); } void ResultsTree::SetCheckDirectory(const QString &dir) @@ -974,11 +978,20 @@ bool ResultsTree::HasResults() const void ResultsTree::Translate() { QStringList labels; - labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary"); + labels << tr("File") << tr("Severity") << tr("Line") << tr("Id") << tr("Summary"); mModel.setHorizontalHeaderLabels(labels); //TODO go through all the errors in the tree and translate severity and message } +void ResultsTree::ShowIdColumn(bool show) +{ + mShowErrorId = show; + if (show) + showColumn(3); + else + hideColumn(3); +} + void ResultsTree::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { QTreeView::currentChanged(current, previous); diff --git a/gui/resultstree.h b/gui/resultstree.h index 680fdbd8a..c9e2ca929 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -103,8 +103,9 @@ public: * @param showFullPath Show full path of files in the tree * @param saveFullPath Save full path of files in reports * @param saveAllErrors Save all visible errors + * @param showErrorId Show error id */ - void UpdateSettings(bool showFullPath, bool saveFullPath, bool saveAllErrors); + void UpdateSettings(bool showFullPath, bool saveFullPath, bool saveAllErrors, bool showErrorId); /** * @brief Set the directory we are checking @@ -138,6 +139,18 @@ public: */ void Translate(); + /** + * @brief Show optional column "Id" + */ + void ShowIdColumn(bool show); + + /** + * @brief Returns true if column "Id" is shown + */ + bool ShowIdColumn() const { + return mShowErrorId; + } + /** * @brief GUI severities. */ @@ -403,6 +416,12 @@ protected: */ bool mSaveAllErrors; + /** + * @brief true if optional column "Id" is shown + * + */ + bool mShowErrorId; + /** * @brief Path we are currently checking * diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 7e576dd23..5540e3be5 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -180,9 +180,10 @@ void ResultsView::Save(const QString &filename, Report::Type type) void ResultsView::UpdateSettings(bool showFullPath, bool saveFullPath, bool saveAllErrors, - bool showNoErrorsMessage) + bool showNoErrorsMessage, + bool showErrorId) { - mUI.mTree->UpdateSettings(showFullPath, saveFullPath, saveAllErrors); + mUI.mTree->UpdateSettings(showFullPath, saveFullPath, saveAllErrors, showErrorId); mShowNoErrorsMessage = showNoErrorsMessage; } @@ -325,8 +326,10 @@ void ResultsView::UpdateDetails(const QModelIndex &index) const QString summary = data["summary"].toString(); const QString message = data["message"].toString(); - const QString formattedMsg = QString("%1: %2\n%3: %4") - .arg(tr("Summary")).arg(summary) - .arg(tr("Message")).arg(message); + QString formattedMsg = QString("%1: %2\n%3: %4") + .arg(tr("Summary")).arg(summary) + .arg(tr("Message")).arg(message); + if (mUI.mTree->ShowIdColumn()) + formattedMsg.prepend(tr("Id") + ": " + data["id"].toString() + "\n"); mUI.mDetails->setText(formattedMsg); } diff --git a/gui/resultsview.h b/gui/resultsview.h index e927dc047..832dc0bc4 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -82,11 +82,13 @@ public: * @param saveFullPath Save full path of files in reports * @param saveAllErrors Save all visible errors * @param showNoErrorsMessage Show "no errors"? + * @param showErrorId Show error id? */ void UpdateSettings(bool showFullPath, bool saveFullPath, bool saveAllErrors, - bool showNoErrorsMessage); + bool showNoErrorsMessage, + bool showErrorId); /** * @brief Set the directory we are checking diff --git a/gui/settings.ui b/gui/settings.ui index 103f8bd05..5bec58ec9 100644 --- a/gui/settings.ui +++ b/gui/settings.ui @@ -129,6 +129,13 @@ + + + + Display error Id in column "Id" + + + diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index 80a1e47e8..fb4062d72 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -51,6 +51,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list, mUI.mSaveFullPath->setCheckState(BoolToCheckState(settings.value(SETTINGS_SAVE_FULL_PATH, false).toBool())); mUI.mInlineSuppressions->setCheckState(BoolToCheckState(settings.value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool())); mUI.mEnableInconclusive->setCheckState(BoolToCheckState(settings.value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool())); + mUI.mShowErrorId->setCheckState(BoolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool())); connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(Ok())); connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject())); @@ -172,6 +173,7 @@ void SettingsDialog::SaveSettingValues() SaveCheckboxValue(&settings, mUI.mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS); SaveCheckboxValue(&settings, mUI.mInlineSuppressions, SETTINGS_INLINE_SUPPRESSIONS); SaveCheckboxValue(&settings, mUI.mEnableInconclusive, SETTINGS_INCONCLUSIVE_ERRORS); + SaveCheckboxValue(&settings, mUI.mShowErrorId, SETTINGS_SHOW_ERROR_ID); QListWidgetItem *currentLang = mUI.mListLanguages->currentItem(); const QString langcode = currentLang->data(LangCodeRole).toString(); @@ -302,6 +304,11 @@ bool SettingsDialog::ShowNoErrorsMessage() return CheckStateToBool(mUI.mShowNoErrorsMessage->checkState()); } +bool SettingsDialog::ShowErrorId() +{ + return CheckStateToBool(mUI.mShowErrorId->checkState()); +} + void SettingsDialog::AddIncludePath() { QString selectedDir = QFileDialog::getExistingDirectory(this, diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h index acbed88ac..bfd5e1873 100644 --- a/gui/settingsdialog.h +++ b/gui/settingsdialog.h @@ -71,6 +71,13 @@ public: */ bool ShowNoErrorsMessage(); + /** + * @brief Get checkbox value for mShowIdColumn + * + * @return Should error id column be displayed + */ + bool ShowErrorId(); + /** * @brief Get checkbox value for mSaveAllErrors *