Krita Source Code Documentation
Loading...
Searching...
No Matches
KisKraSaveVisitor Class Reference

#include <kis_kra_save_visitor.h>

+ Inheritance diagram for KisKraSaveVisitor:

Public Member Functions

QStringList errorMessages () const
 
 KisKraSaveVisitor (KoStore *store, const QString &name, QMap< const KisNode *, QString > nodeFileNames)
 
void setExternalUri (const QString &uri)
 
bool visit (KisAdjustmentLayer *layer) override
 
virtual bool visit (KisAdjustmentLayer *layer)=0
 
bool visit (KisCloneLayer *layer) override
 
virtual bool visit (KisCloneLayer *layer)=0
 
bool visit (KisColorizeMask *mask) override
 
virtual bool visit (KisColorizeMask *mask)=0
 
bool visit (KisExternalLayer *) override
 
virtual bool visit (KisExternalLayer *layer)=0
 
bool visit (KisFilterMask *mask) override
 
virtual bool visit (KisFilterMask *mask)=0
 
bool visit (KisGeneratorLayer *layer) override
 
virtual bool visit (KisGeneratorLayer *layer)=0
 
bool visit (KisGroupLayer *layer) override
 
virtual bool visit (KisGroupLayer *layer)=0
 
bool visit (KisNode *) override
 
virtual bool visit (KisNode *node)=0
 
bool visit (KisPaintLayer *layer) override
 
virtual bool visit (KisPaintLayer *layer)=0
 
bool visit (KisSelectionMask *mask) override
 
virtual bool visit (KisSelectionMask *mask)=0
 
bool visit (KisTransformMask *mask) override
 
virtual bool visit (KisTransformMask *mask)=0
 
bool visit (KisTransparencyMask *mask) override
 
virtual bool visit (KisTransparencyMask *mask)=0
 
 ~KisKraSaveVisitor () override
 
- Public Member Functions inherited from KisNodeVisitor
 KisNodeVisitor ()
 
virtual ~KisNodeVisitor ()
 

Private Member Functions

QString getLocation (const QString &filename, const QString &suffix=QString())
 
QString getLocation (KisNode *node, const QString &suffix=QString())
 
bool saveAnnotations (KisLayer *layer)
 
bool saveFilterConfiguration (KisNode *node)
 
bool saveIccProfile (KisNode *node, const KoColorProfile *profile)
 
bool saveMetaData (KisNode *node)
 
bool savePaintDevice (KisPaintDeviceSP device, QString location)
 
template<class DevicePolicy >
bool savePaintDeviceFrame (KisPaintDeviceSP device, QString location, DevicePolicy policy)
 
bool saveSelection (KisNode *node)
 

Private Attributes

QStringList m_errorMessages
 
bool m_external
 
QString m_name
 
QMap< const KisNode *, QString > m_nodeFileNames
 
KoStorem_store
 
QString m_uri
 
KisPaintDeviceWriterm_writer
 

Additional Inherited Members

- Protected Member Functions inherited from KisNodeVisitor
bool visitAll (KisNode *node, bool breakOnFail=false)
 
bool visitAllInverse (KisNode *node, bool breakOnFail=false)
 

Detailed Description

Definition at line 21 of file kis_kra_save_visitor.h.

Constructor & Destructor Documentation

◆ KisKraSaveVisitor()

KisKraSaveVisitor::KisKraSaveVisitor ( KoStore * store,
const QString & name,
QMap< const KisNode *, QString > nodeFileNames )

Definition at line 60 of file kis_kra_save_visitor.cpp.

62 , m_store(store)
63 , m_external(false)
64 , m_name(name)
65 , m_nodeFileNames(nodeFileNames)
67{
68}
KisPaintDeviceWriter * m_writer
QMap< const KisNode *, QString > m_nodeFileNames

◆ ~KisKraSaveVisitor()

KisKraSaveVisitor::~KisKraSaveVisitor ( )
override

Definition at line 70 of file kis_kra_save_visitor.cpp.

71{
72 delete m_writer;
73}

References m_writer.

Member Function Documentation

◆ errorMessages()

QStringList KisKraSaveVisitor::errorMessages ( ) const
Returns
a list with everything that went wrong while saving

