From b6835305fc11517a504518ecf69a44337df93a11 Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Wed, 6 Mar 2024 14:35:28 +0800 Subject: [PATCH] =?UTF-8?q?perf(frontend):=E4=BC=98=E5=8C=96=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=8D=A0=E7=94=A8=EF=BC=8C=E6=B8=85=E9=99=A4=E6=9C=80?= =?UTF-8?q?=E4=BD=B3=E5=8C=B9=E9=85=8D=E5=81=9C=E6=AD=A2=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E7=BC=93=E5=AD=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/control/stack-pages/search-page-section.cpp | 1 + frontend/model/best-list-model.cpp | 12 ++++++++++++ frontend/model/best-list-model.h | 1 + frontend/view/best-list-view.cpp | 2 ++ frontend/view/best-list-view.h | 1 + 5 files changed, 17 insertions(+) diff --git a/frontend/control/stack-pages/search-page-section.cpp b/frontend/control/stack-pages/search-page-section.cpp index e50bec9..c117bf8 100644 --- a/frontend/control/stack-pages/search-page-section.cpp +++ b/frontend/control/stack-pages/search-page-section.cpp @@ -467,6 +467,7 @@ void ResultArea::initConnections() m_selectedPluginID = ""; m_isClicked = false; }); + connect(this, &ResultArea::stopSearch, m_bestListWidget, &BestListWidget::stopSearch); connect(m_bestListWidget, &BestListWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged); connect(m_bestListWidget, &BestListWidget::sizeChanged, this, [=] () { QModelIndex index = m_bestListWidget->getModlIndex(0, 0); diff --git a/frontend/model/best-list-model.cpp b/frontend/model/best-list-model.cpp index 3d4e743..a336043 100644 --- a/frontend/model/best-list-model.cpp +++ b/frontend/model/best-list-model.cpp @@ -218,3 +218,15 @@ bool BestListModel::setData(const QModelIndex &index, const QVariant &value, int } return false; } + +void BestListModel::stopSearchSlot() { + beginResetModel(); + qDeleteAll(m_items); + m_pluginIdList.clear(); + m_resourceTypes.clear(); + m_items.clear(); + m_items.squeeze(); + endResetModel(); + Q_EMIT this->itemListChanged(m_items.length()); +// Q_EMIT stopSearch(); +} diff --git a/frontend/model/best-list-model.h b/frontend/model/best-list-model.h index a11c1fa..763b1c3 100644 --- a/frontend/model/best-list-model.h +++ b/frontend/model/best-list-model.h @@ -53,6 +53,7 @@ public Q_SLOTS: void removeInfo(const QString &); void moveInfo(const QString &pluginName, int pos); void startSearch(const QString &); + void stopSearchSlot(); Q_SIGNALS: void stopSearch(); diff --git a/frontend/view/best-list-view.cpp b/frontend/view/best-list-view.cpp index 97f3673..72a98f6 100644 --- a/frontend/view/best-list-view.cpp +++ b/frontend/view/best-list-view.cpp @@ -273,6 +273,7 @@ void BestListView::initConnections() m_model->startSearch(keyword); }); connect(this, &BestListView::startSearch, m_model, &BestListModel::startSearch); + connect(this, &BestListView::stopSearch, m_model, &BestListModel::stopSearchSlot); connect(this, &BestListView::clicked, this, &BestListView::onRowSelectedSlot); connect(this, &BestListView::activated, this, &BestListView::onRowDoubleClickedSlot); connect(m_model, &BestListModel::itemListChanged, this, &BestListView::onItemListChanged); @@ -418,6 +419,7 @@ void BestListWidget::initUi() void BestListWidget::initConnections() { connect(this, &BestListWidget::startSearch, m_bestListView, &BestListView::startSearch); + connect(this, &BestListWidget::stopSearch, m_bestListView, &BestListView::stopSearch); connect(this, &BestListWidget::startSearch, m_titleLabel, &TitleLabel::startSearch); connect(this, &BestListWidget::startSearch, m_titleLabel, &TitleLabel::startSearch); connect(this, &BestListWidget::stopSearch, m_titleLabel, &TitleLabel::stopSearch); diff --git a/frontend/view/best-list-view.h b/frontend/view/best-list-view.h index 7e94829..fd7699b 100644 --- a/frontend/view/best-list-view.h +++ b/frontend/view/best-list-view.h @@ -73,6 +73,7 @@ private: Q_SIGNALS: void startSearch(const QString &); + void stopSearch(); void currentRowChanged(const QString &, const SearchPluginIface::ResultInfo&); void sendBestListData(const QString &, const SearchPluginIface::ResultInfo&); void listLengthChanged(const int &);