Skip to content

Commit

Permalink
fix #2788
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13681 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 7, 2010
1 parent 8a54d4e commit 0770f17
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/plugins/grass/modules-common/r.in.gdal.qgis.qgm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<qgisgrassmodule label="Import loaded raster" module="r.in.gdal">
<flag key="o" answer="on" hidden="yes" />
<flag key="e" answer="off" hidden="yes" />
<gdal key="input" label="GDAL raster layer" />
<gdal key="input" label="GDAL raster layer" />
<option key="output" />
</qgisgrassmodule>
41 changes: 19 additions & 22 deletions src/plugins/grass/qgsgrassmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2269,11 +2269,11 @@ void QgsGrassModuleInput::updateQgisLayers()

QString current = mLayerComboBox->currentText();
mLayerComboBox->clear();
mMaps.resize( 0 );
mGeometryTypes.resize( 0 );
mVectorLayerNames.resize( 0 );
mMapLayers.resize( 0 );
mVectorFields.resize( 0 );
mMaps.clear();
mGeometryTypes.clear();
mVectorLayerNames.clear();
mMapLayers.clear();
mVectorFields.clear();

// If not required, add an empty item to combobox and a padding item into
// layer containers.
Expand Down Expand Up @@ -2458,12 +2458,10 @@ QStringList QgsGrassModuleInput::options()
QStringList list;
QString opt;

int c = mLayerComboBox->currentIndex();
if ( c < 0 ) // not found
int current = mLayerComboBox->currentIndex();
if ( current < 0 ) // not found
return list;

unsigned current = c;

// TODO: this is hack for network nodes, do it somehow better
if ( mMapId.isEmpty() )
{
Expand Down Expand Up @@ -2537,15 +2535,15 @@ QString QgsGrassModuleInput::currentMap()
{
QgsDebugMsg( "called." );

unsigned int limit = 0;
int limit = 0;
if ( !mRequired )
limit = 1;

unsigned int current = mLayerComboBox->currentIndex();
int current = mLayerComboBox->currentIndex();
if ( current < limit )
return QString();

if ( current >= limit && current < mMaps.size() )
if ( current >= limit && current < mMaps.size() )
{
return mMaps[current];
}
Expand Down Expand Up @@ -2762,8 +2760,8 @@ void QgsGrassModuleGdalInput::updateQgisLayers()

QString current = mLayerComboBox->currentText();
mLayerComboBox->clear();
mUri.resize( 0 );
mOgrLayers.resize( 0 );
mUri.clear();
mOgrLayers.clear();

// If not required, add an empty item to combobox and a padding item into
// layer containers.
Expand Down Expand Up @@ -2857,7 +2855,6 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
if ( layer->name() == current ) mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current );

mUri.push_back( uri );

mOgrLayers.push_back( ogrLayer );
mOgrWheres.push_back( ogrWhere );
}
Expand All @@ -2867,6 +2864,8 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
mLayerComboBox->addItem( layer->name() );
if ( layer->name() == current ) mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current );
mUri.push_back( uri );
mOgrLayers.push_back( "" );
mOgrWheres.push_back( "" );
}
}
}
Expand All @@ -2875,21 +2874,19 @@ QStringList QgsGrassModuleGdalInput::options()
{
QStringList list;

int c = mLayerComboBox->currentIndex();
if ( c < 0 )
int current = mLayerComboBox->currentIndex();
if ( current < 0 )
return list;

unsigned int current = c;

QString opt( mKey + "=" );

if ( current >= 0 && current < mUri.size() )
if ( current >= 0 && current < mUri.size() )
{
opt.append( mUri[current] );
}
list.push_back( opt );

if ( !mOgrLayerOption.isNull() && mOgrLayers[current].length() > 0 )
if ( !mOgrLayerOption.isEmpty() && mOgrLayers[current].size() > 0 )
{
opt = mOgrLayerOption + "=";
// GDAL 1.4.0 supports schemas (r9998)
Expand Down Expand Up @@ -2918,7 +2915,7 @@ QStringList QgsGrassModuleGdalInput::options()
list.push_back( opt );
}

if ( !mOgrWhereOption.isNull() && mOgrWheres[current].length() > 0 )
if ( !mOgrWhereOption.isEmpty() && mOgrWheres[current].length() > 0 )
{
list.push_back( mOgrWhereOption + "=" + mOgrWheres[current] );
}
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/grass/qgsgrassmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,13 +640,13 @@ class QgsGrassModuleInput: public QgsGrassModuleGroupBoxItem
QString mMapId;

//! Vector of map@mapset in the combobox
std::vector<QString> mMaps;
QStringList mMaps;

//! Type of vector in the combobox
std::vector<QString> mGeometryTypes;
QStringList mGeometryTypes;

//! Layer names in the combobox
std::vector<QString> mVectorLayerNames;
QStringList mVectorLayerNames;

//! Pointers to vector layers in combobox
std::vector<QgsMapLayer*> mMapLayers;
Expand Down Expand Up @@ -709,13 +709,13 @@ class QgsGrassModuleGdalInput: public QgsGrassModuleGroupBoxItem
QComboBox *mLayerComboBox;

//! Vector of URI in the combobox
std::vector<QString> mUri;
QStringList mUri;

//! Ogr layer options
std::vector<QString> mOgrLayers;
QStringList mOgrLayers;

//! Ogr where clauses
std::vector<QString> mOgrWheres;
QStringList mOgrWheres;

//! Required field
bool mRequired;
Expand Down

0 comments on commit 0770f17

Please sign in to comment.