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;