kleopatra
keylistmodel.h
Go to the documentation of this file.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 #ifndef __KLEOPATRA_MODELS_KEYLISTMODEL_H__
00033 #define __KLEOPATRA_MODELS_KEYLISTMODEL_H__
00034
00035 #include <QAbstractItemModel>
00036
00037 #include <models/keylistmodelinterface.h>
00038
00039 #include <utils/pimpl_ptr.h>
00040
00041 #include <vector>
00042
00043 namespace GpgME {
00044 class Key;
00045 }
00046
00047 namespace Kleo {
00048
00049 class AbstractKeyListModel : public QAbstractItemModel, public KeyListModelInterface {
00050 Q_OBJECT
00051 public:
00052 explicit AbstractKeyListModel( QObject * parent=0 );
00053 ~AbstractKeyListModel();
00054
00055 static AbstractKeyListModel * createFlatKeyListModel( QObject * parent=0 );
00056 static AbstractKeyListModel * createHierarchicalKeyListModel( QObject * parent=0 );
00057
00058 enum Columns {
00059 PrettyName,
00060 PrettyEMail,
00061 ValidFrom,
00062 ValidUntil,
00063 TechnicalDetails,
00064 Fingerprint,
00065 #if 0
00066
00067 LongKeyID,
00068 ShortKeyID,
00069
00070 Issuer,
00071 Subject,
00072 SerialNumber,
00073 #endif
00074
00075 NumColumns,
00076 Icon = PrettyName
00077 };
00078
00079 GpgME::Key key( const QModelIndex & idx ) const;
00080 std::vector<GpgME::Key> keys( const QList<QModelIndex> & indexes ) const;
00081
00082 using QAbstractItemModel::index;
00083 QModelIndex index( const GpgME::Key & key ) const {
00084 return index( key, 0 );
00085 }
00086 QModelIndex index( const GpgME::Key & key, int col ) const;
00087 QList<QModelIndex> indexes( const std::vector<GpgME::Key> & keys ) const;
00088
00089 Q_SIGNALS:
00090 void rowAboutToBeMoved( const QModelIndex & old_parent, int old_row );
00091 void rowMoved( const QModelIndex & new_parent, int new_row );
00092
00093 public Q_SLOTS:
00094 void setKeys( const std::vector<GpgME::Key> & keys );
00095 QModelIndex addKey( const GpgME::Key & key );
00096 QList<QModelIndex> addKeys( const std::vector<GpgME::Key> & keys );
00097 void removeKey( const GpgME::Key & key );
00098 void clear();
00099
00100 public:
00101 int columnCount( const QModelIndex & pidx ) const;
00102 QVariant headerData( int section, Qt::Orientation o, int role=Qt::DisplayRole ) const;
00103 QVariant data( const QModelIndex & index, int role=Qt::DisplayRole ) const;
00104
00109 int toolTipOptions() const;
00110
00111 void setToolTipOptions( int opts );
00112
00113 private:
00114 virtual GpgME::Key doMapToKey( const QModelIndex & index ) const = 0;
00115 virtual QModelIndex doMapFromKey( const GpgME::Key & key, int column ) const = 0;
00116 virtual QList<QModelIndex> doAddKeys( const std::vector<GpgME::Key> & keys ) = 0;
00117 virtual void doRemoveKey( const GpgME::Key & key ) = 0;
00118 virtual void doClear() = 0;
00119
00120 private:
00121 class Private;
00122 kdtools::pimpl_ptr<Private> d;
00123 };
00124
00125 }
00126
00127 #endif