certmanager/lib 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 00056 void setKey( const GpgME::Key & key ); 00057 const GpgME::Key & key() const { return mKey; } 00058 00059 enum { RTTI_MASK = 0xFFFFFFF0, RTTI = 0x2C1362E0 }; 00060 00061 // 00062 // only boring stuff below: 00063 // 00064 virtual QString toolTip( int column ) const; 00065 00067 KeyListView * listView() const; 00069 KeyListViewItem * nextSibling() const; 00071 int compare( QListViewItem * other, int col, bool ascending ) const; 00073 QString key( int col, bool ascending ) const { return QListViewItem::key( col, ascending ); } 00075 int rtti() const { return RTTI; } 00077 void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int alignment ); 00078 00079 private: 00080 GpgME::Key mKey; 00081 }; 00082 00083 class SubkeyKeyListViewItem : public KeyListViewItem { 00084 public: 00085 SubkeyKeyListViewItem( KeyListView * parent, const GpgME::Subkey & subkey ); 00086 SubkeyKeyListViewItem( KeyListView * parent, KeyListViewItem * after, const GpgME::Subkey & subkey ); 00087 SubkeyKeyListViewItem( KeyListViewItem * parent, const GpgME::Subkey & subkey ); 00088 SubkeyKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, const GpgME::Subkey & subkey ); 00089 00090 void setSubkey( const GpgME::Subkey & subkey ); 00091 const GpgME::Subkey & subkey() const { return mSubkey; } 00092 00093 enum { RTTI = KeyListViewItem::RTTI + 1 }; 00094 00095 // 00096 // only boring stuff below: 00097 // 00099 QString toolTip( int col ) const; 00101 QString text( int col ) const; 00103 const QPixmap * pixmap( int col ) const; 00105 int compare( QListViewItem * other, int col, bool ascending ) const; 00107 int rtti() const { return RTTI; } 00109 void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int alignment ); 00110 00111 private: 00112 GpgME::Subkey mSubkey; 00113 }; 00114 00115 class UserIDKeyListViewItem : public KeyListViewItem { 00116 public: 00117 UserIDKeyListViewItem( KeyListView * parent, const GpgME::UserID & userid ); 00118 UserIDKeyListViewItem( KeyListView * parent, KeyListViewItem * after, const GpgME::UserID & userid ); 00119 UserIDKeyListViewItem( KeyListViewItem * parent, const GpgME::UserID & userid ); 00120 UserIDKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, const GpgME::UserID & userid ); 00121 00122 void setUserID( const GpgME::UserID & userid ); 00123 const GpgME::UserID userID() const { return mUserID; } 00124 00125 enum { RTTI = KeyListViewItem::RTTI + 2 }; 00126 00127 // 00128 // only boring stuff below: 00129 // 00131 QString toolTip( int col ) const; 00133 QString text( int col ) const; 00135 const QPixmap * pixmap( int col ) const; 00137 int compare( QListViewItem * other, int col, bool ascending ) const; 00139 int rtti() const { return RTTI; } 00141 void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int alignment ); 00142 00143 private: 00144 GpgME::UserID mUserID; 00145 }; 00146 00147 class SignatureKeyListViewItem : public KeyListViewItem { 00148 public: 00149 SignatureKeyListViewItem( KeyListView * parent, const GpgME::UserID::Signature & sig ); 00150 SignatureKeyListViewItem( KeyListView * parent, KeyListViewItem * after, const GpgME::UserID::Signature & sig ); 00151 SignatureKeyListViewItem( KeyListViewItem * parent, const GpgME::UserID::Signature & sig ); 00152 SignatureKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after, const GpgME::UserID::Signature & sig ); 00153 00154 void setSignature( const GpgME::UserID::Signature & sig ); 00155 const GpgME::UserID::Signature & signature() const { return mSignature; } 00156 00157 enum { RTTI = KeyListViewItem::RTTI + 3 }; 00158 00159 // 00160 // only boring stuff below: 00161 // 00163 QString toolTip( int col ) const; 00165 QString text( int col ) const; 00167 const QPixmap * pixmap( int col ) const; 00169 int compare( QListViewItem * other, int col, bool ascending ) const; 00171 int rtti() const { return RTTI; } 00173 void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int alignment ); 00174 00175 private: 00176 GpgME::UserID::Signature mSignature; 00177 }; 00178 00179 00180 class KeyListView : public KListView { 00181 Q_OBJECT 00182 public: 00183 class ColumnStrategy; 00184 class DisplayStrategy; 00185 00186 00187 KeyListView( const ColumnStrategy * strategy, 00188 const DisplayStrategy * display=0, 00189 QWidget * parent=0, const char * name=0, WFlags f=0 ); 00190 00191 ~KeyListView(); 00192 00193 const ColumnStrategy * columnStrategy() const { return mColumnStrategy; } 00194 const DisplayStrategy * displayStrategy() const { return mDisplayStrategy; } 00195 00196 bool hierarchical() const { return mHierarchical; } 00197 virtual void setHierarchical( bool hier ); 00198 00199 void flushKeys() { slotUpdateTimeout(); } 00200 00201 bool hasSelection() const; 00202 00203 signals: 00204 void doubleClicked( Kleo::KeyListViewItem*, const QPoint&, int ); 00205 void returnPressed( Kleo::KeyListViewItem* ); 00206 void selectionChanged( Kleo::KeyListViewItem* ); 00207 void contextMenu( Kleo::KeyListViewItem*, const QPoint& ); 00208 00209 public slots: 00210 virtual void slotAddKey( const GpgME::Key & key ); 00211 virtual void slotRefreshKey( const GpgME::Key & key ); 00212 00213 // 00214 // Only boring stuff below: 00215 // 00216 private slots: 00217 void slotEmitDoubleClicked( QListViewItem*, const QPoint&, int ); 00218 void slotEmitReturnPressed( QListViewItem* ); 00219 void slotEmitSelectionChanged( QListViewItem* ); 00220 void slotEmitContextMenu( KListView*, QListViewItem*, const QPoint& ); 00221 void slotUpdateTimeout(); 00222 00223 public: 00225 KeyListViewItem * selectedItem() const; 00227 QPtrList<KeyListViewItem> selectedItems() const; 00229 KeyListViewItem * firstChild() const; 00231 void clear(); 00232 00233 private: 00234 void doHierarchicalInsert( const GpgME::Key & ); 00235 void gatherScattered(); 00236 void scatterGathered( QListViewItem * ); 00237 void refillFingerprintDictionary(); 00238 KeyListViewItem * parentFor( const QCString & ) const; 00239 00240 private: 00241 const ColumnStrategy * mColumnStrategy; 00242 const DisplayStrategy * mDisplayStrategy; 00243 bool mHierarchical; 00244 00245 class Private; 00246 Private * d; 00247 }; 00248 00249 class KeyListView::ColumnStrategy { 00250 public: 00251 virtual ~ColumnStrategy(); 00252 virtual QString title( int column ) const = 0; 00253 virtual int width( int column, const QFontMetrics & fm ) const; 00254 virtual QListView::WidthMode widthMode( int ) const { return QListView::Manual; } 00255 00256 virtual QString text( const GpgME::Key & key, int column ) const = 0; 00257 virtual QString toolTip( const GpgME::Key & key, int column ) const; 00258 virtual const QPixmap * pixmap( const GpgME::Key &, int ) const { return 0; } 00259 virtual int compare( const GpgME::Key & key1, const GpgME::Key & key2, const int column ) const; 00260 00261 virtual QString subkeyText( const GpgME::Subkey &, int ) const { return QString::null; } 00262 virtual QString subkeyToolTip( const GpgME::Subkey & subkey, int column ) const; 00263 virtual const QPixmap * subkeyPixmap( const GpgME::Subkey &, int ) const { return 0; } 00264 virtual int subkeyCompare( const GpgME::Subkey & subkey1, const GpgME::Subkey & subkey2, const int column ) const; 00265 00266 virtual QString userIDText( const GpgME::UserID &, int ) const { return QString::null; } 00267 virtual QString userIDToolTip( const GpgME::UserID & userID, int column ) const; 00268 virtual const QPixmap * userIDPixmap( const GpgME::UserID &, int ) const { return 0; } 00269 virtual int userIDCompare( const GpgME::UserID & userID1, const GpgME::UserID & userID2, const int column ) const; 00270 00271 virtual QString signatureText( const GpgME::UserID::Signature &, int ) const { return QString::null; } 00272 virtual QString signatureToolTip( const GpgME::UserID::Signature & sig, int column ) const; 00273 virtual const QPixmap * signaturePixmap( const GpgME::UserID::Signature &, int ) const { return 0; } 00274 virtual int signatureCompare( const GpgME::UserID::Signature & sig1, const GpgME::UserID::Signature & sig2, const int column ) const; 00275 }; 00276 00277 class KeyListView::DisplayStrategy { 00278 public: 00279 virtual ~DisplayStrategy(); 00280 //font 00281 virtual QFont keyFont( const GpgME::Key &, const QFont & ) const; 00282 virtual QFont subkeyFont( const GpgME::Subkey &, const QFont & ) const; 00283 virtual QFont useridFont( const GpgME::UserID &, const QFont & ) const; 00284 virtual QFont signatureFont( const GpgME::UserID::Signature & , const QFont & ) const; 00285 //foreground 00286 virtual QColor keyForeground( const GpgME::Key & , const QColor & ) const; 00287 virtual QColor subkeyForeground( const GpgME::Subkey &, const QColor & ) const; 00288 virtual QColor useridForeground( const GpgME::UserID &, const QColor & ) const; 00289 virtual QColor signatureForeground( const GpgME::UserID::Signature &, const QColor & ) const; 00290 //background 00291 virtual QColor keyBackground( const GpgME::Key &, const QColor & ) const; 00292 virtual QColor subkeyBackground( const GpgME::Subkey &, const QColor & ) const; 00293 virtual QColor useridBackground( const GpgME::UserID &, const QColor & ) const; 00294 virtual QColor signatureBackground( const GpgME::UserID::Signature &, const QColor & ) const; 00295 }; 00296 00297 } 00298 00299 #endif // __KLEO_KEYLISTVIEW_H__
KDE Logo
This file is part of the documentation for certmanager/lib Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:50:05 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003