File indexing completed on 2024-05-12 04:19:40
0001 // vim: set tabstop=4 shiftwidth=4 expandtab: 0002 /* 0003 Gwenview: an image viewer 0004 Copyright 2008 Aurélien Gâteau <agateau@kde.org> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License 0008 as published by the Free Software Foundation; either version 2 0009 of the License, or (at your option) any later version. 0010 0011 This program is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with this program; if not, write to the Free Software 0018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. 0019 0020 */ 0021 #ifndef SVGVIEWADAPTER_H 0022 #define SVGVIEWADAPTER_H 0023 0024 #include <lib/gwenviewlib_export.h> 0025 0026 // Qt 0027 #include <QGraphicsWidget> 0028 0029 // KF 0030 0031 // Local 0032 #include <lib/documentview/abstractdocumentviewadapter.h> 0033 #include <lib/documentview/abstractimageview.h> 0034 0035 class QGraphicsSvgItem; 0036 0037 namespace Gwenview 0038 { 0039 class SvgImageView : public AbstractImageView 0040 { 0041 Q_OBJECT 0042 public: 0043 explicit SvgImageView(QGraphicsItem *parent = nullptr); 0044 0045 protected: 0046 void loadFromDocument() override; 0047 void onZoomChanged() override; 0048 void onImageOffsetChanged() override; 0049 void onScrollPosChanged(const QPointF &oldPos) override; 0050 0051 private Q_SLOTS: 0052 void finishLoadFromDocument(); 0053 0054 private: 0055 QGraphicsSvgItem *mSvgItem; 0056 void adjustItemPos(); 0057 }; 0058 0059 struct SvgViewAdapterPrivate; 0060 class GWENVIEWLIB_EXPORT SvgViewAdapter : public AbstractDocumentViewAdapter 0061 { 0062 Q_OBJECT 0063 public: 0064 SvgViewAdapter(); 0065 ~SvgViewAdapter() override; 0066 0067 QCursor cursor() const override; 0068 0069 void setCursor(const QCursor &) override; 0070 0071 void setDocument(const Document::Ptr &) override; 0072 0073 Document::Ptr document() const override; 0074 0075 void loadConfig() override; 0076 0077 MimeTypeUtils::Kind kind() const override 0078 { 0079 return MimeTypeUtils::KIND_SVG_IMAGE; 0080 } 0081 0082 bool canZoom() const override 0083 { 0084 return true; 0085 } 0086 0087 void setZoomToFit(bool) override; 0088 0089 void setZoomToFill(bool on, const QPointF ¢er) override; 0090 0091 bool zoomToFit() const override; 0092 0093 bool zoomToFill() const override; 0094 0095 qreal zoom() const override; 0096 0097 void setZoom(qreal /*zoom*/, const QPointF & /*center*/ = QPointF(-1, -1)) override; 0098 0099 qreal computeZoomToFit() const override; 0100 0101 qreal computeZoomToFill() const override; 0102 0103 QPointF scrollPos() const override; 0104 void setScrollPos(const QPointF &pos) override; 0105 0106 QRectF visibleDocumentRect() const override; 0107 0108 AbstractImageView *imageView() const override; 0109 0110 private: 0111 SvgViewAdapterPrivate *const d; 0112 }; 0113 0114 } // namespace 0115 0116 #endif /* SVGVIEWADAPTER_H */