[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/3.5/kdeutils/kgpg
From:       Jean-Baptiste Mardelle <bj () altern ! org>
Date:       2005-08-17 12:35:23
Message-ID: 1124282123.890410.3054.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 450010 by mardelle:

First move to fix bug #87293

 M  +21 -7     listkeys.cpp  
 M  +1 -1      listkeys.h  


--- branches/KDE/3.5/kdeutils/kgpg/listkeys.cpp #450009:450010
@@ -213,13 +213,13 @@
 ////////////////////////////////////////////////////////////////////////////////////////////////////
  
 ////////////////   Secret key selection dialog, used when user wants to sign a key
-KgpgSelKey::KgpgSelKey(QWidget *parent, const char *name):KDialogBase( parent, name, \
true,i18n("Private Key List"),Ok | Cancel) +KgpgSelKey::KgpgSelKey(QWidget *parent, \
const char *name,bool allowMultipleSelection, QString preselected): +KDialogBase( \
parent, name, true,i18n("Private Key List"),Ok | Cancel)  {
         QString keyname;
         page = new QWidget(this);
         QLabel *labeltxt;
         KIconLoader *loader = KGlobal::iconLoader();
-
         keyPair=loader->loadIcon("kgpg_key2",KIcon::Small,20);
 
         setMinimumSize(350,100);
@@ -231,11 +231,12 @@
         keysListpr->setShowSortIndicator(true);
         keysListpr->setFullWidth(true);
 	keysListpr->setAllColumnsShowFocus(true);
+	if (allowMultipleSelection) keysListpr->setSelectionMode(QListView::Extended);
 
-        labeltxt=new QLabel(i18n("Choose secret key for signing:"),page);
+        labeltxt=new QLabel(i18n("Choose secret key:"),page);
         vbox=new QVBoxLayout(page);
 
-        QString defaultKeyID= KGpgSettings::defaultKey().right(8);
+        if (preselected==QString::null) preselected = KGpgSettings::defaultKey();
 
         FILE *fp,*fp2;
         QString fullname,tst,tst2;
@@ -243,6 +244,7 @@
 
         bool selectedok=false;
 	bool warn=false;
+	KListViewItem *item;
 
         fp = popen("gpg --no-tty --with-colon --list-secret-keys", "r");
         while ( fgets( line, sizeof(line), fp)) {
@@ -294,13 +296,14 @@
         		keyName=KgpgInterface::checkForUtf8(keyName);
 			
 			
-                                KListViewItem *item=new \
KListViewItem(keysListpr,keyName,keyMail,id); +                                \
                item=new KListViewItem(keysListpr,keyName,keyMail,id);
                                 //KListViewItem *sub= new \
KListViewItem(item,i18n("ID: %1, trust: %2, expiration: \
%3").arg(id).arg(trust).arg(val));  KListViewItem *sub= new \
KListViewItem(item,i18n("Expiration:"),val);  sub->setSelectable(false);
                                 item->setPixmap(0,keyPair);
-                                if ((!defaultKeyID.isEmpty()) && \
(id.right(8)==defaultKeyID)) { +                                if \
                (preselected.find(id,0,false)!=-1) {
                                         keysListpr->setSelected(item,true);
+					keysListpr->setCurrentItem(item);
                                         selectedok=true;
                                 }
                         }
@@ -317,7 +320,10 @@
 
 
         if (!selectedok)
+	{
                 keysListpr->setSelected(keysListpr->firstChild(),true);
+		keysListpr->setCurrentItem(keysListpr->firstChild());
+	}
 
         vbox->addWidget(labeltxt);
         vbox->addWidget(keysListpr);
@@ -357,7 +363,15 @@
         /////  emit selected key
         if (keysListpr->currentItem()==NULL)
                 return(QString::null);
-        return(keysListpr->currentItem()->text(2));
+	QString result;
+	QPtrList< QListViewItem > list = keysListpr->selectedItems(false);
+	QListViewItem *item;
+    	for ( item = list.first(); item; item = list.next() )
+	{
+	result.append(item->text(2));
+	if (item!=list.getLast()) result.append(", ");
+	}
+        return(result);
 }
 
 QString KgpgSelKey::getkeyMail()
--- branches/KDE/3.5/kdeutils/kgpg/listkeys.h #450009:450010
@@ -70,7 +70,7 @@
         Q_OBJECT
 
 public:
-        KgpgSelKey( QWidget *parent = 0, const char *name = 0);
+        KgpgSelKey( QWidget *parent = 0, const char *name = 0,bool \
allowMultipleSelection=false, QString preselected=QString::null);  KListView \
*keysListpr;  QPixmap keyPair;
         QCheckBox *local;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic