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 e17fe89a4..b3087d367 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -207,7 +207,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/resultstree.cpp b/gui/resultstree.cpp index a4f75d635..c9c10545b 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" @@ -53,7 +54,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 +192,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 +210,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 - } } } } @@ -942,8 +937,13 @@ 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 } +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 971b8969b..538d4ce97 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 /// @{ @@ -131,6 +133,13 @@ signals: */ void ResultsHidden(bool hidden); + /** + * @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 @@ -170,6 +179,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 e067a4a08..d09d650a2 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -19,6 +19,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include "erroritem.h" #include "resultsview.h" #include "resultstree.h" @@ -35,28 +41,30 @@ ResultsView::ResultsView(QWidget * parent) : mUI.setupUi(this); connect(mUI.mTree, SIGNAL(ResultsHidden(bool)), this, SIGNAL(ResultsHidden(bool))); + connect(mUI.mTree, SIGNAL(SelectionChanged(const QModelIndex &)), this, SLOT(UpdateDetails(const QModelIndex &))); } 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); } - ResultsView::~ResultsView() { //dtor } - void ResultsView::Clear() { mUI.mTree->Clear(); + mUI.mDetails->setText(""); mErrorsFound = false; //Clear the progressbar @@ -206,9 +214,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() @@ -255,3 +266,17 @@ void ResultsView::ReadErrorsXml(const QString &filename) } mUI.mTree->SetCheckDirectory(""); } + +void ResultsView::UpdateDetails(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 f390e7358..26ef17b77 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -29,6 +29,8 @@ #include "ui_resultsview.h" class ErrorItem; +class QModelIndex; +class QSettings; /// @addtogroup GUI /// @{ @@ -120,8 +122,9 @@ public: /** * @brief Save View's settings * + * @param settings program settings. */ - void SaveSettings(); + void SaveSettings(QSettings *settings); /** * @brief Translate this view @@ -184,6 +187,13 @@ public slots: */ void ShowHiddenResults(); + /** + * @brief Update detailed message when selected item is changed. + * + * @param index Position of new selected item. + */ + void UpdateDetails(const QModelIndex &index); + protected: /** * @brief Have any errors been found diff --git a/gui/resultsview.ui b/gui/resultsview.ui index 4d2223665..532a873df 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 +