Definition at line 305 of file kis_kra_save_visitor.cpp.

306{
307 return m_errorMessages;
308}

References m_errorMessages.

◆ getLocation() [1/2]

QString KisKraSaveVisitor::getLocation ( const QString & filename,
const QString & suffix = QString() )
private

Definition at line 545 of file kis_kra_save_visitor.cpp.

546{
547 QString location = m_external ? QString() : m_uri;
548 location += m_name + LAYER_PATH + filename + suffix;
549 return location;
550}
const QString LAYER_PATH

References KRA::LAYER_PATH, m_external, m_name, and m_uri.

◆ getLocation() [2/2]

QString KisKraSaveVisitor::getLocation ( KisNode * node,
const QString & suffix = QString() )
private

Definition at line 538 of file kis_kra_save_visitor.cpp.

539{
540
541 Q_ASSERT(m_nodeFileNames.contains(node));
542 return getLocation(m_nodeFileNames[node], suffix);
543}
QString getLocation(KisNode *node, const QString &suffix=QString())

References getLocation(), and m_nodeFileNames.

◆ saveAnnotations()

bool KisKraSaveVisitor::saveAnnotations ( KisLayer * layer)
private

Definition at line 393 of file kis_kra_save_visitor.cpp.

394{
395 if (!layer) return false;
396 if (!layer->paintDevice()) return false;
397 if (!layer->paintDevice()->colorSpace()) return false;
398
399 if (layer->paintDevice()->colorSpace()->profile()) {
400 return saveIccProfile(layer, layer->paintDevice()->colorSpace()->profile());
401 }
402 return true;
403
404}
bool saveIccProfile(KisNode *node, const KoColorProfile *profile)
const KoColorSpace * colorSpace() const
virtual const KoColorProfile * profile() const =0
virtual KisPaintDeviceSP paintDevice() const =0

References KisPaintDevice::colorSpace(), KisBaseNode::paintDevice(), KoColorSpace::profile(), and saveIccProfile().

◆ saveFilterConfiguration()

bool KisKraSaveVisitor::saveFilterConfiguration ( KisNode * node)
private

Definition at line 476 of file kis_kra_save_visitor.cpp.

477{
478 KisNodeFilterInterface *filterInterface =
479 dynamic_cast<KisNodeFilterInterface*>(node);
480
482
483 if (filterInterface) {
484 filter = filterInterface->filter();
485 }
486
487 bool retval = false;
488
489 if (filter) {
490 QString location = getLocation(node, DOT_FILTERCONFIG);
491 if (m_store->open(location)) {
492 QString s = filter->toXML();
493 retval = (m_store->write(s.toUtf8(), qstrlen(s.toUtf8())) == qstrlen(s.toUtf8())); m_store->close();
494 }
495 }
496 return retval;
497}
virtual KisFilterConfigurationSP filter() const
qint64 write(const QByteArray &data)
Definition KoStore.cpp:198
bool close()
Definition KoStore.cpp:156
bool open(const QString &name)
Definition KoStore.cpp:109
const QString DOT_FILTERCONFIG

References KoStore::close(), KRA::DOT_FILTERCONFIG, KisNodeFilterInterface::filter(), getLocation(), m_store, KoStore::open(), and KoStore::write().

◆ saveIccProfile()

bool KisKraSaveVisitor::saveIccProfile ( KisNode * node,
const KoColorProfile * profile )
private

Definition at line 406 of file kis_kra_save_visitor.cpp.

407{
408 if (profile) {
409 KisAnnotationSP annotation;
410 if (profile) {
411 QByteArray profileRawData = profile->rawData();
412 if (!profileRawData.isEmpty()) {
413 if (profile->type() == "icc") {
414 annotation = new KisAnnotation(ICC, profile->name(), profile->rawData());
415 } else {
416 annotation = new KisAnnotation(PROFILE, profile->name(), profile->rawData());
417 }
418 }
419 }
420
421 if (annotation) {
422 // save layer profile
423 if (m_store->open(getLocation(node, DOT_ICC))) {
424 m_store->write(annotation->annotation());
425 m_store->close();
426 } else {
427 return false;
428 }
429 }
430 }
431 return true;
432}
A data extension mechanism for Krita.
const QString ICC
const QString DOT_ICC
const QString PROFILE
virtual QByteArray rawData() const
virtual QString type() const

