File indexing completed on 2024-05-12 04:19:36

0001 // vim: set tabstop=4 shiftwidth=4 expandtab:
0002 /*
0003 Gwenview: an image viewer
0004 Copyright 2007 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, Boston, MA 02110-1301, USA.
0019 
0020 */
0021 #ifndef ABSTRACTDOCUMENTIMPL_H
0022 #define ABSTRACTDOCUMENTIMPL_H
0023 
0024 // Qt
0025 #include <QByteArray>
0026 #include <QObject>
0027 
0028 // KF
0029 
0030 // Local
0031 #include <lib/document/document.h>
0032 #include <lib/orientation.h>
0033 
0034 class QImage;
0035 class QRect;
0036 
0037 namespace Exiv2
0038 {
0039 class Image;
0040 }
0041 
0042 namespace Gwenview
0043 {
0044 class Document;
0045 class DocumentJob;
0046 class AbstractDocumentEditor;
0047 
0048 struct AbstractDocumentImplPrivate;
0049 class AbstractDocumentImpl : public QObject
0050 {
0051     Q_OBJECT
0052 public:
0053     AbstractDocumentImpl(Document *);
0054     ~AbstractDocumentImpl() override;
0055 
0056     /**
0057      * This method is called by Document::switchToImpl after it has connected
0058      * signals to the object
0059      */
0060     virtual void init() = 0;
0061 
0062     virtual Document::LoadingState loadingState() const = 0;
0063 
0064     virtual DocumentJob *save(const QUrl &, const QByteArray & /*format*/)
0065     {
0066         return nullptr;
0067     }
0068 
0069     virtual AbstractDocumentEditor *editor()
0070     {
0071         return nullptr;
0072     }
0073 
0074     virtual QByteArray rawData() const
0075     {
0076         return {};
0077     }
0078 
0079     virtual bool isEditable() const
0080     {
0081         return false;
0082     }
0083 
0084     virtual bool isAnimated() const
0085     {
0086         return false;
0087     }
0088 
0089     virtual void startAnimation()
0090     {
0091     }
0092 
0093     virtual void stopAnimation()
0094     {
0095     }
0096 
0097     Document *document() const;
0098 
0099     virtual QSvgRenderer *svgRenderer() const
0100     {
0101         return nullptr;
0102     }
0103 
0104 Q_SIGNALS:
0105     void imageRectUpdated(const QRect &);
0106     void metaInfoLoaded();
0107     void loaded();
0108     void loadingFailed();
0109     void isAnimatedUpdated();
0110 
0111 protected:
0112     void setDocumentImage(const QImage &image);
0113     void setDocumentImageSize(const QSize &size);
0114     void setDocumentKind(MimeTypeUtils::Kind);
0115     void setDocumentFormat(const QByteArray &format);
0116     void setDocumentExiv2Image(std::unique_ptr<Exiv2::Image>);
0117     void setDocumentDownSampledImage(const QImage &, int invertedZoom);
0118     void setDocumentCmsProfile(const Cms::Profile::Ptr &profile);
0119     void setDocumentErrorString(const QString &);
0120     void switchToImpl(AbstractDocumentImpl *impl);
0121 
0122 private:
0123     AbstractDocumentImplPrivate *const d;
0124 };
0125 
0126 } // namespace
0127 
0128 #endif /* ABSTRACTDOCUMENTIMPL_H */