From b47720396e8ea5302f20adf22485f26d10a4aba0 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Wed, 12 May 2021 15:40:57 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20Seletion=20is=20cleared=20when=20palette?= =?UTF-8?q?d=20changed.=20=E4=BF=AE=E5=A4=8D=E6=94=B6=E5=88=B0palettechang?= =?UTF-8?q?ed=E4=BF=A1=E5=8F=B7=E6=97=B6=E5=88=97=E8=A1=A8=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E7=8A=B6=E6=80=81=E6=B6=88=E5=A4=B1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/control/search-list-view.cpp | 6 ++++++ src/model/search-item-model.cpp | 5 +++++ src/model/search-item-model.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/control/search-list-view.cpp b/src/control/search-list-view.cpp index 2cbb308..e4611e7 100644 --- a/src/control/search-list-view.cpp +++ b/src/control/search-list-view.cpp @@ -128,7 +128,13 @@ void SearchListView::clear() { */ void SearchListView::refresh() { + QModelIndex index = this->currentIndex(); m_model->refresh(); + if(index.row() >= 0 && index.row() < m_model->length() && m_isSelected) { + this->blockSignals(true); + this->setCurrentIndex(index); + this->blockSignals(false); + } rowheight = this->rowHeight(this->model()->index(0, 0, QModelIndex())) + 1; this->setFixedHeight(m_item->getCurrentSize() * rowheight + 4); } diff --git a/src/model/search-item-model.cpp b/src/model/search-item-model.cpp index 264fe74..66e2cee 100644 --- a/src/model/search-item-model.cpp +++ b/src/model/search-item-model.cpp @@ -186,3 +186,8 @@ void SearchItemModel::refresh() this->beginResetModel(); this->endResetModel(); } + +int SearchItemModel::length() +{ + return m_item->m_pathlist.length(); +} diff --git a/src/model/search-item-model.h b/src/model/search-item-model.h index 8104566..396c77e 100644 --- a/src/model/search-item-model.h +++ b/src/model/search-item-model.h @@ -60,6 +60,7 @@ public: void clear(); void setBestAppIcon(const QString &, const bool &); void refresh(); + int length(); private : SearchItem * m_item = nullptr;