kgpg
kgpgitemmodel.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 #ifndef KGPGITEMMODEL_H
00020 #define KGPGITEMMODEL_H
00021
00022 #include <QAbstractItemModel>
00023
00024 #define KEYCOLUMN_NAME 0
00025 #define KEYCOLUMN_EMAIL 1
00026 #define KEYCOLUMN_TRUST 2
00027 #define KEYCOLUMN_EXPIR 3
00028 #define KEYCOLUMN_SIZE 4
00029 #define KEYCOLUMN_CREAT 5
00030 #define KEYCOLUMN_ID 6
00031
00032 #include "kgpgitemnode.h"
00033 #include "kgpgkey.h"
00034
00035 class QColor;
00036
00037 class KGpgItemModel : public QAbstractItemModel
00038 {
00039 Q_OBJECT
00040
00041 private:
00042 KGpgRootNode *m_root;
00043 QString m_default;
00044
00045 public:
00046
00047 explicit KGpgItemModel(QObject *parent = 0);
00048 virtual ~KGpgItemModel();
00049
00050 virtual QModelIndex index(int row, int column,
00051 const QModelIndex &parent = QModelIndex()) const;
00052 virtual QModelIndex parent(const QModelIndex &child) const;
00053
00054 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
00055 virtual int columnCount(const QModelIndex & ) const
00056 { return 7; }
00057
00058 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00059 virtual bool hasChildren(const QModelIndex &parent) const;
00060 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00061
00062 KGpgNode *nodeForIndex(const QModelIndex &index) const;
00063
00064 KGpgRootNode *getRootNode() const;
00065 QString statusCountMessage() const;
00066
00067 public Q_SLOTS:
00068 KGpgGroupNode *addGroup(const QString &name, const KGpgKeyNodeList &keys);
00069 void delNode(const KGpgNode *node);
00070 void changeGroup(KGpgGroupNode *node, const QList<KGpgNode *> &keys);
00071 void setDefaultKey(const QString &def);
00072 QModelIndex nodeIndex(KGpgNode *node);
00073 void refreshKey(const QString &id);
00074 void refreshKey(KGpgKeyNode *nd);
00075 void refreshKeys(const QStringList &ids = QStringList());
00076 void refreshKeys(KGpgKeyNodeList keys);
00077 void refreshGroups();
00078 void invalidateIndexes(KGpgNode *nd);
00079 void refreshTrust(const KgpgCore::KgpgKeyTrust &trust, const QColor &color);
00080
00081 protected:
00082 int rowForNode(KGpgNode *node) const;
00083 void refreshKeyIds(const QStringList &id);
00084 void refreshKeyIds(KGpgKeyNodeList &nodes);
00085 bool isDefaultKey(const KGpgNode *node) const;
00086 void fixPersistentIndexes();
00087 void updateNodeTrustColor(KGpgExpandableNode *node, const KgpgCore::KgpgKeyTrust &trust, const QColor &color);
00088 };
00089
00090 #endif