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

List:       kde-commits
Subject:    [kdepim] composereditor-ng/extendattributes: composer: Iterate the hash directly saving the temporar
From:       Sergio Martins <iamsergio () gmail ! com>
Date:       2015-07-31 18:31:26
Message-ID: E1ZLF5a-00083M-DT () scm ! kde ! org
[Download RAW message or body]

Git commit f4f9be311281a072016d5e7bf6d6c6a467a23c3f by Sergio Martins.
Committed on 31/07/2015 at 18:31.
Pushed by smartins into branch 'master'.

composer: Iterate the hash directly saving the temporary QList construction

M  +9    -11   composereditor-ng/extendattributes/extendattributeswidget.cpp

http://commits.kde.org/kdepim/f4f9be311281a072016d5e7bf6d6c6a467a23c3f

diff --git a/composereditor-ng/extendattributes/extendattributeswidget.cpp \
b/composereditor-ng/extendattributes/extendattributeswidget.cpp index \
                e119a4b..c1c00d6 100644
--- a/composereditor-ng/extendattributes/extendattributeswidget.cpp
+++ b/composereditor-ng/extendattributes/extendattributeswidget.cpp
@@ -216,12 +216,11 @@ void ExtendAttributesWidgetPrivate::_k_slotRemoveAttribute()
 void ExtendAttributesWidgetPrivate::initialize()
 {
     if (!webElement.isNull()) {
-        const QStringList keys = attributesMap.keys();
-        Q_FOREACH (const QString &str, keys) {
-            if (webElement.hasAttribute(str)) {
+        for (auto it = attributesMap.cbegin(), end = attributesMap.cend(); it != \
end; ++it) { +            if (webElement.hasAttribute(it.key())) {
                 QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget);
-                item->setText(0, str);
-                item->setText(1, webElement.attribute(str));
+                item->setText(0, it.key());
+                item->setText(1, webElement.attribute(it.key()));
             }
         }
     }
@@ -230,17 +229,16 @@ void ExtendAttributesWidgetPrivate::initialize()
 void ExtendAttributesWidgetPrivate::changeAttributes()
 {
     if (!webElement.isNull()) {
-        const QStringList keys = attributesMap.keys();
-        Q_FOREACH (const QString &str, keys) {
-            const QList<QTreeWidgetItem *> lstItems = treeWidget->findItems(str, \
Qt::MatchCaseSensitive); +        for (auto it = attributesMap.cbegin(), end = \
attributesMap.cend(); it != end; ++it) { +            const QList<QTreeWidgetItem *> \
lstItems = treeWidget->findItems(it.key(), Qt::MatchCaseSensitive);  if \
                (lstItems.isEmpty()) {
-                if (webElement.hasAttribute(str)) {
-                    webElement.removeAttribute(str);
+                if (webElement.hasAttribute(it.key())) {
+                    webElement.removeAttribute(it.key());
                 }
             } else {
                 const QString value = lstItems.at(0)->text(1);
                 if (!value.isEmpty()) {
-                    webElement.setAttribute(str, value);
+                    webElement.setAttribute(it.key(), value);
                 }
             }
         }


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

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