forked from openkylin/ukui-search
Add remove block dir function.
This commit is contained in:
parent
af19c6c94d
commit
63f945ee17
|
@ -10,6 +10,8 @@
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
#include <QMimeType>
|
#include <QMimeType>
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
|
size_t FileUtils::_max_index_count = 0;
|
||||||
|
size_t FileUtils::_current_index_count = 0;
|
||||||
QMap<QString, QStringList> FileUtils::map_chinese2pinyin = QMap<QString, QStringList>();
|
QMap<QString, QStringList> FileUtils::map_chinese2pinyin = QMap<QString, QStringList>();
|
||||||
|
|
||||||
FileUtils::FileUtils()
|
FileUtils::FileUtils()
|
||||||
|
|
|
@ -29,6 +29,8 @@ public:
|
||||||
static QString getMimetype(QString &path, bool getsuffix = false);
|
static QString getMimetype(QString &path, bool getsuffix = false);
|
||||||
static QString *getDocxTextContent(QString &path);
|
static QString *getDocxTextContent(QString &path);
|
||||||
static QString *getTxtContent(QString &path);
|
static QString *getTxtContent(QString &path);
|
||||||
|
static size_t _max_index_count;
|
||||||
|
static size_t _current_index_count;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileUtils();
|
FileUtils();
|
||||||
|
|
|
@ -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();
|
QStringList blockDirs = m_block_dirs_settings->allKeys();
|
||||||
for(QString i:blockDirs)
|
for(QString i:blockDirs)
|
||||||
{
|
{
|
||||||
// qWarning()<<i;
|
if(pathKey.startsWith(i))
|
||||||
if(path.right(path.length()-1).startsWith(i))
|
|
||||||
{
|
{
|
||||||
returnMessage = QString(tr("Parent folder has been blocked!"));
|
returnMessage = QString(tr("Parent folder has been blocked!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i.startsWith(path.right(path.length()-1)))
|
if(i.startsWith(pathKey))
|
||||||
m_block_dirs_settings->remove(i);
|
m_block_dirs_settings->remove(i);
|
||||||
}
|
}
|
||||||
m_block_dirs_settings->setValue(path.right(path.length()-1),"0");
|
m_block_dirs_settings->setValue(pathKey,"0");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,10 @@ public Q_SLOTS:
|
||||||
* set path for blacklist,return true if success,otherwise return false.
|
* set path for blacklist,return true if success,otherwise return false.
|
||||||
* @param path path to be blocked
|
* @param path path to be blocked
|
||||||
* @param returnMessage this message will be set when return false.
|
* @param returnMessage this message will be set when return false.
|
||||||
|
* @param true to remove blocking,false to set blocking,default set false.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool setBlockDirs(const QString& path, QString &returnMessage);
|
bool setBlockDirs(const QString& path, QString &returnMessage,bool remove = false);
|
||||||
QStringList getBlockDirs();
|
QStringList getBlockDirs();
|
||||||
|
|
||||||
void forceSync(const QString& = nullptr);
|
void forceSync(const QString& = nullptr);
|
||||||
|
|
Loading…
Reference in New Issue