Skip to content

Commit 0da55d6

Browse files
committed
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.
1 parent f1b511a commit 0da55d6

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

gui/resultstree.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <QFileDialog>
3737
#include <QClipboard>
3838
#include <QContextMenuEvent>
39+
#include <QModelIndex>
3940
#include "erroritem.h"
4041
#include "settings.h"
4142
#include "applicationlist.h"
@@ -939,3 +940,8 @@ void ResultsTree::Translate()
939940
//TODO go through all the errors in the tree and translate severity and message
940941
}
941942

943+
void ResultsTree::currentChanged(const QModelIndex &current, const QModelIndex &previous)
944+
{
945+
QTreeView::currentChanged(current, previous);
946+
emit SelectionChanged(current);
947+
}

gui/resultstree.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
class Report;
3333
class ErrorItem;
3434
class ErrorLine;
35+
class QModelIndex;
36+
class QWidget;
3537

3638
/// @addtogroup GUI
3739
/// @{
@@ -122,6 +124,16 @@ class ResultsTree : public QTreeView
122124
*
123125
*/
124126
void Translate();
127+
128+
signals:
129+
130+
/**
131+
* @brief Signal for selection change in result tree.
132+
*
133+
* @param index Model index to specify new selected item.
134+
*/
135+
void SelectionChanged(const QModelIndex &current);
136+
125137
protected slots:
126138
/**
127139
* @brief Slot to quickstart an error with default application
@@ -161,6 +173,14 @@ protected slots:
161173
*/
162174
void HideResult();
163175

176+
/**
177+
* @brief Slot for selection change in the results tree.
178+
*
179+
* @param index Model index to specify new selected item.
180+
* @param index Model index to specify previous selected item.
181+
*/
182+
virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
183+
164184
protected:
165185

166186
/**

gui/resultsview.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ResultsView::ResultsView(QWidget * parent) :
3939
mShowNoErrorsMessage(true)
4040
{
4141
mUI.setupUi(this);
42-
connect(mUI.mTree, SIGNAL(clicked(const QModelIndex &)), this, SLOT(ItemClicked(const QModelIndex &)));
42+
connect(mUI.mTree, SIGNAL(SelectionChanged(const QModelIndex &)), this, SLOT(UpdateDetails(const QModelIndex &)));
4343
}
4444

4545
void ResultsView::Initialize(QSettings *settings, ApplicationList *list)
@@ -54,13 +54,11 @@ void ResultsView::Initialize(QSettings *settings, ApplicationList *list)
5454
mUI.mTree->Initialize(settings, list);
5555
}
5656

57-
5857
ResultsView::~ResultsView()
5958
{
6059
//dtor
6160
}
6261

63-
6462
void ResultsView::Clear()
6563
{
6664
mUI.mTree->Clear();
@@ -266,7 +264,7 @@ void ResultsView::ReadErrorsXml(const QString &filename)
266264
mUI.mTree->SetCheckDirectory("");
267265
}
268266

269-
void ResultsView::ItemClicked(const QModelIndex &index)
267+
void ResultsView::UpdateDetails(const QModelIndex &index)
270268
{
271269
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(mUI.mTree->model());
272270
QStandardItem *item = model->itemFromIndex(index);

gui/resultsview.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ public slots:
182182
void ShowHiddenResults();
183183

184184
/**
185-
* @brief Update detailed message when item is clicked.
185+
* @brief Update detailed message when selected item is changed.
186186
*
187-
* @param index Position of item clicked.
187+
* @param index Position of new selected item.
188188
*/
189-
void ItemClicked(const QModelIndex &index);
189+
void UpdateDetails(const QModelIndex &index);
190190

191191
protected:
192192
/**

0 commit comments

Comments
 (0)