fix(duplicates): correct result visibility
This commit is contained in:
+12
-11
@@ -518,9 +518,12 @@ public slots:
|
|||||||
record.group = group;
|
record.group = group;
|
||||||
record.duplicateCopy = duplicateCopy++;
|
record.duplicateCopy = duplicateCopy++;
|
||||||
duplicatedPaths.insert(record.path);
|
duplicatedPaths.insert(record.path);
|
||||||
if (o.mode == QStringLiteral("Duplicates search"))
|
if (o.mode == QStringLiteral("Duplicates search")
|
||||||
|
&& shouldShowDuplicateResult(
|
||||||
|
o.showDuplicateCopiesOnly, record.duplicateCopy)) {
|
||||||
results.push_back(record);
|
results.push_back(record);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
++group;
|
++group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -529,10 +532,6 @@ public slots:
|
|||||||
for (const auto &record : candidates)
|
for (const auto &record : candidates)
|
||||||
if (record.type == QStringLiteral("File") && !duplicatedPaths.contains(record.path))
|
if (record.type == QStringLiteral("File") && !duplicatedPaths.contains(record.path))
|
||||||
results.push_back(record);
|
results.push_back(record);
|
||||||
} else if (!o.showOnlyDuplicateFiles) {
|
|
||||||
for (const auto &record : candidates)
|
|
||||||
if (record.type == QStringLiteral("File") && !duplicatedPaths.contains(record.path))
|
|
||||||
results.push_back(record);
|
|
||||||
}
|
}
|
||||||
} else if (o.mode == QStringLiteral("Duplicate names search")) {
|
} else if (o.mode == QStringLiteral("Duplicate names search")) {
|
||||||
QHash<QString, QVector<FileRecord>> byName;
|
QHash<QString, QVector<FileRecord>> byName;
|
||||||
@@ -1221,14 +1220,14 @@ public:
|
|||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
duplicateOptionsGroup->addAction(action);
|
duplicateOptionsGroup->addAction(action);
|
||||||
}
|
}
|
||||||
showOnlyDuplicates->setChecked(options_.showOnlyDuplicateFiles);
|
showOnlyDuplicates->setChecked(options_.showDuplicateCopiesOnly);
|
||||||
showAllDuplicates->setChecked(!options_.showOnlyDuplicateFiles);
|
showAllDuplicates->setChecked(!options_.showDuplicateCopiesOnly);
|
||||||
connect(showOnlyDuplicates, &QAction::triggered, this, [this] {
|
connect(showOnlyDuplicates, &QAction::triggered, this, [this] {
|
||||||
options_.showOnlyDuplicateFiles = true;
|
options_.showDuplicateCopiesOnly = true;
|
||||||
saveOptions();
|
saveOptions();
|
||||||
});
|
});
|
||||||
connect(showAllDuplicates, &QAction::triggered, this, [this] {
|
connect(showAllDuplicates, &QAction::triggered, this, [this] {
|
||||||
options_.showOnlyDuplicateFiles = false;
|
options_.showDuplicateCopiesOnly = false;
|
||||||
saveOptions();
|
saveOptions();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1991,7 +1990,7 @@ private:
|
|||||||
settings.setValue(QStringLiteral("mode"), options_.mode);
|
settings.setValue(QStringLiteral("mode"), options_.mode);
|
||||||
settings.setValue(QStringLiteral("duplicateNameMode"), options_.duplicateNameMode);
|
settings.setValue(QStringLiteral("duplicateNameMode"), options_.duplicateNameMode);
|
||||||
settings.setValue(QStringLiteral("duplicateNameWithoutExtension"), options_.duplicateNameWithoutExtension);
|
settings.setValue(QStringLiteral("duplicateNameWithoutExtension"), options_.duplicateNameWithoutExtension);
|
||||||
settings.setValue(QStringLiteral("showOnlyDuplicateFiles"), options_.showOnlyDuplicateFiles);
|
settings.setValue(QStringLiteral("showDuplicateCopiesOnly"), options_.showDuplicateCopiesOnly);
|
||||||
settings.setValue(QStringLiteral("includeSubfoldersInSummary"), options_.includeSubfoldersInSummary);
|
settings.setValue(QStringLiteral("includeSubfoldersInSummary"), options_.includeSubfoldersInSummary);
|
||||||
settings.setValue(QStringLiteral("hidden"), options_.hidden);
|
settings.setValue(QStringLiteral("hidden"), options_.hidden);
|
||||||
settings.setValue(QStringLiteral("readonly"), options_.readonly);
|
settings.setValue(QStringLiteral("readonly"), options_.readonly);
|
||||||
@@ -2028,7 +2027,9 @@ private:
|
|||||||
options_.mode = s.value(QStringLiteral("mode"), options_.mode).toString();
|
options_.mode = s.value(QStringLiteral("mode"), options_.mode).toString();
|
||||||
options_.duplicateNameMode = s.value(QStringLiteral("duplicateNameMode"), options_.duplicateNameMode).toString();
|
options_.duplicateNameMode = s.value(QStringLiteral("duplicateNameMode"), options_.duplicateNameMode).toString();
|
||||||
options_.duplicateNameWithoutExtension = s.value(QStringLiteral("duplicateNameWithoutExtension"), false).toBool();
|
options_.duplicateNameWithoutExtension = s.value(QStringLiteral("duplicateNameWithoutExtension"), false).toBool();
|
||||||
options_.showOnlyDuplicateFiles = s.value(QStringLiteral("showOnlyDuplicateFiles"), true).toBool();
|
options_.showDuplicateCopiesOnly =
|
||||||
|
s.value(QStringLiteral("showDuplicateCopiesOnly"),
|
||||||
|
s.value(QStringLiteral("showOnlyDuplicateFiles"), true)).toBool();
|
||||||
options_.includeSubfoldersInSummary = s.value(QStringLiteral("includeSubfoldersInSummary"), false).toBool();
|
options_.includeSubfoldersInSummary = s.value(QStringLiteral("includeSubfoldersInSummary"), false).toBool();
|
||||||
options_.hidden = s.value(QStringLiteral("hidden"), options_.hidden).toString();
|
options_.hidden = s.value(QStringLiteral("hidden"), options_.hidden).toString();
|
||||||
options_.readonly = s.value(QStringLiteral("readonly"), options_.readonly).toString();
|
options_.readonly = s.value(QStringLiteral("readonly"), options_.readonly).toString();
|
||||||
|
|||||||
@@ -54,6 +54,13 @@ bool wildcardMatch(const QString &value, const QStringList &items, Qt::CaseSensi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool shouldShowDuplicateResult(bool copiesOnly, int keeperPriority)
|
||||||
|
{
|
||||||
|
if (keeperPriority < 1)
|
||||||
|
return false;
|
||||||
|
return !copiesOnly || keeperPriority > 1;
|
||||||
|
}
|
||||||
|
|
||||||
QString humanSize(qint64 bytes)
|
QString humanSize(qint64 bytes)
|
||||||
{
|
{
|
||||||
static const QStringList units{QStringLiteral("B"), QStringLiteral("KB"),
|
static const QStringList units{QStringLiteral("B"), QStringLiteral("KB"),
|
||||||
|
|||||||
+2
-1
@@ -40,7 +40,7 @@ struct SearchOptions {
|
|||||||
QString mode = QStringLiteral("Standard search");
|
QString mode = QStringLiteral("Standard search");
|
||||||
QString duplicateNameMode = QStringLiteral("All files and folders");
|
QString duplicateNameMode = QStringLiteral("All files and folders");
|
||||||
bool duplicateNameWithoutExtension = false;
|
bool duplicateNameWithoutExtension = false;
|
||||||
bool showOnlyDuplicateFiles = true;
|
bool showDuplicateCopiesOnly = true;
|
||||||
bool includeSubfoldersInSummary = false;
|
bool includeSubfoldersInSummary = false;
|
||||||
QString hidden = QStringLiteral("Any");
|
QString hidden = QStringLiteral("Any");
|
||||||
QString readonly = QStringLiteral("Any");
|
QString readonly = QStringLiteral("Any");
|
||||||
@@ -78,3 +78,4 @@ bool fileContains(const QString &path, const SearchOptions &options);
|
|||||||
bool filesEqual(const QString &leftPath, const QString &rightPath);
|
bool filesEqual(const QString &leftPath, const QString &rightPath);
|
||||||
QByteArray sha256(const QString &path);
|
QByteArray sha256(const QString &path);
|
||||||
bool parseOptionalIsoDate(const QString &text, qint64 &seconds);
|
bool parseOptionalIsoDate(const QString &text, qint64 &seconds);
|
||||||
|
bool shouldShowDuplicateResult(bool copiesOnly, int keeperPriority);
|
||||||
|
|||||||
@@ -33,6 +33,17 @@ private slots:
|
|||||||
QVERIFY(!parseOptionalIsoDate(QStringLiteral("2026-not-a-date"), seconds));
|
QVERIFY(!parseOptionalIsoDate(QStringLiteral("2026-not-a-date"), seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void selectsDuplicateRowsForDisplay()
|
||||||
|
{
|
||||||
|
QVERIFY(!shouldShowDuplicateResult(true, 0));
|
||||||
|
QVERIFY(!shouldShowDuplicateResult(true, 1));
|
||||||
|
QVERIFY(shouldShowDuplicateResult(true, 2));
|
||||||
|
|
||||||
|
QVERIFY(!shouldShowDuplicateResult(false, 0));
|
||||||
|
QVERIFY(shouldShowDuplicateResult(false, 1));
|
||||||
|
QVERIFY(shouldShowDuplicateResult(false, 2));
|
||||||
|
}
|
||||||
|
|
||||||
void searchesContentsAndHashes()
|
void searchesContentsAndHashes()
|
||||||
{
|
{
|
||||||
QTemporaryDir directory;
|
QTemporaryDir directory;
|
||||||
|
|||||||
Reference in New Issue
Block a user