[graphics/digikam] /: include non-existent pick or color label tags in the search result
Maik Qualmann <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit f688d0b3aefe88b560f268a7bb8ab0ad5b70554e by Maik Qualmann.
Committed on 19/07/2026 at 18:33.
Pushed by mqualmann into branch 'master'.
include non-existent pick or color label tags in the search result
BUGS: 522889
FIXED-IN: 9.2.0
M +1 -1 NEWS
M +36 -0 core/libs/database/item/query/itemquerybuilder.cpp
M +3 -1 core/libs/database/item/query/itemquerybuilder_p.h
https://invent.kde.org/graphics/digikam/-/commit/f688d0b3aefe88b560f268a7bb8ab0ad5b70554e
diff --git a/NEWS b/NEWS
index 7b454b1b9d..fac3e1a8a8 100644
--- a/NEWS
+++ b/NEWS
@@ -44,7 +44,7 @@ BUGFIXES:
020 --> 522968 - Missing folders.
021 --> 523055 - Test GPU AI Compatibility fails instantly with QString::arg Argument missing: OpenCLDNN error (Windows, NVIDIA RTX 3080 Ti).
022 --> 523250 - Created filename on import is wrong (date/time).
-023 -->
+023 --> 522889 - Pick Label "None" filter and Advanced Search return drastically different counts for the same criterion.
024 -->
025 -->
026 -->
diff --git a/core/libs/database/item/query/itemquerybuilder.cpp b/core/libs/database/item/query/itemquerybuilder.cpp
index d263d9015e..0560948a51 100644
--- a/core/libs/database/item/query/itemquerybuilder.cpp
+++ b/core/libs/database/item/query/itemquerybuilder.cpp
@@ -271,6 +271,42 @@ bool ItemQueryBuilder::buildField(QString& sql, SearchXmlCachingReader& reader,
}
sql += QString::fromUtf8(" )) ");
+
+ if (name == QLatin1String("labels"))
+ {
+ bool noPick = ids.contains(TagsCache::instance()->tagForPickLabel(NoPickLabel));
+ bool noColor = ids.contains(TagsCache::instance()->tagForColorLabel(NoColorLabel));
+
+ if (noPick || noColor)
+ {
+ sql += QString::fromUtf8(" OR (Images.id NOT IN ");
+ sql += QString::fromUtf8(" (SELECT ImageTags.imageid FROM ImageTags "
+ " WHERE ");
+
+ if (noPick && noColor)
+ {
+ sql += QString::fromUtf8(" (ImageTags.tagid BETWEEN ? AND ? OR ImageTags.tagid BETWEEN ? AND ? ) ");
+ }
+ else
+ {
+ sql += QString::fromUtf8(" (ImageTags.tagid BETWEEN ? AND ? ) ");
+ }
+
+ if (noPick)
+ {
+ *boundValues << TagsCache::instance()->tagForPickLabel(FirstPickLabel + 1)
+ << TagsCache::instance()->tagForPickLabel(LastPickLabel);
+ }
+
+ if (noColor)
+ {
+ *boundValues << TagsCache::instance()->tagForColorLabel(FirstColorLabel + 1)
+ << TagsCache::instance()->tagForColorLabel(LastColorLabel);
+ }
+
+ sql += QString::fromUtf8(" )) ");
+ }
+ }
}
else if (relation == SearchXml::OneOf)
{
diff --git a/core/libs/database/item/query/itemquerybuilder_p.h b/core/libs/database/item/query/itemquerybuilder_p.h
index 3e99f90c49..9a413a1e02 100644
--- a/core/libs/database/item/query/itemquerybuilder_p.h
+++ b/core/libs/database/item/query/itemquerybuilder_p.h
@@ -35,10 +35,12 @@
// Local includes
-#include "metaengine.h"
#include "digikam_debug.h"
+#include "digikam_globals.h"
+#include "metaengine.h"
#include "coredbaccess.h"
#include "coredb.h"
+#include "tagscache.h"
#include "coredbbackend.h"
#include "fieldquerybuilder.h"