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()
|
void ResultView::initConnections()
|
||||||
{
|
{
|
||||||
connect(this, &ResultView::startSearch, [ = ](const QString &keyword) {
|
connect(this, &ResultView::startSearch, [ = ](const QString &keyword) {
|
||||||
|
|
|
@ -33,6 +33,10 @@ public Q_SLOTS:
|
||||||
const bool &isExpanded();
|
const bool &isExpanded();
|
||||||
void onMenuTriggered(QAction *);
|
void onMenuTriggered(QAction *);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initConnections();
|
void initConnections();
|
||||||
SearchResultModel * m_model = nullptr;
|
SearchResultModel * m_model = nullptr;
|
||||||
|
@ -40,6 +44,7 @@ private:
|
||||||
bool m_is_selected = false;
|
bool m_is_selected = false;
|
||||||
ResultViewDelegate * m_style_delegate = nullptr;
|
ResultViewDelegate * m_style_delegate = nullptr;
|
||||||
int m_count = 0;
|
int m_count = 0;
|
||||||
|
QModelIndex m_mousePressIndex;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void startSearch(const QString &);
|
void startSearch(const QString &);
|
||||||
|
|
Loading…
Reference in New Issue