File indexing completed on 2024-05-12 16:42:17

0001 /*
0002     SPDX-FileCopyrightText: 2016-2017 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef COSTCENTERMODEL_H
0007 #define COSTCENTERMODEL_H
0008 
0009 // ----------------------------------------------------------------------------
0010 // QT Includes
0011 
0012 #include <QAbstractListModel>
0013 
0014 // ----------------------------------------------------------------------------
0015 // KDE Includes
0016 
0017 // ----------------------------------------------------------------------------
0018 // Project Includes
0019 
0020 
0021 /**
0022   */
0023 class CostCenterModel : public QAbstractListModel
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     explicit CostCenterModel(QObject* parent = 0);
0029     virtual ~CostCenterModel();
0030 
0031     enum Roles {
0032         CostCenterIdRole = Qt::UserRole,      // must remain Qt::UserRole due to KMyMoneyMVCCombo::selectedItem
0033         ShortNameRole,
0034     };
0035 
0036     int rowCount(const QModelIndex& parent = QModelIndex()) const final override;
0037     int columnCount(const QModelIndex& parent = QModelIndex()) const final override;
0038     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const final override;
0039     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final override;
0040 
0041     Qt::ItemFlags flags(const QModelIndex& index) const final override;
0042     bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) final override;
0043 
0044     /**
0045      * clears all objects currently in the model
0046      */
0047     void unload();
0048 
0049     /**
0050      * Loads the model with data from the engine
0051      */
0052     void load();
0053 
0054 public Q_SLOTS:
0055 
0056 private:
0057     struct Private;
0058     QScopedPointer<Private> d;
0059 };
0060 
0061 #endif // COSTCENTERMODEL_H
0062