References KoStore::close(), KRA::DOT_ICC, getLocation(), KRA::ICC, m_store, KoColorProfile::name, KoStore::open(), KRA::PROFILE, KoColorProfile::rawData(), KoColorProfile::type(), and KoStore::write().

◆ saveMetaData()

bool KisKraSaveVisitor::saveMetaData ( KisNode * node)
private

Definition at line 499 of file kis_kra_save_visitor.cpp.

500{
501 if (!node->inherits("KisLayer")) return true;
502
503 KisMetaData::Store* metadata = (static_cast<KisLayer*>(node))->metaData();
504 if (metadata->isEmpty()) return true;
505
506 // Serialize all the types of metadata there are
508 if (!backend->supportSaving()) {
509 dbgFile << "Backend " << backend->id() << " does not support saving.";
510 return false;
511 }
512
513 QString location = getLocation(node, QString(".") + backend->id() + DOT_METADATA);
514 dbgFile << "going to save " << backend->id() << ", " << backend->name() << " to " << location;
515
516 QBuffer buffer;
517 // not that the metadata backends every return anything but true...
518 bool retval = backend->saveTo(metadata, &buffer);
519
520 if (!retval) {
521 m_errorMessages << i18n("The metadata backend failed to save the metadata for %1", node->name());
522 }
523 else {
524 QByteArray data = buffer.data();
525 dbgFile << "\t information size is" << data.size();
526
527 if (data.size() > 0 && m_store->open(location)) {
528 retval = m_store->write(data, data.size());
529 m_store->close();
530 }
531 if (!retval) {
532 m_errorMessages << i18n("Could not write for %1 metadata to the file.", node->name());
533 }
534 }
535 return retval;
536}
virtual QString name() const =0
virtual bool saveTo(const Store *store, QIODevice *ioDevice, HeaderType headerType=NoHeader) const =0
virtual QString id() const =0
virtual bool supportSaving() const =0
static KisMetadataBackendRegistry * instance()
T get(const QString &id) const
#define dbgFile
Definition kis_debug.h:53
const QString DOT_METADATA
QString name() const

References KoStore::close(), dbgFile, KRA::DOT_METADATA, KoGenericRegistry< T >::get(), getLocation(), KisMetaData::IOBackend::id(), KisMetadataBackendRegistry::instance(), KisMetaData::Store::isEmpty(), m_errorMessages, m_store, KisBaseNode::name(), KisMetaData::IOBackend::name(), KoStore::open(), KisMetaData::IOBackend::saveTo(), KisMetaData::IOBackend::supportSaving(), and KoStore::write().

◆ savePaintDevice()

bool KisKraSaveVisitor::savePaintDevice ( KisPaintDeviceSP device,
QString location )
private

Definition at line 337 of file kis_kra_save_visitor.cpp.

339{
340 // Layer data
341 KisConfig cfg(true);
342 m_store->setCompressionEnabled(cfg.compressKra());
343
344 KisPaintDeviceFramesInterface *frameInterface = device->framesInterface();
345 QList<int> frames;
346
347 if (frameInterface) {
348 frames = frameInterface->frames();
349 }
350
351 if (!frameInterface || frames.count() <= 1) {
352 savePaintDeviceFrame(device, location, SimpleDevicePolicy());
353 } else {
354 KisRasterKeyframeChannel *keyframeChannel = device->keyframeChannel();
355
356 for (int i = 0; i < frames.count(); i++) {
357 int id = frames[i];
358
359 QString frameFilename = getLocation(keyframeChannel->frameFilename(id));
360 Q_ASSERT(!frameFilename.isEmpty());
361
362 if (!savePaintDeviceFrame(device, frameFilename, FramedDevicePolicy(id))) {
363 return false;
364 }
365 }
366 }
367
369 return true;
370}
bool savePaintDeviceFrame(KisPaintDeviceSP device, QString location, DevicePolicy policy)
KisRasterKeyframeChannel * keyframeChannel() const
KisPaintDeviceFramesInterface * framesInterface()
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
QString frameFilename(int frameId) const
virtual void setCompressionEnabled(bool e)
Definition KoStore.cpp:403

