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

kleopatra

  • sources
  • kde-4.12
  • kdepim
  • kleopatra
  • commands
commands/command_p.h
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  commands/command_p.h
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 #ifndef __KLEOPATRA_COMMANDS_COMMAND_P_H__
34 #define __KLEOPATRA_COMMANDS_COMMAND_P_H__
35 
36 #include "command.h"
37 #include "view/keylistcontroller.h"
38 #include "models/keylistmodel.h"
39 
40 #include <KMessageBox>
41 
42 #include <QAbstractItemView>
43 #include <QPointer>
44 #include <QList>
45 #include <QModelIndex>
46 
47 #include <gpgme++/key.h>
48 
49 #include <algorithm>
50 #include <iterator>
51 
52 class Kleo::Command::Private {
53  friend class ::Kleo::Command;
54 protected:
55  Command * const q;
56 public:
57  explicit Private( Command * qq, KeyListController * controller );
58  virtual ~Private();
59 
60  QAbstractItemView * view() const { return view_; }
61  QWidget * parentWidgetOrView() const { if ( parentWidget_ ) return parentWidget_; else return view_; }
62  KeyListModelInterface * model() const { return view_ ? dynamic_cast<KeyListModelInterface*>( view_->model() ) : 0 ; }
63  KeyListController * controller() const { return controller_; }
64  QList<QModelIndex> indexes() const {
65  QList<QModelIndex> result;
66  std::copy( indexes_.begin(), indexes_.end(), std::back_inserter( result ) );
67  return result;
68  }
69  GpgME::Key key() const { return keys_.empty() ? model() && !indexes_.empty() ? model()->key( indexes_.front() ) : GpgME::Key::null : keys_.front() ; }
70  std::vector<GpgME::Key> keys() const { return keys_.empty() ? model() ? model()->keys( indexes() ) : std::vector<GpgME::Key>() : keys_ ; }
71 
72  void finished() {
73  emit q->finished();
74  if ( autoDelete )
75  q->deleteLater();
76  }
77 
78  void canceled() {
79  emit q->canceled();
80  finished();
81  }
82 
83  void error( const QString & text, const QString & caption=QString(), KMessageBox::Options options=KMessageBox::Notify ) const {
84  if ( parentWId )
85  KMessageBox::errorWId( parentWId, text, caption, options );
86  else
87  KMessageBox::error( parentWidgetOrView(), text, caption, options );
88  }
89  void information( const QString & text, const QString & caption=QString(), const QString & dontShowAgainName=QString(), KMessageBox::Options options=KMessageBox::Notify ) const {
90  if ( parentWId )
91  KMessageBox::informationWId( parentWId, text, caption, dontShowAgainName, options );
92  else
93  KMessageBox::information( parentWidgetOrView(), text, caption, dontShowAgainName, options );
94  }
95 
96  void applyWindowID( QWidget * w ) const {
97  return q->applyWindowID( w );
98  }
99 
100 private:
101  bool autoDelete : 1;
102  bool warnWhenRunningAtShutdown : 1;
103  std::vector<GpgME::Key> keys_;
104  QList<QPersistentModelIndex> indexes_;
105  QPointer<QAbstractItemView> view_;
106  QPointer<QWidget> parentWidget_;
107  WId parentWId;
108  QPointer<KeyListController> controller_;
109 };
110 
111 #endif /* __KLEOPATRA_COMMANDS_COMMAND_P_H__ */
Kleo::Command::Private::canceled
void canceled()
Definition: commands/command_p.h:78
keylistcontroller.h
Kleo::Command::Private::model
KeyListModelInterface * model() const
Definition: commands/command_p.h:62
Kleo::Command::finished
void finished()
Kleo::Command::Private
Definition: commands/command_p.h:52
Kleo::KeyListController
Definition: keylistcontroller.h:55
QWidget
Kleo::Command::Private::key
GpgME::Key key() const
Definition: commands/command_p.h:69
Kleo::KeyListModelInterface::key
virtual GpgME::Key key(const QModelIndex &idx) const =0
Kleo::Command::Private::q
Command *const q
Definition: commands/command_p.h:55
Kleo::Command::Private::parentWidgetOrView
QWidget * parentWidgetOrView() const
Definition: commands/command_p.h:61
Kleo::Command::Private::~Private
virtual ~Private()
Definition: commands/command.cpp:60
Kleo::Command::Private::indexes
QList< QModelIndex > indexes() const
Definition: commands/command_p.h:64
Kleo::Command::Private::keys
std::vector< GpgME::Key > keys() const
Definition: commands/command_p.h:70
Kleo::Command::Private::applyWindowID
void applyWindowID(QWidget *w) const
Definition: commands/command_p.h:96
Kleo::KeyListModelInterface
Definition: keylistmodelinterface.h:47
keylistmodel.h
Kleo::Command::Private::controller
KeyListController * controller() const
Definition: commands/command_p.h:63
Kleo::Command::canceled
void canceled()
command.h
Kleo::Command::Private::finished
void finished()
Definition: commands/command_p.h:72
Kleo::Command::Private::information
void information(const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), KMessageBox::Options options=KMessageBox::Notify) const
Definition: commands/command_p.h:89
Kleo::Command::Private::view
QAbstractItemView * view() const
Definition: commands/command_p.h:60
Kleo::KeyListModelInterface::keys
virtual std::vector< GpgME::Key > keys(const QList< QModelIndex > &idxs) const =0
Kleo::Command::Private::Private
Private(Command *qq, KeyListController *controller)
Definition: commands/command.cpp:48
Kleo::Command
Definition: commands/command.h:58
QList
Definition: commands/command.h:46
Kleo::Command::Private::error
void error(const QString &text, const QString &caption=QString(), KMessageBox::Options options=KMessageBox::Notify) const
Definition: commands/command_p.h:83
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:40 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

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