33 #ifndef __KLEO_KEYLISTVIEW_H__
34 #define __KLEO_KEYLISTVIEW_H__
36 #include <tdelistview.h>
38 #include <gpgmepp/key.h>
39 #include <tdemacros.h>
49 #define TEMPLATE_TYPENAME(T) template <typename T>
51 inline T * lvi_cast( TQListViewItem * item ) {
52 return item && (item->rtti() & T::RTTI_MASK) == T::RTTI
53 ?
static_cast<T*
>( item ) : 0 ;
57 inline const T * lvi_cast(
const TQListViewItem * item ) {
58 return item && (item->rtti() & T::RTTI_MASK) == T::RTTI
59 ?
static_cast<const T*
>( item ) : 0 ;
61 #undef TEMPLATE_TYPENAME
65 class TDE_EXPORT KeyListViewItem :
public TQListViewItem {
67 KeyListViewItem( KeyListView * parent,
const GpgME::Key & key );
68 KeyListViewItem( KeyListView * parent, KeyListViewItem * after,
const GpgME::Key & key );
69 KeyListViewItem( KeyListViewItem * parent,
const GpgME::Key & key );
70 KeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after,
const GpgME::Key & key );
73 void setKey(
const GpgME::Key & key );
74 const GpgME::Key & key()
const {
return mKey; }
76 enum { RTTI_MASK = 0xFFFFFFF0, RTTI = 0x2C1362E0 };
81 virtual TQString toolTip(
int column )
const;
84 KeyListView * listView()
const;
86 KeyListViewItem * nextSibling()
const;
88 int compare( TQListViewItem * other,
int col,
bool ascending )
const;
90 TQString key(
int col,
bool ascending )
const {
return TQListViewItem::key( col, ascending ); }
92 int rtti()
const {
return RTTI; }
94 void paintCell( TQPainter * p,
const TQColorGroup & cg,
int column,
int width,
int alignment );
96 void insertItem( TQListViewItem * item );
98 void takeItem( TQListViewItem * item );
104 class TDE_EXPORT SubkeyKeyListViewItem :
public KeyListViewItem {
106 SubkeyKeyListViewItem( KeyListView * parent,
const GpgME::Subkey & subkey );
107 SubkeyKeyListViewItem( KeyListView * parent, KeyListViewItem * after,
const GpgME::Subkey & subkey );
108 SubkeyKeyListViewItem( KeyListViewItem * parent,
const GpgME::Subkey & subkey );
109 SubkeyKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after,
const GpgME::Subkey & subkey );
111 void setSubkey(
const GpgME::Subkey & subkey );
112 const GpgME::Subkey & subkey()
const {
return mSubkey; }
114 enum { RTTI = KeyListViewItem::RTTI + 1 };
120 TQString toolTip(
int col )
const;
122 TQString text(
int col )
const;
124 const TQPixmap * pixmap(
int col )
const;
126 int compare( TQListViewItem * other,
int col,
bool ascending )
const;
128 int rtti()
const {
return RTTI; }
130 void paintCell( TQPainter * p,
const TQColorGroup & cg,
int column,
int width,
int alignment );
133 GpgME::Subkey mSubkey;
136 class TDE_EXPORT UserIDKeyListViewItem :
public KeyListViewItem {
138 UserIDKeyListViewItem( KeyListView * parent,
const GpgME::UserID & userid );
139 UserIDKeyListViewItem( KeyListView * parent, KeyListViewItem * after,
const GpgME::UserID & userid );
140 UserIDKeyListViewItem( KeyListViewItem * parent,
const GpgME::UserID & userid );
141 UserIDKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after,
const GpgME::UserID & userid );
143 void setUserID(
const GpgME::UserID & userid );
144 const GpgME::UserID userID()
const {
return mUserID; }
146 enum { RTTI = KeyListViewItem::RTTI + 2 };
152 TQString toolTip(
int col )
const;
154 TQString text(
int col )
const;
156 const TQPixmap * pixmap(
int col )
const;
158 int compare( TQListViewItem * other,
int col,
bool ascending )
const;
160 int rtti()
const {
return RTTI; }
162 void paintCell( TQPainter * p,
const TQColorGroup & cg,
int column,
int width,
int alignment );
165 GpgME::UserID mUserID;
168 class TDE_EXPORT SignatureKeyListViewItem :
public KeyListViewItem {
170 SignatureKeyListViewItem( KeyListView * parent,
const GpgME::UserID::Signature & sig );
171 SignatureKeyListViewItem( KeyListView * parent, KeyListViewItem * after,
const GpgME::UserID::Signature & sig );
172 SignatureKeyListViewItem( KeyListViewItem * parent,
const GpgME::UserID::Signature & sig );
173 SignatureKeyListViewItem( KeyListViewItem * parent, KeyListViewItem * after,
const GpgME::UserID::Signature & sig );
175 void setSignature(
const GpgME::UserID::Signature & sig );
176 const GpgME::UserID::Signature & signature()
const {
return mSignature; }
178 enum { RTTI = KeyListViewItem::RTTI + 3 };
184 TQString toolTip(
int col )
const;
186 TQString text(
int col )
const;
188 const TQPixmap * pixmap(
int col )
const;
190 int compare( TQListViewItem * other,
int col,
bool ascending )
const;
192 int rtti()
const {
return RTTI; }
194 void paintCell( TQPainter * p,
const TQColorGroup & cg,
int column,
int width,
int alignment );
197 GpgME::UserID::Signature mSignature;
201 class TDE_EXPORT KeyListView :
public TDEListView {
204 friend class KeyListViewItem;
207 class TDE_EXPORT ColumnStrategy {
209 virtual ~ColumnStrategy();
210 virtual TQString title(
int column )
const = 0;
211 virtual int width(
int column,
const TQFontMetrics & fm )
const;
212 virtual TQListView::WidthMode widthMode(
int )
const {
return TQListView::Manual; }
214 virtual TQString text(
const GpgME::Key & key,
int column )
const = 0;
215 virtual TQString toolTip(
const GpgME::Key & key,
int column )
const;
216 virtual const TQPixmap * pixmap(
const GpgME::Key &,
int )
const {
return 0; }
217 virtual int compare(
const GpgME::Key & key1,
const GpgME::Key & key2,
const int column )
const;
219 virtual TQString subkeyText(
const GpgME::Subkey &,
int )
const {
return TQString(); }
220 virtual TQString subkeyToolTip(
const GpgME::Subkey & subkey,
int column )
const;
221 virtual const TQPixmap * subkeyPixmap(
const GpgME::Subkey &,
int )
const {
return 0; }
222 virtual int subkeyCompare(
const GpgME::Subkey & subkey1,
const GpgME::Subkey & subkey2,
const int column )
const;
224 virtual TQString userIDText(
const GpgME::UserID &,
int )
const {
return TQString(); }
225 virtual TQString userIDToolTip(
const GpgME::UserID & userID,
int column )
const;
226 virtual const TQPixmap * userIDPixmap(
const GpgME::UserID &,
int )
const {
return 0; }
227 virtual int userIDCompare(
const GpgME::UserID & userID1,
const GpgME::UserID & userID2,
const int column )
const;
229 virtual TQString signatureText(
const GpgME::UserID::Signature &,
int )
const {
return TQString(); }
230 virtual TQString signatureToolTip(
const GpgME::UserID::Signature & sig,
int column )
const;
231 virtual const TQPixmap * signaturePixmap(
const GpgME::UserID::Signature &,
int )
const {
return 0; }
232 virtual int signatureCompare(
const GpgME::UserID::Signature & sig1,
const GpgME::UserID::Signature & sig2,
const int column )
const;
235 class TDE_EXPORT DisplayStrategy {
237 virtual ~DisplayStrategy();
239 virtual TQFont keyFont(
const GpgME::Key &,
const TQFont & )
const;
240 virtual TQFont subkeyFont(
const GpgME::Subkey &,
const TQFont & )
const;
241 virtual TQFont useridFont(
const GpgME::UserID &,
const TQFont & )
const;
242 virtual TQFont signatureFont(
const GpgME::UserID::Signature & ,
const TQFont & )
const;
244 virtual TQColor keyForeground(
const GpgME::Key & ,
const TQColor & )
const;
245 virtual TQColor subkeyForeground(
const GpgME::Subkey &,
const TQColor & )
const;
246 virtual TQColor useridForeground(
const GpgME::UserID &,
const TQColor & )
const;
247 virtual TQColor signatureForeground(
const GpgME::UserID::Signature &,
const TQColor & )
const;
249 virtual TQColor keyBackground(
const GpgME::Key &,
const TQColor & )
const;
250 virtual TQColor subkeyBackground(
const GpgME::Subkey &,
const TQColor & )
const;
251 virtual TQColor useridBackground(
const GpgME::UserID &,
const TQColor & )
const;
252 virtual TQColor signatureBackground(
const GpgME::UserID::Signature &,
const TQColor & )
const;
255 KeyListView(
const ColumnStrategy * strategy,
256 const DisplayStrategy * display=0,
257 TQWidget * parent=0,
const char * name=0, WFlags f=0 );
261 const ColumnStrategy * columnStrategy()
const {
return mColumnStrategy; }
262 const DisplayStrategy * displayStrategy()
const {
return mDisplayStrategy; }
264 bool hierarchical()
const {
return mHierarchical; }
265 virtual void setHierarchical(
bool hier );
267 void flushKeys() { slotUpdateTimeout(); }
269 bool hasSelection()
const;
271 KeyListViewItem * itemByFingerprint(
const TQCString & )
const;
274 void doubleClicked( Kleo::KeyListViewItem*,
const TQPoint&,
int );
275 void returnPressed( Kleo::KeyListViewItem* );
276 void selectionChanged( Kleo::KeyListViewItem* );
277 void contextMenu( Kleo::KeyListViewItem*,
const TQPoint& );
280 virtual void slotAddKey(
const GpgME::Key & key );
281 virtual void slotRefreshKey(
const GpgME::Key & key );
287 void slotEmitDoubleClicked( TQListViewItem*,
const TQPoint&,
int );
288 void slotEmitReturnPressed( TQListViewItem* );
289 void slotEmitSelectionChanged( TQListViewItem* );
290 void slotEmitContextMenu( TDEListView*, TQListViewItem*,
const TQPoint& );
291 void slotUpdateTimeout();
295 KeyListViewItem * selectedItem()
const;
297 TQPtrList<KeyListViewItem> selectedItems()
const;
299 KeyListViewItem * firstChild()
const;
303 void insertItem( TQListViewItem * );
305 void takeItem( TQListViewItem * );
308 void doHierarchicalInsert(
const GpgME::Key & );
309 void gatherScattered();
310 void scatterGathered( TQListViewItem * );
311 void registerItem( KeyListViewItem * );
312 void deregisterItem(
const KeyListViewItem * );
315 const ColumnStrategy * mColumnStrategy;
316 const DisplayStrategy * mDisplayStrategy;