Skip to content
Permalink
Browse files
Fix for ticket #291 (same as image not giving the choice of image
 formats). The problem seems to with the list of formats that qt is
 supposed to provide, but doesn't. Hard-wired to provide jpg and png
 for the moment.


git-svn-id: http://svn.osgeo.org/qgis/trunk@5868 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Sep 22, 2006
1 parent 0ce82d2 commit d12fb0e
Showing 1 changed file with 17 additions and 2 deletions.
@@ -2996,9 +2996,18 @@ void QgisApp::saveMapAsImage()
// get a list of supported output image types
int myCounterInt=0;
QString myFilters;
for ( ; myCounterInt < QPictureIO::outputFormats().count(); myCounterInt++ )
QList<QByteArray> formats = QPictureIO::outputFormats();
// Workaround for a problem with Qt4 - calls to outputFormats tend
// to return nothing :(
if (formats.count() == 0)
{
QString myFormat=QString(QPictureIO::outputFormats().at( myCounterInt ));
formats.append("png");
formats.append("jpg");
}

for ( ; myCounterInt < formats.count(); myCounterInt++ )
{
QString myFormat=QString(formats.at( myCounterInt ));
QString myFilter = createFileFilter_(myFormat + " format", "*."+myFormat);
myFilters += myFilter;
myFilterMap[myFilter] = myFormat;
@@ -3046,6 +3055,12 @@ void QgisApp::saveMapAsImage()
std::cout << "Image type to be passed to mapcanvas: " << (myFilterMap[myFilterString]).toLocal8Bit().data() << std::endl;
#endif

// Add the file type suffix to the filename if required
if (!myOutputFileNameQString.endsWith(myFilterMap[myFilterString]))
{
myOutputFileNameQString += "." + myFilterMap[myFilterString];
}

myQSettings.writeEntry("/UI/lastSaveAsImageFilter" , myFilterString);
myQSettings.writeEntry("/UI/lastSaveAsImageDir", myQFileDialog->directory().absolutePath());

0 comments on commit d12fb0e

Please sign in to comment.