Commit 4ce59c06 authored by Rolf Eike Beer's avatar Rolf Eike Beer

introduce KGpgItemModel::refreshAllKeys()

Introduce a function that explicitely updates the entire model instead of
requiring to call the usual update functions with a special argument.
parent c736296b
......@@ -1186,7 +1186,7 @@ void KeysManager::showOptions()
QPointer<kgpgOptions> optionsDialog = new kgpgOptions(this, imodel);
connect(optionsDialog, &kgpgOptions::settingsUpdated, this, &KeysManager::readAllOptions);
connect(optionsDialog, &kgpgOptions::homeChanged, imodel, static_cast<void(KGpgItemModel::*)()>(&KGpgItemModel::refreshKeys));
connect(optionsDialog, &kgpgOptions::homeChanged, imodel, &KGpgItemModel::refreshAllKeys);
connect(optionsDialog.data(), &kgpgOptions::homeChanged, imodel, &KGpgItemModel::refreshGroups);
connect(optionsDialog.data(), &kgpgOptions::refreshTrust, imodel, &KGpgItemModel::refreshTrust);
connect(optionsDialog, &kgpgOptions::changeFont, this, &KeysManager::fontChanged);
......@@ -2645,7 +2645,7 @@ void KeysManager::slotImportDone(int result)
void KeysManager::refreshkey()
{
imodel->refreshKeys();
imodel->refreshAllKeys();
updateStatusCounter();
}
......
......@@ -420,15 +420,15 @@ KGpgItemModel::nodeIndex(KGpgNode *node, const int column)
}
void
KGpgItemModel::refreshKeys(KGpgKeyNode::List keys)
KGpgItemModel::refreshKeys(const QStringList &ids)
{
refreshKeyIds(keys);
refreshKeyIds(ids);
}
void
KGpgItemModel::refreshKeys(const QStringList &ids)
KGpgItemModel::refreshKeys(KGpgKeyNode::List keys)
{
refreshKeyIds(ids);
refreshKeyIds(keys);
}
static QStringList
......@@ -438,16 +438,27 @@ readGroups()
}
void
KGpgItemModel::refreshKeyIds(const QStringList &ids)
KGpgItemModel::refreshAllKeys()
{
beginResetModel();
if (ids.isEmpty()) {
for (int i = m_root->getChildCount() - 1; i >= 0; i--)
delete m_root->getChild(i);
m_root->addKeys();
m_root->addGroups(readGroups());
for (int i = m_root->getChildCount() - 1; i >= 0; i--)
delete m_root->getChild(i);
m_root->addKeys();
m_root->addGroups(readGroups());
endResetModel();
}
void
KGpgItemModel::refreshKeyIds(const QStringList &ids)
{
if (ids.isEmpty()) {
refreshAllKeys();
} else {
beginResetModel();
QStringList::ConstIterator it = ids.constBegin();
const QStringList::ConstIterator itEnd = ids.constEnd();
......@@ -466,9 +477,9 @@ KGpgItemModel::refreshKeyIds(const QStringList &ids)
m_root->refreshKeys(refreshNodes);
if (!addIds.isEmpty())
m_root->addKeys(addIds);
}
endResetModel();
endResetModel();
}
}
void
......
......@@ -85,10 +85,9 @@ public Q_SLOTS:
{ refreshKeys(QStringList(id)); }
inline void refreshKey(KGpgKeyNode *nd)
{ refreshKeys(KGpgKeyNode::List() << nd); }
inline void refreshKeys()
{ refreshKeys(QStringList()); }
void refreshKeys(const QStringList &ids);
void refreshKeys(KGpgKeyNode::List keys);
void refreshAllKeys();
void refreshGroups();
void invalidateIndexes(KGpgNode *nd);
void refreshTrust(const KgpgCore::KgpgKeyTrust trust, const QColor &color);
......
Markdown is supported
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