File indexing completed on 2024-09-22 05:16:04
0001 /* 0002 This file is part of the Kasten Framework, 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_VERSIONTABLEMODEL_HPP 0010 #define KASTEN_VERSIONTABLEMODEL_HPP 0011 0012 // Qt 0013 #include <QAbstractTableModel> 0014 0015 namespace Kasten { 0016 0017 class DocumentVersionData; 0018 namespace If { 0019 class Versionable; 0020 } 0021 class AbstractModel; 0022 0023 class VersionTableModel : public QAbstractTableModel 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 enum ColumnIds 0029 { 0030 CurrentColumnId = 0, 0031 IdColumnId = 1, 0032 ChangeDescriptionColumnId = 2, 0033 NoOfColumnIds = 3 // TODO: what pattern is usually used to mark number of ids? 0034 }; 0035 0036 public: 0037 VersionTableModel(AbstractModel* model, If::Versionable* versionControl, QObject* parent = nullptr); 0038 ~VersionTableModel() 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 0046 public: 0047 void setModel(AbstractModel* model, If::Versionable* versionControl); 0048 0049 private Q_SLOTS: 0050 void onRevertedToVersionIndex(int versionIndex); 0051 void onHeadVersionChanged(int newHeadVersionIndex); 0052 void onHeadVersionDataChanged(const Kasten::DocumentVersionData& newVersionData); 0053 0054 private: 0055 AbstractModel* mModel; 0056 If::Versionable* mVersionControl; 0057 /// holds the current version index 0058 int mVersionIndex; 0059 }; 0060 0061 } 0062 0063 #endif