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

libkleo

  • sources
  • kde-4.12
  • kdepim
  • libkleo
  • ui
keylistview.h
Go to the documentation of this file.
1 /*
2  keylistview.h
3 
4  This file is part of libkleopatra, the KDE keymanagement library
5  Copyright (c) 2004 Klarälvdalens Datakonsult AB
6 
7  Libkleopatra is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of the
10  License, or (at your option) any later version.
11 
12  Libkleopatra 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 __KLEO_KEYLISTVIEW_H__
34 #define __KLEO_KEYLISTVIEW_H__
35 
36 #include "kleo/kleo_export.h"
37 
38 #include <gpgme++/key.h>
39 
40 #include <QtCore/QByteArray>
41 #include <QTreeWidget>
42 #include <QHeaderView>
43 #include <KIcon>
44 
45 class QPainter;
46 class QColorGroup;
47 class QFont;
48 class QColor;
49 
50 namespace Kleo {
51 
52  // work around moc parser bug...
53 #define TEMPLATE_TYPENAME(T) template <typename T>
54  TEMPLATE_TYPENAME(T)
55  inline T * lvi_cast( QTreeWidgetItem * item ) {
56  return item && (item->type() == T::RTTI)
57  ? static_cast<T*>( item ) : 0 ;
58  }
59 
60  TEMPLATE_TYPENAME(T)
61  inline const T * lvi_cast( const QTreeWidgetItem * item ) {
62  return item && (item->type() == T::RTTI)
63  ? static_cast<const T*>( item ) : 0 ;
64  }
65 #undef TEMPLATE_TYPENAME
66 
67  class KeyListView;
68 
69  class KLEO_EXPORT KeyListViewItem : public QTreeWidgetItem {
70  public:
71  KeyListViewItem( KeyListView * parent, const GpgME::Key & key );
72  KeyListViewItem( KeyListView * parent, KeyListViewItem * after, const GpgME::Key & key );
73  KeyListViewItem( KeyListViewItem * parent, const GpgME::Key & key );
74  KeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, const GpgME::Key & key );
75  ~KeyListViewItem();
76 
77  void setKey( const GpgME::Key & key );
78  const GpgME::Key & key() const { return mKey; }
79 
80  enum { RTTI = QTreeWidgetItem::UserType + 1 };
81 
82  //
83  // only boring stuff below:
84  //
85  virtual QString toolTip( int column ) const;
86 
88  KeyListView * listView() const;
90  KeyListViewItem * nextSibling() const;
92  bool operator<( const QTreeWidgetItem &other ) const;
94  void takeItem( QTreeWidgetItem* item );
95 
96  private:
97  GpgME::Key mKey;
98  };
99 
100 
101  class KLEO_EXPORT KeyListView : public QTreeWidget {
102  Q_OBJECT
103  friend class KeyListViewItem;
104  public:
105 
106  class KLEO_EXPORT ColumnStrategy {
107  public:
108  virtual ~ColumnStrategy();
109  virtual QString title( int column ) const = 0;
110  virtual int width( int column, const QFontMetrics & fm ) const;
111  virtual QHeaderView::ResizeMode resizeMode( int ) const { return QHeaderView::Interactive; }
112 
113  virtual QString text( const GpgME::Key & key, int column ) const = 0;
114  virtual QString toolTip( const GpgME::Key & key, int column ) const;
115  virtual KIcon icon( const GpgME::Key &, int ) const { return KIcon(); }
116  virtual int compare( const GpgME::Key & key1, const GpgME::Key & key2, const int column ) const;
117  };
118 
119  class KLEO_EXPORT DisplayStrategy {
120  public:
121  virtual ~DisplayStrategy();
122  //font
123  virtual QFont keyFont( const GpgME::Key &, const QFont & ) const;
124  //foreground
125  virtual QColor keyForeground( const GpgME::Key & , const QColor & ) const;
126  //background
127  virtual QColor keyBackground( const GpgME::Key &, const QColor & ) const;
128  };
129 
130  explicit KeyListView( const ColumnStrategy * strategy,
131  const DisplayStrategy * display=0,
132  QWidget * parent=0, Qt::WindowFlags f=0 );
133 
134  ~KeyListView();
135 
136  const ColumnStrategy * columnStrategy() const { return mColumnStrategy; }
137  const DisplayStrategy * displayStrategy() const { return mDisplayStrategy; }
138 
139  bool hierarchical() const { return mHierarchical; }
140  virtual void setHierarchical( bool hier );
141 
142  void flushKeys() { slotUpdateTimeout(); }
143 
144  bool isMultiSelection() const;
145 
146  KeyListViewItem * itemByFingerprint( const QByteArray & ) const;
147 
148  using QTreeWidget::selectionChanged; // for below, but moc doesn't like it to be in the signals: section
149  Q_SIGNALS:
150  void doubleClicked( Kleo::KeyListViewItem*, int );
151  void returnPressed( Kleo::KeyListViewItem* );
152  void selectionChanged( Kleo::KeyListViewItem* );
153  void contextMenu( Kleo::KeyListViewItem*, const QPoint& );
154 
155  protected:
156  void keyPressEvent(QKeyEvent* event);
157 
158  public Q_SLOTS:
159  virtual void slotAddKey( const GpgME::Key & key );
160  virtual void slotRefreshKey( const GpgME::Key & key );
161 
162  //
163  // Only boring stuff below:
164  //
165  private Q_SLOTS:
166  void slotEmitDoubleClicked( QTreeWidgetItem*, int );
167  void slotEmitReturnPressed( QTreeWidgetItem* );
168  void slotEmitSelectionChanged();
169  void slotEmitContextMenu( const QPoint& pos );
170  void slotUpdateTimeout();
171 
172  public:
174  KeyListViewItem * selectedItem() const;
176  QList<KeyListViewItem*> selectedItems() const;
178  KeyListViewItem * firstChild() const;
180  void clear();
182  void takeItem( QTreeWidgetItem * );
183 
184  private:
185  void doHierarchicalInsert( const GpgME::Key & );
186  void gatherScattered();
187  void scatterGathered( KeyListViewItem* );
188  void registerItem( KeyListViewItem * );
189  void deregisterItem( const KeyListViewItem * );
190 
191  private:
192  const ColumnStrategy * mColumnStrategy;
193  const DisplayStrategy * mDisplayStrategy;
194  bool mHierarchical;
195 
196  class Private;
197  Private *const d;
198  };
199 }
200 
201 #endif // __KLEO_KEYLISTVIEW_H__
QTreeWidget
Kleo::KeyListView::flushKeys
void flushKeys()
Definition: keylistview.h:142
QWidget
QString
Kleo::KeyListView::hierarchical
bool hierarchical() const
Definition: keylistview.h:139
Kleo::KeyListView::columnStrategy
const ColumnStrategy * columnStrategy() const
Definition: keylistview.h:136
TEMPLATE_TYPENAME
#define TEMPLATE_TYPENAME(T)
Definition: keylistview.h:53
KLEO_EXPORT
#define KLEO_EXPORT
Definition: kleo_export.h:41
QTreeWidgetItem
Kleo::KeyListView::displayStrategy
const DisplayStrategy * displayStrategy() const
Definition: keylistview.h:137
Kleo::KeyListViewItem::key
const GpgME::Key & key() const
Definition: keylistview.h:78
Kleo::KeyListView::DisplayStrategy
Definition: keylistview.h:119
Kleo::KeyListView
Definition: keylistview.h:101
Kleo::KeyListView::ColumnStrategy::resizeMode
virtual QHeaderView::ResizeMode resizeMode(int) const
Definition: keylistview.h:111
Kleo::KeyListView::ColumnStrategy::icon
virtual KIcon icon(const GpgME::Key &, int) const
Definition: keylistview.h:115
Kleo::KeyListViewItem
Definition: keylistview.h:69
kleo_export.h
Kleo::lvi_cast
T * lvi_cast(QTreeWidgetItem *item)
Definition: keylistview.h:55
Kleo::KeyListView::ColumnStrategy
Definition: keylistview.h:106
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:57:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkleo

Skip menu "libkleo"
  • 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