File indexing completed on 2024-06-23 05:48:45
0001 /* 0002 This file is part of the Okteta Kasten module, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2007 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_BYTETABLEMODEL_HPP 0010 #define KASTEN_BYTETABLEMODEL_HPP 0011 0012 // Qt 0013 #include <QAbstractTableModel> 0014 #include <QFont> 0015 0016 namespace Okteta { 0017 class CharCodec; 0018 class ValueCodec; 0019 } 0020 0021 namespace Kasten { 0022 0023 class ByteTableModel : public QAbstractTableModel 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 enum ColumnIds 0029 { 0030 DecimalId = 0, 0031 HexadecimalId = 1, 0032 OctalId = 2, 0033 BinaryId = 3, 0034 CharacterId = 4, 0035 NoOfIds = 5 // TODO: what pattern is usually used to mark number of ids? 0036 }; 0037 0038 public: 0039 explicit ByteTableModel(QObject* parent = nullptr); 0040 ~ByteTableModel() override; 0041 0042 public: // QAbstractTableModel API 0043 int rowCount(const QModelIndex& parent) const override; 0044 int columnCount(const QModelIndex& parent) const override; 0045 QVariant data(const QModelIndex& index, int role) const override; 0046 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0047 0048 public Q_SLOTS: 0049 void setCharCodec(const QString& codecName); 0050 void setSubstituteChar(QChar substituteChar); 0051 void setUndefinedChar(QChar undefinedChar); 0052 0053 public: 0054 const QFont &fixedFont() const; 0055 0056 private: 0057 static constexpr int NofOfValueCodings = 4; 0058 0059 private: 0060 Okteta::ValueCodec* mValueCodec[NofOfValueCodings]; 0061 Okteta::CharCodec* mCharCodec; 0062 QChar mSubstituteChar; 0063 QChar mUndefinedChar; 0064 QFont mFixedFont; 0065 }; 0066 0067 inline const QFont &ByteTableModel::fixedFont() const 0068 { 0069 return mFixedFont; 0070 } 0071 0072 } 0073 0074 #endif