Optionally display error Id in additional column and details view (#3526)

This commit is contained in:
PKEuS 2012-10-27 11:16:52 +02:00
parent 8750c93a7a
commit 7ffffdfc16
9 changed files with 75 additions and 15 deletions

View File

@ -76,6 +76,7 @@
#define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions" #define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions"
#define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors" #define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors"
#define SETTINGS_MRU_PROJECTS "MRU Projects" #define SETTINGS_MRU_PROJECTS "MRU Projects"
#define SETTINGS_DISPLAY_ERROR_ID "Show error Id"
// The maximum value for the progress bar // The maximum value for the progress bar
#define PROGRESS_MAX 1024.0 #define PROGRESS_MAX 1024.0

View File

@ -604,7 +604,8 @@ void MainWindow::ProgramSettings()
mUI.mResults->UpdateSettings(dialog.ShowFullPath(), mUI.mResults->UpdateSettings(dialog.ShowFullPath(),
dialog.SaveFullPath(), dialog.SaveFullPath(),
dialog.SaveAllErrors(), dialog.SaveAllErrors(),
dialog.ShowNoErrorsMessage()); dialog.ShowNoErrorsMessage(),
dialog.ShowErrorId());
const QString newLang = mSettings->value(SETTINGS_LANGUAGE, "en").toString(); const QString newLang = mSettings->value(SETTINGS_LANGUAGE, "en").toString();
SetLanguage(newLang); SetLanguage(newLang);
} }

View File

