File indexing completed on 2024-06-16 05:24:55

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2008-2009 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef KASTEN_PODTABLEMODEL_HPP
0010 #define KASTEN_PODTABLEMODEL_HPP
0011 
0012 // Qt
0013 #include <QAbstractTableModel>
0014 
0015 namespace Kasten {
0016 
0017 class PODDecoderTool;
0018 
0019 class PODTableModel : public QAbstractTableModel
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     enum ColumnIds
0025     {
0026         NameId = 0,
0027         ValueId = 1,
0028         // UsedBytes = x,  TODO: add hint how many bytes a datatype uses
0029         NoOfColumnIds = 2 // TODO: what pattern is usually used to mark number of ids?
0030     };
0031 
0032 public:
0033     explicit PODTableModel(PODDecoderTool* tool, QObject* parent = nullptr);
0034     ~PODTableModel() override;
0035 
0036 public: // QAbstractItemModel API
0037     int rowCount(const QModelIndex& parent) const override;
0038     int columnCount(const QModelIndex& parent) const override;
0039     QVariant data(const QModelIndex& index, int role) const override;
0040     Qt::ItemFlags flags(const QModelIndex& index) const override;
0041     QModelIndex buddy(const QModelIndex& index) const override;
0042     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0043 
0044     bool setData(const QModelIndex& index, const QVariant& value, int role) override;
0045 
0046 private Q_SLOTS:
0047     void onDataChanged();
0048 
0049 private:
0050     PODDecoderTool* mTool;
0051     const QString mEmptyNote;
0052 };
0053 
0054 }
0055 
0056 #endif