Bug 104825 - Item "delete signature" missing from context menu for more than one signature
Summary: Item "delete signature" missing from context menu for more than one signature
Status: RESOLVED FIXED
Alias: None
Product: kgpg
Classification: Applications
Component: general (show other bugs)
Version: 1.2
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: bj
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-30 14:46 UTC by Oliver Klee
Modified: 2007-08-14 08:31 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Klee 2005-04-30 14:46:16 UTC
Version:           1.2 (using KDE KDE 3.3.2)
Installed from:    Debian testing/unstable Packages

The context menu items for signatures are incostitent dependent on whether one signauter is selected or more. The difference shouldn't be in the menu items present, but only in which items are enabled an which aren't.

Steps to reproduce:
1. Expand a key to see all signatures.
2. Select a signature and right-click it.
  Context menu:
  - import key from key server
  - delete signature (missing from the context menu for >1 signatures)
3. Select two signatures and click-click them.
  Context menu:
  - import keys (different wording!)
  - generate key pair (new item!)
Comment 1 Rolf Eike Beer 2007-08-14 08:30:56 UTC
SVN commit 699871 by dakon:

Improve popup menus

-"Generate key pair" should not show up in any popup menu
-importing of several missing signatures at once works now

FEATURE:74873
BUG:104825
GUI


 M  +38 -18    keysmanager.cpp  
 M  +2 -1      keysmanager.h  


--- trunk/KDE/kdeutils/kgpg/keysmanager.cpp #699870:699871
@@ -272,9 +272,9 @@
     deletePhoto->setIcon(KIcon("delete"));
     deletePhoto->setText(i18n("&Delete Photo"));
     connect(deletePhoto, SIGNAL(triggered(bool)), SLOT(slotDeletePhoto()));
-    QAction *delSignKey = actionCollection()->addAction("key_delsign");
+    delSignKey = actionCollection()->addAction("key_delsign");
     delSignKey->setIcon(KIcon("edit-delete"));
-    delSignKey->setText(i18n("Delete Sign&ature"));
+    delSignKey->setText(i18n("Delete sign&ature(s)"));
     connect(delSignKey, SIGNAL(triggered(bool)), SLOT(delsignkey()));
 
     importAllSignKeys = actionCollection()->addAction("key_importallsign");
@@ -291,7 +291,7 @@
     connect(signKey, SIGNAL(triggered(bool)), SLOT(signkey()));
     importSignatureKey = actionCollection()->addAction("key_importsign");
     importSignatureKey->setIcon(KIcon("network-wired"));
-    importSignatureKey->setText(i18n("Import Key From Keyserver"));
+    importSignatureKey->setText(i18n("Import key(s) from keyserver"));
     connect(importSignatureKey, SIGNAL(triggered(bool)), SLOT(preimportsignkey()));
 
     sTrust = actionCollection()->add<KToggleAction>("show_trust");
@@ -356,7 +356,6 @@
 
     m_popupout = new KMenu();
     m_popupout->addAction(importKey);
-    m_popupout->addAction(generateKey);
 
     m_popupsig = new KMenu();
     m_popupsig->addAction(importSignatureKey);
@@ -1283,8 +1282,8 @@
 
 bool KeysManager::isSignatureUnknown(KeyListViewItem *item)
 {
-	Q_ASSERT(isSignature(item));
-
+	if (!isSignature(item))
+		return false;
 	// ugly hack to detect unknown keys
 	return (item->text(0).startsWith("[") && item->text(0).endsWith("]"));
 }
@@ -1300,12 +1299,26 @@
         {
             QList<KeyListViewItem*> exportList = keysList2->selectedItems();
             bool keyDepth = true;
+            bool allunksig = true;
+            bool allsig = true;
+
             for (int i = 0; i < exportList.count(); ++i)
                 if (exportList.at(i))
-                    if (exportList.at(i)->depth() != 0)
+                    if (exportList.at(i)->depth() != 0) {
                         keyDepth = false;
+                        allsig &= isSignature(exportList.at(i));
+                        allunksig &= isSignatureUnknown(exportList.at(i));
+                    } else {
+                      allunksig = false;
+                      allsig = false;
+                    }
 
-            if (!keyDepth)
+            if (allsig) {
+                importSignatureKey->setEnabled(allunksig);
+                delSignKey->setEnabled(false);
+                m_popupsig->exec(pos);
+                return;
+            } else if (!keyDepth)
             {
                 signKey->setEnabled(false);
                 refreshKey->setEnabled(false);
@@ -1330,6 +1343,7 @@
                         importSignatureKey->setEnabled(true);
                     else
                         importSignatureKey->setEnabled(false);
+                    delSignKey->setEnabled(true);
                     m_popupsig->exec(pos);
                     return;
                 }
@@ -1946,27 +1960,33 @@
         keysList2->currentItem()->setOpen(false);
     }
 
-    QString missingKeysList;
+    QStringList missingKeys;
     KeyListViewItem *current = keysList2->currentItem()->firstChild();
     while (current)
     {
         if (isSignatureUnknown(current))
-            missingKeysList += current->text(6) + ' ';
+            missingKeys << current->text(6);
         current = current->nextSibling();
     }
 
-    if (!missingKeysList.isEmpty())
-        importsignkey(missingKeysList);
+    if (!missingKeys.isEmpty())
+        importsignkey(missingKeys);
     else
         KMessageBox::information(this, i18n("All signatures for this key are already in your keyring"));
 }
 
 void KeysManager::preimportsignkey()
 {
-    if (keysList2->currentItem() == NULL)
-        return;
-    else
-        importsignkey(keysList2->currentItem()->text(6));
+    QList<KeyListViewItem*> exportList = keysList2->selectedItems();
+    QStringList idlist;
+
+    if (exportList.empty())
+      return;
+
+    for (int i = 0; i < exportList.count(); ++i)
+      idlist << exportList.at(i)->text(6);
+
+    importsignkey(idlist);
 }
 
 bool KeysManager::importRemoteKey(const QString &keyID)
@@ -2002,11 +2022,11 @@
     refreshkey();
 }
 
-void KeysManager::importsignkey(const QString &importKeyId)
+void KeysManager::importsignkey(const QStringList &importKeyId)
 {
     // sign a key
     kServer = new KeyServer(0, false);
-    kServer->slotSetText(importKeyId);
+    kServer->slotSetText(importKeyId.join(" "));
     //kServer->Buttonimport->setDefault(true);
     kServer->slotImport();
     //kServer->show();
--- trunk/KDE/kdeutils/kgpg/keysmanager.h #699870:699871
@@ -161,7 +161,7 @@
     void signkey();
     void delsignkey();
     void preimportsignkey();
-    void importsignkey(const QString &importKeyId);
+    void importsignkey(const QStringList &importKeyId);
     void importallsignkey();
     void importfinished();
     void signatureResult(int success, KgpgInterface*);
@@ -222,6 +222,7 @@
     QAction *signKey;
     QAction *refreshKey;
     QAction *setPrimUid;
+    QAction *delSignKey;
 
     KeyServer *kServer;
     groupEdit *gEdit;