Skip to content
Permalink
Browse files

Added the possibility to select multiple files in modules such as r.p…

…atch.

Changed the module r.patch to exploit the new feature (fixes ticket #1489)
Fixed the starting point of the selection dialog to the last directory used (fixes ticket #1362)


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10945 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rugginoso
rugginoso committed Jun 17, 2009
1 parent 9bbefcb commit d28e86286f7aa5b4862f48219cea7e7c9e1f99b0
@@ -4,6 +4,6 @@
<qgisgrassmodule label="Create new raster by combining other rasters" module="r.patch">
<option key="input"/>
<flag key="z" answer="off" hidden="no" />
<file key="input" label="Type in map names separated by a comma" />
<file key="input" type="multiple" />
<option key="output" />
</qgisgrassmodule>
@@ -3013,6 +3013,10 @@ QgsGrassModuleFile::QgsGrassModuleFile(
if ( qdesc.attribute( "type" ).toLower() == "new" )
{
mType = New;
}
if ( qdesc.attribute( "type" ).toLower() == "multiple" )
{
mType = Multiple;
}

if ( !qdesc.attribute( "filters" ).isNull() )
@@ -3071,17 +3075,21 @@ void QgsGrassModuleFile::browse()
// TODO: unfortunately QFileDialog does not support 'new' directory
QFileDialog *fd = new QFileDialog( this, NULL, mLineEdit->text() );

fd->setDirectory( QDir::current() );

fd->setFileMode( QFileDialog::AnyFile );
static QDir currentDir = QDir::current();
fd->setDirectory( currentDir );

if ( mType == New )
{
fd->setAcceptMode( QFileDialog::AcceptSave );
}
else
{
fd->setAcceptMode( QFileDialog::AcceptOpen );
switch( mType ) {
case New:
fd->setFileMode( QFileDialog::AnyFile );
fd->setAcceptMode( QFileDialog::AcceptSave );
break;
case Multiple:
fd->setFileMode( QFileDialog::ExistingFiles );
fd->setAcceptMode( QFileDialog::AcceptOpen );
break;
default:
fd->setFileMode( QFileDialog::ExistingFile );
fd->setAcceptMode( QFileDialog::AcceptOpen );
}

if ( mFilters.size() > 0 )
@@ -3092,7 +3100,14 @@ void QgsGrassModuleFile::browse()

if ( fd->exec() == QDialog::Accepted )
{
mLineEdit->setText( fd->selectedFiles().first() );
QString selectedFile = fd->selectedFiles().first();
QFileInfo fi = QFileInfo(selectedFile);
currentDir = fi.absoluteDir();
if (mType == Multiple)
{
selectedFile = fd->selectedFiles().join(",");
}
mLineEdit->setText( selectedFile );
}
}

@@ -816,7 +816,7 @@ class QgsGrassModuleFile: public QgsGrassModuleGroupBoxItem
~QgsGrassModuleFile();

//! File type
enum Type { Old, New };
enum Type { Old, New, Multiple };

// Reimplemented methods from QgsGrassModuleOptions
QStringList options();

0 comments on commit d28e862

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