SVN commit 755276 by dakon: port some small stuff in keysmanager away from KeyListView M +40 -52 keysmanager.cpp M +0 -2 keysmanager.h --- branches/work/kgpg2/keysmanager.cpp #755275:755276 @@ -131,6 +131,7 @@ keysList2->photoKeysList = QString(); keysList2->groupNb = 0; m_statusbar = 0; + imodel = NULL; readOptions(); if (showTipOfDay) @@ -406,12 +407,9 @@ // setCentralWidget(keysList2); KConfigGroup cg = KConfigGroup(KGlobal::config().data(), "KeyView"); - keysList2->restoreLayout(cg); iview->restoreLayout(cg); connect(keysList2, SIGNAL(returnPressed(Q3ListViewItem *)), this, SLOT(defaultAction())); - connect(keysList2, SIGNAL(doubleClicked(Q3ListViewItem *, const QPoint &, int)), this, SLOT(defaultAction())); - connect(keysList2, SIGNAL(destroyed()), this, SLOT(annule())); connect(photoProps, SIGNAL(activated(int)), this, SLOT(slotSetPhotoSize(int))); // get all keys data @@ -603,7 +601,7 @@ } else { - changeMessage(keysList2->statusCountMessage(), 1); + changeMessage(imodel->statusCountMessage(), 1); KDialog *keyCreated = new KDialog(this); keyCreated->setCaption(i18n("New Key Pair Created")); @@ -1154,12 +1152,6 @@ } } -void KeysManager::annule() -{ - // close window - close(); -} - void KeysManager::quitApp() { // close window @@ -1169,7 +1161,8 @@ void KeysManager::saveToggleOpts(void) { - keysList2->saveLayout(KGlobal::config().data(), "KeyView"); + KConfigGroup cg = KConfigGroup(KGlobal::config().data(), "KeyView"); + iview->saveLayout(cg); KGpgSettings::setPhotoProperties(photoProps->currentItem()); KGpgSettings::setShowTrust(sTrust->isChecked()); KGpgSettings::setShowExpi(sExpi->isChecked()); @@ -1189,8 +1182,8 @@ // re-read groups in case the config file location was changed QStringList groups = KgpgInterface::getGpgGroupNames(KGpgSettings::gpgConfigPath()); KGpgSettings::setGroups(groups.join(",")); - keysList2->groupNb = groups.count(); - changeMessage(keysList2->statusCountMessage(), 1); + if (imodel != NULL) + changeMessage(imodel->statusCountMessage(), 1); showTipOfDay = KGpgSettings::showTipOfDay(); } @@ -1600,26 +1593,31 @@ void KeysManager::keyproperties() { - KeyListViewItem *cur = keysList2->currentItem(); - if (cur == NULL) - return; + KGpgNode *cur = iview->selectedNode(); + if (cur == NULL) + return; - if (cur->itemType() == KeyListViewItem::Secret) - { - if (KMessageBox::questionYesNo(this, i18n("This key is an orphaned secret key (secret key without public key.) It is currently not usable.\n\n" - "Would you like to regenerate the public key?"), QString(), KGuiItem(i18n("Generate")), KGuiItem(i18n("Do Not Generate"))) == KMessageBox::Yes) - slotregenerate(); - return; - } - - QString key = cur->keyId(); - if (!key.isEmpty()) - { - KgpgKeyInfo *opts = new KgpgKeyInfo(key, this); - connect(opts, SIGNAL(keyNeedsRefresh(const QString &)), imodel, SLOT(refreshKey(const QString &))); - opts->exec(); - delete opts; - } + switch (cur->getType()) { + case ITYPE_SECRET: + case ITYPE_GSECRET: + if (KMessageBox::questionYesNo(this, + i18n("

This key is an orphaned secret key (secret key without public key.) It is currently not usable.

" + "

Would you like to regenerate the public key?

"), QString(), KGuiItem(i18n("Generate")), KGuiItem(i18n("Do Not Generate"))) == KMessageBox::Yes) + slotregenerate(); + break; + case ITYPE_PAIR: + case ITYPE_PUBLIC: + case ITYPE_GPAIR: + case ITYPE_GPUBLIC: { + KgpgKeyInfo *opts = new KgpgKeyInfo(cur->getId(), this); + connect(opts, SIGNAL(keyNeedsRefresh(const QString &)), imodel, SLOT(refreshKey(const QString &))); + opts->exec(); + delete opts; + break; + } + default: + kDebug(3125) << "Oops, called with invalid item type" << cur->getType(); + } } void KeysManager::deleteGroup() @@ -1808,17 +1806,6 @@ signLoop(); } -void KeysManager::getMissingSigs(QStringList *missingKeys, KeyListViewItem *item) -{ - while (item) { - if (isSignatureUnknown(item)) - *missingKeys << item->keyId(); - if (item->firstChild() != NULL) - getMissingSigs(missingKeys, item->firstChild()); - item = item->nextSibling(); - } -} - void KeysManager::getMissingSigs(QStringList *missingKeys, KGpgExpandableNode *nd) { for (int i = nd->getChildCount() - 1; i >= 0; i--) { @@ -1837,7 +1824,7 @@ void KeysManager::importallsignkey() { - QList sel = keysList2->selectedItems(); + QList sel = iview->selectedNodes(); QStringList missingKeys; int i; @@ -1845,16 +1832,17 @@ return; for (i = 0; i < sel.count(); i++) { - KeyListViewItem *cur = sel.at(i); - KeyListViewItem *item = cur->firstChild(); + KGpgNode *nd = sel.at(i); - if (item == NULL) { - cur->setOpen(true); - cur->setOpen(false); - item = cur->firstChild(); - } + if (nd->hasChildren()) { + KGpgExpandableNode *en = static_cast(nd); + getMissingSigs(&missingKeys, en); + } else if (nd->getType() == ITYPE_SIGN) { + KGpgSignNode *sn = static_cast(nd); - getMissingSigs(&missingKeys, item); + if (sn->isUnknown()) + missingKeys << sn->getId(); + } } if (missingKeys.isEmpty()) { --- branches/work/kgpg2/keysmanager.h #755275:755276 @@ -150,7 +150,6 @@ void slotProcessExportClip(const QString &keys); void readOptions(); void slotSetDefKey(); - void annule(); void confirmdeletekey(); void deletekey(); void deleteseckey(); @@ -181,7 +180,6 @@ void refreshKeyFromServer(); void slotregenerate(); void reloadSecretKeys(); - void getMissingSigs(QStringList *missingKeys, KeyListViewItem *item); void getMissingSigs(QStringList *missingKeys, KGpgExpandableNode *nd); void slotEditDone(int exitcode); void importRemoteFinished(KGpgTransaction *);