References KisConfig::compressKra(), KisRasterKeyframeChannel::frameFilename(), KisPaintDeviceFramesInterface::frames(), KisPaintDevice::framesInterface(), getLocation(), KisPaintDevice::keyframeChannel(), m_store, savePaintDeviceFrame(), and KoStore::setCompressionEnabled().

◆ savePaintDeviceFrame()

template<class DevicePolicy >
bool KisKraSaveVisitor::savePaintDeviceFrame ( KisPaintDeviceSP device,
QString location,
DevicePolicy policy )
private

Definition at line 374 of file kis_kra_save_visitor.cpp.

375{
376 if (m_store->open(location)) {
377 if (!policy.write(device, *m_writer)) {
378 device->disconnect();
379 m_store->close();
380 return false;
381 }
382
383 m_store->close();
384 }
385 if (m_store->open(location + ".defaultpixel")) {
386 m_store->write((char*)policy.defaultPixel(device).data(), device->colorSpace()->pixelSize());
387 m_store->close();
388 }
389
390 return true;
391}
virtual quint32 pixelSize() const =0

References KoStore::close(), KisPaintDevice::colorSpace(), m_store, m_writer, KoStore::open(), KoColorSpace::pixelSize(), and KoStore::write().

◆ saveSelection()

bool KisKraSaveVisitor::saveSelection ( KisNode * node)
private

Definition at line 434 of file kis_kra_save_visitor.cpp.

435{
436 KisSelectionSP selection;
437 if (node->inherits("KisMask")) {
438 selection = static_cast<KisMask*>(node)->selection();
439 } else if (node->inherits("KisAdjustmentLayer")) {
440 selection = static_cast<KisAdjustmentLayer*>(node)->internalSelection();
441 } else if (node->inherits("KisGeneratorLayer")) {
442 selection = static_cast<KisGeneratorLayer*>(node)->internalSelection();
443 } else {
444 return false;
445 }
446
447 bool retval = true;
448
449 if (node->isAnimated() || selection->hasNonEmptyPixelSelection()) {
450 KisPaintDeviceSP dev = selection->pixelSelection();
452 m_errorMessages << i18n("Failed to save the pixel selection data for layer %1.", node->name());
453 retval = false;
454 }
455 }
456
457 if (selection->hasNonEmptyShapeSelection()) {
460 if (retval) {
461 KisShapeSelection* shapeSelection = dynamic_cast<KisShapeSelection*>(selection->shapeSelection());
462 if (!shapeSelection) {
463 retval = false;
464 }
465
466 if (retval && !shapeSelection->saveSelection(m_store, node->image()->bounds())) {
467 m_errorMessages << i18n("Failed to save the vector selection data for layer %1.", node->name());
468 retval = false;
469 }
470 }
472 }
473 return retval;
474}
QRect bounds() const override
bool savePaintDevice(KisPaintDeviceSP device, QString location)
bool saveSelection(KoStore *store, const QRect &imageRect) const
void pushDirectory()
Definition KoStore.cpp:294
void popDirectory()
Definition KoStore.cpp:300
virtual bool enterDirectory(const QString &directory)
Definition KoStore.cpp:253
const QString DOT_SHAPE_SELECTION
const QString DOT_PIXEL_SELECTION
KisImageWSP image
bool isAnimated() const
bool hasNonEmptyPixelSelection() const
KisPixelSelectionSP pixelSelection
bool hasNonEmptyShapeSelection() const
KisSelectionComponent * shapeSelection

References KisImage::bounds(), KRA::DOT_PIXEL_SELECTION, KRA::DOT_SHAPE_SELECTION, KoStore::enterDirectory(), getLocation(), KisSelection::hasNonEmptyPixelSelection(), KisSelection::hasNonEmptyShapeSelection(), KisBaseNode::image, KisBaseNode::isAnimated(), m_errorMessages, m_store, KisBaseNode::name(), KisSelection::pixelSelection, KoStore::popDirectory(), KoStore::pushDirectory(), savePaintDevice(), KisShapeSelection::saveSelection(), and KisSelection::shapeSelection.

