From 25c18aa4f0171bb4d72f528dde9de7dc9cd8acbd Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Fri, 26 Feb 2021 11:42:40 +0800 Subject: [PATCH] fix(frontend): Two list items can be selected simultaneously. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 修复可以同时选中两个列表项的bug Log: 修复可以同时选中两个列表项的bug Bug: http://172.17.66.192/biz/bug-view-40056.html --- src/control/search-list-view.cpp | 4 +++- src/control/search-list-view.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/control/search-list-view.cpp b/src/control/search-list-view.cpp index 4f82f6c..9922615 100644 --- a/src/control/search-list-view.cpp +++ b/src/control/search-list-view.cpp @@ -47,6 +47,7 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const m_type = type; connect(this->selectionModel(), &QItemSelectionModel::selectionChanged, this, [ = ]() { Q_EMIT this->currentRowChanged(getCurrentType(), m_item->m_pathlist.at(this->currentIndex().row())); + m_isSelected = true; }); } @@ -78,7 +79,7 @@ void SearchListView::setList(QStringList list) { QModelIndex index = this->currentIndex(); m_model->setList(list); - if (index.row() >= 0 && index.row() < list.length()) { + if (index.row() >= 0 && index.row() < list.length() && m_isSelected) { this->blockSignals(true); this->setCurrentIndex(index); this->blockSignals(false); @@ -184,4 +185,5 @@ int SearchListView::getResType(const QString& path) { */ void SearchListView::clearSelection() { this->selectionModel()->clearSelection(); + m_isSelected = false; } diff --git a/src/control/search-list-view.h b/src/control/search-list-view.h index 50e7df2..e636648 100644 --- a/src/control/search-list-view.h +++ b/src/control/search-list-view.h @@ -61,6 +61,7 @@ public: private: SearchItemModel * m_model = nullptr; SearchItem * m_item = nullptr; + bool m_isSelected = false; HighlightItemDelegate * m_styleDelegate = nullptr;