Skip to content

Commit

Permalink
Added the possibility to select multiple files in modules such as r.p…
Browse files Browse the repository at this point in the history
…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@10945 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rugginoso committed Jun 17, 2009
1 parent 7b08127 commit 26fba47
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/plugins/grass/modules-common/r.patch.qgm
Original file line number Diff line number Diff line change
Expand Up @@ -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>
37 changes: 26 additions & 11 deletions src/plugins/grass/qgsgrassmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down Expand Up @@ -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 )
Expand All @@ -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 );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/qgsgrassmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 26fba47

Please sign in to comment.