certmanager Library API Documentation

keylistview.h

00001 /* 00002 keylistview.h 00003 00004 This file is part of libkleopatra, the KDE keymanagement library 00005 Copyright (c) 2004 Klarälvdalens Datakonsult AB 00006 00007 Libkleopatra is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License as 00009 published by the Free Software Foundation; either version 2 of the 00010 License, or (at your option) any later version. 00011 00012 Libkleopatra is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 In addition, as a special exception, the copyright holders give 00022 permission to link the code of this program with any edition of 00023 the Qt library by Trolltech AS, Norway (or with modified versions 00024 of Qt that use the same license as Qt), and distribute linked 00025 combinations including the two. You must obey the GNU General 00026 Public License in all respects for all of the code used other than 00027 Qt. If you modify this file, you may extend this exception to 00028 your version of the file, but you are not obligated to do so. If 00029 you do not wish to do so, delete this exception statement from 00030 your version. 00031 */ 00032 00033 #ifndef __KLEO_KEYLISTVIEW_H__ 00034 #define __KLEO_KEYLISTVIEW_H__ 00035 00036 #include <klistview.h> 00037 00038 #include <gpgmepp/key.h> 00039 00040 class QPainter; 00041 class QColorGroup; 00042 class QFont; 00043 class QColor; 00044 00045 namespace Kleo { 00046 00047 class KeyListView; 00048 00049 class KeyListViewItem : public QListViewItem { 00050 public: 00051 KeyListViewItem( KeyListView * parent, const GpgME::Key & key ); 00052 KeyListViewItem( KeyListView * parent, KeyListViewItem * after, const GpgME::Key & key ); 00053 KeyListViewItem( KeyListViewItem * parent, const GpgME::Key & key ); 00054 KeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, const GpgME::Key & key ); 00055 ~KeyListViewItem(); 00056 00057 void setKey( const GpgME::Key & key ); 00058 const GpgME::Key & key() const { return mKey; } 00059 00060 enum { RTTI_MASK = 0xFFFFFFF0, RTTI = 0x2C1362E0 }; 00061 00062 // 00063 // only boring stuff below: 00064 // 00065 virtual QString toolTip( int column ) const; 00066 00068 KeyListView * listView() const; 00070 KeyListViewItem * nextSibling() const; 00072 int compare( QListViewItem * other, int col, bool ascending ) const; 00074 QString key( int col, bool ascending ) const { return QListViewItem::key( col, ascending ); } 00076 int rtti() const { return RTTI; } 00078 void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int alignment ); 00079 00080 private: 00081 GpgME::Key mKey; 00082 }; 00083 00084 class SubkeyKeyListViewItem : public KeyListViewItem { 00085 public: 00086 SubkeyKeyListViewItem( KeyListView * parent, const GpgME::Subkey & subkey ); 00087 SubkeyKeyListViewItem( KeyListView * parent, KeyListViewItem * after, const GpgME::Subkey & subkey ); 00088 SubkeyKeyListViewItem( KeyListViewItem * parent, const GpgME::Subkey & subkey ); 00089 SubkeyKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, const GpgME::Subkey & subkey ); 00090 00091 void setSubkey( const GpgME::Subkey & subkey ); 00092 const GpgME::Subkey & subkey() const { return mSubkey; } 00093 00094 enum { RTTI = KeyListViewItem::RTTI + 1 }; 00095 00096 // 00097 // only boring stuff below: 00098 // 00100 QString toolTip( int col ) const; 00102 QString text( int col ) const; 00104 const QPixmap * pixmap( int col ) const; 00106 int compare( QListViewItem * other, int col, bool ascending ) const; 00108 int rtti() const { return RTTI; } 00110 void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int alignment ); 00111 00112 private: 00113 GpgME::Subkey mSubkey; 00114 }; 00115 00116 class UserIDKeyListViewItem : public KeyListViewItem { 00117 public: 00118 UserIDKeyListViewItem( KeyListView * parent, const GpgME::UserID & userid ); 00119 UserIDKeyListViewItem( KeyListView * parent, KeyListViewItem * after, const GpgME::UserID & userid ); 00120 UserIDKeyListViewItem( KeyListViewItem * parent, const GpgME::UserID & userid ); 00121 UserIDKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, const GpgME::UserID & userid ); 00122 00123 void setUserID( const GpgME::UserID & userid ); 00124 const GpgME::UserID userID() const { return mUserID; } 00125 00126 enum { RTTI = KeyListViewItem::RTTI + 2 }; 00127 00128 // 00129 // only boring stuff below: 00130 // 00132 QString toolTip( int col ) const; 00134 QString text( int col ) const; 00136 const QPixmap * pixmap( int col ) const; 00138 int compare( QListViewItem * other, int col, bool ascending ) const; 00140 int rtti() const { return RTTI; } 00142 void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int alignment ); 00143 00144 private: 00145 GpgME::UserID mUserID; 00146 }; 00147 00148 class SignatureKeyListViewItem : public KeyListViewItem { 00149 public: 00150 SignatureKeyListViewItem( KeyListView * parent, const GpgME::UserID::Signature & sig ); 00151 SignatureKeyListViewItem( KeyListView * parent, KeyListViewItem * after, const GpgME::UserID::Signature & sig ); 00152 SignatureKeyListViewItem( KeyListViewItem * parent, const GpgME::UserID::Signature & sig ); 00153 SignatureKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, const GpgME::UserID::Signature & sig ); 00154 00155 void setSignature( const GpgME::UserID::Signature & sig ); 00156 const GpgME::UserID::Signature & signature() const { return mSignature; } 00157 00158 enum { RTTI = KeyListViewItem::RTTI + 3 }; 00159 00160 // 00161 // only boring stuff below: 00162 // 00164 QString toolTip( int col ) const; 00166 QString text( int col ) const; 00168 const QPixmap * pixmap( int col ) const; 00170 int compare( QListViewItem * other, int col, bool ascending ) const; 00172 int rtti() const { return RTTI; } 00174 void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int alignment ); 00175 00176 private: 00177 GpgME::UserID::Signature mSignature; 00178 }; 00179 00180 00181 class KeyListView : public KListView { 00182 Q_OBJECT 00183 friend class KeyListViewItem; 00184 public: 00185 class ColumnStrategy; 00186 class DisplayStrategy; 00187 00188 00189 KeyListView( const ColumnStrategy * strategy, 00190 const DisplayStrategy * display=0, 00191 QWidget * parent=0, const char * name=0, WFlags f=0 ); 00192 00193 ~KeyListView(); 00194 00195 const ColumnStrategy * columnStrategy() const { return mColumnStrategy; } 00196 const DisplayStrategy * displayStrategy() const { return mDisplayStrategy; } 00197 00198 bool hierarchical() const { return mHierarchical; } 00199 virtual void setHierarchical( bool hier ); 00200 00201 void flushKeys() { slotUpdateTimeout(); } 00202 00203 bool hasSelection() const; 00204 00205 signals: 00206 void doubleClicked( Kleo::KeyListViewItem*, const QPoint&, int ); 00207 void returnPressed( Kleo::KeyListViewItem* ); 00208 void selectionChanged( Kleo::KeyListViewItem* ); 00209 void contextMenu( Kleo::KeyListViewItem*, const QPoint& ); 00210 00211 public slots: 00212 virtual void slotAddKey( const GpgME::Key & key ); 00213 virtual void slotRefreshKey( const GpgME::Key & key ); 00214 00215 // 00216 // Only boring stuff below: 00217 // 00218 private slots: 00219 void slotEmitDoubleClicked( QListViewItem*, const QPoint&, int ); 00220 void slotEmitReturnPressed( QListViewItem* ); 00221 void slotEmitSelectionChanged( QListViewItem* ); 00222 void slotEmitContextMenu( KListView*, QListViewItem*, const QPoint& ); 00223 void slotUpdateTimeout(); 00224 00225 public: 00227 KeyListViewItem * selectedItem() const; 00229 QPtrList<KeyListViewItem> selectedItems() const; 00231 KeyListViewItem * firstChild() const; 00233 void clear(); 00234 00235 private: 00236 void doHierarchicalInsert( const GpgME::Key & ); 00237 void gatherScattered(); 00238 void scatterGathered( QListViewItem * ); 00239 void refillFingerprintDictionary(); 00240 KeyListViewItem * parentFor( const QCString & ) const; 00241 void deregisterItem( const KeyListViewItem * ); 00242 00243 private: 00244 const ColumnStrategy * mColumnStrategy; 00245 const DisplayStrategy * mDisplayStrategy; 00246 bool mHierarchical; 00247 00248 class Private; 00249 Private * d; 00250 }; 00251 00252 class KeyListView::ColumnStrategy { 00253 public: 00254 virtual ~ColumnStrategy(); 00255 virtual QString title( int column ) const = 0; 00256 virtual int width( int column, const QFontMetrics & fm ) const; 00257 virtual QListView::WidthMode widthMode( int ) const { return QListView::Manual; } 00258 00259 virtual QString text( const GpgME::Key & key, int column ) const = 0; 00260 virtual QString toolTip( const GpgME::Key & key, int column ) const; 00261 virtual const QPixmap * pixmap( const GpgME::Key &, int ) const { return 0; } 00262 virtual int compare( const GpgME::Key & key1, const GpgME::Key & key2, const int column ) const; 00263 00264 virtual QString subkeyText( const GpgME::Subkey &, int ) const { return QString::null; } 00265 virtual QString subkeyToolTip( const GpgME::Subkey & subkey, int column ) const; 00266 virtual const QPixmap * subkeyPixmap( const GpgME::Subkey &, int ) const { return 0; } 00267 virtual int subkeyCompare( const GpgME::Subkey & subkey1, const GpgME::Subkey & subkey2, const int column ) const; 00268 00269 virtual QString userIDText( const GpgME::UserID &, int ) const { return QString::null; } 00270 virtual QString userIDToolTip( const GpgME::UserID & userID, int column ) const; 00271 virtual const QPixmap * userIDPixmap( const GpgME::UserID &, int ) const { return 0; } 00272 virtual int userIDCompare( const GpgME::UserID & userID1, const GpgME::UserID & userID2, const int column ) const; 00273 00274 virtual QString signatureText( const GpgME::UserID::Signature &, int ) const { return QString::null; } 00275 virtual QString signatureToolTip( const GpgME::UserID::Signature & sig, int column ) const; 00276 virtual const QPixmap * signaturePixmap( const GpgME::UserID::Signature &, int ) const { return 0; } 00277 virtual int signatureCompare( const GpgME::UserID::Signature & sig1, const GpgME::UserID::Signature & sig2, const int column ) const; 00278 }; 00279 00280 class KeyListView::DisplayStrategy { 00281 public: 00282 virtual ~DisplayStrategy(); 00283 //font 00284 virtual QFont keyFont( const GpgME::Key &, const QFont & ) const; 00285 virtual QFont subkeyFont( const GpgME::Subkey &, const QFont & ) const; 00286 virtual QFont useridFont( const GpgME::UserID &, const QFont & ) const; 00287 virtual QFont signatureFont( const GpgME::UserID::Signature & , const QFont & ) const; 00288 //foreground 00289 virtual QColor keyForeground( const GpgME::Key & , const QColor & ) const; 00290 virtual QColor subkeyForeground( const GpgME::Subkey &, const QColor & ) const; 00291 virtual QColor useridForeground( const GpgME::UserID &, const QColor & ) const; 00292 virtual QColor signatureForeground( const GpgME::UserID::Signature &, const QColor & ) const; 00293 //background 00294 virtual QColor keyBackground( const GpgME::Key &, const QColor & ) const; 00295 virtual QColor subkeyBackground( const GpgME::Subkey &, const QColor & ) const; 00296 virtual QColor useridBackground( const GpgME::UserID &, const QColor & ) const; 00297 virtual QColor signatureBackground( const GpgME::UserID::Signature &, const QColor & ) const; 00298 }; 00299 00300 } 00301 00302 #endif // __KLEO_KEYLISTVIEW_H__
KDE Logo
This file is part of the documentation for certmanager Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:18:46 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003