From 9cd15760ba36f306477cd75e5c7335404cd17676 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Fri, 15 Jan 2021 16:16:51 +0800 Subject: [PATCH] fix(setting-widget): Index is empty. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 索引项接口对接 Log: 索引项接口对接 Bug: http://172.17.66.192/biz/bug-view-33094.html --- libsearch/index/file-searcher.h | 2 +- src/settings-widget.cpp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libsearch/index/file-searcher.h b/libsearch/index/file-searcher.h index 22008e8..8b2ebb5 100644 --- a/libsearch/index/file-searcher.h +++ b/libsearch/index/file-searcher.h @@ -20,7 +20,7 @@ public: explicit FileSearcher(QObject *parent = nullptr); ~FileSearcher(); - int getCurrentIndexCount(); + static int getCurrentIndexCount(); static size_t uniqueSymbol1; static size_t uniqueSymbol2; diff --git a/src/settings-widget.cpp b/src/settings-widget.cpp index 2413a76..8b7b2f0 100644 --- a/src/settings-widget.cpp +++ b/src/settings-widget.cpp @@ -7,6 +7,7 @@ #include "folder-list-item.h" #include "global-settings.h" #include "file-utils.h" +#include "index/file-searcher.h" extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent) @@ -181,7 +182,6 @@ void SettingsWidget::setupBlackList(const QStringList& list) { FolderListItem * item = new FolderListItem(m_dirListWidget, path); m_dirListLyt->addWidget(item); item->setMaximumWidth(470); - //测试用,实际调用中应等待后端完成操作后删除该控件 connect(item, SIGNAL(onDelBtnClicked(const QString&)), this, SLOT(onBtnDelClicked(const QString&))); } m_dirListLyt->addStretch(); @@ -209,12 +209,20 @@ void SettingsWidget::clearLayout(QLayout * layout) { */ void SettingsWidget::refreshIndexState() { - m_indexStateLabel->setText(QString::number(FileUtils::_index_status)); - m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileUtils::_current_index_count)).arg(QString::number(FileUtils::_max_index_count))); + if (FileUtils::_index_status == CREATING_INDEX) { + this->setIndexState(true); + } else { + this->setIndexState(false); + } + m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileSearcher::getCurrentIndexCount())).arg(QString::number(FileUtils::_max_index_count))); m_timer = new QTimer; connect(m_timer, &QTimer::timeout, this, [ = ]() { - m_indexStateLabel->setText(QString::number(FileUtils::_index_status)); - m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileUtils::_current_index_count)).arg(QString::number(FileUtils::_max_index_count))); + if (FileUtils::_index_status == CREATING_INDEX) { + this->setIndexState(true); + } else { + this->setIndexState(false); + } + m_indexNumLabel->setText(QString("%1/%2").arg(QString::number(FileSearcher::getCurrentIndexCount())).arg(QString::number(FileUtils::_max_index_count))); }); m_timer->start(0.5 * 1000); }