Commit 3129c99b authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add a way to get error messages from the kra saver/loader

parent 7d63cd03
......@@ -257,6 +257,11 @@ bool KisKraLoadVisitor::visit(KisSelectionMask *mask)
return true;
}
QStringList KisKraLoadVisitor::errorMessages() const
{
return m_errorMessages;
}
bool KisKraLoadVisitor::loadPaintDevice(KisPaintDeviceSP device, const QString& location)
{
// Layer data
......
......@@ -21,6 +21,7 @@
#define KIS_KRA_LOAD_VISITOR_H_
#include <QRect>
#include <QStringList>
// kritaimage
#include "kis_types.h"
......@@ -56,6 +57,8 @@ public:
bool visit(KisTransparencyMask *mask);
bool visit(KisSelectionMask *mask);
QStringList errorMessages() const;
private:
bool loadPaintDevice(KisPaintDeviceSP device, const QString& location);
......@@ -74,6 +77,7 @@ private:
QMap<KisNode *, QString> m_layerFilenames;
QString m_name;
int m_syntaxVersion;
QStringList m_errorMessages;
};
#endif // KIS_KRA_LOAD_VISITOR_H_
......
......@@ -19,18 +19,13 @@
#include "kra/kis_kra_loader.h"
#include "kis_kra_tags.h"
#include "kis_kra_utils.h"
#include "kis_kra_load_visitor.h"
#include <QStringList>
#include <KoStore.h>
#include <KoColorSpaceRegistry.h>
#include <KoColorProfile.h>
#include <KoDocumentInfo.h>
#include "kis_doc2.h"
#include "kis_config.h"
#include <filter/kis_filter.h>
#include <filter/kis_filter_registry.h>
#include <generator/kis_generator.h>
......@@ -56,6 +51,13 @@
#include <kis_layer_composition.h>
#include <kis_file_layer.h>
#include "kis_doc2.h"
#include "kis_config.h"
#include "kis_kra_tags.h"
#include "kis_kra_utils.h"
#include "kis_kra_load_visitor.h"
/*
Color model id comparison through the ages:
......@@ -105,6 +107,7 @@ public:
vKisNodeSP selectedNodes; // the nodes that were active when saving the document.
QMap<QString, QString> assistantsFilenames;
QList<KisPaintingAssistant*> assistants;
QStringList errorMessages;
};
void convertColorSpaceNames(QString &colorspacename, QString &profileProductName) {
......@@ -321,6 +324,11 @@ QList<KisPaintingAssistant *> KisKraLoader::assistants() const
return m_d->assistants;
}
QStringList KisKraLoader::errorMessages() const
{
return m_d->errorMessages;
}
void KisKraLoader::loadAssistants(KoStore *store, const QString &uri, bool external)
{
QString file_path;
......@@ -404,8 +412,11 @@ KisNodeSP KisKraLoader::loadNode(const KoXmlElement& element, KisImageWSP image,
colorSpace = KoColorSpaceRegistry::instance()->colorSpace(colorspaceModel, colorspaceDepth, "");
dbgFile << "found colorspace" << colorSpace;
if (!colorSpace) {
warnFile << "Could not create a colorspace for" << colorspacename;
return 0;
}
}
KIS_ASSERT_RECOVER_RETURN_VALUE(colorSpace, 0);
bool visible = element.attribute(VISIBLE, "1") == "0" ? false : true;
bool locked = element.attribute(LOCKED, "0") == "0" ? false : true;
......
......@@ -20,6 +20,7 @@
#define KIS_KRA_LOADER_H
class QString;
class QStringList;
#include "KoXmlReaderForward.h"
class KoStore;
......@@ -58,6 +59,9 @@ public:
// it's neater to follow the same design as with selectedNodes, so let's have a getter here
QList<KisPaintingAssistant*> assistants() const;
/// if empty, loading didn't fail...
QStringList errorMessages() const;
private:
// this needs to be private, for neatness sake
......
......@@ -157,6 +157,11 @@ bool KisKraSaveVisitor::visit(KisSelectionMask *mask)
return true;
}
QStringList KisKraSaveVisitor::errorMessages() const
{
return m_errorMessages;
}
bool KisKraSaveVisitor::savePaintDevice(KisPaintDeviceSP device,
QString location)
......
......@@ -21,10 +21,13 @@
#define KIS_KRA_SAVE_VISITOR_H_
#include <QRect>
#include <QStringList>
#include "kis_types.h"
#include "kis_node_visitor.h"
#include "kis_image.h"
class KisPaintDeviceWriter;
class KoStore;
......@@ -60,6 +63,9 @@ public:
bool visit(KisSelectionMask *mask);
/// @return a list with everything that went wrong while saving
QStringList errorMessages() const;
private:
bool savePaintDevice(KisPaintDeviceSP device, QString location);
......@@ -78,7 +84,7 @@ private:
QString m_name;
QMap<const KisNode*, QString> m_nodeFileNames;
KisPaintDeviceWriter *m_writer;
QStringList m_errorMessages;
};
#endif // KIS_KRA_SAVE_VISITOR_H_
......
......@@ -25,7 +25,7 @@
#include <QDomDocument>
#include <QDomElement>
#include <QString>
#include <QMessageBox>
#include <QStringList>
#include <KoDocumentInfo.h>
#include <KoColorSpace.h>
......@@ -53,6 +53,7 @@ public:
KisDoc2* doc;
QMap<const KisNode*, QString> nodeFileNames;
QString imageName;
QStringList errorMessages;
};
KisKraSaver::KisKraSaver(KisDoc2* document)
......@@ -164,6 +165,11 @@ bool KisKraSaver::saveBinaryData(KoStore* store, KisImageWSP image, const QStrin
return true;
}
QStringList KisKraSaver::errorMessages() const
{
return m_d->errorMessages;
}
void KisKraSaver::saveCompositions(QDomDocument& doc, QDomElement& element, KisImageWSP image)
{
if (!image->compositions().isEmpty()) {
......
......@@ -26,6 +26,7 @@ class QDomElement;
class QDomDocument;
class KoStore;
class QString;
class QStringList;
class KisKraSaver
{
......@@ -39,6 +40,9 @@ public:
bool saveBinaryData(KoStore* store, KisImageWSP image, const QString & uri, bool external);
/// @return a list with everthing that went wrong while saving
QStringList errorMessages() const;
private:
void saveCompositions(QDomDocument& doc, QDomElement& element, KisImageWSP image);
bool saveAssistants(KoStore *store,QString uri, bool external);
......
......@@ -61,6 +61,11 @@ void KisSaveXmlVisitor::setSelectedNodes(vKisNodeSP selectedNodes)
m_selectedNodes = selectedNodes;
}
QStringList KisSaveXmlVisitor::errorMessages() const
{
return m_errorMessages;
}
bool KisSaveXmlVisitor::visit(KisExternalLayer * layer)
{
if (layer->inherits("KisShapeLayer")) {
......
......@@ -21,6 +21,7 @@
#include <QDomDocument>
#include <QDomElement>
#include <QStringList>
#include "kis_node_visitor.h"
#include "kis_types.h"
......@@ -35,6 +36,8 @@ public:
using KisNodeVisitor::visit;
QStringList errorMessages() const;
public:
bool visit(KisNode*) {
......@@ -69,6 +72,7 @@ private:
quint32 &m_count;
QString m_url;
bool m_root;
QStringList m_errorMessages;
};
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment