Commit 8da20a5e authored by Sven Langkamp's avatar Sven Langkamp

Pass also the real filename to the filters, Fixes QML export which uses it for it's image folder

parent 9e661852
......@@ -676,7 +676,7 @@ bool KisDocument::saveFile(const QString &filePath, KisPropertiesConfigurationSP
Q_ASSERT(!tempororaryFileName.isEmpty());
//qDebug() << "saving to tempory file" << tempororaryFileName;
status = d->importExportManager->exportDocument(tempororaryFileName, outputMimeType, !d->isExporting , exportConfiguration);
status = d->importExportManager->exportDocument(tempororaryFileName, filePath, outputMimeType, !d->isExporting , exportConfiguration);
ret = (status == KisImportExportFilter::OK);
suppressErrorDialog = (isAutosaving() || status == KisImportExportFilter::UserCancelled || status == KisImportExportFilter::BadConversionGraph);
......
......@@ -37,6 +37,7 @@ public:
QPointer<KoUpdater> updater;
QByteArray mime;
QString filename;
QString realFilename;
bool batchmode;
QMap<QString, KisExportCheckBase*> capabilities;
......@@ -69,12 +70,16 @@ KisImportExportFilter::~KisImportExportFilter()
delete d;
}
QString KisImportExportFilter::filename() const
{
return d->filename;
}
QString KisImportExportFilter::realFilename() const
{
return d->realFilename;
}
bool KisImportExportFilter::batchMode() const
{
return d->batchmode;
......@@ -91,6 +96,12 @@ void KisImportExportFilter::setFilename(const QString &filename)
d->filename = filename;
}
void KisImportExportFilter::setRealFilename(const QString &filename)
{
d->realFilename = filename;
}
void KisImportExportFilter::setMimeType(const QString &mime)
{
d->mime = mime.toLatin1();
......
......@@ -95,6 +95,7 @@ public:
void setBatchMode(bool batchmode);
void setFilename(const QString &filename);
void setRealFilename(const QString &filename);
void setMimeType(const QString &mime);
void setUpdater(QPointer<KoUpdater> updater);
......@@ -153,6 +154,7 @@ protected:
KisImportExportFilter(QObject *parent = 0);
QString filename() const;
QString realFilename() const;
bool batchMode() const;
QByteArray mimeType() const;
......
......@@ -81,12 +81,12 @@ KisImportExportManager::~KisImportExportManager()
KisImportExportFilter::ConversionStatus KisImportExportManager::importDocument(const QString& location, const QString& mimeType)
{
return convert(Import, location, mimeType, false, 0);
return convert(Import, location, location, mimeType, false, 0);
}
KisImportExportFilter::ConversionStatus KisImportExportManager::exportDocument(const QString& location, QByteArray& mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfiguration)
KisImportExportFilter::ConversionStatus KisImportExportManager::exportDocument(const QString& location, const QString& realLocation, QByteArray& mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfiguration)
{
return convert(Export, location, mimeType, showWarnings, exportConfiguration);
return convert(Export, location, realLocation, mimeType, showWarnings, exportConfiguration);
}
// The static method to figure out to which parts of the
......@@ -190,7 +190,7 @@ void KisImportExportManager::setProgresUpdater(KoProgressUpdater *updater)
d->progressUpdater = updater;
}
KisImportExportFilter::ConversionStatus KisImportExportManager::convert(KisImportExportManager::Direction direction, const QString &location, const QString &mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfiguration)
KisImportExportFilter::ConversionStatus KisImportExportManager::convert(KisImportExportManager::Direction direction, const QString &location, const QString& realLocation, const QString &mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfiguration)
{
QString typeName = mimeType;
......@@ -204,6 +204,7 @@ KisImportExportFilter::ConversionStatus KisImportExportManager::convert(KisImpor
}
filter->setFilename(location);
filter->setRealFilename(realLocation);
filter->setBatchMode(batchMode());
filter->setMimeType(typeName);
......
......@@ -83,7 +83,7 @@ public:
* and when the method returns @p mimeType contains this mimetype.
* Oh, well, export is a C++ keyword ;)
*/
KisImportExportFilter::ConversionStatus exportDocument(const QString &location, QByteArray &mimeType, bool showWarnings = true, KisPropertiesConfigurationSP exportConfiguration = 0);
KisImportExportFilter::ConversionStatus exportDocument(const QString &location, const QString& realLocation, QByteArray &mimeType, bool showWarnings = true, KisPropertiesConfigurationSP exportConfiguration = 0);
///@name Static API
//@{
......@@ -125,7 +125,7 @@ private Q_SLOTS:
private:
KisImportExportFilter::ConversionStatus convert(Direction direction, const QString &location, const QString &mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfiguration);
KisImportExportFilter::ConversionStatus convert(Direction direction, const QString &location, const QString& realLocation, const QString &mimeType, bool showWarnings, KisPropertiesConfigurationSP exportConfiguration);
// Private API
KisImportExportManager(const KisImportExportManager& rhs);
......
......@@ -62,7 +62,7 @@ void KisExrTest::testRoundTrip()
QString typeName = KisMimeDatabase::mimeTypeForFile(savedFileName);
QByteArray mimeType(typeName.toLatin1());
status = manager.exportDocument(savedFileName, mimeType);
status = manager.exportDocument(savedFileName, savedFileName, mimeType);
QVERIFY(QFileInfo(savedFileName).exists());
{
......
......@@ -35,7 +35,7 @@ QMLConverter::~QMLConverter()
{
}
KisImageBuilder_Result QMLConverter::buildFile(const QString &filename, QIODevice *io, KisImageSP image)
KisImageBuilder_Result QMLConverter::buildFile(const QString &filename, const QString &realFilename, QIODevice *io, KisImageSP image)
{
QTextStream out(io);
out.setCodec("UTF-8");
......@@ -46,9 +46,10 @@ KisImageBuilder_Result QMLConverter::buildFile(const QString &filename, QIODevic
out << "\n";
QFileInfo info(filename);
QFileInfo infoRealFile(realFilename);
KisNodeSP node = image->rootLayer()->firstChild();
QString imageDir = info.baseName() + "_images";
QString imagePath = info.absolutePath() + '/' + imageDir;
QString imageDir = infoRealFile.baseName() + "_images";
QString imagePath = infoRealFile.absolutePath() + '/' + imageDir;
if (node) {
QDir dir;
dir.mkpath(imagePath);
......
......@@ -34,7 +34,7 @@ public:
QMLConverter();
virtual ~QMLConverter();
public:
KisImageBuilder_Result buildFile(const QString &filename, QIODevice *io, KisImageSP image);
KisImageBuilder_Result buildFile(const QString &filename, const QString &realFilename, QIODevice *io, KisImageSP image);
private:
void writeString(QTextStream& out, int spacing, const QString& setting, const QString& value);
......
......@@ -47,7 +47,7 @@ KisImportExportFilter::ConversionStatus QMLExport::convert(KisDocument *document
Q_CHECK_PTR(image);
QMLConverter converter;
KisImageBuilder_Result result = converter.buildFile(filename(), io, image);
KisImageBuilder_Result result = converter.buildFile(filename(), realFilename(), io, image);
if (result == KisImageBuilder_RESULT_OK) {
dbgFile << "success !";
return KisImportExportFilter::OK;
......
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