File indexing completed on 2024-12-22 04:15:48

0001 /*
0002  *  SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
0003  *  SPDX-FileCopyrightText: 2005 C. Boemann <cbo@boemann.dk>
0004  *  SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org>
0005  *
0006  *  SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 #ifndef KIS_KRA_SAVE_VISITOR_H_
0009 #define KIS_KRA_SAVE_VISITOR_H_
0010 
0011 #include <QRect>
0012 #include <QStringList>
0013 
0014 #include "kis_types.h"
0015 #include "kis_node_visitor.h"
0016 #include "kis_image.h"
0017 #include "kritalibkra_export.h"
0018 
0019 class KisPaintDeviceWriter;
0020 class KoStore;
0021 
0022 class KRITALIBKRA_EXPORT KisKraSaveVisitor : public KisNodeVisitor
0023 {
0024 public:
0025     KisKraSaveVisitor(KoStore *store, const QString & name, QMap<const KisNode*, QString> nodeFileNames);
0026     ~KisKraSaveVisitor() override;
0027     using KisNodeVisitor::visit;
0028 
0029 public:
0030     void setExternalUri(const QString &uri);
0031 
0032     bool visit(KisNode*) override {
0033         return true;
0034     }
0035 
0036     bool visit(KisExternalLayer *) override;
0037 
0038     bool visit(KisPaintLayer *layer) override;
0039 
0040     bool visit(KisGroupLayer *layer) override;
0041 
0042     bool visit(KisAdjustmentLayer* layer) override;
0043 
0044     bool visit(KisGeneratorLayer * layer) override;
0045 
0046     bool visit(KisCloneLayer *layer) override;
0047 
0048     bool visit(KisFilterMask *mask) override;
0049 
0050     bool visit(KisTransformMask *mask) override;
0051 
0052     bool visit(KisTransparencyMask *mask) override;
0053 
0054     bool visit(KisSelectionMask *mask) override;
0055 
0056     bool visit(KisColorizeMask *mask) override;
0057 
0058     /// @return a list with everything that went wrong while saving
0059     QStringList errorMessages() const;
0060 
0061 private:
0062 
0063     bool savePaintDevice(KisPaintDeviceSP device, QString location);
0064 
0065     template<class DevicePolicy>
0066     bool savePaintDeviceFrame(KisPaintDeviceSP device, QString location, DevicePolicy policy);
0067 
0068     bool saveAnnotations(KisLayer* layer);
0069     bool saveSelection(KisNode* node);
0070     bool saveFilterConfiguration(KisNode* node);
0071     bool saveMetaData(KisNode* node);
0072     bool saveIccProfile(KisNode* node, const KoColorProfile *profile);
0073     QString getLocation(KisNode* node, const QString& suffix = QString());
0074     QString getLocation(const QString &filename, const QString &suffix = QString());
0075 
0076 private:
0077 
0078     KoStore *m_store;
0079     bool m_external;
0080     QString m_uri;
0081     QString m_name;
0082     QMap<const KisNode*, QString> m_nodeFileNames;
0083     KisPaintDeviceWriter *m_writer;
0084     QStringList m_errorMessages;
0085 };
0086 
0087 #endif // KIS_KRA_SAVE_VISITOR_H_
0088