Optionally display error Id in additional column and details view (#3526)
This commit is contained in:
parent
8750c93a7a
commit
7ffffdfc16
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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")
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -129,6 +129,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mShowErrorId">
|
||||
<property name="text">
|
||||
<string>Display error Id in column "Id"</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mInlineSuppressions">
|
||||
<property name="text">
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue