diff --git a/libsearch/index/file-searcher.cpp b/libsearch/index/file-searcher.cpp index 145ba68..c41f2b7 100644 --- a/libsearch/index/file-searcher.cpp +++ b/libsearch/index/file-searcher.cpp @@ -36,7 +36,7 @@ void FileSearcher::onKeywordSearch(QString keyword,QQueue *searchResult ++uniqueSymbol3; m_mutex3.unlock(); //file - QtConcurrent::run([&, uniqueSymbol1](){ + QtConcurrent::run([&, uniqueSymbol1, keyword](){ if(!m_search_result_file->isEmpty()) m_search_result_file->clear(); int begin = 0; @@ -54,7 +54,7 @@ void FileSearcher::onKeywordSearch(QString keyword,QQueue *searchResult }); // Q_EMIT this->resultFile(m_search_result_file); //dir - QtConcurrent::run([&, uniqueSymbol2](){ + QtConcurrent::run([&, uniqueSymbol2, keyword](){ if(!m_search_result_dir->isEmpty()) m_search_result_dir->clear(); int begin = 0; @@ -72,13 +72,14 @@ void FileSearcher::onKeywordSearch(QString keyword,QQueue *searchResult }); // Q_EMIT this->resultDir(m_search_result_dir); //content - QtConcurrent::run([&, uniqueSymbol3](){ + QtConcurrent::run([&, uniqueSymbol3, keyword](){ if(!m_search_result_content->isEmpty()) m_search_result_content->clear(); int begin = 0; int num = 5; int resultCount = 0; int total = 0; + while(total<20) { keywordSearchContent(uniqueSymbol3,keyword,begin,num); @@ -328,14 +329,18 @@ QMap FileSearcher::getContentResult(size_t uniqueSymbol, Xa m_mutex3.lock(); if(uniqueSymbol == FileSearcher::uniqueSymbol3) { + m_search_result_content->enqueue(qMakePair(path,snippets)); m_mutex3.unlock(); } else { m_mutex3.unlock(); - exit(0); + break; +// exit(0); } + + qDebug() << "after"; searchResult.insert(path,snippets); qDebug()<< "path="<< path << ",weight=" <setText(getTitleName(type)); + m_listLyt->addWidget(titleLabel); + m_listLyt->addWidget(m_fileListView); + connect(m_fileListView, &SearchListView::currentRowChanged, this, [ = ](const int& type, const QString& path) { + m_detailView->setupWidget(type, path); + m_fileListView->is_current_list = true; + Q_EMIT this->currentItemChanged(); + m_fileListView->is_current_list = false; + }); + connect(this, &ContentWidget::currentItemChanged, m_fileListView, [ = ]() { + if (! m_fileListView->is_current_list) { + m_fileListView->blockSignals(true); + m_fileListView->clearSelection(); + m_fileListView->blockSignals(false); + } + }); + m_resultList->setFixedHeight(m_resultList->height() + m_fileListView->height() + titleLabel->height()); + } + if (m_fileListView->isHidden) { + m_fileListView->isHidden = false; + QLabel * titleLabel = new QLabel(m_resultList); //表头 + titleLabel->setContentsMargins(8, 0, 0, 0); + titleLabel->setStyleSheet("QLabel{background: rgba(0,0,0,0.1);}"); + titleLabel->setText(getTitleName(type)); + m_listLyt->addWidget(titleLabel); + m_listLyt->addWidget(m_fileListView); + m_resultList->setFixedHeight(m_resultList->height() + m_fileListView->height() + titleLabel->height()); + } + m_fileListView->appendItem(path); + m_resultList->setFixedHeight(m_resultList->height() + m_fileListView->rowheight); + return; + break; + } + case SearchItem::SearchType::Dirs: { + if (!m_dirListView) { + m_dirListView = new SearchListView(m_resultList, QStringList(), type, keyword); + QLabel * titleLabel = new QLabel(m_resultList); //表头 + titleLabel->setContentsMargins(8, 0, 0, 0); + titleLabel->setStyleSheet("QLabel{background: rgba(0,0,0,0.1);}"); + titleLabel->setText(getTitleName(type)); + m_listLyt->addWidget(titleLabel); + m_listLyt->addWidget(m_dirListView); + connect(m_dirListView, &SearchListView::currentRowChanged, this, [ = ](const int& type, const QString& path) { + m_detailView->setupWidget(type, path); + m_dirListView->is_current_list = true; + Q_EMIT this->currentItemChanged(); + m_dirListView->is_current_list = false; + }); + connect(this, &ContentWidget::currentItemChanged, m_dirListView, [ = ]() { + if (! m_dirListView->is_current_list) { + m_dirListView->blockSignals(true); + m_dirListView->clearSelection(); + m_dirListView->blockSignals(false); + } + }); + m_resultList->setFixedHeight(m_resultList->height() + m_dirListView->height() + titleLabel->height()); + } + if (m_dirListView->isHidden) { + m_dirListView->isHidden = false; + QLabel * titleLabel = new QLabel(m_resultList); //表头 + titleLabel->setContentsMargins(8, 0, 0, 0); + titleLabel->setStyleSheet("QLabel{background: rgba(0,0,0,0.1);}"); + titleLabel->setText(getTitleName(type)); + m_listLyt->addWidget(titleLabel); + m_listLyt->addWidget(m_dirListView); + m_resultList->setFixedHeight(m_resultList->height() + m_dirListView->height() + titleLabel->height()); + } + m_dirListView->appendItem(path); + m_resultList->setFixedHeight(m_resultList->height() + m_dirListView->rowheight); + return; + break; + } + case SearchItem::SearchType::Contents: { + if (!m_contentListView) { + m_contentListView = new SearchListView(m_resultList, QStringList(), type, keyword); + QLabel * titleLabel = new QLabel(m_resultList); //表头 + titleLabel->setContentsMargins(8, 0, 0, 0); + titleLabel->setStyleSheet("QLabel{background: rgba(0,0,0,0.1);}"); + titleLabel->setText(getTitleName(type)); + m_listLyt->addWidget(titleLabel); + m_listLyt->addWidget(m_contentListView); + connect(m_contentListView, &SearchListView::currentRowChanged, this, [ = ](const int& type, const QString& path) { + m_detailView->setContent(m_contentList.at(m_contentListView->currentIndex().row()), keyword); + m_detailView->setupWidget(type, path); + m_contentListView->is_current_list = true; + Q_EMIT this->currentItemChanged(); + m_contentListView->is_current_list = false; + }); + connect(this, &ContentWidget::currentItemChanged, m_contentListView, [ = ]() { + if (! m_contentListView->is_current_list) { + m_contentListView->blockSignals(true); + m_contentListView->clearSelection(); + m_contentListView->blockSignals(false); + } + }); + m_resultList->setFixedHeight(m_resultList->height() + m_contentListView->height() + titleLabel->height()); + } + if (m_contentListView->isHidden) { + m_contentListView->isHidden = false; + QLabel * titleLabel = new QLabel(m_resultList); //表头 + titleLabel->setContentsMargins(8, 0, 0, 0); + titleLabel->setStyleSheet("QLabel{background: rgba(0,0,0,0.1);}"); + titleLabel->setText(getTitleName(type)); + m_listLyt->addWidget(titleLabel); + m_listLyt->addWidget(m_contentListView); + m_resultList->setFixedHeight(m_resultList->height() + m_contentListView->height() + titleLabel->height()); + } + m_contentListView->appendItem(path); + m_resultList->setFixedHeight(m_resultList->height() + m_contentListView->rowheight); + QString temp; + for (auto s : contents){ + temp.append(s); + } + m_contentList.append(temp); + return; + break; + } + default: + break; + } +} + /** * @brief ContentWidget::getTitleName 获取表头 * @param type 搜索类型 @@ -257,6 +392,16 @@ QString ContentWidget::getTitleName(const int& type) { * @param layout 需要清空的布局 */ void ContentWidget::clearLayout(QLayout * layout) { + if (m_fileListView) { + m_fileListView->clear(); + } + if (m_dirListView) { + m_dirListView->clear(); + } + if (m_contentListView) { + m_contentListView->clear(); + } + m_contentList.clear(); if (! layout) return; QLayoutItem * child; while ((child = layout->takeAt(0)) != 0) { diff --git a/src/content-widget.h b/src/content-widget.h index 9ea84de..028ed38 100644 --- a/src/content-widget.h +++ b/src/content-widget.h @@ -18,6 +18,7 @@ public: void setPage(const int&); int currentPage(); void refreshSearchList(const QVector&, const QVector&, const QString&); + void appendSearchItem(const int& type, const QString& path, const QString& keyword, QStringList contents = QStringList()); void initHomePage(); void setContentList(const QStringList&); private: @@ -36,6 +37,9 @@ private: QVBoxLayout * m_detailLyt = nullptr; SearchDetailView * m_detailView = nullptr; + SearchListView * m_fileListView = nullptr; + SearchListView * m_dirListView = nullptr; + SearchListView * m_contentListView = nullptr; int m_currentType = 0; diff --git a/src/control/search-list-view.cpp b/src/control/search-list-view.cpp index 1295d20..b7a7c2e 100644 --- a/src/control/search-list-view.cpp +++ b/src/control/search-list-view.cpp @@ -14,8 +14,8 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const this->setHeaderHidden(true); this->setColumnWidth(0, 20); this->setColumnWidth(1, 80); - int rowHeight = this->rowHeight(this->model()->index(0,1, QModelIndex())) + 1; - this->setFixedHeight(list.count() * rowHeight + 2); + rowheight = this->rowHeight(this->model()->index(0,1, QModelIndex())) + 1; + this->setFixedHeight(list.count() * rowheight + 2); this->setAttribute(Qt::WA_TranslucentBackground, true); this->setAutoFillBackground(false); this->setStyleSheet("QWidget{background:transparent;}"); @@ -41,6 +41,29 @@ SearchListView::~SearchListView() } } +/** + * @brief SearchListView::appendItem + */ +void SearchListView::appendItem(QString path) { + m_model->appendItem(path); + rowheight = this->rowHeight(this->model()->index(0,1, QModelIndex())) + 1; + this->setFixedHeight(m_item->getCurrentSize() * rowheight + 3); +} + +/** + * @brief SearchListView::removeItem + */ +void SearchListView::removeItem(QString path) { + m_model->removeItem(path); +} + +void SearchListView::clear() +{ + m_model->clear(); + this->setFixedHeight(0); + this->isHidden = true; +} + //获取当前选项所属搜索类型 int SearchListView::getCurrentType() { switch (m_type) { diff --git a/src/control/search-list-view.h b/src/control/search-list-view.h index 8367c67..3e1d459 100644 --- a/src/control/search-list-view.h +++ b/src/control/search-list-view.h @@ -26,7 +26,12 @@ public: static int getResType(const QString&); bool is_current_list = false; + int rowheight = 0; + void appendItem(QString); + void removeItem(QString); + void clear(); + bool isHidden = false; private: SearchItemModel * m_model = nullptr; SearchItem * m_item = nullptr; diff --git a/src/input-box.cpp b/src/input-box.cpp index 7f4bed5..e873bce 100644 --- a/src/input-box.cpp +++ b/src/input-box.cpp @@ -65,7 +65,7 @@ UkuiSearchBarHLayout::UkuiSearchBarHLayout() // connect(m_queryLineEdit, SIGNAL(textChanged(QString)), SIGNAL(textChanged(QString))); m_timer = new QTimer; - QObject::connect(m_timer, &QTimer::timeout, this, [ = ](){ + connect(m_timer, &QTimer::timeout, this, [ = ](){ m_timer->stop(); Q_EMIT this->textChanged(m_queryLineEdit->text()); }); @@ -76,8 +76,8 @@ UkuiSearchBarHLayout::UkuiSearchBarHLayout() } else { if (text == "") { m_isEmpty = true; - Q_EMIT this->textChanged(m_queryLineEdit->text()); m_timer->stop(); + Q_EMIT this->textChanged(m_queryLineEdit->text()); return; } m_timer->stop(); diff --git a/src/main.cpp b/src/main.cpp index e9b28d4..e54b6d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -85,13 +85,14 @@ void centerToScreen(QWidget* widget) { int desk_y = desk_rect.height(); int x = widget->width(); int y = widget->height(); - widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top()); +// widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top()); } int main(int argc, char *argv[]) { - qInstallMessageHandler(messageOutput); +// qInstallMessageHandler(messageOutput); + qRegisterMetaType>("QPair"); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8c428b3..783e726 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -28,12 +28,12 @@ #include #include #include -#include "libsearch.h" #include "kwindowsystem.h" //#include "inotify-manager.h" #include "settings-widget.h" #include "global-settings.h" +#include "search-result.h" extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); /** @@ -46,6 +46,8 @@ extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int tran MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { + + m_searcher = new FileSearcher(); // FileUtils::findMultiToneWords("仇仇仇仇仇仇仇仇仇仇仇翟康宁test"); /*-------------Inotify Test Start---------------*/ // QTime t1 = QTime::currentTime(); @@ -80,6 +82,21 @@ MainWindow::MainWindow(QWidget *parent) : this->setPalette(pal); this->update(); }); + + m_search_result_file = new QQueue; + m_search_result_dir = new QQueue; + m_search_result_content = new QQueue>; + m_search_result_thread = new SearchResult(this); +// m_search_result_thread->start(); + connect(m_search_result_thread, &SearchResult::searchResultFile, this, [ = ](QString path) { + m_contentFrame->appendSearchItem(SearchItem::SearchType::Files, path, m_keyword); + }); + connect(m_search_result_thread, &SearchResult::searchResultDir, this, [ = ](QString path) { + m_contentFrame->appendSearchItem(SearchItem::SearchType::Dirs, path, m_keyword); + }); + connect(m_search_result_thread, &SearchResult::searchResultContent, this, [ = ](QPair pair) { + m_contentFrame->appendSearchItem(SearchItem::SearchType::Contents, pair.first, m_keyword, pair.second); + }); } MainWindow::~MainWindow() @@ -174,9 +191,9 @@ void MainWindow::initUi() m_contentFrame->setCurrentIndex(0); } else { m_contentFrame->setCurrentIndex(1); - QTimer::singleShot(50,this,[=](){ +// QTimer::singleShot(50,this,[=](){ searchContent(text); - }); +// }); } }); @@ -190,13 +207,11 @@ void MainWindow::initUi() */ void MainWindow::bootOptionsFilter(QString opt) { - - if (opt == "-s" || opt == "-show") { - clearSearchResult(); - this->show(); - this->raise(); - this->activateWindow(); - } + clearSearchResult(); + this->show(); + this->raise(); + this->activateWindow(); + m_search_result_thread->start(); } /** @@ -235,83 +250,25 @@ void MainWindow::primaryScreenChangedSlot(QScreen *screen) * @param searchcontent */ void MainWindow::searchContent(QString searchcontent){ + m_keyword = searchcontent; m_lists.clear(); m_types.clear(); AppMatch * appMatchor = new AppMatch(this); SettingsMatch * settingMatchor = new SettingsMatch(this); //应用与设置搜索 - QStringList list; - list = appMatchor->startMatchApp(searchcontent); - QStringList list3; - list3 = settingMatchor->startMatchApp(searchcontent); + QStringList appList; + appList = appMatchor->startMatchApp(searchcontent); + QStringList settingList; + settingList = settingMatchor->startMatchApp(searchcontent); m_types.append(SearchItem::SearchType::Apps); m_types.append(SearchItem::SearchType::Settings); - m_lists.append(list); - m_lists.append(list3); - - //文件、文件夹、内容搜索 - FileSearcher *search = new FileSearcher(); - connect(search, &FileSearcher::resultDir, this, [ = ](QQueue * dirQueue) { - qWarning()<<"resultDir---"; - QString firstDir; - while(1) - { - if(!dirQueue->isEmpty()){ - firstDir = dirQueue->at(0); - qWarning()<<"firstDir"< * fileQueue) { - qWarning()<<"resultFile---"; - }); - connect(search, &FileSearcher::resultContent, this, [ = ](QQueue> * contentQueue) { - qWarning()<<"resultContent---"; - }); - search->onKeywordSearch(searchcontent); - //将搜索结果加入列表 + m_lists.append(appList); + m_lists.append(settingList); m_contentFrame->refreshSearchList(m_types, m_lists, searchcontent); -//iaom--------this part shall be rewrite -// connect(search, &FileSearcher::contentResult, this, [ = ](QMap map) { -// m_types.append(SearchItem::SearchType::Contents); -// QStringList pathlist, contentList; -// qDebug() << map; -// for (auto i : map.keys()){ -// QString temp; -// pathlist << i; -// for (auto s : map[i]){ -// temp.append(s); -// } -// contentList.append(temp); -// } -// m_lists.append(pathlist); -// m_contentFrame->setContentList(contentList); -// }); - -// search->onKeywordSearch(searchcontent); - -//iaom--------this part shall be rewrite -// connect(searcher,&FileSearcher::result,[=](QVector resultV){ - -// QStringList list1 = resultV.at(0); -// QStringList list2 = resultV.at(1); - -// // QVector lists; -// m_lists.append(list1); -// m_lists.append(list2); -// // QVector types; -// m_types.append(SearchItem::SearchType::Dirs); -// m_types.append(SearchItem::SearchType::Files); -// m_contentFrame->refreshSearchList(m_types, m_lists, searchcontent); -// }); -// searcher->onKeywordSearch(searchcontent,0,10); - // QStringList res = IndexGenerator::IndexSearch(searchcontent); - // types.append(SearchItem::SearchType::Files); - // lists.append(res); + //文件、文件夹、内容搜索 + this->m_searcher->onKeywordSearch(searchcontent, m_search_result_file, m_search_result_dir, m_search_result_content); } //使用GSetting获取当前窗口应该使用的透明度 @@ -339,6 +296,7 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *r switch (event->response_type & ~0x80) { case XCB_FOCUS_OUT: this->hide(); + m_search_result_thread->quit(); break; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 3ab57d6..65fe479 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -41,9 +41,12 @@ #include "input-box.h" #include "index/index-generator.h" #include "settings-widget.h" +#include "libsearch.h" +class SearchResult; class MainWindow : public QMainWindow { + friend class SearchResult; Q_OBJECT public: @@ -80,6 +83,15 @@ private: QVector m_types; QVector m_lists; QStringList m_dirList; + + QQueue *m_search_result_file = nullptr; + QQueue *m_search_result_dir = nullptr; + QQueue> *m_search_result_content = nullptr; + SearchResult * m_search_result_thread = nullptr; + QString m_keyword = 0; + + FileSearcher* m_searcher = nullptr; + protected: void paintEvent(QPaintEvent *); void initUi(); diff --git a/src/model/search-item-model.cpp b/src/model/search-item-model.cpp index 5b8b4b8..e01f0f4 100644 --- a/src/model/search-item-model.cpp +++ b/src/model/search-item-model.cpp @@ -103,6 +103,13 @@ QVariant SearchItemModel::data(const QModelIndex &index, int role) const return QVariant(); } +bool SearchItemModel::insertRows(int row, int count, const QModelIndex &parent) +{ + this->beginInsertRows(parent, row, count); + this->endInsertRows(); + return true; +} + /** * @brief SearchItemModel::setItem 传入存储数据的item * @param item @@ -110,3 +117,23 @@ QVariant SearchItemModel::data(const QModelIndex &index, int role) const void SearchItemModel::setItem(SearchItem * item) { m_item = item; } + +/** + * @brief SearchItemModel::appendItem + */ +void SearchItemModel::appendItem(QString path) { + m_item->appendItem(path); + this->insertRow(rowCount(QModelIndex()) - 1); +} + +/** + * @brief SearchItemModel::removeItem + */ +void SearchItemModel::removeItem(QString path) { + m_item->removeItem(path); +} + +void SearchItemModel::clear() +{ + m_item->clear(); +} diff --git a/src/model/search-item-model.h b/src/model/search-item-model.h index 8ea3ad1..2aa2858 100644 --- a/src/model/search-item-model.h +++ b/src/model/search-item-model.h @@ -27,10 +27,15 @@ public: int columnCount(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role) const override; + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex())override; // QVariant headerData(int section, Qt::Orientation orientation, int role) const override; void setItem(SearchItem *); + void appendItem(QString); + void removeItem(QString); + void clear(); + private : SearchItem * m_item = nullptr; }; diff --git a/src/model/search-item.cpp b/src/model/search-item.cpp index 3296e11..d79d7ff 100644 --- a/src/model/search-item.cpp +++ b/src/model/search-item.cpp @@ -82,3 +82,26 @@ void SearchItem::setSearchList(const int& type, const QStringList& searchResult) m_searchtype = type; m_pathlist = searchResult; } + +/** + * @brief SearchItem::appendItem + */ +void SearchItem::appendItem(QString path) { + m_pathlist.append(path); +} + +/** + * @brief SearchItem::removeItem + */ +void SearchItem::removeItem(QString path) { + m_pathlist.removeOne(path); +} + +int SearchItem::getCurrentSize() { + return m_pathlist.length(); +} + +void SearchItem::clear() +{ + m_pathlist.clear(); +} diff --git a/src/model/search-item.h b/src/model/search-item.h index f588827..b322e51 100644 --- a/src/model/search-item.h +++ b/src/model/search-item.h @@ -26,6 +26,10 @@ public: }; void setSearchList(const int&, const QStringList&); + void appendItem(QString); + void removeItem(QString); + int getCurrentSize(); + void clear(); private: // SearchItem * m_parent = nullptr; diff --git a/src/search-result.cpp b/src/search-result.cpp new file mode 100644 index 0000000..defc5ae --- /dev/null +++ b/src/search-result.cpp @@ -0,0 +1,46 @@ +#include "search-result.h" +#include + +SearchResult::SearchResult(QObject * parent) : QThread(parent) +{ + m_mainwindow = static_cast(parent); +} + +SearchResult::~SearchResult() +{ + +} + +void SearchResult::run() +{ + int emptyLists = 0; + while(!isInterruptionRequested()) { + emptyLists = 0; + m_mainwindow->m_searcher->m_mutex1.lock(); + if (!m_mainwindow->m_search_result_file->isEmpty()) { + Q_EMIT this->searchResultFile(m_mainwindow->m_search_result_file->dequeue()); + m_mainwindow->m_searcher->m_mutex1.unlock(); + } else { + emptyLists ++; + m_mainwindow->m_searcher->m_mutex1.unlock(); + } + m_mainwindow->m_searcher->m_mutex2.lock(); + if (!m_mainwindow->m_search_result_dir->isEmpty()) { + Q_EMIT this->searchResultDir(m_mainwindow->m_search_result_dir->dequeue()); + m_mainwindow->m_searcher->m_mutex2.unlock(); + } else { + emptyLists ++; + m_mainwindow->m_searcher->m_mutex2.unlock(); + } + m_mainwindow->m_searcher->m_mutex3.lock(); + if (!m_mainwindow->m_search_result_content->isEmpty()) + qDebug() << m_mainwindow->m_search_result_content->head(); + if (!m_mainwindow->m_search_result_content->isEmpty()) { + Q_EMIT this->searchResultContent(m_mainwindow->m_search_result_content->dequeue()); + m_mainwindow->m_searcher->m_mutex3.unlock(); + } else { + emptyLists ++; + m_mainwindow->m_searcher->m_mutex3.unlock(); + } + } +} diff --git a/src/search-result.h b/src/search-result.h new file mode 100644 index 0000000..e2057fe --- /dev/null +++ b/src/search-result.h @@ -0,0 +1,26 @@ +#ifndef SEARCHRESULT_H +#define SEARCHRESULT_H +#include +#include +#include "mainwindow.h" + +class SearchResult : public QThread +{ + Q_OBJECT +public: + SearchResult(QObject * parent = nullptr); + ~SearchResult(); +protected: + void run() override; + +private: + MainWindow * m_mainwindow = nullptr; + +Q_SIGNALS: + void searchResultFile(const QString&); + void searchResultDir(const QString&); +// void searchResultContent(const QString&, const QStringList&); + void searchResultContent(const QPair); + +}; +#endif // SEARCHRESULT_H diff --git a/src/settings-widget.cpp b/src/settings-widget.cpp index 529c452..ce124f9 100644 --- a/src/settings-widget.cpp +++ b/src/settings-widget.cpp @@ -207,13 +207,20 @@ void SettingsWidget::clearLayout(QLayout * layout) { * @param path 文件夹路径 */ void SettingsWidget::onBtnDelClicked(const QString& path) { - qDebug()<findChildren()) { - if (item->getPath() == path) { - item->deleteLater(); - item = NULL; - return; + QString returnMessage; + if (GlobalSettings::getInstance()->setBlockDirs(path, returnMessage, true)) { + qDebug()<<"Remove block dir in onBtnDelClicked() successed."; + Q_FOREACH (FolderListItem * item, m_dirListWidget->findChildren()) { + if (item->getPath() == path) { + item->deleteLater(); + item = NULL; + return; + } } + + } else { + qWarning()<