summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolf Eike Beer <kde@opensource.sf-tec.de>2016-10-21 18:31:57 (GMT)
committerRolf Eike Beer <kde@opensource.sf-tec.de>2016-10-21 18:31:57 (GMT)
commit4ce59c06857aeb40dbb1b2ea1bbc0479797d12af (patch)
treec16834f218a65bb02a378718cf6c6288c367217d
parentc736296b6d5709e7652a10babfa1ec5f4f55c025 (diff)
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.
-rw-r--r--keysmanager.cpp4
-rw-r--r--model/kgpgitemmodel.cpp35
-rw-r--r--model/kgpgitemmodel.h3
3 files changed, 26 insertions, 16 deletions
diff --git a/keysmanager.cpp b/keysmanager.cpp
index 41bb9c5..e2b3781 100644
--- a/keysmanager.cpp
+++ b/keysmanager.cpp
@@ -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();
}
diff --git a/model/kgpgitemmodel.cpp b/model/kgpgitemmodel.cpp
index a6c13da..c2b803e 100644
--- a/model/kgpgitemmodel.cpp
+++ b/model/kgpgitemmodel.cpp
@@ -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
diff --git a/model/kgpgitemmodel.h b/model/kgpgitemmodel.h
index 24aede4..c24badc 100644
--- a/model/kgpgitemmodel.h
+++ b/model/kgpgitemmodel.h
@@ -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);