◆ setExternalUri()

void KisKraSaveVisitor::setExternalUri ( const QString & uri)

Definition at line 75 of file kis_kra_save_visitor.cpp.

76{
77 m_external = true;
78 m_uri = uri;
79}

References m_external, and m_uri.

◆ visit() [1/24]

bool KisKraSaveVisitor::visit ( KisAdjustmentLayer * layer)
overridevirtual

Implements KisNodeVisitor.

Definition at line 147 of file kis_kra_save_visitor.cpp.

148{
149 if (!layer->filter()) {
150 m_errorMessages << i18n("Failed to save the filter layer %1: it has no filter.", layer->name());
151 return false;
152 }
153 if (!saveSelection(layer)) {
154 m_errorMessages << i18n("Failed to save the selection for filter layer %1.", layer->name());
155 return false;
156 }
157 if (!saveFilterConfiguration(layer)) {
158 m_errorMessages << i18n("Failed to save the filter configuration for filter layer %1.", layer->name());
159 return false;
160 }
161 if (!saveMetaData(layer)) {
162 m_errorMessages << i18n("Failed to save the metadata for layer %1.", layer->name());
163 return false;
164 }
165 return visitAllInverse(layer);
166}
bool saveMetaData(KisNode *node)
bool saveFilterConfiguration(KisNode *node)
bool saveSelection(KisNode *node)
bool visitAllInverse(KisNode *node, bool breakOnFail=false)

References KisNodeFilterInterface::filter(), m_errorMessages, KisBaseNode::name(), saveFilterConfiguration(), saveMetaData(), saveSelection(), and KisNodeVisitor::visitAllInverse().

◆ visit() [2/24]

virtual bool KisNodeVisitor::visit ( KisAdjustmentLayer * layer)
virtual

Implements KisNodeVisitor.

◆ visit() [3/24]

bool KisKraSaveVisitor::visit ( KisCloneLayer * layer)
overridevirtual

Implements KisNodeVisitor.

Definition at line 185 of file kis_kra_save_visitor.cpp.

186{
187 // Clone layers do not have a profile
188 if (!saveMetaData(layer)) {
189 m_errorMessages << i18n("Failed to save the metadata for layer %1.", layer->name());
190 return false;
191 }
192 return visitAllInverse(layer);
193}

References m_errorMessages, KisBaseNode::name(), saveMetaData(), and KisNodeVisitor::visitAllInverse().

◆ visit() [4/24]

virtual bool KisNodeVisitor::visit ( KisCloneLayer * layer)
virtual

Implements KisNodeVisitor.

◆ visit() [5/24]

bool KisKraSaveVisitor::visit ( KisColorizeMask * mask)
overridevirtual

Implements KisNodeVisitor.

Definition at line 263 of file kis_kra_save_visitor.cpp.

264{
266 QString location = getLocation(mask, DOT_COLORIZE_MASK);
267 bool result = m_store->enterDirectory(location);
268
269 if (!result) {
270 m_errorMessages << i18n("Failed to open %1.", location);
271 return false;
272 }
273
274 if (!m_store->open("content.xml"))
275 return false;
276
277 KoStoreDevice storeDev(m_store);
278
279 QDomDocument doc("doc");
280 QDomElement root = doc.createElement("colorize");
281 doc.appendChild(root);
283
284 QTextStream stream(&storeDev);
286 stream << doc;
287
288 if (!m_store->close())
289 return false;
290
291 int i = 0;
292 Q_FOREACH (const KisLazyFillTools::KeyStroke &stroke, mask->fetchKeyStrokesDirect()) {
293 const QString fileName = QString("%1_%2").arg(COLORIZE_KEYSTROKE).arg(i++);
294 savePaintDevice(stroke.dev, fileName);
295 }
296
298 saveIccProfile(mask, mask->colorSpace()->profile());
299
301
302 return true;
303}
const KoColorSpace * colorSpace() const override
KisPaintDeviceSP coloringProjection() const
QList< KisLazyFillTools::KeyStroke > fetchKeyStrokesDirect() const
const QString DOT_COLORIZE_MASK
const QString COLORIZE_KEYSTROKE
const QString COLORIZE_COLORING_DEVICE
const QString COLORIZE_KEYSTROKES_SECTION
void saveValue(QDomElement *parent, const QString &tag, const QSize &size)
void setUtf8OnStream(QTextStream &stream)

