Fix multiple widget selection bug;
This commit is contained in:
parent
d1c65e08d5
commit
9ea51f22ad
|
@ -278,6 +278,21 @@ void ResultView::onMenuTriggered(QAction *action)
|
|||
}
|
||||
}
|
||||
|
||||
void ResultView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePressIndex = indexAt(event->pos());
|
||||
return QTreeView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void ResultView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
QModelIndex index = indexAt(event->pos());
|
||||
if (!index.isValid() or index != m_mousePressIndex) {
|
||||
this->clearSelection();
|
||||
}
|
||||
return QTreeView::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void ResultView::initConnections()
|
||||
{
|
||||
connect(this, &ResultView::startSearch, [ = ](const QString &keyword) {
|
||||
|
|
|
@ -33,6 +33,10 @@ public Q_SLOTS:
|
|||
const bool &isExpanded();
|
||||
void onMenuTriggered(QAction *);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void initConnections();
|
||||
SearchResultModel * m_model = nullptr;
|
||||
|
@ -40,6 +44,7 @@ private:
|
|||
bool m_is_selected = false;
|
||||
ResultViewDelegate * m_style_delegate = nullptr;
|
||||
int m_count = 0;
|
||||
QModelIndex m_mousePressIndex;
|
||||
|
||||
Q_SIGNALS:
|
||||
void startSearch(const QString &);
|
||||
|
|
Loading…
Reference in New Issue