diff --git a/src/kleo/defaultkeyfilter.h b/src/kleo/defaultkeyfilter.h index 85e2a98..cf0f7ca 100644 --- a/src/kleo/defaultkeyfilter.h +++ b/src/kleo/defaultkeyfilter.h @@ -1,154 +1,154 @@ /* defaultkeyfilter.h This file is part of libkleopatra, the KDE keymanagement library Copyright (c) 2004 Klarälvdalens Datakonsult AB 2016 by Bundesamt für Sicherheit in der Informationstechnik Software engineering by Intevation GmbH Libkleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Libkleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef __KLEO_DEFAULTKEYFILTER_H__ #define __KLEO_DEFAULTKEYFILTER_H__ #include "keyfilter.h" #include "kleo_export.h" #include #include #include #include #include namespace Kleo { /** Default implemation of key filter class. */ class KLEO_EXPORT DefaultKeyFilter : public KeyFilter { public: DefaultKeyFilter(); - ~DefaultKeyFilter(); + ~DefaultKeyFilter() override; /** Used for bool checks */ enum TriState { DoesNotMatter = 0, Set = 1, NotSet = 2 }; /** Used for level checks */ enum LevelState { LevelDoesNotMatter = 0, Is = 1, IsNot = 2, IsAtLeast = 3, IsAtMost = 4 }; bool matches(const GpgME::Key &key, MatchContexts ctx) const override; unsigned int specificity() const override; void setSpecificity(unsigned int value) const; QString id() const override; void setId(const QString &value) const; KeyFilter::MatchContexts availableMatchContexts() const override; void setMatchContexts(KeyFilter::MatchContexts value) const; QColor fgColor() const override; void setFgColor(const QColor &value) const; QColor bgColor() const override; void setBgColor(const QColor &value) const; FontDescription fontDescription() const override; QString name() const override; void setName(const QString &value) const; QString icon() const override; void setIcon(const QString &value) const; QFont font() const; void setFont(const QFont &value) const; TriState revoked() const; TriState expired() const; TriState disabled() const; TriState root() const; TriState canEncrypt() const; TriState canSign() const; TriState canCertify() const; TriState canAuthenticate() const; TriState qualified() const; TriState cardKey() const; TriState hasSecret() const; TriState isOpenPGP() const; TriState wasValidated() const; LevelState ownerTrust() const; GpgME::Key::OwnerTrust ownerTrustReferenceLevel() const; LevelState validity() const; GpgME::UserID::Validity validityReferenceLevel() const; bool italic() const; bool bold() const; bool strikeOut() const; bool useFullFont() const; void setRevoked(const TriState) const; void setExpired(const TriState) const; void setDisabled(const TriState) const; void setRoot(const TriState) const; void setCanEncrypt(const TriState) const; void setCanSign(const TriState) const; void setCanCertify(const TriState) const; void setCanAuthenticate(const TriState) const; void setQualified(const TriState) const; void setCardKey(const TriState) const; void setHasSecret(const TriState) const; void setIsOpenPGP(const TriState) const; void setWasValidated(const TriState) const; void setOwnerTrust(const LevelState) const; void setOwnerTrustReferenceLevel(const GpgME::Key::OwnerTrust) const; void setValidity(const LevelState) const; void setValidityReferenceLevel(const GpgME::UserID::Validity) const; void setItalic(bool value) const; void setBold(bool value) const; void setStrikeOut(bool value) const; void setUseFullFont(bool value) const; private: class Private; const QScopedPointer d_ptr; }; } // namespace Kleo #endif diff --git a/src/kleo/defaultkeygenerationjob.h b/src/kleo/defaultkeygenerationjob.h index f40bf51..00a8e4f 100644 --- a/src/kleo/defaultkeygenerationjob.h +++ b/src/kleo/defaultkeygenerationjob.h @@ -1,76 +1,76 @@ /* This file is part of Kleopatra, the KDE keymanager Copyright (c) 2016 Klarälvdalens Datakonsult AB Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef LIBKLEO_DEFAULTKEYGENERATION_H #define LIBKLEO_DEFAULTKEYGENERATION_H #include #include namespace GpgME { class KeyGenerationResult; } namespace Kleo { /** * Generates a PGP RSA/2048 bit key pair for given name and email address. * * @since 5.4 */ class KLEO_EXPORT DefaultKeyGenerationJob : public QGpgME::Job { Q_OBJECT public: explicit DefaultKeyGenerationJob(QObject *parent = nullptr); - ~DefaultKeyGenerationJob(); + ~DefaultKeyGenerationJob() override; /** * Set key passphrase * * Use this method to specify custom passphrase, including an empty * one. If no passphrase (not even empty) is specified, gpg me will * automatically prompt for passphrase using Pinentry dialog. */ void setPassphrase(const QString &passphrase); GpgME::Error start(const QString &email, const QString &name); QString auditLogAsHtml() const override; GpgME::Error auditLogError() const override; public Q_SLOTS: void slotCancel() override; Q_SIGNALS: void result(const GpgME::KeyGenerationResult &result, const QByteArray &pubkeyData, const QString &auditLogAsHtml, const GpgME::Error &auditLogError); protected: bool eventFilter(QObject *watched, QEvent *event) override; private: class Private; Private * const d; }; } #endif diff --git a/src/models/keylistmodel.h b/src/models/keylistmodel.h index 5308050..dbebdf4 100644 --- a/src/models/keylistmodel.h +++ b/src/models/keylistmodel.h @@ -1,113 +1,113 @@ /* -*- mode: c++; c-basic-offset:4 -*- models/keylistmodel.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2007 Klarälvdalens Datakonsult AB Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef __KLEOPATRA_MODELS_KEYLISTMODEL_H__ #define __KLEOPATRA_MODELS_KEYLISTMODEL_H__ #include #include #include "keylistmodelinterface.h" #include namespace GpgME { class Key; } namespace Kleo { class KLEO_EXPORT AbstractKeyListModel : public QAbstractItemModel , public KeyListModelInterface { Q_OBJECT public: explicit AbstractKeyListModel(QObject *parent = nullptr); - ~AbstractKeyListModel(); + ~AbstractKeyListModel() override; static AbstractKeyListModel *createFlatKeyListModel(QObject *parent = nullptr); static AbstractKeyListModel *createHierarchicalKeyListModel(QObject *parent = nullptr); GpgME::Key key(const QModelIndex &idx) const override; std::vector keys(const QList &indexes) const override; using QAbstractItemModel::index; QModelIndex index(const GpgME::Key &key) const override { return index(key, 0); } QModelIndex index(const GpgME::Key &key, int col) const; QList indexes(const std::vector &keys) const override; Q_SIGNALS: void rowAboutToBeMoved(const QModelIndex &old_parent, int old_row); void rowMoved(const QModelIndex &new_parent, int new_row); public Q_SLOTS: void setKeys(const std::vector &keys); /* Set this to set all or only secret keys from the keycache. */ void useKeyCache(bool value, bool secretOnly); QModelIndex addKey(const GpgME::Key &key); QList addKeys(const std::vector &keys); void removeKey(const GpgME::Key &key); void clear(); public: int columnCount(const QModelIndex &pidx) const override; QVariant headerData(int section, Qt::Orientation o, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; /** * defines which information is displayed in tooltips * see Kleo::Formatting::ToolTipOption */ int toolTipOptions() const; void setToolTipOptions(int opts); private: virtual GpgME::Key doMapToKey(const QModelIndex &index) const = 0; virtual QModelIndex doMapFromKey(const GpgME::Key &key, int column) const = 0; virtual QList doAddKeys(const std::vector &keys) = 0; virtual void doRemoveKey(const GpgME::Key &key) = 0; virtual void doClear() = 0; private: class Private; QScopedPointer const d; }; } #endif /* __KLEOPATRA_MODELS_KEYLISTMODEL_H__ */ diff --git a/src/models/keylistsortfilterproxymodel.h b/src/models/keylistsortfilterproxymodel.h index c4783ff..1c2ac6b 100644 --- a/src/models/keylistsortfilterproxymodel.h +++ b/src/models/keylistsortfilterproxymodel.h @@ -1,100 +1,100 @@ /* -*- mode: c++; c-basic-offset:4 -*- models/keylistsortfilterproxymodel.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2007 Klarälvdalens Datakonsult AB Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef __KLEOPATRA_MODELS_KEYLISTSORTFILTERPROXYMODEL_H__ #define __KLEOPATRA_MODELS_KEYLISTSORTFILTERPROXYMODEL_H__ #include #include "keylistmodelinterface.h" #include #include namespace GpgME { class Key; } namespace Kleo { class KeyFilter; class KLEO_EXPORT AbstractKeyListSortFilterProxyModel : public QSortFilterProxyModel , public KeyListModelInterface { Q_OBJECT protected: AbstractKeyListSortFilterProxyModel(const AbstractKeyListSortFilterProxyModel &); public: explicit AbstractKeyListSortFilterProxyModel(QObject *parent = nullptr); - ~AbstractKeyListSortFilterProxyModel(); + ~AbstractKeyListSortFilterProxyModel() override; virtual AbstractKeyListSortFilterProxyModel *clone() const = 0; GpgME::Key key(const QModelIndex &idx) const override; std::vector keys(const QList &indexes) const override; using QAbstractItemModel::index; QModelIndex index(const GpgME::Key &key) const override; QList indexes(const std::vector &keys) const override; private: void init(); }; class KLEO_EXPORT KeyListSortFilterProxyModel : public AbstractKeyListSortFilterProxyModel { Q_OBJECT protected: KeyListSortFilterProxyModel(const KeyListSortFilterProxyModel &); public: explicit KeyListSortFilterProxyModel(QObject *parent = nullptr); ~KeyListSortFilterProxyModel(); std::shared_ptr keyFilter() const; void setKeyFilter(const std::shared_ptr &kf); KeyListSortFilterProxyModel *clone() const override; protected: bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; private: class Private; QScopedPointer const d; }; } #endif /* __KLEOPATRA_MODELS_KEYLISTMODEL_H__ */ diff --git a/src/models/subkeylistmodel.h b/src/models/subkeylistmodel.h index a6a312d..ad070cd 100644 --- a/src/models/subkeylistmodel.h +++ b/src/models/subkeylistmodel.h @@ -1,96 +1,96 @@ /* -*- mode: c++; c-basic-offset:4 -*- models/subkeylistmodel.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2007 Klarälvdalens Datakonsult AB Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef __KLEOPATRA_MODELS_SUBKEYLISTMODEL_H__ #define __KLEOPATRA_MODELS_SUBKEYLISTMODEL_H__ #include #include #include namespace GpgME { class Key; class Subkey; } namespace Kleo { class KLEO_EXPORT SubkeyListModel : public QAbstractTableModel { Q_OBJECT public: explicit SubkeyListModel(QObject *parent = nullptr); - ~SubkeyListModel(); + ~SubkeyListModel() override; GpgME::Key key() const; enum Columns { ID, Type, ValidFrom, ValidUntil, Status, Strength, Usage, NumColumns, Icon = ID // which column shall the icon be displayed in? }; GpgME::Subkey subkey(const QModelIndex &idx) const; std::vector subkeys(const QList &indexes) const; using QAbstractTableModel::index; QModelIndex index(const GpgME::Subkey &subkey, int col = 0) const; QList indexes(const std::vector &subkeys) const; public Q_SLOTS: void setKey(const GpgME::Key &key); void clear(); public: int columnCount(const QModelIndex &pidx = QModelIndex()) const override; int rowCount(const QModelIndex &pidx = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation o, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; private: class Private; QScopedPointer const d; }; } #endif /* __KLEOPATRA_MODELS_SUBKEYLISTMODEL_H__ */ diff --git a/src/models/useridlistmodel.h b/src/models/useridlistmodel.h index 150963a..3d4240c 100644 --- a/src/models/useridlistmodel.h +++ b/src/models/useridlistmodel.h @@ -1,79 +1,79 @@ /* -*- mode: c++; c-basic-offset:4 -*- models/userIDlistmodel.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2007 Klarälvdalens Datakonsult AB 2016 Andre Heinecke Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef __KLEOPATRA_MODELS_USERIDLISTMODEL_H__ #define __KLEOPATRA_MODELS_USERIDLISTMODEL_H__ #include #include #include // since Signature is nested in UserID... class UIDModelItem; namespace Kleo { class KLEO_EXPORT UserIDListModel : public QAbstractItemModel { Q_OBJECT public: explicit UserIDListModel(QObject *parent = nullptr); - ~UserIDListModel(); + ~UserIDListModel() override; GpgME::Key key() const; public: QVector userIDs(const QModelIndexList &indexs) const; QVector signatures(const QModelIndexList &indexs) const; public Q_SLOTS: void setKey(const GpgME::Key &key); public: int columnCount(const QModelIndex &pindex = QModelIndex()) const override; int rowCount(const QModelIndex &pindex = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation o, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QModelIndex index(int row, int col, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &index) const override; private: GpgME::Key mKey; UIDModelItem *mRootItem = nullptr; }; } #endif /* __KLEOPATRA_MODELS_USERIDLISTMODEL_H__ */ diff --git a/src/ui/kdhorizontalline.h b/src/ui/kdhorizontalline.h index 8e59fe8..e474c27 100644 --- a/src/ui/kdhorizontalline.h +++ b/src/ui/kdhorizontalline.h @@ -1,87 +1,87 @@ /* -*- Mode: C++ -*- KD Tools - a set of useful widgets for Qt */ /**************************************************************************** ** Copyright (C) 2005 Klarälvdalens Datakonsult AB. All rights reserved. ** ** This file is part of the KD Tools library. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** Licensees holding valid commercial KD Tools licenses may use this file in ** accordance with the KD Tools Commercial License Agreement provided with ** the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.klaralvdalens-datakonsult.se/?page=products for ** information about KD Tools Commercial License Agreements. ** ** Contact info@klaralvdalens-datakonsult.se if any conditions of this ** licensing are not clear to you. ** ** In addition, as a special exception, the copyright holders give ** permission to link the code of this program with any edition of the ** Qt library by Trolltech AS, Norway (or with modified versions of Qt ** that use the same license as Qt), and distribute linked ** combinations including the two. You must obey the GNU General ** Public License in all respects for all of the code used other than ** Qt. If you modify this file, you may extend this exception to your ** version of the file, but you are not obligated to do so. If you do ** not wish to do so, delete this exception statement from your ** version. ** **********************************************************************/ #ifndef __KDTOOLS__KDHORIZONTALLINE_H__ #define __KDTOOLS__KDHORIZONTALLINE_H__ #include "kleo_export.h" #include class KLEO_EXPORT KDHorizontalLine : public QFrame { Q_OBJECT Q_PROPERTY(QString title READ title WRITE setTitle) public: explicit KDHorizontalLine(QWidget *parent = nullptr, const char *name = nullptr, Qt::WindowFlags f = 0); explicit KDHorizontalLine(const QString &title, QWidget *parent = nullptr, const char *name = nullptr, Qt::WindowFlags f = 0); - ~KDHorizontalLine(); + ~KDHorizontalLine() override; QString title() const { return mTitle; } /*! \reimp to hard-code the frame shape */ void setFrameStyle(int style); QSize sizeHint() const override; QSize minimumSizeHint() const override; QSizePolicy sizePolicy() const; static int indentHint(); public Q_SLOTS: virtual void setTitle(const QString &title); protected: void paintEvent(QPaintEvent *) override; private: void calculateFrame(); private: QString mTitle; Qt::Alignment mAlign; int mLenVisible; }; #endif /* __KDTOOLS__KDHORIZONTALLINE_H__ */ diff --git a/src/ui/keylistview.h b/src/ui/keylistview.h index 1f72148..3f23942 100644 --- a/src/ui/keylistview.h +++ b/src/ui/keylistview.h @@ -1,227 +1,227 @@ /* keylistview.h This file is part of libkleopatra, the KDE keymanagement library Copyright (c) 2004 Klarälvdalens Datakonsult AB Libkleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Libkleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef __KLEO_KEYLISTVIEW_H__ #define __KLEO_KEYLISTVIEW_H__ #include "kleo_export.h" #include #include #include #include #include class QFont; class QColor; namespace Kleo { // work around moc parser bug... #define TEMPLATE_TYPENAME(T) template TEMPLATE_TYPENAME(T) inline T *lvi_cast(QTreeWidgetItem *item) { return item && (item->type() == T::RTTI) ? static_cast(item) : nullptr; } TEMPLATE_TYPENAME(T) inline const T *lvi_cast(const QTreeWidgetItem *item) { return item && (item->type() == T::RTTI) ? static_cast(item) : nullptr; } #undef TEMPLATE_TYPENAME class KeyListView; class KeyListViewItem : public QTreeWidgetItem { public: KeyListViewItem(KeyListView *parent, const GpgME::Key &key); KeyListViewItem(KeyListView *parent, KeyListViewItem *after, const GpgME::Key &key); KeyListViewItem(KeyListViewItem *parent, const GpgME::Key &key); KeyListViewItem(KeyListViewItem *parent, KeyListViewItem *after, const GpgME::Key &key); - ~KeyListViewItem(); + ~KeyListViewItem() override; void setKey(const GpgME::Key &key); const GpgME::Key &key() const { return mKey; } enum { RTTI = QTreeWidgetItem::UserType + 1 }; // // only boring stuff below: // virtual QString toolTip(int column) const; /*! \reimp for covariant return */ KeyListView *listView() const; /*! \reimp for covariant return */ KeyListViewItem *nextSibling() const; /*! \reimp */ bool operator<(const QTreeWidgetItem &other) const override; /*! \reimp */ void takeItem(QTreeWidgetItem *item); private: GpgME::Key mKey; }; class KLEO_EXPORT KeyListView : public QTreeWidget { Q_OBJECT friend class KeyListViewItem; public: class KLEO_EXPORT ColumnStrategy { public: virtual ~ColumnStrategy(); virtual QString title(int column) const = 0; virtual int width(int column, const QFontMetrics &fm) const; virtual QHeaderView::ResizeMode resizeMode(int) const { return QHeaderView::Interactive; } virtual QString text(const GpgME::Key &key, int column) const = 0; virtual QString toolTip(const GpgME::Key &key, int column) const; virtual QIcon icon(const GpgME::Key &, int) const { return QIcon(); } virtual int compare(const GpgME::Key &key1, const GpgME::Key &key2, const int column) const; }; class KLEO_EXPORT DisplayStrategy { public: virtual ~DisplayStrategy(); //font virtual QFont keyFont(const GpgME::Key &, const QFont &) const; //foreground virtual QColor keyForeground(const GpgME::Key &, const QColor &) const; //background virtual QColor keyBackground(const GpgME::Key &, const QColor &) const; }; explicit KeyListView(const ColumnStrategy *strategy, const DisplayStrategy *display = 0, QWidget *parent = nullptr, Qt::WindowFlags f = 0); ~KeyListView(); const ColumnStrategy *columnStrategy() const { return mColumnStrategy; } const DisplayStrategy *displayStrategy() const { return mDisplayStrategy; } bool hierarchical() const { return mHierarchical; } virtual void setHierarchical(bool hier); void flushKeys() { slotUpdateTimeout(); } bool isMultiSelection() const; KeyListViewItem *itemByFingerprint(const QByteArray &) const; public: using QTreeWidget::selectionChanged; // for below, but moc doesn't like it to be in the Q_SIGNALS: section Q_SIGNALS: void doubleClicked(Kleo::KeyListViewItem *, int); void returnPressed(Kleo::KeyListViewItem *); void selectionChanged(Kleo::KeyListViewItem *); void contextMenu(Kleo::KeyListViewItem *, const QPoint &); protected: void keyPressEvent(QKeyEvent *event) override; public Q_SLOTS: virtual void slotAddKey(const GpgME::Key &key); virtual void slotRefreshKey(const GpgME::Key &key); // // Only boring stuff below: // private Q_SLOTS: void slotEmitDoubleClicked(QTreeWidgetItem *, int); void slotEmitReturnPressed(QTreeWidgetItem *); void slotEmitSelectionChanged(); void slotEmitContextMenu(const QPoint &pos); void slotUpdateTimeout(); public: /*! \reimp for covariant return */ KeyListViewItem *selectedItem() const; /*! \reimp */ QList selectedItems() const; /*! \reimp for covariant return */ KeyListViewItem *firstChild() const; /*! \reimp */ void clear(); /*! \reimp */ void takeItem(QTreeWidgetItem *); private: void doHierarchicalInsert(const GpgME::Key &); void gatherScattered(); void scatterGathered(KeyListViewItem *); void registerItem(KeyListViewItem *); void deregisterItem(const KeyListViewItem *); private: const ColumnStrategy *mColumnStrategy = nullptr; const DisplayStrategy *mDisplayStrategy = nullptr; bool mHierarchical = false; class Private; Private *const d; }; } #endif // __KLEO_KEYLISTVIEW_H__