References KoStore::close(), KisColorizeMask::coloringProjection(), KRA::COLORIZE_COLORING_DEVICE, KRA::COLORIZE_KEYSTROKE, KRA::COLORIZE_KEYSTROKES_SECTION, KisColorizeMask::colorSpace(), KisLazyFillTools::KeyStroke::dev, KRA::DOT_COLORIZE_MASK, KoStore::enterDirectory(), KisColorizeMask::fetchKeyStrokesDirect(), getLocation(), m_errorMessages, m_store, KoStore::open(), KoStore::popDirectory(), KoColorSpace::profile(), KoStore::pushDirectory(), saveIccProfile(), savePaintDevice(), KisDomUtils::saveValue(), and KisPortingUtils::setUtf8OnStream().

◆ visit() [6/24]

virtual bool KisNodeVisitor::visit ( KisColorizeMask * mask)
virtual

Implements KisNodeVisitor.

◆ visit() [7/24]

bool KisKraSaveVisitor::visit ( KisExternalLayer * layer)
overridevirtual

Implements KisNodeVisitor.

Definition at line 81 of file kis_kra_save_visitor.cpp.

82{
83 bool result = false;
84 if (auto* referencesLayer = dynamic_cast<KisReferenceImagesLayer*>(layer)) {
85 result = true;
86 QList <KoShape *> shapes = referencesLayer->shapes();
87 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex);
88 Q_FOREACH(KoShape *shape, shapes) {
89 auto *reference = dynamic_cast<KisReferenceImage*>(shape);
90 KIS_ASSERT_RECOVER_RETURN_VALUE(reference, false);
91 bool saved = reference->saveImage(m_store);
92 if (!saved) {
93 m_errorMessages << i18n("Failed to save reference image %1.", reference->internalFile());
94 result = false;
95 }
96 }
97 }
98 else if (KisShapeLayer *shapeLayer = dynamic_cast<KisShapeLayer*>(layer)) {
99 if (!saveMetaData(layer)) {
100 m_errorMessages << i18n("Failed to save the metadata for layer %1.", layer->name());
101 return false;
102 }
104 QString location = getLocation(layer, DOT_SHAPE_LAYER);
105 result = m_store->enterDirectory(location);
106 if (!result) {
107 m_errorMessages << i18n("Failed to open %1.", location);
108 }
109 else {
110 result = shapeLayer->saveLayer(m_store);
112 }
113 }
114 else if (KisFileLayer *fileLayer = dynamic_cast<KisFileLayer*>(layer)) {
115 Q_UNUSED(fileLayer); // We don't save data for file layers, but we still want to save the masks.
116 result = true;
117 }
118 return result && visitAllInverse(layer);
119}
The KisFileLayer class loads a particular file as a layer into the layer stack.
The KisReferenceImage class represents a single reference image.
static bool compareShapeZIndex(KoShape *s1, KoShape *s2)
Definition KoShape.cpp:434
#define KIS_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:85
const QString DOT_SHAPE_LAYER

References KoShape::compareShapeZIndex(), KRA::DOT_SHAPE_LAYER, KoStore::enterDirectory(), getLocation(), KIS_ASSERT_RECOVER_RETURN_VALUE, m_errorMessages, m_store, KisBaseNode::name(), KoStore::popDirectory(), KoStore::pushDirectory(), saveMetaData(), and KisNodeVisitor::visitAllInverse().

◆ visit() [8/24]

virtual bool KisNodeVisitor::visit ( KisExternalLayer * layer)
virtual

Implements KisNodeVisitor.

◆ visit() [9/24]

bool KisKraSaveVisitor::visit ( KisFilterMask * mask)
overridevirtual

Implements KisNodeVisitor.

Definition at line 195 of file kis_kra_save_visitor.cpp.

