File indexing completed on 2024-05-05 05:56:43

0001 /*
0002     This file is part of the Okteta KPart module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2003, 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 OKTETAPART_HPP
0010 #define OKTETAPART_HPP
0011 
0012 // Kasten
0013 #include <Kasten/KastenCore>
0014 // KF
0015 #include <kparts_version.h>
0016 #include <KParts/ReadWritePart>
0017 // Qt
0018 #include <QVector>
0019 
0020 namespace Kasten {
0021 class ByteArrayViewProfileManager;
0022 class ByteArrayView;
0023 class ByteArrayDocument;
0024 class SingleViewArea;
0025 class ModelCodecViewManager;
0026 class ModelCodecManager;
0027 class AbstractXmlGuiController;
0028 class AbstractXmlGuiControllerFactory;
0029 class AbstractDocument;
0030 }
0031 class KPluginMetaData;
0032 class QVBoxLayout;
0033 
0034 class OktetaPart : public KParts::ReadWritePart
0035 {
0036     Q_OBJECT
0037 
0038     friend class OktetaBrowserExtension;
0039 
0040 public:
0041     enum Modus
0042     {
0043         ReadOnly = 0,
0044         BrowserView = 1,
0045         ReadWrite = 2
0046     };
0047 
0048 public:
0049     OktetaPart(QObject* parent,
0050                const KPluginMetaData& metaData,
0051                Modus modus,
0052                Kasten::ByteArrayViewProfileManager* viewProfileManager,
0053                Kasten::ModelCodecManager* modelCodecManager,
0054                Kasten::ModelCodecViewManager* modelCodecViewManager);
0055 
0056     ~OktetaPart() override;
0057 
0058 public: // KParts::ReadWritePart API
0059     void setReadWrite(bool readWrite = true) override;
0060 
0061 Q_SIGNALS:
0062     void hasSelectedDataChanged(bool hasSelectedData);
0063 
0064 protected: // KParts::ReadWritePart API
0065     bool saveFile() override;
0066 
0067 protected: // KParts::ReadOnlyPart API
0068     bool openFile() override;
0069 
0070 private:
0071     void setupActions(bool browserViewWanted);
0072     void addController(const Kasten::AbstractXmlGuiControllerFactory& factory);
0073 
0074 private:
0075     Kasten::ByteArrayView* byteArrayView() const;
0076 
0077 private Q_SLOTS:
0078     void onDocumentLoaded(Kasten::AbstractDocument* document);
0079     void onModified(Kasten::LocalSyncState state);
0080 
0081 private:
0082     const Modus mModus;
0083     QVBoxLayout* mLayout;
0084 
0085     Kasten::ByteArrayDocument* mDocument;
0086     Kasten::ByteArrayView* mByteArrayView;
0087 
0088     Kasten::SingleViewArea* mSingleViewArea;
0089     QVector<Kasten::AbstractXmlGuiController*> mControllers;
0090 
0091     Kasten::ByteArrayViewProfileManager* mViewProfileManager;
0092 };
0093 
0094 inline Kasten::ByteArrayView* OktetaPart::byteArrayView() const { return mByteArrayView; }
0095 
0096 #endif