File indexing completed on 2024-05-12 05:06:48
0001 /* 0002 SPDX-FileCopyrightText: 2019 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef STATUSMODEL_H 0007 #define STATUSMODEL_H 0008 0009 #include "kmm_mymoney_export.h" 0010 0011 // ---------------------------------------------------------------------------- 0012 // QT Includes 0013 0014 // ---------------------------------------------------------------------------- 0015 // KDE Includes 0016 0017 // ---------------------------------------------------------------------------- 0018 // Project Includes 0019 0020 #include <mymoneymodel.h> 0021 #include <mymoneyenums.h> 0022 0023 class StatusEntry { 0024 public: 0025 explicit StatusEntry() {} 0026 explicit StatusEntry(const QString& id, const StatusEntry& other) 0027 : m_id(id) 0028 , m_shortName(other.m_shortName) 0029 , m_longName(other.m_longName) 0030 , m_state(other.m_state) 0031 {} 0032 explicit StatusEntry(const QString& id, eMyMoney::Split::State state, const QString& shortName, const QString& longName) 0033 : m_id(id) 0034 , m_shortName(shortName) 0035 , m_longName(longName) 0036 , m_state(state) 0037 {} 0038 0039 inline const QString& id() const { 0040 return m_id; 0041 } 0042 inline const QString& shortName() const { 0043 return m_shortName; 0044 } 0045 inline const QString& longName() const { 0046 return m_longName; 0047 } 0048 inline eMyMoney::Split::State state() const { 0049 return m_state; 0050 } 0051 inline QSet<QString> referencedObjects() const { 0052 return {}; 0053 } 0054 bool hasReferenceTo(const QString& id) const { 0055 Q_UNUSED(id) return false; 0056 } 0057 0058 private: 0059 QString m_id; 0060 QString m_shortName; 0061 QString m_longName; 0062 eMyMoney::Split::State m_state; 0063 }; 0064 0065 class KMM_MYMONEY_EXPORT StatusModel : public MyMoneyModel<StatusEntry> 0066 { 0067 Q_OBJECT 0068 0069 public: 0070 explicit StatusModel(QObject* parent = nullptr); 0071 virtual ~StatusModel(); 0072 0073 int columnCount(const QModelIndex& parent = QModelIndex()) const final override; 0074 QVariant data(const QModelIndex& idx, int role = Qt::DisplayRole) const override; 0075 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const final override; 0076 Qt::ItemFlags flags(const QModelIndex & index) const override; 0077 0078 private: 0079 0080 }; 0081 #endif // STATUSMODEL_H 0082