196{
197 if (!mask->filter()) {
198 m_errorMessages << i18n("Failed to save filter mask %1. It has no filter.", mask->name());
199 return false;
200 }
201 if (!saveSelection(mask)) {
202 m_errorMessages << i18n("Failed to save the selection for filter mask %1.", mask->name());
203 return false;
204 }
205 if (!saveFilterConfiguration(mask)) {
206 m_errorMessages << i18n("Failed to save the filter configuration for filter mask %1.", mask->name());
207 return false;
208 }
209 return true;
210}

References KisNodeFilterInterface::filter(), m_errorMessages, KisBaseNode::name(), saveFilterConfiguration(), and saveSelection().

◆ visit() [10/24]

virtual bool KisNodeVisitor::visit ( KisFilterMask * mask)
virtual

Implements KisNodeVisitor.

◆ visit() [11/24]

bool KisKraSaveVisitor::visit ( KisGeneratorLayer * layer)
overridevirtual

Implements KisNodeVisitor.

Definition at line 168 of file kis_kra_save_visitor.cpp.

169{
170 if (!saveSelection(layer)) {
171 m_errorMessages << i18n("Failed to save the selection for layer %1.", layer->name());
172 return false;
173 }
174 if (!saveFilterConfiguration(layer)) {
175 m_errorMessages << i18n("Failed to save the generator configuration for layer %1.", layer->name());
176 return false;
177 }
178 if (!saveMetaData(layer)) {
179 m_errorMessages << i18n("Failed to save the metadata for layer %1.", layer->name());
180 return false;
181 }
182 return visitAllInverse(layer);
183}

References m_errorMessages, KisBaseNode::name(), saveFilterConfiguration(), saveMetaData(), saveSelection(), and KisNodeVisitor::visitAllInverse().

◆ visit() [12/24]

virtual bool KisNodeVisitor::visit ( KisGeneratorLayer * layer)
virtual

Implements KisNodeVisitor.

◆ visit() [13/24]

bool KisKraSaveVisitor::visit ( KisGroupLayer * layer)
overridevirtual

Implements KisNodeVisitor.

Definition at line 138 of file kis_kra_save_visitor.cpp.

139{
140 if (!saveMetaData(layer)) {
141 m_errorMessages << i18n("Failed to save the metadata for layer %1.", layer->name());
142 return false;
143 }
144 return visitAllInverse(layer);
145}

References m_errorMessages, KisBaseNode::name(), saveMetaData(), and KisNodeVisitor::visitAllInverse().

◆ visit() [14/24]

virtual bool KisNodeVisitor::visit ( KisGroupLayer * layer)
virtual

Implements KisNodeVisitor.

◆ visit() [15/24]

bool KisKraSaveVisitor::visit ( KisNode * )
inlineoverridevirtual

Implements KisNodeVisitor.

Definition at line 31 of file kis_kra_save_visitor.h.

31 {
32 return true;
33 }

◆ visit() [16/24]

virtual bool KisNodeVisitor::visit ( KisNode * node)
virtual

Implements KisNodeVisitor.

◆ visit() [17/24]

bool KisKraSaveVisitor::visit ( KisPaintLayer * layer)
overridevirtual

Implements KisNodeVisitor.

Definition at line 121 of file kis_kra_save_visitor.cpp.

122{
123 if (!savePaintDevice(layer->paintDevice(), getLocation(layer))) {
124 m_errorMessages << i18n("Failed to save the pixel data for layer %1.", layer->name());
125 return false;
126 }
127 if (!saveAnnotations(layer)) {
128 m_errorMessages << i18n("Failed to save the annotations for layer %1.", layer->name());
129 return false;
130 }
131 if (!saveMetaData(layer)) {
132 m_errorMessages << i18n("Failed to save the metadata for layer %1.", layer->name());
133 return false;
134 }
135 return visitAllInverse(layer);
136}
bool saveAnnotations(KisLayer *layer)
KisPaintDeviceSP paintDevice

References getLocation(), m_errorMessages, KisBaseNode::name(), KisPaintLayer::paintDevice, saveAnnotations(), saveMetaData(), savePaintDevice(), and KisNodeVisitor::visitAllInverse().

◆ visit() [18/24]

virtual bool KisNodeVisitor::visit ( KisPaintLayer * layer)
virtual

