added clear selection to YACReaderTreeView if a mouse click is received in a place without a valid model index

This commit is contained in:
Luis Ángel San Martín 2014-11-12 15:58:13 +01:00
parent fdf0a2d047
commit e5a48915d5
2 changed files with 13 additions and 1 deletions

View File

@ -91,6 +91,18 @@ YACReaderTreeView::YACReaderTreeView(QWidget *parent) :
} }
void YACReaderTreeView::mousePressEvent(QMouseEvent *event)
{
QTreeView::mousePressEvent(event);
QModelIndex destinationIndex = indexAt(event->pos());
if(!destinationIndex.isValid() && event->button() == Qt::LeftButton)
{
clearSelection();
}
}
void YACReaderTreeView::expandCurrent() void YACReaderTreeView::expandCurrent()
{ {
QModelIndex index = indexAt(expandPos); QModelIndex index = indexAt(expandPos);

View File

@ -8,7 +8,7 @@ class YACReaderTreeView : public QTreeView
Q_OBJECT Q_OBJECT
public: public:
explicit YACReaderTreeView(QWidget *parent = 0); explicit YACReaderTreeView(QWidget *parent = 0);
void mousePressEvent(QMouseEvent *event);
protected slots: protected slots:
//fix for drop auto expand //fix for drop auto expand
void expandCurrent(); void expandCurrent();