fix(frontend): Selection canceled with 'Show More' button clicked.

Description: 修复点击显示更多按钮时列表选中项被取消的问题

Log: 修复点击显示更多按钮时列表选中项被取消的问题
This commit is contained in:
zhangjiaping 2021-02-20 10:05:16 +08:00
parent f2bddcc0ae
commit 8d30052518
3 changed files with 10 additions and 4 deletions

View File

@ -76,7 +76,13 @@ void SearchListView::appendItem(QString path) {
*/
void SearchListView::setList(QStringList list)
{
m_model->appendList(list);
QModelIndex index = this->currentIndex();
m_model->setList(list);
if (index.row() >= 0 && index.row() < list.length()) {
this->blockSignals(true);
this->setCurrentIndex(index);
this->blockSignals(false);
}
rowheight = this->rowHeight(this->model()->index(0, 0, QModelIndex()));
this->setFixedHeight(m_item->getCurrentSize() * rowheight + 4);
}

View File

@ -149,10 +149,10 @@ void SearchItemModel::appendItem(QString path) {
}
/**
* @brief SearchItemModel::appendList
* @brief SearchItemModel::setList
* @param list
*/
void SearchItemModel::appendList(QStringList list)
void SearchItemModel::setList(QStringList list)
{
this->beginResetModel();
m_item->m_pathlist = list;

View File

@ -53,7 +53,7 @@ public:
void setItem(SearchItem *);
void appendItem(QString);
void appendList(QStringList);
void setList(QStringList);
void removeItem(QString);
void clear();