@ -48,12 +48,11 @@ ResultsTree::ResultsTree(QWidget * parent) :
QTreeView(parent), QTreeView(parent),
mContextItem(0), mContextItem(0),
mVisibleErrors(false), mVisibleErrors(false),
mShowErrorId(false),
mSelectionModel(0) mSelectionModel(0)
{ {
setModel(&mModel); setModel(&mModel);
QStringList labels; Translate(); // Adds columns to grid
labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary");
mModel.setHorizontalHeaderLabels(labels);
setExpandsOnDoubleClick(false); setExpandsOnDoubleClick(false);
setSortingEnabled(true); setSortingEnabled(true);
@ -198,6 +197,7 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
const QString severity = SeverityToTranslatedString(item.severity); const QString severity = SeverityToTranslatedString(item.severity);
list << CreateNormalItem(severity); list << CreateNormalItem(severity);
list << CreateLineNumberItem(QString("%1").arg(item.line)); list << CreateLineNumberItem(QString("%1").arg(item.line));
list << CreateNormalItem(item.errorId);
//TODO message has parameter names so we'll need changes to the core //TODO message has parameter names so we'll need changes to the core
//cppcheck so we can get proper translations //cppcheck so we can get proper translations
QString summary; QString summary;
@ -314,14 +314,15 @@ void ResultsTree::Clear(const QString &filename)
void ResultsTree::LoadSettings() void ResultsTree::LoadSettings()
{ {
for (int i = 0; i < mModel.columnCount(); i++) { for (int i = 0; i < mModel.columnCount(); i++) {
//mFileTree.columnWidth(i);
QString temp = QString(SETTINGS_RESULT_COLUMN_WIDTH).arg(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(); mSaveFullPath = mSettings->value(SETTINGS_SAVE_FULL_PATH, false).toBool();
mSaveAllErrors = mSettings->value(SETTINGS_SAVE_ALL_ERRORS, false).toBool(); mSaveAllErrors = mSettings->value(SETTINGS_SAVE_ALL_ERRORS, false).toBool();
mShowFullPath = mSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool(); mShowFullPath = mSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool();
ShowIdColumn(mSettings->value(SETTINGS_SHOW_ERROR_ID, false).toBool());
} }
void ResultsTree::SaveSettings() void ResultsTree::SaveSettings()
@ -866,7 +867,8 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item)
void ResultsTree::UpdateSettings(bool showFullPath, void ResultsTree::UpdateSettings(bool showFullPath,
bool saveFullPath, bool saveFullPath,
bool saveAllErrors) bool saveAllErrors,
bool showErrorId)
{ {
if (mShowFullPath != showFullPath) { if (mShowFullPath != showFullPath) {
mShowFullPath = showFullPath; mShowFullPath = showFullPath;
@ -875,6 +877,8 @@ void ResultsTree::UpdateSettings(bool showFullPath,
mSaveFullPath = saveFullPath; mSaveFullPath = saveFullPath;
mSaveAllErrors = saveAllErrors; mSaveAllErrors = saveAllErrors;
ShowIdColumn(showErrorId);
} }
void ResultsTree::SetCheckDirectory(const QString &dir) void ResultsTree::SetCheckDirectory(const QString &dir)
@ -974,11 +978,20 @@ bool ResultsTree::HasResults() const
void ResultsTree::Translate() void ResultsTree::Translate()
{ {
QStringList labels; 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); mModel.setHorizontalHeaderLabels(labels);
//TODO go through all the errors in the tree and translate severity and message //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 &current, const QModelIndex &previous) void ResultsTree::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{ {
QTreeView::currentChanged(current, previous); QTreeView::currentChanged(current, previous);

View File

@ -103,8 +103,9 @@ public:
* @param showFullPath Show full path of files in the tree * @param showFullPath Show full path of files in the tree
* @param saveFullPath Save full path of files in reports * @param saveFullPath Save full path of files in reports
* @param saveAllErrors Save all visible errors * @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 * @brief Set the directory we are checking
@ -138,6 +139,18 @@ public:
*/ */
void Translate(); 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. * @brief GUI severities.
*/ */
@ -403,6 +416,12 @@ protected:
*/ */
bool mSaveAllErrors; bool mSaveAllErrors;
/**
* @brief true if optional column "Id" is shown
*
*/
bool mShowErrorId;
/** /**
* @brief Path we are currently checking * @brief Path we are currently checking
* *

View File

@ -180,9 +180,10 @@ void ResultsView::Save(const QString &filename, Report::Type type)
void ResultsView::UpdateSettings(bool showFullPath, void ResultsView::UpdateSettings(bool showFullPath,
bool saveFullPath, bool saveFullPath,
bool saveAllErrors, bool saveAllErrors,
bool showNoErrorsMessage) bool showNoErrorsMessage,
bool showErrorId)
{ {
mUI.mTree->UpdateSettings(showFullPath, saveFullPath, saveAllErrors); mUI.mTree->UpdateSettings(showFullPath, saveFullPath, saveAllErrors, showErrorId);
mShowNoErrorsMessage = showNoErrorsMessage; mShowNoErrorsMessage = showNoErrorsMessage;
} }
@ -325,8 +326,10 @@ void ResultsView::UpdateDetails(const QModelIndex &index)
const QString summary = data["summary"].toString(); const QString summary = data["summary"].toString();
const QString message = data["message"].toString(); const QString message = data["message"].toString();
const QString formattedMsg = QString("%1: %2\n%3: %4") QString formattedMsg = QString("%1: %2\n%3: %4")
.arg(tr("Summary")).arg(summary) .arg(tr("Summary")).arg(summary)
.arg(tr("Message")).arg(message); .arg(tr("Message")).arg(message);
if (mUI.mTree->ShowIdColumn())
formattedMsg.prepend(tr("Id") + ": " + data["id"].toString() + "\n");
mUI.mDetails->setText(formattedMsg); mUI.mDetails->setText(formattedMsg);
} }

View File

@ -82,11 +82,13 @@ public:
* @param saveFullPath Save full path of files in reports * @param saveFullPath Save full path of files in reports
* @param saveAllErrors Save all visible errors * @param saveAllErrors Save all visible errors
* @param showNoErrorsMessage Show "no errors"? * @param showNoErrorsMessage Show "no errors"?
* @param showErrorId Show error id?
*/ */
void UpdateSettings(bool showFullPath, void UpdateSettings(bool showFullPath,
bool saveFullPath, bool saveFullPath,
bool saveAllErrors, bool saveAllErrors,
bool showNoErrorsMessage); bool showNoErrorsMessage,
bool showErrorId);
/** /**
* @brief Set the directory we are checking * @brief Set the directory we are checking

View File

@ -129,6 +129,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="mShowErrorId">
<property name="text">
<string>Display error Id in column &quot;Id&quot;</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="mInlineSuppressions"> <widget class="QCheckBox" name="mInlineSuppressions">
<property name="text"> <property name="text">

View File

@ -51,6 +51,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
mUI.mSaveFullPath->setCheckState(BoolToCheckState(settings.value(SETTINGS_SAVE_FULL_PATH, false).toBool())); mUI.mSaveFullPath->setCheckState(BoolToCheckState(settings.value(SETTINGS_SAVE_FULL_PATH, false).toBool()));
mUI.mInlineSuppressions->setCheckState(BoolToCheckState(settings.value(SETTINGS_INLINE_SUPPRESSIONS, 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.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(accepted()), this, SLOT(Ok()));
connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject())); 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.mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS);
SaveCheckboxValue(&settings, mUI.mInlineSuppressions, SETTINGS_INLINE_SUPPRESSIONS); SaveCheckboxValue(&settings, mUI.mInlineSuppressions, SETTINGS_INLINE_SUPPRESSIONS);
SaveCheckboxValue(&settings, mUI.mEnableInconclusive, SETTINGS_INCONCLUSIVE_ERRORS); SaveCheckboxValue(&settings, mUI.mEnableInconclusive, SETTINGS_INCONCLUSIVE_ERRORS);
SaveCheckboxValue(&settings, mUI.mShowErrorId, SETTINGS_SHOW_ERROR_ID);
QListWidgetItem *currentLang = mUI.mListLanguages->currentItem(); QListWidgetItem *currentLang = mUI.mListLanguages->currentItem();
const QString langcode = currentLang->data(LangCodeRole).toString(); const QString langcode = currentLang->data(LangCodeRole).toString();
@ -302,6 +304,11 @@ bool SettingsDialog::ShowNoErrorsMessage()
return CheckStateToBool(mUI.mShowNoErrorsMessage->checkState()); return CheckStateToBool(mUI.mShowNoErrorsMessage->checkState());
} }
bool SettingsDialog::ShowErrorId()
{
return CheckStateToBool(mUI.mShowErrorId->checkState());
}
void SettingsDialog::AddIncludePath() void SettingsDialog::AddIncludePath()
{ {
QString selectedDir = QFileDialog::getExistingDirectory(this, QString selectedDir = QFileDialog::getExistingDirectory(this,

View File

@ -71,6 +71,13 @@ public:
*/ */
bool ShowNoErrorsMessage(); bool ShowNoErrorsMessage();
/**
* @brief Get checkbox value for mShowIdColumn
*
* @return Should error id column be displayed
*/
bool ShowErrorId();
/** /**
* @brief Get checkbox value for mSaveAllErrors * @brief Get checkbox value for mSaveAllErrors
* *