perf(frontend):优化内存占用,清除最佳匹配停止搜索时的缓存.

This commit is contained in:
JunjieBai 2024-03-06 14:35:28 +08:00 committed by iaom
parent 7e6f22a7f0
commit 983e6ec99a
5 changed files with 17 additions and 0 deletions

View File

@ -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);

View File

@ -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();
}

View File

@ -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();

View File

@ -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);

View File

@ -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 &);