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

kleopatra

  • sources
  • kde-4.14
  • kdepim
  • kleopatra
  • commands
detailscommand.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  commands/detailscommand.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2007 Klarälvdalens Datakonsult AB
6 
7  Kleopatra is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  Kleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the Qt library by Trolltech AS, Norway (or with modified versions
24  of Qt that use the same license as Qt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  Qt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #include <config-kleopatra.h>
34 
35 #include "detailscommand.h"
36 #include "command_p.h"
37 
38 #include <dialogs/certificatedetailsdialog.h>
39 
40 #include <KDebug>
41 
42 #include <cassert>
43 
44 using namespace Kleo;
45 using namespace Kleo::Commands;
46 using namespace Kleo::Dialogs;
47 using namespace GpgME;
48 
49 class DetailsCommand::Private : public Command::Private {
50  friend class ::Kleo::Commands::DetailsCommand;
51  DetailsCommand * q_func() const { return static_cast<DetailsCommand*>( q ); }
52 public:
53  explicit Private( DetailsCommand * qq, KeyListController * c );
54  ~Private();
55 
56 private:
57  void ensureDialogCreated() {
58  if ( dialog )
59  return;
60 
61  CertificateDetailsDialog * dlg = new CertificateDetailsDialog;
62  applyWindowID( dlg );
63  dlg->setAttribute( Qt::WA_DeleteOnClose );
64  connect( dlg, SIGNAL(rejected()), q_func(), SLOT(slotDialogClosed()) );
65 
66  dialog = dlg;
67  }
68 
69  void ensureDialogVisible() {
70  ensureDialogCreated();
71  if ( dialog->isVisible() )
72  dialog->raise();
73  else
74  dialog->show();
75  }
76 
77  void init() {
78  q->setWarnWhenRunningAtShutdown( false );
79  }
80 
81 private:
82  void slotDialogClosed();
83 
84 private:
85  QPointer<CertificateDetailsDialog> dialog;
86 };
87 
88 DetailsCommand::Private * DetailsCommand::d_func() { return static_cast<Private*>( d.get() ); }
89 const DetailsCommand::Private * DetailsCommand::d_func() const { return static_cast<const Private*>( d.get() ); }
90 
91 #define q q_func()
92 #define d d_func()
93 
94 DetailsCommand::Private::Private( DetailsCommand * qq, KeyListController * c )
95  : Command::Private( qq, c ),
96  dialog()
97 {
98 
99 }
100 
101 DetailsCommand::Private::~Private() {}
102 
103 DetailsCommand::DetailsCommand( KeyListController * p )
104  : Command( new Private( this, p ) )
105 {
106  d->init();
107 }
108 
109 DetailsCommand::DetailsCommand( QAbstractItemView * v, KeyListController * p )
110  : Command( v, new Private( this, p ) )
111 {
112  d->init();
113 }
114 
115 DetailsCommand::DetailsCommand( const Key & key, KeyListController * p )
116  : Command( new Private( this, p ) )
117 {
118  assert( !key.isNull() );
119  d->init();
120  setKey( key );
121 }
122 
123 DetailsCommand::DetailsCommand( const Key & key, QAbstractItemView * v, KeyListController * p )
124  : Command( v, new Private( this, p ) )
125 {
126  assert( !key.isNull() );
127  d->init();
128  setKey( key );
129 }
130 
131 DetailsCommand::~DetailsCommand() {}
132 
133 void DetailsCommand::doStart() {
134  const std::vector<Key> keys = d->keys();
135  Key key;
136  if ( keys.size() == 1 )
137  key = keys.front();
138  else
139  kWarning() << "can only work with one certificate at a time";
140 
141  if ( key.isNull() ) {
142  d->finished();
143  return;
144  }
145 
146  d->ensureDialogCreated();
147 
148  d->dialog->setKey( key );
149 
150  d->ensureDialogVisible();
151 }
152 
153 
154 void DetailsCommand::doCancel() {
155  if ( d->dialog )
156  d->dialog->close();
157 }
158 
159 void DetailsCommand::Private::slotDialogClosed() {
160  finished();
161 }
162 
163 
164 #undef q_func
165 #undef d_func
166 
167 #include "moc_detailscommand.cpp"
QAbstractItemView
Kleo::Command::Private
Definition: commands/command_p.h:52
Kleo::Commands::DetailsCommand::DetailsCommand
DetailsCommand(KeyListController *parent)
Definition: detailscommand.cpp:103
Kleo::KeyListController
Definition: keylistcontroller.h:55
QPointer< CertificateDetailsDialog >
Kleo::Command::d
kdtools::pimpl_ptr< Private > d
Definition: commands/command.h:129
Kleo::Command::setKey
void setKey(const GpgME::Key &key)
Definition: commands/command.cpp:172
detailscommand.h
command_p.h
q
#define q
Definition: detailscommand.cpp:91
Kleo::Commands::DetailsCommand
Definition: detailscommand.h:45
certificatedetailsdialog.h
d
#define d
Definition: detailscommand.cpp:92
Kleo::Commands::DetailsCommand::~DetailsCommand
~DetailsCommand()
Definition: detailscommand.cpp:131
Kleo::Command
Definition: commands/command.h:58
Kleo::Dialogs::CertificateDetailsDialog
Definition: certificatedetailsdialog.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kleopatra

Skip menu "kleopatra"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

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