From 060131df2f0c91b1b3379dec96eef8da0499048a Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Mon, 22 Nov 2010 23:13:12 +0200 Subject: [PATCH 1/7] GUI: Add own panel for detailed error messages. This commit adds new rich text panel for the detailed error messages. When user clicks error item the detailed error text is updated to the panel. This way we have much more freedom in formatting the message and user can easily copy/paste (parts of) the message. --- gui/resultsview.cpp | 15 +++++++++++ gui/resultsview.h | 7 +++++ gui/resultsview.ui | 63 ++++++++++++++++++++++++++++++--------------- 3 files changed, 64 insertions(+), 21 deletions(-) diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 12786743c..64fa367ab 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -33,6 +33,7 @@ ResultsView::ResultsView(QWidget * parent) : mShowNoErrorsMessage(true) { mUI.setupUi(this); + connect(mUI.mTree, SIGNAL(clicked(const QModelIndex &)), this, SLOT(ItemClicked(const QModelIndex &))); } void ResultsView::Initialize(QSettings *settings, ApplicationList *list) @@ -253,3 +254,17 @@ void ResultsView::ReadErrorsXml(const QString &filename) } mUI.mTree->SetCheckDirectory(""); } + +void ResultsView::ItemClicked(const QModelIndex &index) +{ + QStandardItemModel *model = qobject_cast(mUI.mTree->model()); + QStandardItem *item = model->itemFromIndex(index); + + // Make sure we are working with the first column + if (item->parent() && item->column() != 0) + item = item->parent()->child(item->row(), 0); + + QVariantMap data = item->data().toMap(); + QString message = data["message"].toString(); + mUI.mDetails->setText(message); +} diff --git a/gui/resultsview.h b/gui/resultsview.h index 59ac1f7d6..c82ec0ae6 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -178,6 +178,13 @@ public slots: */ void ShowHiddenResults(); + /** + * @brief Update detailed message when item is clicked. + * + * @param index Position of item clicked. + */ + void ItemClicked(const QModelIndex &index); + protected: /** * @brief Have any errors been found diff --git a/gui/resultsview.ui b/gui/resultsview.ui index 4d2223665..54897b86c 100644 --- a/gui/resultsview.ui +++ b/gui/resultsview.ui @@ -30,27 +30,44 @@ 0 - - - - 0 - 0 - - - - 24 - - - - - - - - 0 - 0 - - - + + + + + + 0 + 0 + + + + 24 + + + + + + + Qt::Vertical + + + + + 0 + 0 + + + + + + false + + + true + + + + + @@ -61,6 +78,10 @@
resultstree.h
+ + mTree + mDetails + From 20334815c67d88aa057ab33254cdbe130123afda Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Mon, 22 Nov 2010 23:32:04 +0200 Subject: [PATCH 2/7] GUI: Remove Message-column from the error tree view. The full detailed message is shown in the own panel below error tree. --- gui/resultstree.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 48784b95d..be92ef1f6 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -53,7 +53,7 @@ ResultsTree::ResultsTree(QWidget * parent) : setModel(&mModel); QStringList labels; - labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary") << tr("Message"); + labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary"); mModel.setHorizontalHeaderLabels(labels); setExpandsOnDoubleClick(false); setSortingEnabled(true); @@ -191,7 +191,6 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent, //TODO message has parameter names so we'll need changes to the core //cppcheck so we can get proper translations list << CreateNormalItem(tr(item.summary.toLatin1())); - list << CreateNormalItem(tr(item.message.toLatin1())); // Check for duplicate rows and don't add them if found for (int i = 0; i < parent->rowCount(); i++) @@ -210,20 +209,15 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent, // the fourth column is the summary so check it last if (parent->child(i, 3)->text() == list[3]->text()) { - - // the fifth column is the message so check it last - if (parent->child(i, 4)->text() == list[4]->text()) - { #if defined(_WIN32) - const QString first = parent->child(i, 0)->text().toLower(); - const QString second = list[0]->text().toLower(); - if (first == second) - return 0; -#else - // this row matches so don't add it + const QString first = parent->child(i, 0)->text().toLower(); + const QString second = list[0]->text().toLower(); + if (first == second) return 0; +#else + // this row matches so don't add it + return 0; #endif // _WIN32 - } } } } @@ -940,7 +934,7 @@ bool ResultsTree::HasResults() const void ResultsTree::Translate() { QStringList labels; - labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary") << tr("Message"); + labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary"); mModel.setHorizontalHeaderLabels(labels); //TODO go through all the errors in the tree and translate severity and message } From 74c15d436b82aeef20480417efb062bc6c98d1ac Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 23 Nov 2010 00:37:29 +0200 Subject: [PATCH 3/7] GUI: Add missing include lines. --- gui/resultsview.cpp | 5 +++++ gui/resultsview.h | 1 + 2 files changed, 6 insertions(+) diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 64fa367ab..494b1cb45 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -19,6 +19,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "erroritem.h" #include "resultsview.h" #include "resultstree.h" diff --git a/gui/resultsview.h b/gui/resultsview.h index c82ec0ae6..d957cea9d 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -29,6 +29,7 @@ #include "ui_resultsview.h" class ErrorItem; +class QModelIndex; /// @addtogroup GUI /// @{ From 81a599e2600ae6f8ff22b76b8c85fc71b35c6296 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 23 Nov 2010 21:32:35 +0200 Subject: [PATCH 4/7] GUI: Rename the splitter widget. --- gui/resultsview.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/resultsview.ui b/gui/resultsview.ui index 54897b86c..532a873df 100644 --- a/gui/resultsview.ui +++ b/gui/resultsview.ui @@ -45,7 +45,7 @@ - + Qt::Vertical From f1b511a3663c8057d066230a9c42af024878de61 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 23 Nov 2010 21:57:16 +0200 Subject: [PATCH 5/7] GUI: Remember main window splitter state. Save and restore the vertical splitter state (sizes of tree view and details panel). --- gui/common.h | 1 + gui/mainwindow.cpp | 2 +- gui/resultsview.cpp | 10 ++++++++-- gui/resultsview.h | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gui/common.h b/gui/common.h index e7e419d99..6c4a436ef 100644 --- a/gui/common.h +++ b/gui/common.h @@ -65,6 +65,7 @@ ShowTypes; #define SETTINGS_TOOLBARS_VIEW_SHOW "Toolbars/ShowView" #define SETTINGS_LOG_VIEW_WIDTH "Log/View width" #define SETTINGS_LOG_VIEW_HEIGHT "Log/View height" +#define SETTINGS_MAINWND_SPLITTER_STATE "Mainwindow/Vertical splitter state" /// @} #endif diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 63be090a7..6e49a1123 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -206,7 +206,7 @@ void MainWindow::SaveSettings() mApplications->SaveSettings(mSettings); mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->GetCurrentLanguage()); - mUI.mResults->SaveSettings(); + mUI.mResults->SaveSettings(mSettings); } void MainWindow::DoCheckFiles(const QStringList &files) diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 494b1cb45..02f1514e6 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "erroritem.h" #include "resultsview.h" #include "resultstree.h" @@ -43,9 +44,11 @@ ResultsView::ResultsView(QWidget * parent) : void ResultsView::Initialize(QSettings *settings, ApplicationList *list) { - mUI.mProgress->setMinimum(0); mUI.mProgress->setVisible(false); + + QByteArray state = settings->value(SETTINGS_MAINWND_SPLITTER_STATE).toByteArray(); + mUI.mVerticalSplitter->restoreState(state); mShowNoErrorsMessage = settings->value(SETTINGS_SHOW_NO_ERRORS, true).toBool(); mUI.mTree->Initialize(settings, list); @@ -210,9 +213,12 @@ bool ResultsView::HasResults() const return mUI.mTree->HasResults(); } -void ResultsView::SaveSettings() +void ResultsView::SaveSettings(QSettings *settings) { mUI.mTree->SaveSettings(); + QByteArray state = mUI.mVerticalSplitter->saveState(); + settings->setValue(SETTINGS_MAINWND_SPLITTER_STATE, state); + mUI.mVerticalSplitter->restoreState(state); } void ResultsView::Translate() diff --git a/gui/resultsview.h b/gui/resultsview.h index d957cea9d..413a2b0df 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -30,6 +30,7 @@ class ErrorItem; class QModelIndex; +class QSettings; /// @addtogroup GUI /// @{ @@ -121,8 +122,9 @@ public: /** * @brief Save View's settings * + * @param settings program settings. */ - void SaveSettings(); + void SaveSettings(QSettings *settings); /** * @brief Translate this view From 0da55d64777a42b5e470a6c3ec3409ccdac29f04 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 23 Nov 2010 22:37:31 +0200 Subject: [PATCH 6/7] GUI: Improve updating details view. After previous patches the details view was only updated when the item was clicked with mouse. This patch improves the updating and now it works also when changing selected item using keyboard. --- gui/resultstree.cpp | 6 ++++++ gui/resultstree.h | 20 ++++++++++++++++++++ gui/resultsview.cpp | 6 ++---- gui/resultsview.h | 6 +++--- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index be92ef1f6..fd35673a9 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include "erroritem.h" #include "settings.h" #include "applicationlist.h" @@ -939,3 +940,8 @@ void ResultsTree::Translate() //TODO go through all the errors in the tree and translate severity and message } +void ResultsTree::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) +{ + QTreeView::currentChanged(current, previous); + emit SelectionChanged(current); +} diff --git a/gui/resultstree.h b/gui/resultstree.h index 3c807f4ca..df787eac4 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -32,6 +32,8 @@ class Report; class ErrorItem; class ErrorLine; +class QModelIndex; +class QWidget; /// @addtogroup GUI /// @{ @@ -122,6 +124,16 @@ public: * */ void Translate(); + +signals: + + /** + * @brief Signal for selection change in result tree. + * + * @param index Model index to specify new selected item. + */ + void SelectionChanged(const QModelIndex ¤t); + protected slots: /** * @brief Slot to quickstart an error with default application @@ -161,6 +173,14 @@ protected slots: */ void HideResult(); + /** + * @brief Slot for selection change in the results tree. + * + * @param index Model index to specify new selected item. + * @param index Model index to specify previous selected item. + */ + virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); + protected: /** diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 02f1514e6..6ed83c413 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -39,7 +39,7 @@ ResultsView::ResultsView(QWidget * parent) : mShowNoErrorsMessage(true) { mUI.setupUi(this); - connect(mUI.mTree, SIGNAL(clicked(const QModelIndex &)), this, SLOT(ItemClicked(const QModelIndex &))); + connect(mUI.mTree, SIGNAL(SelectionChanged(const QModelIndex &)), this, SLOT(UpdateDetails(const QModelIndex &))); } void ResultsView::Initialize(QSettings *settings, ApplicationList *list) @@ -54,13 +54,11 @@ void ResultsView::Initialize(QSettings *settings, ApplicationList *list) mUI.mTree->Initialize(settings, list); } - ResultsView::~ResultsView() { //dtor } - void ResultsView::Clear() { mUI.mTree->Clear(); @@ -266,7 +264,7 @@ void ResultsView::ReadErrorsXml(const QString &filename) mUI.mTree->SetCheckDirectory(""); } -void ResultsView::ItemClicked(const QModelIndex &index) +void ResultsView::UpdateDetails(const QModelIndex &index) { QStandardItemModel *model = qobject_cast(mUI.mTree->model()); QStandardItem *item = model->itemFromIndex(index); diff --git a/gui/resultsview.h b/gui/resultsview.h index 413a2b0df..15067d64f 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -182,11 +182,11 @@ public slots: void ShowHiddenResults(); /** - * @brief Update detailed message when item is clicked. + * @brief Update detailed message when selected item is changed. * - * @param index Position of item clicked. + * @param index Position of new selected item. */ - void ItemClicked(const QModelIndex &index); + void UpdateDetails(const QModelIndex &index); protected: /** From c6046b6663209770a00964e9a7bf405a5eda9fa5 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Wed, 24 Nov 2010 17:09:02 +0200 Subject: [PATCH 7/7] GUI: Clear the details panel when starting new check. --- gui/resultsview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 6ed83c413..8a505cfc0 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -62,6 +62,7 @@ ResultsView::~ResultsView() void ResultsView::Clear() { mUI.mTree->Clear(); + mUI.mDetails->setText(""); mErrorsFound = false; //Clear the progressbar