File indexing completed on 2024-04-14 04:29:20

0001 /*
0002     SPDX-FileCopyrightText: 2007 Aurélien Gâteau
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef SVGPART_H
0008 #define SVGPART_H
0009 
0010 // KF
0011 #include <KParts/ReadOnlyPart>
0012 
0013 class SvgBrowserExtension;
0014 class SvgView;
0015 class KPluginMetaData;
0016 class QGraphicsScene;
0017 class QGraphicsSvgItem;
0018 class QSvgRenderer;
0019 
0020 class SvgPart : public KParts::ReadOnlyPart
0021 {
0022     Q_OBJECT
0023 
0024 public:
0025     SvgPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &);
0026 
0027     bool openUrl(const QUrl &url) override;
0028     bool closeUrl() override;
0029 
0030     void setExtendedRestoreArguments(qreal zoom);
0031 
0032     qreal zoom() const;
0033     int horizontalScrollPosition() const;
0034     int verticalScrollPosition() const;
0035 
0036 protected:
0037     bool openFile() override;
0038     bool doOpenStream(const QString &mimeType) override;
0039     bool doWriteStream(const QByteArray &data) override;
0040     bool doCloseStream() override;
0041 
0042 private Q_SLOTS:
0043     void delayedRestoreViewState();
0044 
0045 private:
0046     void createViewForDocument();
0047 
0048 private:
0049     SvgView *mView;
0050     QGraphicsScene *mScene;
0051     QGraphicsSvgItem *mItem;
0052     QSvgRenderer *mRenderer;
0053 
0054     SvgBrowserExtension *m_browserExtension;
0055 
0056     bool mCloseUrlFromOpen = false;
0057 
0058     bool mHasExtendedRestoreArguments = false;
0059     qreal mRestoreZoom;
0060 
0061     QUrl mPreviousUrl;
0062     qreal mPreviousZoom = 1.0;
0063     int mPreviousHorizontalScrollPosition = 0;
0064     int mPreviousVerticalScrollPosition = 0;
0065 
0066     QByteArray mStreamedData;
0067 };
0068 
0069 #endif /* SVGPART_H */