diff options
Diffstat (limited to 'keylist.cpp')
-rw-r--r-- | keylist.cpp | 110 |
1 files changed, 60 insertions, 50 deletions
diff --git a/keylist.cpp b/keylist.cpp index 28e1376..9580bb7 100644 --- a/keylist.cpp +++ b/keylist.cpp @@ -1,7 +1,3 @@ - -#include <QWidget> -#include <QVBoxLayout> -#include <QListWidgetItem> /* * keylist.cpp * @@ -22,13 +18,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ +#include <QWidget> +#include <QVBoxLayout> +#include <QListWidgetItem> #include <QLabel> #include <QMessageBox> #include <QtGui> #include "keylist.h" KeyList::KeyList(QWidget *parent) - : QWidget(parent) + : QWidget(parent) { m_keyList = new QListWidget(); m_idList = new QList<QString>(); @@ -44,76 +43,87 @@ KeyList::KeyList(QWidget *parent) } -void KeyList::setContext(GpgME::Context *ctx) { - m_ctx = ctx; - refresh(); +void KeyList::setContext(GpgME::Context *ctx) +{ + m_ctx = ctx; + refresh(); +} + +void KeyList::setIconPath( QString path ) +{ + this->iconPath = path; } void KeyList::contextMenuEvent(QContextMenuEvent *event) { - QMenu menu(this); - menu.addAction(deleteKeyAct); - menu.exec(event->globalPos()); + QMenu menu(this); + menu.addAction(deleteKeyAct); + menu.exec(event->globalPos()); } -void KeyList::refresh() { - m_keyList->clear(); - m_idList->clear(); +void KeyList::refresh() +{ + m_keyList->clear(); + m_idList->clear(); - GpgKeyList keys = m_ctx->listKeys(); - GpgKeyList::iterator it = keys.begin(); - while (it != keys.end()) { - QListWidgetItem *tmp = new QListWidgetItem( + GpgKeyList keys = m_ctx->listKeys(); + 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->setCheckState( Qt::Unchecked ); - if(it->privkey == 1) tmp->setIcon(QIcon("icons/kgpg_key2.png")); - m_keyList->addItem(tmp); - - *m_idList << QString(it->id); - it++; - } + ); + 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); + it++; + } } -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); +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); + } } - } - return ret; + return ret; } -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); +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); + } } - } - return ret; + return ret; } -void KeyList::deleteKeys() { +void KeyList::deleteKeys() +{ - m_ctx->deleteKeys(getChecked()); - refresh(); + m_ctx->deleteKeys(getChecked()); + refresh(); } -void KeyList::deleteKey() { +void KeyList::deleteKey() +{ - m_ctx->deleteKeys(getSelected()); - refresh(); + m_ctx->deleteKeys(getSelected()); + refresh(); } void KeyList::createActions() { - deleteKeyAct = new QAction(tr("Delete Key"), this); - deleteKeyAct->setStatusTip(tr("Delete the selected keys")); - connect(deleteKeyAct, SIGNAL(triggered()), this, SLOT(deleteKey())); + deleteKeyAct = new QAction(tr("Delete Key"), this); + deleteKeyAct->setStatusTip(tr("Delete the selected keys")); + connect(deleteKeyAct, SIGNAL(triggered()), this, SLOT(deleteKey())); } |