fix(ukccPlugin):修改删除目录的ui触发逻辑,避免添加后被删除的文件夹无法从ui上移除

This commit is contained in:
JunjieBai 2023-09-13 17:34:18 +08:00
parent b71d5cf5a9
commit 400fe58a5a
1 changed files with 10 additions and 10 deletions

View File

@ -546,6 +546,7 @@ void Search::getBlockDirs()
int Search::setBlockDir(const QString &dirPath, const bool &is_add) int Search::setBlockDir(const QString &dirPath, const bool &is_add)
{ {
if (!QFile::exists(dirPath)) { if (!QFile::exists(dirPath)) {
removeBlockDirFromList(dirPath);
return ReturnCode::NotExists; return ReturnCode::NotExists;
} }
@ -627,6 +628,10 @@ int Search::setSearchDir(const QString &dirPath, const bool isAdd)
{ {
QFileInfo info(dirPath); QFileInfo info(dirPath);
if (!(info.isExecutable() && info.isReadable())) { if (!(info.isExecutable() && info.isReadable())) {
//路径不存在时从ui上删除
if (!isAdd) {
this->removeSearchDirFromList(dirPath);
}
return ReturnCode::PermissionDenied; return ReturnCode::PermissionDenied;
} }
@ -642,18 +647,18 @@ int Search::setSearchDir(const QString &dirPath, const bool isAdd)
} }
if (isAdd) { if (isAdd) {
QDBusReply<QStringList> indexDirsRpl = m_interface->call("currentIndexableDir"); QDBusReply<QStringList> indexDirsRpl = m_interface->call("currentSearchDirs");
QStringList indexDirs; QStringList indexDirs;
if (indexDirsRpl.isValid()) { if (indexDirsRpl.isValid()) {
indexDirs = indexDirsRpl.value(); indexDirs = indexDirsRpl.value();
} }
QDBusReply<int> appendIndexRpl = m_setSearchDirInterface->call("appendIndexableListItem", dirPath); QDBusReply<int> appendIndexRpl = m_setSearchDirInterface->call("appendSearchDir", dirPath);
if (appendIndexRpl.isValid()) { if (appendIndexRpl.isValid()) {
if (appendIndexRpl.value() == 0) { if (appendIndexRpl.value() == 0) {
this->appendSearchDirToList(dirPath); this->appendSearchDirToList(dirPath);
if (!indexDirs.isEmpty()) { if (!indexDirs.isEmpty()) {
indexDirsRpl = m_interface->call("currentIndexableDir"); indexDirsRpl = m_interface->call("currentSearchDirs");
if (indexDirsRpl.isValid() && (indexDirsRpl.value().size() < indexDirs.size() + 1)) { if (indexDirsRpl.isValid() && (indexDirsRpl.value().size() < indexDirs.size() + 1)) {
QStringList dirsAfterAppend = indexDirsRpl.value(); QStringList dirsAfterAppend = indexDirsRpl.value();
for (const QString& dir : indexDirs) { for (const QString& dir : indexDirs) {
@ -667,13 +672,8 @@ int Search::setSearchDir(const QString &dirPath, const bool isAdd)
return appendIndexRpl.value(); return appendIndexRpl.value();
} }
} else { } else {
QDBusReply<bool> reply = m_setSearchDirInterface->call("removeIndexableListItem", dirPath); this->removeSearchDirFromList(dirPath);
if (reply.isValid()) { m_setSearchDirInterface->call("removeSearchDir", dirPath);
if (reply.value()) {
this->removeSearchDirFromList(dirPath);
}
return reply.value();
}
} }
return ReturnCode::Successful; return ReturnCode::Successful;