From 63f945ee17ca2e7edd2c6a83c4dd8eb55da191a0 Mon Sep 17 00:00:00 2001 From: zhangpengfei Date: Sun, 10 Jan 2021 09:23:02 +0800 Subject: [PATCH] Add remove block dir function. --- libsearch/file-utils.cpp | 2 ++ libsearch/file-utils.h | 2 ++ libsearch/global-settings.cpp | 16 +++++++++++----- libsearch/global-settings.h | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/libsearch/file-utils.cpp b/libsearch/file-utils.cpp index 21c5c83..8830f44 100644 --- a/libsearch/file-utils.cpp +++ b/libsearch/file-utils.cpp @@ -10,6 +10,8 @@ #include #include #include +size_t FileUtils::_max_index_count = 0; +size_t FileUtils::_current_index_count = 0; QMap FileUtils::map_chinese2pinyin = QMap(); FileUtils::FileUtils() diff --git a/libsearch/file-utils.h b/libsearch/file-utils.h index 3e9271b..d9f707e 100644 --- a/libsearch/file-utils.h +++ b/libsearch/file-utils.h @@ -29,6 +29,8 @@ public: static QString getMimetype(QString &path, bool getsuffix = false); static QString *getDocxTextContent(QString &path); static QString *getTxtContent(QString &path); + static size_t _max_index_count; + static size_t _current_index_count; private: FileUtils(); diff --git a/libsearch/global-settings.cpp b/libsearch/global-settings.cpp index 2511b3e..a0eee27 100644 --- a/libsearch/global-settings.cpp +++ b/libsearch/global-settings.cpp @@ -80,22 +80,28 @@ void GlobalSettings::resetAll() }); } -bool GlobalSettings::setBlockDirs(const QString &path, QString &returnMessage) +bool GlobalSettings::setBlockDirs(const QString &path, QString &returnMessage, bool remove) { + //why QSetting's key can't start with "/"?? + QString pathKey = path.right(path.length()-1); + if(remove) + { + m_block_dirs_settings->remove(pathKey); + return true; + } QStringList blockDirs = m_block_dirs_settings->allKeys(); for(QString i:blockDirs) { -// qWarning()<remove(i); } - m_block_dirs_settings->setValue(path.right(path.length()-1),"0"); + m_block_dirs_settings->setValue(pathKey,"0"); return true; } diff --git a/libsearch/global-settings.h b/libsearch/global-settings.h index 6685db2..a4d13d5 100644 --- a/libsearch/global-settings.h +++ b/libsearch/global-settings.h @@ -39,9 +39,10 @@ public Q_SLOTS: * set path for blacklist,return true if success,otherwise return false. * @param path path to be blocked * @param returnMessage this message will be set when return false. + * @param true to remove blocking,false to set blocking,default set false. * @return */ - bool setBlockDirs(const QString& path, QString &returnMessage); + bool setBlockDirs(const QString& path, QString &returnMessage,bool remove = false); QStringList getBlockDirs(); void forceSync(const QString& = nullptr);