aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--context.cpp4
-rw-r--r--context.h2
-rw-r--r--gpgwin.cpp8
-rw-r--r--gpgwin.h3
-rw-r--r--keylist.cpp68
-rw-r--r--keylist.h5
6 files changed, 56 insertions, 34 deletions
diff --git a/context.cpp b/context.cpp
index 47188fb..caa9884 100644
--- a/context.cpp
+++ b/context.cpp
@@ -150,9 +150,9 @@ GpgKeyList Context::listKeys()
GpgKeyList::iterator it = keys.begin();
while (it != keys.end()) {
if (key->subkeys->keyid == it->id.toStdString())
- it->privkey = 1;
+ it->privkey = true;
else
- it->privkey = 0;
+ it->privkey = false;
it++;
}
diff --git a/context.h b/context.h
index 868b085..74488b4 100644
--- a/context.h
+++ b/context.h
@@ -33,7 +33,7 @@ public:
QString id;
QString name;
QString email;
- int privkey;
+ bool privkey;
};
typedef QLinkedList< GpgKey > GpgKeyList;
diff --git a/gpgwin.cpp b/gpgwin.cpp
index 34baee8..fbf8c24 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -56,10 +56,10 @@ GpgWin::GpgWin()
m_keyList->setContext(myCtx);
/* List of binary Attachments */
- m_attachments = new Attachments();
+ /*m_attachments = new Attachments();
m_attachments->setIconPath(iconPath);
m_attachments->setContext(myCtx);
- m_attachments->setKeyList(m_keyList);
+ m_attachments->setKeyList(m_keyList);*/
createActions();
createMenus();
@@ -232,10 +232,10 @@ void GpgWin::createDockWindows()
addDockWidget(Qt::RightDockWidgetArea, dock);
dock->setWidget(m_keyList);
- dock = new QDockWidget(tr("Attached files:"), this);
+ /*dock = new QDockWidget(tr("Attached files:"), this);
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea );
addDockWidget(Qt::BottomDockWidgetArea, dock);
- dock->setWidget(m_attachments);
+ dock->setWidget(m_attachments);*/
}
diff --git a/gpgwin.h b/gpgwin.h
index 995662f..53028da 100644
--- a/gpgwin.h
+++ b/gpgwin.h
@@ -81,9 +81,6 @@ private:
QToolBar *editToolBar;
QPushButton *browseButton;
QWidget *keywindow;
- QGroupBox *prStyGroup;
- QRadioButton *prsty1;
- QRadioButton *prsty2;
QAction *openAct;
QAction *saveAct;
diff --git a/keylist.cpp b/keylist.cpp
index 710afc7..c4a62a0 100644
--- a/keylist.cpp
+++ b/keylist.cpp
@@ -20,7 +20,7 @@
*/
#include <QWidget>
#include <QVBoxLayout>
-#include <QListWidgetItem>
+#include <QTableWidgetItem>
#include <QLabel>
#include <QMessageBox>
#include <QtGui>
@@ -29,9 +29,17 @@
KeyList::KeyList(QWidget *parent)
: QWidget(parent)
{
- m_keyList = new QListWidget();
- m_idList = new QList<QString>();
- m_deleteButton = new QPushButton(tr("Delete Selected Keys"));
+ m_keyList = new QTableWidget(this);
+ m_keyList->setColumnCount(5);
+ m_keyList->verticalHeader()->hide();
+ m_keyList->setShowGrid(false);
+ m_keyList->setColumnWidth(0, 24);
+ m_keyList->setColumnWidth(1, 20);
+ m_keyList->sortByColumn(2,Qt::AscendingOrder);
+ m_keyList->setSelectionBehavior(QAbstractItemView::SelectRows);
+ m_keyList->setColumnHidden(4, true);
+
+ m_deleteButton = new QPushButton(tr("Delete Checked Keys"));
connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteKeys()));
@@ -64,31 +72,48 @@ void KeyList::contextMenuEvent(QContextMenuEvent *event)
void KeyList::refresh()
{
m_keyList->clear();
- m_idList->clear();
-
+
+ QStringList labels;
+ labels << "" << "" << "Name" << "EMail" << "id";
+ m_keyList->setHorizontalHeaderLabels(labels);
+
GpgKeyList keys = m_ctx->listKeys();
+ m_keyList->setRowCount(keys.size());
+ QTableWidgetItem *tmp;
+ int row=0;
GpgKeyList::iterator it = keys.begin();
while (it != keys.end()) {
- QListWidgetItem *tmp = new QListWidgetItem(
- it->name + " <" + it->email + ">"
- );
- tmp->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+
+ tmp = new QTableWidgetItem();
+ tmp->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
tmp->setCheckState(Qt::Unchecked);
- if (it->privkey == 1) tmp->setIcon(QIcon(iconPath + "kgpg_key2.png"));
- m_keyList->addItem(tmp);
-
- *m_idList << QString(it->id);
+ m_keyList->setItem(row, 0, tmp);
+
+ if(it->privkey) {
+ tmp = new QTableWidgetItem(QIcon(iconPath + "kgpg_key2.png"),"");
+ m_keyList->setItem(row, 1, tmp);
+ }
+ tmp = new QTableWidgetItem(it->name);
+ tmp->setToolTip(it->name);
+ m_keyList->setItem(row, 2, tmp);
+ tmp = new QTableWidgetItem(it->email);
+ tmp->setToolTip(it->email);
+ m_keyList->setItem(row, 3, tmp);
+ tmp = new QTableWidgetItem(it->id);
+ m_keyList->setItem(row, 4, tmp);
it++;
+ ++row;
}
+ m_keyList->setSortingEnabled(true);
}
QList<QString> *KeyList::getChecked()
{
QList<QString> *ret = new QList<QString>();
- for (int i = 0; i < m_keyList->count(); i++) {
- if (m_keyList->item(i)->checkState() == Qt::Checked) {
- *ret << m_idList->at(i);
+ for (int i = 0; i < m_keyList->rowCount(); i++) {
+ if (m_keyList->item(i,0)->checkState() == Qt::Checked) {
+ *ret << m_keyList->item(i,4)->text();
}
}
return ret;
@@ -97,9 +122,10 @@ QList<QString> *KeyList::getChecked()
QList<QString> *KeyList::getSelected()
{
QList<QString> *ret = new QList<QString>();
- for (int i = 0; i < m_keyList->count(); i++) {
- if (m_keyList->item(i)->isSelected() == 1) {
- *ret << m_idList->at(i);
+
+ for (int i = 0; i < m_keyList->rowCount(); i++) {
+ if (m_keyList->item(i,0)->isSelected() == 1) {
+ *ret << m_keyList->item(i,4)->text();
}
}
return ret;
@@ -124,6 +150,6 @@ void KeyList::deleteKey()
void KeyList::createActions()
{
deleteKeyAct = new QAction(tr("Delete Key"), this);
- deleteKeyAct->setStatusTip(tr("Delete the selected keys"));
+ deleteKeyAct->setStatusTip(tr("Delete the checked keys"));
connect(deleteKeyAct, SIGNAL(triggered()), this, SLOT(deleteKey()));
}
diff --git a/keylist.h b/keylist.h
index 2edd0f3..e1637a7 100644
--- a/keylist.h
+++ b/keylist.h
@@ -23,7 +23,7 @@
#define __KEYLIST_H__
#include <QWidget>
-#include <QListWidget>
+#include <QTableWidget>
#include <QPushButton>
#include "context.h"
@@ -47,8 +47,7 @@ public:
private:
GpgME::Context *m_ctx;
- QListWidget *m_keyList;
- QList<QString> *m_idList;
+ QTableWidget *m_keyList;
QPushButton *m_deleteButton;
QAction *deleteKeyAct;
void createActions();