00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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
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
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
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
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
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
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
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
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