Commit 2fe1b683 authored by Rolf Eike Beer's avatar Rolf Eike Beer
Browse files

prevent that a key shows up twice after reloading it from keyserver

BUG:299044
FIXED-IN:4.8.4
parent be8ce449
......@@ -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()
{
......
......@@ -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();
......
......@@ -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;
}
......
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment