Add remove block dir function.
This commit is contained in:
parent
af19c6c94d
commit
63f945ee17
|
@ -10,6 +10,8 @@
|
|||
#include <QMimeDatabase>
|
||||
#include <QMimeType>
|
||||
#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>();
|
||||
|
||||
FileUtils::FileUtils()
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()<<i;
|
||||
if(path.right(path.length()-1).startsWith(i))
|
||||
if(pathKey.startsWith(i))
|
||||
{
|
||||
returnMessage = QString(tr("Parent folder has been blocked!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(i.startsWith(path.right(path.length()-1)))
|
||||
if(i.startsWith(pathKey))
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue