File indexing completed on 2024-06-16 05:24:57
0001 /* 0002 This file is part of the Okteta Kasten module, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2008 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_CONTAINEDSTRINGTABLEMODEL_HPP 0010 #define KASTEN_CONTAINEDSTRINGTABLEMODEL_HPP 0011 0012 // tool 0013 #include "containedstring.hpp" 0014 // Okteta gui 0015 #include <Okteta/OffsetFormat> 0016 // Qt 0017 #include <QList> 0018 #include <QAbstractTableModel> 0019 #include <QFont> 0020 0021 namespace Kasten { 0022 0023 class ContainedStringTableModel : public QAbstractTableModel 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 enum ColumnIds 0029 { 0030 OffsetColumnId = 0, 0031 StringColumnId = 1, 0032 NoOfColumnIds = 2 // TODO: what pattern is usually used to mark number of ids? 0033 }; 0034 0035 public: 0036 ContainedStringTableModel(const QList<ContainedString>* containedStringList, int offsetCoding, 0037 QObject* parent = nullptr); 0038 ~ContainedStringTableModel() override; 0039 0040 public: // QAbstractTableModel API 0041 int rowCount(const QModelIndex& parent) const override; 0042 int columnCount(const QModelIndex& parent) const override; 0043 QVariant data(const QModelIndex& index, int role) const override; 0044 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0045 Qt::ItemFlags flags(const QModelIndex& index) const override; 0046 QMimeData* mimeData(const QModelIndexList& indexes) const override; 0047 QStringList mimeTypes() const override; 0048 0049 public Q_SLOTS: 0050 void update(); 0051 void setOffsetCoding(int offsetCoding); 0052 0053 private: 0054 const QList<ContainedString>* const mContainedStringList; 0055 0056 Okteta::OffsetFormat::print mPrintFunction; 0057 mutable char mCodedOffset[Okteta::OffsetFormat::MaxFormatWidth + 1]; 0058 QFont mFixedFont; 0059 }; 0060 0061 } 0062 0063 #endif