[graphics/kphotoalbum/520244] AnnotationDialog: Clear annotation lists

Randall Rude <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 1ed727722dc7a6944eefa13b0671f68cb72e1f87 by Randall Rude.
Committed on 05/08/2026 at 21:37.
Pushed by rsquared into branch '520244'.

Clear annotation lists

M  +17   -4    AnnotationDialog/Dialog.cpp
M  +2    -0    AnnotationDialog/Dialog.h

https://invent.kde.org/graphics/kphotoalbum/-/commit/1ed727722dc7a6944eefa13b0671f68cb72e1f87

diff --git a/AnnotationDialog/Dialog.cpp b/AnnotationDialog/Dialog.cpp
index 1989b5fd4..7d878fef4 100644
--- a/AnnotationDialog/Dialog.cpp
+++ b/AnnotationDialog/Dialog.cpp
@@ -78,6 +78,7 @@
 #include <QtGlobal>
 
 #include <algorithm>
+#include <kwidgetsaddons_version.h>
 #include <tuple>
 
 #ifdef HAVE_MARBLE
@@ -479,11 +480,19 @@ void AnnotationDialog::Dialog::slotIndexChanged(int index)
 void AnnotationDialog::Dialog::doneTagging()
 {
     saveAndClose();
-    if (DB::ImageDB::instance()->untaggedCategoryFeatureConfigured()) {
-        for (DB::ImageInfoListIterator it = m_origList.begin(); it != m_origList.end(); ++it) {
-            (*it)->removeCategoryInfo(Settings::SettingsData::instance()->untaggedCategory(),
-                                      Settings::SettingsData::instance()->untaggedTag());
+
+    // This method is called for both annotation mode and search mode.
+    if (m_setup != SearchMode) {
+        if (DB::ImageDB::instance()->untaggedCategoryFeatureConfigured()) {
+            for (DB::ImageInfoListIterator it = m_origList.begin(); it != m_origList.end(); ++it) {
+                qCDebug(AnnotationDialogLog) << __func__ << "removing untagged tag from" << (*it)->fileName().relative();
+                (*it)->removeCategoryInfo(Settings::SettingsData::instance()->untaggedCategory(),
+                                          Settings::SettingsData::instance()->untaggedTag());
+            }
         }
+
+        m_origList.clear();
+        m_editList.clear();
     }
 }
 
@@ -1436,7 +1445,11 @@ void AnnotationDialog::Dialog::slotRatingChanged(int)
 
 void AnnotationDialog::Dialog::continueLater()
 {
+    // Like doneTagging() but don't remove the "untagged" tag.
     saveAndClose();
+
+    m_origList.clear();
+    m_editList.clear();
 }
 
 void AnnotationDialog::Dialog::saveAndClose()
diff --git a/AnnotationDialog/Dialog.h b/AnnotationDialog/Dialog.h
index 19cb36b00..f6a296b38 100644
--- a/AnnotationDialog/Dialog.h
+++ b/AnnotationDialog/Dialog.h
@@ -218,6 +218,8 @@ private Q_SLOTS:
 private:
     QStackedWidget *m_stack;
     Viewer::ViewerWidget *m_fullScreenPreview;
+    // NOTE: m_origList and m_editList are always the same size and in the same
+    // order, and are only used in annotation mode.
     DB::ImageInfoList m_origList;
     QList<DB::ImageInfo> m_editList;
     int m_current;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.