12#include "kleo_export.h" 
   14#include "treewidget.h" 
   20#include <gpgme++/key.h> 
   29#define TEMPLATE_TYPENAME(T) template<typename T> 
   31inline T *lvi_cast(QTreeWidgetItem *item)
 
   33    return item && (item->
type() == T::RTTI) ? 
static_cast<T *
>(item) : nullptr;
 
   37inline const T *lvi_cast(
const QTreeWidgetItem *item)
 
   39    return item && (item->
type() == T::RTTI) ? 
static_cast<const T *
>(item) : nullptr;
 
   41#undef TEMPLATE_TYPENAME 
   45class KeyListViewItem : 
public QTreeWidgetItem
 
   48    KeyListViewItem(KeyListView *
parent, 
const GpgME::Key &key);
 
   49    KeyListViewItem(KeyListView *
parent, KeyListViewItem *after, 
const GpgME::Key &key);
 
   50    KeyListViewItem(KeyListViewItem *
parent, 
const GpgME::Key &key);
 
   51    KeyListViewItem(KeyListViewItem *
parent, KeyListViewItem *after, 
const GpgME::Key &key);
 
   52    ~KeyListViewItem() 
override;
 
   54    void setKey(
const GpgME::Key &key);
 
   55    const GpgME::Key &key()
 const 
   65    virtual QString toolTip(
int column) 
const;
 
   68    KeyListView *listView() 
const;
 
   70    KeyListViewItem *nextSibling() 
const;
 
   80class KLEO_EXPORT KeyListView : 
public TreeWidget 
   83    friend class KeyListViewItem;
 
   86    class KLEO_EXPORT ColumnStrategy
 
   89        virtual ~ColumnStrategy();
 
   90        virtual QString title(
int column) 
const = 0;
 
   91        virtual int width(
int column, 
const QFontMetrics &fm) 
const;
 
   97        virtual QString text(
const GpgME::Key &key, 
int column) 
const = 0;
 
   98        virtual QString accessibleText(
const GpgME::Key &key, 
int column) 
const = 0;
 
   99        virtual QString toolTip(
const GpgME::Key &key, 
int column) 
const;
 
  100        virtual QIcon icon(
const GpgME::Key &, 
int)
 const 
  104        virtual int compare(
const GpgME::Key &key1, 
const GpgME::Key &key2, 
const int column) 
const;
 
  107    class KLEO_EXPORT DisplayStrategy
 
  110        virtual ~DisplayStrategy();
 
  112        virtual QFont keyFont(
const GpgME::Key &, 
const QFont &) 
const;
 
  114        virtual QColor keyForeground(
const GpgME::Key &, 
const QColor &) 
const;
 
  116        virtual QColor keyBackground(
const GpgME::Key &, 
const QColor &) 
const;
 
  119    explicit KeyListView(
const ColumnStrategy *strategy, 
const DisplayStrategy *display = 
nullptr, QWidget *parent = 
nullptr, 
Qt::WindowFlags f = {});
 
  121    ~KeyListView() 
override;
 
  123    const ColumnStrategy *columnStrategy()
 const 
  125        return mColumnStrategy;
 
  127    const DisplayStrategy *displayStrategy()
 const 
  129        return mDisplayStrategy;
 
  132    bool hierarchical()
 const 
  134        return mHierarchical;
 
  136    virtual void setHierarchical(
bool hier);
 
  143    bool isMultiSelection() 
const;
 
  145    KeyListViewItem *itemByFingerprint(
const QByteArray &) 
const;
 
  150    void doubleClicked(Kleo::KeyListViewItem *, 
int);
 
  151    void returnPressed(Kleo::KeyListViewItem *);
 
  152    void selectionChanged(Kleo::KeyListViewItem *);
 
  153    void contextMenu(Kleo::KeyListViewItem *, 
const QPoint &);
 
  156    void keyPressEvent(QKeyEvent *event) 
override;
 
  159    virtual void slotAddKey(
const GpgME::Key &key);
 
  160    virtual void slotRefreshKey(
const GpgME::Key &key);
 
  166    void slotEmitDoubleClicked(QTreeWidgetItem *, 
int);
 
  167    void slotEmitReturnPressed(QTreeWidgetItem *);
 
  168    void slotEmitSelectionChanged();
 
  169    void slotEmitContextMenu(
const QPoint &pos);
 
  170    void slotUpdateTimeout();
 
  174    KeyListViewItem *selectedItem() 
const;
 
  176    QList<KeyListViewItem *> selectedItems() 
const;
 
  178    KeyListViewItem *firstChild() 
const;
 
  182    void takeItem(QTreeWidgetItem *);
 
  185    void doHierarchicalInsert(
const GpgME::Key &);
 
  186    void gatherScattered();
 
  187    void scatterGathered(KeyListViewItem *);
 
  188    void registerItem(KeyListViewItem *);
 
  189    void deregisterItem(
const KeyListViewItem *);
 
  192    const ColumnStrategy *mColumnStrategy = 
nullptr;
 
  193    const DisplayStrategy *mDisplayStrategy = 
nullptr;
 
  194    bool mHierarchical = 
false;
 
  196    class KeyListViewPrivate;
 
  197    std::unique_ptr<KeyListViewPrivate> 
const d;
 
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)