Implements KisNodeVisitor.

◆ visit() [19/24]

bool KisKraSaveVisitor::visit ( KisSelectionMask * mask)
overridevirtual

Implements KisNodeVisitor.

Definition at line 254 of file kis_kra_save_visitor.cpp.

255{
256 if (!saveSelection(mask)) {
257 m_errorMessages << i18n("Failed to save the selection for local selection %1.", mask->name());
258 return false;
259 }
260 return true;
261}

References m_errorMessages, KisBaseNode::name(), and saveSelection().

◆ visit() [20/24]

virtual bool KisNodeVisitor::visit ( KisSelectionMask * mask)
virtual

Implements KisNodeVisitor.

◆ visit() [21/24]

bool KisKraSaveVisitor::visit ( KisTransformMask * mask)
overridevirtual

Implements KisNodeVisitor.

Definition at line 212 of file kis_kra_save_visitor.cpp.

213{
214 QDomDocument doc("transform_params");
215
216 QDomElement root = doc.createElement("transform_params");
217
218 QDomElement main = doc.createElement("main");
219 main.setAttribute("id", mask->transformParams()->id());
220
221 QDomElement data = doc.createElement("data");
222 mask->transformParams()->toXML(&data);
223
224 doc.appendChild(root);
225 root.appendChild(main);
226 root.appendChild(data);
227
228 QString location = getLocation(mask, DOT_TRANSFORMCONFIG);
229 if (m_store->open(location)) {
230 QByteArray a = doc.toByteArray();
231 bool retval = m_store->write(a) == a.size();
232
233 if (!retval) {
234 warnFile << "Could not write transform mask configuration";
235 }
236 if (!m_store->close()) {
237 warnFile << "Could not close store after writing transform mask configuration";
238 retval = false;
239 }
240 return retval;
241 }
242 return false;
243}
#define warnFile
Definition kis_debug.h:95
int main(int argc, char **argv)
Definition main.cpp:26
const QString DOT_TRANSFORMCONFIG
KisTransformMaskParamsInterfaceSP transformParams() const

References KoStore::close(), KRA::DOT_TRANSFORMCONFIG, getLocation(), m_store, main(), KoStore::open(), KisTransformMask::transformParams(), warnFile, and KoStore::write().

◆ visit() [22/24]

virtual bool KisNodeVisitor::visit ( KisTransformMask * mask)
virtual

Implements KisNodeVisitor.

◆ visit() [23/24]

bool KisKraSaveVisitor::visit ( KisTransparencyMask * mask)
overridevirtual

Implements KisNodeVisitor.

Definition at line 245 of file kis_kra_save_visitor.cpp.

246{
247 if (!saveSelection(mask)) {
248 m_errorMessages << i18n("Failed to save the selection for transparency mask %1.", mask->name());
249 return false;
250 }
251 return true;
252}

References m_errorMessages, KisBaseNode::name(), and saveSelection().

◆ visit() [24/24]

virtual bool KisNodeVisitor::visit ( KisTransparencyMask * mask)
virtual

Implements KisNodeVisitor.

Member Data Documentation

◆ m_errorMessages

QStringList KisKraSaveVisitor::m_errorMessages
private

Definition at line 83 of file kis_kra_save_visitor.h.

◆ m_external

bool KisKraSaveVisitor::m_external
private

Definition at line 78 of file kis_kra_save_visitor.h.

◆ m_name

QString KisKraSaveVisitor::m_name
private

Definition at line 80 of file kis_kra_save_visitor.h.

◆ m_nodeFileNames

QMap<const KisNode*, QString> KisKraSaveVisitor::m_nodeFileNames
private

Definition at line 81 of file kis_kra_save_visitor.h.

◆ m_store

KoStore* KisKraSaveVisitor::m_store
private

Definition at line 77 of file kis_kra_save_visitor.h.

◆ m_uri

QString KisKraSaveVisitor::m_uri
private

Definition at line 79 of file kis_kra_save_visitor.h.

◆ m_writer

KisPaintDeviceWriter* KisKraSaveVisitor::m_writer
private

Definition at line 82 of file kis_kra_save_visitor.h.


The documentation for this class was generated from the following files: