File indexing completed on 2024-11-24 04:39:30
0001 /* 0002 This file is part of Contact Editor. 0003 0004 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include "customfields_p.h" 0012 0013 #include <QAbstractItemModel> 0014 namespace Akonadi 0015 { 0016 class CustomFieldsModel : public QAbstractItemModel 0017 { 0018 Q_OBJECT 0019 public: 0020 enum Role { TypeRole = Qt::UserRole, ScopeRole }; 0021 0022 explicit CustomFieldsModel(QObject *parent = nullptr); 0023 ~CustomFieldsModel() override; 0024 0025 void setCustomFields(const CustomField::List &addresses); 0026 CustomField::List customFields() const; 0027 0028 QModelIndex index(int row, int col, const QModelIndex &parent = QModelIndex()) const override; 0029 QModelIndex parent(const QModelIndex &child) const override; 0030 QVariant data(const QModelIndex &index, int role) const override; 0031 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 0032 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0033 Qt::ItemFlags flags(const QModelIndex &index) const override; 0034 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0035 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0036 0037 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; 0038 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; 0039 0040 private: 0041 CustomField::List mCustomFields; 0042 }; 0043 }