• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kgpg

  • sources
  • kde-4.14
  • kdeutils
  • kgpg
selectsecretkey.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * This program is free software; you can redistribute it and/or modify *
4  * it under the terms of the GNU General Public License as published by *
5  * the Free Software Foundation; either version 2 of the License, or *
6  * (at your option) any later version. *
7  * *
8  ***************************************************************************/
9 
10 #include "selectsecretkey.h"
11 
12 #include "kgpgsettings.h"
13 #include "core/images.h"
14 #include "core/KGpgRootNode.h"
15 #include "model/kgpgitemmodel.h"
16 #include "model/selectkeyproxymodel.h"
17 
18 #include <KComboBox>
19 #include <KLocale>
20 #include <QVBoxLayout>
21 #include <QCheckBox>
22 #include <QLabel>
23 #include <QTableView>
24 
25 using namespace KgpgCore;
26 
27 KgpgSelectSecretKey::KgpgSelectSecretKey(QWidget *parent, KGpgItemModel *model, const int countkey, const bool allowLocal, const bool allowTerminal)
28  : KDialog(parent),
29  m_localsign(NULL),
30  m_terminalsign(NULL),
31  m_signtrust(NULL),
32  m_proxy(new SelectSecretKeyProxyModel(this))
33 {
34  setCaption(i18n("Private Key List"));
35  setButtons(Ok | Cancel);
36  setDefaultButton(Ok);
37  QWidget *page = new QWidget(this);
38 
39  QLabel *label = new QLabel(i18n("Choose secret key for signing:"), page);
40 
41  m_proxy->setKeyModel(model);
42 
43  m_keyslist = new QTableView(page);
44  m_keyslist->setModel(m_proxy);
45  m_keyslist->setSortingEnabled(true);
46  m_keyslist->setSelectionBehavior(QAbstractItemView::SelectRows);
47  m_keyslist->resizeColumnsToContents();
48 
49  QVBoxLayout *vbox = new QVBoxLayout(page);
50  vbox->addWidget(label);
51  vbox->addWidget(m_keyslist);
52 
53  if (countkey > 0) {
54  QLabel *signchecklabel = new QLabel(i18np("How carefully have you checked that the key really "
55  "belongs to the person with whom you wish to communicate:",
56  "How carefully have you checked that the %1 keys really "
57  "belong to the people with whom you wish to communicate:", countkey), page);
58  signchecklabel->setWordWrap(true);
59 
60  m_signtrust = new KComboBox(page);
61  m_signtrust->addItem(i18n("I Will Not Answer"));
62  m_signtrust->addItem(i18n("I Have Not Checked at All"));
63  m_signtrust->addItem(i18n("I Have Done Casual Checking"));
64  m_signtrust->addItem(i18n("I Have Done Very Careful Checking"));
65 
66  vbox->addWidget(signchecklabel);
67  vbox->addWidget(m_signtrust);
68  if (allowLocal){
69  m_localsign = new QCheckBox(i18n("Local signature (cannot be exported)"), page);
70  vbox->addWidget(m_localsign);
71  }
72  if (allowTerminal && (countkey == 1)) {
73  m_terminalsign = new QCheckBox(i18n("Do not sign all user id's (open terminal)"), page);
74  vbox->addWidget(m_terminalsign);
75  }
76  }
77 
78  KGpgNode *nd = model->getRootNode()->findKey(KGpgSettings::defaultKey());
79  if (nd != NULL) {
80  QModelIndex sidx = model->nodeIndex(nd);
81  QModelIndex pidx = m_proxy->mapFromSource(sidx);
82  m_keyslist->selectionModel()->setCurrentIndex(pidx, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
83  }
84 
85  setMinimumSize(550, 200);
86  slotSelectionChanged();
87  setMainWidget(page);
88 
89  connect(m_keyslist->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(slotSelectionChanged()));
90  connect(m_keyslist, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotOk()));
91 }
92 
93 KgpgSelectSecretKey::~KgpgSelectSecretKey()
94 {
95 }
96 
97 QString KgpgSelectSecretKey::getKeyID() const
98 {
99  if (!m_keyslist->selectionModel()->hasSelection())
100  return QString();
101  return m_proxy->nodeForIndex(m_keyslist->selectionModel()->selectedIndexes().at(0))->getId();
102 }
103 
104 QString KgpgSelectSecretKey::getKeyMail() const
105 {
106  if (!m_keyslist->selectionModel()->hasSelection())
107  return QString();
108  return m_proxy->nodeForIndex(m_keyslist->selectionModel()->selectedIndexes().at(0))->getEmail();
109 }
110 
111 int KgpgSelectSecretKey::getSignTrust() const
112 {
113  if (m_signtrust)
114  return m_signtrust->currentIndex();
115  return -1;
116 }
117 
118 bool KgpgSelectSecretKey::isLocalSign() const
119 {
120  return m_localsign && m_localsign->isChecked();
121 }
122 
123 bool KgpgSelectSecretKey::isTerminalSign() const
124 {
125  return m_terminalsign && m_terminalsign->isChecked();
126 }
127 
128 void KgpgSelectSecretKey::slotSelectionChanged()
129 {
130  enableButtonOk(m_keyslist->selectionModel()->hasSelection());
131 }
132 
133 void KgpgSelectSecretKey::slotOk()
134 {
135  if (m_keyslist->selectionModel()->hasSelection())
136  slotButtonClicked(Ok);
137 }
138 
139 #include "selectsecretkey.moc"
SelectKeyProxyModel::nodeForIndex
KGpgNode * nodeForIndex(const QModelIndex &index) const
Definition: selectkeyproxymodel.cpp:81
KGpgItemModel
Definition: kgpgitemmodel.h:44
QModelIndex
QWidget
KgpgSelectSecretKey::getSignTrust
int getSignTrust() const
Definition: selectsecretkey.cpp:111
KGpgSettings::defaultKey
static QString defaultKey()
Definition: kgpgsettings.h:24
QAbstractItemView::selectionModel
QItemSelectionModel * selectionModel() const
QTableView::resizeColumnsToContents
void resizeColumnsToContents()
KgpgSelectSecretKey::isTerminalSign
bool isTerminalSign() const
Definition: selectsecretkey.cpp:123
KgpgSelectSecretKey::KgpgSelectSecretKey
KgpgSelectSecretKey(QWidget *parent, KGpgItemModel *model, const int countkey=0, const bool allowLocal=true, const bool allowTerminal=true)
Constructor.
Definition: selectsecretkey.cpp:27
selectsecretkey.h
QTableView::setSortingEnabled
void setSortingEnabled(bool enable)
images.h
KDialog
QAbstractItemView::setSelectionBehavior
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)
KgpgSelectSecretKey::getKeyID
QString getKeyID() const
Definition: selectsecretkey.cpp:97
KGpgRootNode.h
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QTableView::setModel
virtual void setModel(QAbstractItemModel *model)
QCheckBox
kgpgitemmodel.h
QItemSelectionModel::selectedIndexes
QModelIndexList selectedIndexes() const
KgpgSelectSecretKey::~KgpgSelectSecretKey
~KgpgSelectSecretKey()
Definition: selectsecretkey.cpp:93
QItemSelectionModel::hasSelection
bool hasSelection() const
SelectKeyProxyModel::setKeyModel
void setKeyModel(KGpgItemModel *)
Definition: selectkeyproxymodel.cpp:37
QVBoxLayout
QString
QTableView
KGpgNode
The abstract base class for all classes representing keyring data.
Definition: KGpgNode.h:42
KGpgItemModel::getRootNode
KGpgRootNode * getRootNode() const
Definition: kgpgitemmodel.cpp:250
KGpgRootNode::findKey
KGpgKeyNode * findKey(const QString &keyId)
Find a key node with the given id.
Definition: KGpgRootNode.cpp:118
kgpgsettings.h
QAbstractButton::isChecked
bool isChecked() const
QItemSelection
KgpgSelectSecretKey::isLocalSign
bool isLocalSign() const
Definition: selectsecretkey.cpp:118
QSortFilterProxyModel::mapFromSource
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
SelectSecretKeyProxyModel
Definition: selectkeyproxymodel.h:60
KGpgItemModel::nodeIndex
QModelIndex nodeIndex(KGpgNode *node, const int column=0)
Definition: kgpgitemmodel.cpp:406
KgpgSelectSecretKey::getKeyMail
QString getKeyMail() const
Definition: selectsecretkey.cpp:104
QItemSelectionModel::setCurrentIndex
void setCurrentIndex(const QModelIndex &index, QFlags< QItemSelectionModel::SelectionFlag > command)
QLabel
QLabel::setWordWrap
void setWordWrap(bool on)
selectkeyproxymodel.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kgpg

Skip menu "kgpg"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal