Skip to content
Permalink
Browse files

[layouts] Tweak format of multiple metadata keyword argument exports

  • Loading branch information
nyalldawson committed Jun 19, 2018
1 parent 5b47f94 commit 3ea8a4183443fd7283b12a4ac035bb5bb9028a16
Showing with 8 additions and 10 deletions.
  1. +4 −6 src/core/layout/qgslayoutexporter.cpp
  2. +4 −4 tests/src/python/test_qgslayoutexporter.py
@@ -1389,10 +1389,9 @@ bool QgsLayoutExporter::georeferenceOutputPrivate( const QString &file, QgsLayou
QStringList allKeywords;
for ( auto it = keywords.constBegin(); it != keywords.constEnd(); ++it )
{
allKeywords.append( it.value() );
allKeywords.append( QStringLiteral( "%1: %2" ).arg( it.key(), it.value().join( ',' ) ) );
}
allKeywords = allKeywords.toSet().toList();
const QString keywordString = allKeywords.join( ',' );
const QString keywordString = allKeywords.join( ';' );
GDALSetMetadataItem( outputDS.get(), "KEYWORDS", keywordString.toLocal8Bit().constData(), nullptr );
}

@@ -1568,10 +1567,9 @@ bool QgsLayoutExporter::saveImage( const QImage &image, const QString &imageFile
QStringList allKeywords;
for ( auto it = keywords.constBegin(); it != keywords.constEnd(); ++it )
{
allKeywords.append( it.value() );
allKeywords.append( QStringLiteral( "%1: %2" ).arg( it.key(), it.value().join( ',' ) ) );
}
allKeywords = allKeywords.toSet().toList();
const QString keywordString = allKeywords.join( ',' );
const QString keywordString = allKeywords.join( ';' );
w.setText( "Keywords", keywordString );
}
return w.write( image );
@@ -301,7 +301,7 @@ def testExportToImage(self):
md.setCreationDateTime(QDateTime(QDate(2011, 5, 3), QTime(9, 4, 5), QTimeZone(36000)))
md.setIdentifier('proj identifier')
md.setAbstract('proj abstract')
md.setKeywords({'kw': ['kw1', 'kw2']})
md.setKeywords({'kw': ['kw1', 'kw2'], 'KWx': ['kw3', 'kw4']})
QgsProject.instance().setMetadata(md)
l = QgsLayout(QgsProject.instance())
l.initializeDefaults()
@@ -350,7 +350,7 @@ def testExportToImage(self):
metadata = d.GetMetadata()
self.assertEqual(metadata['Author'], 'proj author')
self.assertEqual(metadata['Created'], '2011-05-03T09:04:05+10:00')
self.assertIn(metadata['Keywords'], ('kw1,kw2', 'kw2,kw1'))
self.assertEqual(metadata['Keywords'], 'KWx: kw3,kw4;kw: kw1,kw2')
self.assertEqual(metadata['Subject'], 'proj abstract')
self.assertEqual(metadata['Title'], 'proj title')

@@ -392,7 +392,7 @@ def testExportToPdf(self):
md.setCreationDateTime(QDateTime(QDate(2011, 5, 3), QTime(9, 4, 5), QTimeZone(36000)))
md.setIdentifier('proj identifier')
md.setAbstract('proj abstract')
md.setKeywords({'kw': ['kw1', 'kw2']})
md.setKeywords({'kw': ['kw1', 'kw2'], 'KWx': ['kw3', 'kw4']})
QgsProject.instance().setMetadata(md)

l = QgsLayout(QgsProject.instance())
@@ -450,7 +450,7 @@ def testExportToPdf(self):
metadata = d.GetMetadata()
self.assertEqual(metadata['AUTHOR'], 'proj author')
self.assertEqual(metadata['CREATION_DATE'], "D:20110503090405+10'0'")
self.assertIn(metadata['KEYWORDS'], ('kw1,kw2', 'kw2,kw1'))
self.assertEqual(metadata['KEYWORDS'], 'KWx: kw3,kw4;kw: kw1,kw2')
self.assertEqual(metadata['SUBJECT'], 'proj abstract')
self.assertEqual(metadata['TITLE'], 'proj title')

0 comments on commit 3ea8a41

Please sign in to comment.
You can’t perform that action at this time.