File indexing completed on 2024-06-23 05:49:21
0001 /* 0002 This file is part of the Kasten Framework, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2007, 2009-2010 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_ABSTRACTMODELSTREAMENCODER_HPP 0010 #define KASTEN_ABSTRACTMODELSTREAMENCODER_HPP 0011 0012 // lib 0013 #include "kastencore_export.hpp" 0014 // Qt 0015 #include <QObject> 0016 #include <QString> 0017 // Std 0018 #include <memory> 0019 0020 class QIODevice; 0021 0022 namespace Kasten { 0023 0024 class AbstractModel; 0025 class AbstractModelSelection; 0026 0027 class AbstractModelStreamEncoderPrivate; 0028 0029 // TODO: General synchronizer would load matching encoder and decoder 0030 // manually defined by desktopfile 0031 0032 // TODO: perhaps just create one instance per encode process, 0033 // giving AbstractModel* model, AbstractModelSelection* selection in the constructor? 0034 // so all precalculated values like used model (type) can be cached 0035 class KASTENCORE_EXPORT AbstractModelStreamEncoder : public QObject 0036 { 0037 Q_OBJECT 0038 0039 protected: 0040 KASTENCORE_NO_EXPORT explicit AbstractModelStreamEncoder(AbstractModelStreamEncoderPrivate* d); 0041 0042 public: 0043 AbstractModelStreamEncoder(const QString& remoteTypeName, const QString& remoteMimeType, 0044 const QString& remoteClipboardMimeType = QString()); 0045 0046 ~AbstractModelStreamEncoder() override; 0047 0048 public: // API to be implemented 0049 virtual bool encodeToStream(QIODevice* device, AbstractModel* model, const AbstractModelSelection* selection) = 0; 0050 virtual QString modelTypeName(AbstractModel* model, const AbstractModelSelection* selection) const = 0; 0051 0052 public: 0053 QString remoteTypeName() const; 0054 QString remoteMimeType() const; 0055 // the clipboard does not yet understand mimetype inheritance 0056 QString remoteClipboardMimeType() const; 0057 0058 protected: 0059 const std::unique_ptr<AbstractModelStreamEncoderPrivate> d_ptr; 0060 0061 private: 0062 Q_DECLARE_PRIVATE(AbstractModelStreamEncoder) 0063 }; 0064 0065 } 0066 0067 #endif