File indexing completed on 2024-09-22 05:16:05
0001 /* 0002 This file is part of the Kasten Framework, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2009, 2012 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_DOCUMENTLISTMODEL_HPP 0010 #define KASTEN_DOCUMENTLISTMODEL_HPP 0011 0012 // Qt 0013 #include <QAbstractTableModel> 0014 0015 namespace Kasten { 0016 0017 class DocumentsTool; 0018 class AbstractModelSynchronizer; 0019 class AbstractDocument; 0020 0021 class DocumentListModel : public QAbstractTableModel 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 enum ColumnIds 0027 { 0028 CurrentColumnId = 0, 0029 LocalStateColumnId = 1, 0030 RemoteStateColumnId = 2, 0031 TitleColumnId = 3, 0032 NoOfColumnIds = 4 // TODO: what pattern is usually used to mark number of ids? 0033 }; 0034 0035 public: 0036 explicit DocumentListModel(DocumentsTool* documentsTool, QObject* parent = nullptr); 0037 ~DocumentListModel() override; 0038 0039 public: // QAbstractTableModel API 0040 int rowCount(const QModelIndex& parent) const override; 0041 int columnCount(const QModelIndex& parent) const override; 0042 QVariant data(const QModelIndex& index, int role) const override; 0043 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0044 0045 private Q_SLOTS: 0046 void onDocumentsAdded(const QVector<Kasten::AbstractDocument*>& documents); 0047 void onDocumentsClosing(const QVector<Kasten::AbstractDocument*>& documents); 0048 void onFocussedDocumentChanged(Kasten::AbstractDocument* document); 0049 void onSyncStatesChanged(); 0050 void onSynchronizerChanged(Kasten::AbstractModelSynchronizer* synchronizer); 0051 0052 private: 0053 DocumentsTool* mDocumentsTool; 0054 }; 0055 0056 } 0057 0058 #endif