File indexing completed on 2024-06-23 05:49:19

0001 /*
0002     This file is part of the Kasten Framework, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2007-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_ABSTRACTDOCUMENT_P_HPP
0010 #define KASTEN_ABSTRACTDOCUMENT_P_HPP
0011 
0012 #include "abstractmodel_p.hpp"
0013 #include "abstractdocument.hpp"
0014 
0015 // lib
0016 #include "abstractmodelsynchronizer.hpp"
0017 
0018 namespace Kasten {
0019 
0020 class AbstractDocumentPrivate : public AbstractModelPrivate
0021 {
0022 public:
0023     explicit AbstractDocumentPrivate(AbstractDocument* parent);
0024 
0025     ~AbstractDocumentPrivate() override;
0026 
0027 public:
0028     const QString& id() const;
0029     AbstractModelSynchronizer* synchronizer() const;
0030 
0031 public:
0032     void setId(const QString& id);
0033     void setSynchronizer(AbstractModelSynchronizer* synchronizer);
0034 
0035 private:
0036     Q_DECLARE_PUBLIC(AbstractDocument)
0037 
0038 private:
0039     QString mId;
0040     AbstractModelSynchronizer* mSynchronizer = nullptr; // TODO: should this be here, with public setters and getters?
0041 };
0042 
0043 inline AbstractDocumentPrivate::AbstractDocumentPrivate(AbstractDocument* parent)
0044     : AbstractModelPrivate(parent)
0045 {}
0046 
0047 inline AbstractDocumentPrivate::~AbstractDocumentPrivate()
0048 {
0049     delete mSynchronizer;
0050 }
0051 
0052 inline const QString& AbstractDocumentPrivate::id() const { return mId; }
0053 inline void AbstractDocumentPrivate::setId(const QString& id) { mId = id; }
0054 
0055 inline AbstractModelSynchronizer* AbstractDocumentPrivate::synchronizer() const { return mSynchronizer; }
0056 inline void AbstractDocumentPrivate::setSynchronizer(AbstractModelSynchronizer* synchronizer)
0057 {
0058     Q_Q(AbstractDocument);
0059 
0060     // plugging the same more than once?
0061     if (mSynchronizer == synchronizer) {
0062         return;
0063     }
0064 
0065     delete mSynchronizer;
0066     mSynchronizer = synchronizer;
0067 
0068     Q_EMIT q->synchronizerChanged(synchronizer);
0069 }
0070 
0071 }
0072 
0073 #endif