summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolf Eike Beer <kde@opensource.sf-tec.de>2012-04-29 21:52:01 (GMT)
committerRolf Eike Beer <kde@opensource.sf-tec.de>2012-04-29 21:52:01 (GMT)
commit2fe1b683cec044f96cf973ea2feace70aeb7e6f5 (patch)
tree0d4da566cc8abea2106516b961228da10437a459
parentbe8ce4498e512a97f9c434c9d5587db1b4b4a838 (diff)
prevent that a key shows up twice after reloading it from keyserver
BUG:299044 FIXED-IN:4.8.4
-rw-r--r--core/KGpgKeyNode.cpp14
-rw-r--r--core/KGpgKeyNode.h8
-rw-r--r--core/KGpgRootNode.cpp2
-rw-r--r--model/kgpgitemmodel.cpp17
4 files changed, 36 insertions, 5 deletions
diff --git a/core/KGpgKeyNode.cpp b/core/KGpgKeyNode.cpp
index 1d29cc0..78a12c5 100644
--- a/core/KGpgKeyNode.cpp
+++ b/core/KGpgKeyNode.cpp
@@ -330,6 +330,20 @@ KGpgKeyNode::getUid(const unsigned int index) const
return NULL;
}
+bool
+KGpgKeyNode::compareId(const QString &other) const
+{
+ if (other.length() == m_key->fullId().length())
+ return other.compare(m_key->fullId(), Qt::CaseInsensitive);
+
+ if (other.length() == m_key->fingerprint().length())
+ return other.compare(m_key->fingerprint(), Qt::CaseInsensitive);
+
+ return other.right(m_key->fullId().length()).compare(
+ m_key->fullId().right(other.length()),
+ Qt::CaseInsensitive);
+}
+
void
KGpgKeyNode::expand()
{
diff --git a/core/KGpgKeyNode.h b/core/KGpgKeyNode.h
index 23fe456..caf0ba4 100644
--- a/core/KGpgKeyNode.h
+++ b/core/KGpgKeyNode.h
@@ -163,6 +163,14 @@ public:
*/
const KGpgSignableNode *getUid(const unsigned int index) const;
+ /**
+ * @brief compare the id of this node to the given other node
+ * @param other key id to compare to
+ * @return if ids are identical
+ *
+ * This handles different length of the id string.
+ */
+ bool compareId(const QString &other) const;
Q_SIGNALS:
void expanded();
diff --git a/core/KGpgRootNode.cpp b/core/KGpgRootNode.cpp
index 7c0a7ed..8e2fc73 100644
--- a/core/KGpgRootNode.cpp
+++ b/core/KGpgRootNode.cpp
@@ -147,7 +147,7 @@ KGpgRootNode::findKeyRow(const QString &keyId)
const KGpgKeyNode *key = node->toKeyNode();
- if (keyId.compare(key->getId().right(keyId.length()), Qt::CaseInsensitive) == 0)
+ if (key->compareId(keyId))
return i;
++i;
}
diff --git a/model/kgpgitemmodel.cpp b/model/kgpgitemmodel.cpp
index e2efb64..92207c6 100644
--- a/model/kgpgitemmodel.cpp
+++ b/model/kgpgitemmodel.cpp
@@ -399,25 +399,34 @@ KGpgItemModel::refreshKeyIds(const QStringList &ids)
continue;
delete nd;
}
+ m_root->addKeys();
} else {
QStringList::ConstIterator it = ids.constBegin();
const QStringList::ConstIterator itEnd = ids.constEnd();
+ KGpgKeyNode::List refreshNodes;
+ QStringList addIds;
+
for (; it != itEnd; ++it) {
KGpgKeyNode *nd = m_root->findKey(*it);
- delete nd;
+ if (nd)
+ refreshNodes << nd;
+ else
+ addIds << *it;
}
+
+ if (!refreshNodes.isEmpty())
+ m_root->refreshKeys(refreshNodes);
+ if (!addIds.isEmpty())
+ m_root->addKeys(addIds);
}
- m_root->addKeys(ids);
endResetModel();
}
void
KGpgItemModel::refreshKeyIds(KGpgKeyNode::List &nodes)
{
- QStringList ids;
-
beginResetModel();
m_root->refreshKeys(nodes);
endResetModel();