File indexing completed on 2024-06-02 05:15:47
0001 /* 0002 This file is part of Akonadi Contact. 0003 0004 SPDX-FileCopyrightText: 2010 KDAB 0005 SPDX-FileContributor: Tobias Koenig <tokoe@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include "akonadi-contact-core_export.h" 0013 #include <QSortFilterProxyModel> 0014 0015 #include <memory> 0016 0017 namespace Akonadi 0018 { 0019 class LeafExtensionProxyModelPrivate; 0020 0021 class AKONADI_CONTACT_CORE_EXPORT LeafExtensionProxyModel : public QSortFilterProxyModel 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 explicit LeafExtensionProxyModel(QObject *parent = nullptr); 0027 ~LeafExtensionProxyModel() override; 0028 0029 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; 0030 QModelIndex parent(const QModelIndex &index) const override; 0031 int rowCount(const QModelIndex &index) const override; 0032 int columnCount(const QModelIndex &index) const override; 0033 0034 QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const override; 0035 Qt::ItemFlags flags(const QModelIndex &index) const override; 0036 bool setData(const QModelIndex &index, const QVariant &data, int role = Qt::EditRole) override; 0037 bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; 0038 QModelIndex buddy(const QModelIndex &index) const override; 0039 void fetchMore(const QModelIndex &index) override; 0040 0041 void setSourceModel(QAbstractItemModel *sourceModel) override; 0042 0043 protected: 0044 /** 0045 * This method is called to retrieve the row count for the given leaf @p index. 0046 */ 0047 virtual int leafRowCount(const QModelIndex &index) const = 0; 0048 0049 /** 0050 * This method is called to retrieve the column count for the given leaf @p index. 0051 */ 0052 virtual int leafColumnCount(const QModelIndex &index) const = 0; 0053 0054 /** 0055 * This method is called to retrieve the data of the child of the given leaf @p index 0056 * at @p row and @p column with the given @p role. 0057 */ 0058 virtual QVariant leafData(const QModelIndex &index, int row, int column, int role = Qt::DisplayRole) const = 0; 0059 0060 private: 0061 //@cond PRIVATE 0062 std::unique_ptr<LeafExtensionProxyModelPrivate> const d; 0063 0064 Q_PRIVATE_SLOT(d, void sourceRowsInserted(const QModelIndex &, int, int)) 0065 Q_PRIVATE_SLOT(d, void sourceRowsRemoved(const QModelIndex &, int, int)) 0066 //@endcond 0067 }; 0068 }