15#include "keylistmodelinterface.h"
16#include "kleo_export.h"
18#include <Libkleo/KeyGroup>
20#include <QAbstractItemModel>
32class KLEO_EXPORT DragHandler
35 virtual ~DragHandler()
38 virtual QMimeData *mimeData(
const QModelIndexList &indexes)
const = 0;
39 virtual Qt::ItemFlags flags(
const QModelIndex &index)
const = 0;
40 virtual QStringList mimeTypes()
const = 0;
43class KLEO_EXPORT AbstractKeyListModel :
public QAbstractItemModel,
public KeyListModelInterface
54 Q_DECLARE_FLAGS(ItemTypes, ItemType)
56 explicit AbstractKeyListModel(QObject *parent =
nullptr);
57 ~AbstractKeyListModel()
override;
59 static AbstractKeyListModel *createFlatKeyListModel(QObject *parent =
nullptr);
60 static AbstractKeyListModel *createHierarchicalKeyListModel(QObject *parent =
nullptr);
62 GpgME::Key key(
const QModelIndex &idx)
const override;
63 std::vector<GpgME::Key> keys(
const QList<QModelIndex> &indexes)
const override;
65 KeyGroup group(
const QModelIndex &idx)
const override;
68 QModelIndex index(
const GpgME::Key &key)
const override;
69 QModelIndex index(
const GpgME::Key &key,
int col)
const;
70 QList<QModelIndex> indexes(
const std::vector<GpgME::Key> &keys)
const override;
72 QModelIndex index(
const KeyGroup &group)
const override;
73 QModelIndex index(
const KeyGroup &group,
int col)
const;
75 void setDragHandler(
const std::shared_ptr<DragHandler> &dragHandler);
78 void rowAboutToBeMoved(
const QModelIndex &old_parent,
int old_row);
79 void rowMoved(
const QModelIndex &new_parent,
int new_row);
83 void setKeys(
const std::vector<GpgME::Key> &keys,
const std::vector<GpgME::Key::Origin> &extraOrigins = {});
85 void useKeyCache(
bool value, Kleo::KeyList::Options options);
86 QModelIndex addKey(
const GpgME::Key &key);
87 QList<QModelIndex> addKeys(
const std::vector<GpgME::Key> &keys);
88 void removeKey(
const GpgME::Key &key);
90 void setGroups(
const std::vector<KeyGroup> &groups);
91 QModelIndex addGroup(
const Kleo::KeyGroup &group);
92 bool removeGroup(
const Kleo::KeyGroup &group);
94 void clear(Kleo::AbstractKeyListModel::ItemTypes types = All);
97 int columnCount(
const QModelIndex &pidx)
const override;
99 QVariant data(
const QModelIndex &index,
int role =
Qt::DisplayRole)
const override;
100 bool setData(
const QModelIndex &index,
const QVariant &value,
int role =
Qt::EditRole)
override;
106 int toolTipOptions()
const;
108 void setToolTipOptions(
int opts);
115 void setRemarkKeys(
const std::vector<GpgME::Key> &remarkKeys);
116 std::vector<GpgME::Key> remarkKeys()
const;
118 Qt::ItemFlags flags(
const QModelIndex &index)
const override;
119 QStringList mimeTypes()
const override;
120 QMimeData *mimeData(
const QModelIndexList &indexes)
const override;
123 bool modelResetInProgress();
126 QVariant data(
const GpgME::Key &key,
int row,
int column,
int role)
const;
127 QVariant data(
const KeyGroup &group,
int column,
int role)
const;
129 virtual GpgME::Key doMapToKey(
const QModelIndex &index)
const = 0;
130 virtual QModelIndex doMapFromKey(
const GpgME::Key &key,
int column)
const = 0;
131 virtual QList<QModelIndex> doAddKeys(
const std::vector<GpgME::Key> &keys) = 0;
132 virtual void doRemoveKey(
const GpgME::Key &key) = 0;
134 virtual KeyGroup doMapToGroup(
const QModelIndex &index)
const = 0;
135 virtual QModelIndex doMapFromGroup(
const KeyGroup &group,
int column)
const = 0;
136 virtual void doSetGroups(
const std::vector<KeyGroup> &groups) = 0;
137 virtual QModelIndex doAddGroup(
const KeyGroup &group) = 0;
138 virtual bool doSetGroupData(
const QModelIndex &index,
const KeyGroup &group) = 0;
139 virtual bool doRemoveGroup(
const KeyGroup &group) = 0;
141 virtual void doClear(ItemTypes types) = 0;
145 QScopedPointer<Private>
const d;
148Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractKeyListModel::ItemTypes)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0