[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kphotoalbum/category_l10n_removal] Settings: Restored the original behavior about pending changes.
From:       Tobias Leupold <tobias.leupold () web ! de>
Date:       2015-12-04 10:09:11
Message-ID: E1a4nId-00010P-A9 () scm ! kde ! org
[Download RAW message or body]

Git commit 2b316d5b3b18dd898e8fa8e53e8e9c228e70c63f by Tobias Leupold.
Committed on 04/12/2015 at 10:08.
Pushed by tleupold into branch 'category_l10n_removal'.

Restored the original behavior about pending changes.

M  +23   -3    Settings/CategoryPage.cpp

http://commits.kde.org/kphotoalbum/2b316d5b3b18dd898e8fa8e53e8e9c228e70c63f

diff --git a/Settings/CategoryPage.cpp b/Settings/CategoryPage.cpp
index b526d03..64e3210 100644
--- a/Settings/CategoryPage.cpp
+++ b/Settings/CategoryPage.cpp
@@ -186,11 +186,12 @@ void Settings::CategoryPage::editCategory(QListWidgetItem* i)
 
     Settings::CategoryItem* item = static_cast<Settings::CategoryItem*>(i);
     m_currentCategory = item;
-    m_categoryLabel->setText(QString::fromUtf8("%1 <b>%2</b>").arg(i18n("Settings \
for category")).arg(m_currentCategory->text())); +    \
m_categoryLabel->setText(QString::fromUtf8("%1 <b>%2</b>") +                          \
.arg(i18n("Settings for category"), item->originalName()));  
     if (m_currentCategory->originalName() != m_categoryNameBeforeEdit) {
-        m_renameLabel->setText(i18n("<i>Pending change: rename from \"%1\" to \
                \"%2\"</i>")
-            .arg(item->originalName(), m_categoryNameBeforeEdit));
+        m_renameLabel->setText(i18n("<i>Pending change: rename to \"%1\"</i>")
+            .arg(m_categoryNameBeforeEdit));
         m_renameLabel->show();
     } else {
         m_renameLabel->clear();
@@ -260,6 +261,25 @@ void \
Settings::CategoryPage::categoryNameChanged(QListWidgetItem* item)  return;
     }
 
+    // Let's see if we have any pending name changes that would cause collisions.
+    for (int i = 0; i < m_categoriesListWidget->count(); i++) {
+       Settings::CategoryItem* cat = \
static_cast<Settings::CategoryItem*>(m_categoriesListWidget->item(i)); +        if \
(cat == m_currentCategory) { +            continue;
+        }
+
+        if (newCategoryName == cat->originalName()) {
+            resetCategory(item);
+            KMessageBox::sorry(this,
+                               i18n("<p>Can't change the name of category \"%1\" to \
\"%2\":</p>" +                                    "<p>There's a pending rename action \
on the category \"%2\". " +                                    "Please save this \
change first.</p>", +                                    m_currentCategory->text(), \
newCategoryName), +                               i18n("Unsaved pending renaming \
action")); +            return;
+        }
+    }
+
     m_categoriesListWidget->blockSignals(true);
     item->setText(newCategoryName);
     m_categoriesListWidget->blockSignals(false);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic