File indexing completed on 2025-01-05 05:23:27
0001 /* 0002 This file is part of the Kasten Framework, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 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_BOOKMARKLISTMODEL_HPP 0010 #define KASTEN_BOOKMARKLISTMODEL_HPP 0011 0012 // Okteta gui 0013 #include <Okteta/OffsetFormat> 0014 // Qt 0015 #include <QAbstractTableModel> 0016 #include <QFont> 0017 0018 namespace Okteta { 0019 class Bookmark; 0020 } 0021 template <class T> class QVector; 0022 0023 namespace Kasten { 0024 0025 class BookmarksTool; 0026 0027 class BookmarkListModel : public QAbstractTableModel 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 enum ColumnIds 0033 { 0034 OffsetColumnId = 0, 0035 TitleColumnId = 1, 0036 NoOfColumnIds = 2 // TODO: what pattern is usually used to mark number of ids? 0037 }; 0038 0039 public: 0040 explicit BookmarkListModel(BookmarksTool* tool, QObject* parent = nullptr); 0041 ~BookmarkListModel() override; 0042 0043 public: // QAbstractTableModel API 0044 int rowCount(const QModelIndex& parent) const override; 0045 int columnCount(const QModelIndex& parent) const override; 0046 QVariant data(const QModelIndex& index, int role) const override; 0047 Qt::ItemFlags flags(const QModelIndex& index) const override; 0048 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0049 bool setData(const QModelIndex& index, const QVariant& value, int role) override; 0050 0051 public: 0052 const Okteta::Bookmark& bookmark(const QModelIndex& index) const; 0053 QModelIndex index(const Okteta::Bookmark& bookmark, int column = BookmarkListModel::TitleColumnId) const; 0054 using QAbstractTableModel::index; 0055 0056 private Q_SLOTS: 0057 void onHasBookmarksChanged(bool hasBookmarks); 0058 void onBookmarksChanged(); 0059 void onBookmarksChanged(const QVector<int>& bookmarkIndizes); 0060 // void onHeadVersionChanged( int newHeadVersionIndex ); 0061 // void onHeadVersionDataChanged( const DocumentVersionData &newVersionData ); 0062 void onOffsetCodingChanged(int offsetCoding); 0063 0064 private: 0065 BookmarksTool* mTool; 0066 0067 Okteta::OffsetFormat::print mPrintFunction; 0068 mutable char mCodedOffset[Okteta::OffsetFormat::MaxFormatWidth + 1]; 0069 QFont mFixedFont; 0070 }; 0071 0072 } 0073 0074 #endif