diff --git a/control/search-detail-view.h b/control/search-detail-view.h index 8a10d70..5038aab 100644 --- a/control/search-detail-view.h +++ b/control/search-detail-view.h @@ -12,11 +12,11 @@ public: ~SearchDetailView(); void setupWidget(const int&, const QString&); + void clearLayout(); private: QVBoxLayout * m_layout = nullptr; - void clearLayout(); bool openAction(const int&, const QString&); bool addDesktopShortcut(const QString&); bool addPanelShortcut(const QString&); diff --git a/src/content-widget.cpp b/src/content-widget.cpp index 8456edf..550f4ae 100644 --- a/src/content-widget.cpp +++ b/src/content-widget.cpp @@ -135,10 +135,12 @@ void ContentWidget::refreshSearchList(const QVector& types, const QVectorisEmpty()) { clearSearchList(); } + bool isEmpty = true; for (int i = 0; i < types.count(); i ++) { if (lists.at(i).isEmpty()) { continue; } + isEmpty = false; SearchListView * searchList = new SearchListView(m_resultList, lists.at(i), types.at(i)); //Treeview QLabel * titleLabel = new QLabel(m_resultList); //表头 titleLabel->setContentsMargins(8, 0, 0, 0); @@ -156,6 +158,9 @@ void ContentWidget::refreshSearchList(const QVector& types, const QVectorsetupWidget(type, path); }); } + if (isEmpty) { + m_detailView->clearLayout(); //没有搜到结果,清空详情页 + } } /**