File indexing completed on 2025-01-19 05:20:21

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2007 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_ABSTRACTBYTEARRAYSTREAMENCODER_HPP
0010 #define KASTEN_ABSTRACTBYTEARRAYSTREAMENCODER_HPP
0011 
0012 // lib
0013 #include "oktetakastengui_export.hpp"
0014 // Kasten core
0015 #include <Kasten/AbstractModelStreamEncoder>
0016 // Okteta core
0017 #include <Okteta/AddressRange>
0018 
0019 namespace Okteta {
0020 class AbstractByteArrayModel;
0021 }
0022 
0023 namespace Kasten {
0024 
0025 // TODO: make display model an interface, so these encoders can stay in core
0026 class ByteArrayView;
0027 
0028 class OKTETAKASTENGUI_EXPORT AbstractByteArrayStreamEncoder : public AbstractModelStreamEncoder
0029 {
0030     Q_OBJECT
0031 
0032 private:
0033     static inline constexpr int MaxPreviewSize = 100;
0034 
0035 public:
0036     AbstractByteArrayStreamEncoder(const QString& remoteTypeName, const QString& remoteMimeType,
0037                                    const QString& remoteClipboardMimeType = QString());
0038     ~AbstractByteArrayStreamEncoder() override;
0039 
0040 public: // AbstractModelStreamEncoder API
0041     bool encodeToStream(QIODevice* device, AbstractModel* model, const AbstractModelSelection* selection) override;
0042     QString modelTypeName(AbstractModel* model, const AbstractModelSelection* selection) const override;
0043 
0044 public:
0045     QString previewData(AbstractModel* model, const AbstractModelSelection* selection);
0046 
0047 Q_SIGNALS:
0048     void settingsChanged();
0049 
0050 protected: // API to be implemented
0051     virtual bool encodeDataToStream(QIODevice* device,
0052                                     const ByteArrayView* byteArrayView,
0053                                     const Okteta::AbstractByteArrayModel* byteArrayModel,
0054                                     const Okteta::AddressRange& range) = 0;
0055 };
0056 
0057 }
0058 
0059 #endif