1 /* 2 This file is part of the Kasten Framework, made within the KDE community. 3 4 SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org> 5 6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 7 */ 8 9 #ifndef KASTEN_IF_VERSIONABLE_HPP 10 #define KASTEN_IF_VERSIONABLE_HPP 11 12 // lib 13 // #include "documentversionid.hpp" 14 #include "documentversiondata.hpp" 15 // Qt 16 #include <QtPlugin> 17 18 /* 19 This interface for now just deals with the working copy of the model, 20 versions in the storing (like revision control systems) are not supported/integrated, 21 needs a more general approach to input, synchronizer, changesets and such. 22 23 A model/document can be versioned if the changes to it are traced and reversable. 24 25 Addressing: 26 While we don't do a distributed model and concurrent changes we use simple 27 increasing indizes to address the different version, starting with 0. 28 The initial version as created/loaded in memory gets the index 0. All following 29 versions get a indexOfPrevious+1. This approach might be reusable for local 30 addressing later. 31 32 Wandering in the version "tree": 33 The model can be reset to a previous version, or be set 34 again to a newer version it had been advanced to before. 35 If the model was reset to a previous version and is changed, currently no branch is 36 created but all the versions that are newer are simply skipped. 37 38 Version 39 ^ Changes 40 Version 41 ^ Changes 42 Version 43 ^ Changed 44 Version 45 ^ Changes 46 InitialVersion : Index = 0 47 */ 48 49 namespace Kasten { 50 namespace If { 51 52 class Versionable 53 { 54 public: 55 virtual ~Versionable(); 56 57 public: // get 58 // virtual KDocumentVersionId versionId() const = 0; 59 virtual int versionIndex() const = 0; 60 virtual DocumentVersionData versionData(int versionIndex) const = 0; 61 // virtual KDocumentVersionIterator currentVersion() const = 0; 62 // virtual KDocumentVersionIterator rootVersion() const = 0; 63 // virtual KDocumentVersionIterator headVersion() const = 0; 64 // for those with multiple branches: 65 // virtual KDocumentVersionIterator headVersion( const KDocumentVersionBranchId& id) const = 0; 66 // virtual QList<KDocumentVersionBranchId> heads() const = 0; 67 virtual int versionCount() const = 0; 68 69 public: // set/action 70 // virtual void setVersion( KDocumentVersionId id ) = 0; 71 virtual void revertToVersionByIndex(int versionIndex) = 0; 72 73 public: // signal 74 // virtual void versionChanged( KDocumentVersionId id ) = 0; 75 // 76 virtual void revertedToVersionIndex(int versionIndex) = 0; 77 // 78 virtual void headVersionDataChanged(const DocumentVersionData& versionData) = 0; 79 virtual void headVersionChanged(int newHeadVersionIndex) = 0; 80 }; 81 82 inline Versionable::~Versionable() = default; 83 84 } 85 } 86 87 Q_DECLARE_INTERFACE(Kasten::If::Versionable, "org.kde.kasten.if.versionable/1.0") 88 89 #endif 90