Skip to content

Commit 9dd0eff

Browse files
author
rblazek
committedJan 6, 2010
fixed #1619, and another not yet reported bug for field
git-svn-id: http://svn.osgeo.org/qgis/trunk@12679 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7431269 commit 9dd0eff

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed
 

‎src/plugins/grass/modules-common/v.what.vect.qgm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
<option key="vector" layeroption="layer" typemask="point"/>
66
<field key="column" layer="vector" type="integer,double,string"/>
77
<option key="qvector" layeroption="layer" typemask="area"/>
8-
<option key="qcolumn" layer="qvector" type="string"/>
8+
<field key="qcolumn" layer="qvector" type="string"/>
99
</qgisgrassmodule>

‎src/plugins/grass/qgsgrassmodule.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,23 @@ QStringList QgsGrassModuleStandardOptions::arguments()
562562
return arg;
563563
}
564564

565+
// id is not used in fact, was intended for field, but key is used instead
566+
QgsGrassModuleItem *QgsGrassModuleStandardOptions::itemByKey( QString key )
567+
{
568+
QgsDebugMsg( "key = " + key );
569+
570+
for ( unsigned int i = 0; i < mItems.size(); i++ )
571+
{
572+
if ( mItems[i]->key() == key )
573+
{
574+
return mItems[i];
575+
}
576+
}
577+
578+
QMessageBox::warning( 0, tr( "Warning" ), tr( "Item with key %1 not found" ).arg( key ) );
579+
return 0;
580+
}
581+
565582
QgsGrassModuleItem *QgsGrassModuleStandardOptions::item( QString id )
566583
{
567584
QgsDebugMsg( "id = " + id );
@@ -2908,16 +2925,19 @@ QgsGrassModuleField::QgsGrassModuleField(
29082925
QDomElement promptElem = promptNode.toElement();
29092926
QString element = promptElem.attribute( "element" );
29102927

2911-
mLayerId = qdesc.attribute( "layerid" );
2912-
29132928
mType = qdesc.attribute( "type" );
29142929

2915-
QgsGrassModuleItem *item = mModuleStandardOptions->item( mLayerId );
2916-
// TODO check type
2917-
if ( item )
2918-
{
2919-
mLayerInput = dynamic_cast<QgsGrassModuleInput *>( item );
2920-
connect( mLayerInput, SIGNAL( valueChanged() ), this, SLOT( updateFields() ) );
2930+
mLayerKey = qdesc.attribute( "layer" );
2931+
if ( mLayerKey.isNull() || mLayerKey.length() == 0 ) {
2932+
QMessageBox::warning( 0, tr( "Warning" ), tr( "'layer' attribute in field tag with key= %1 is missing." ).arg( mKey ) );
2933+
} else {
2934+
QgsGrassModuleItem *item = mModuleStandardOptions->itemByKey( mLayerKey );
2935+
// TODO check type
2936+
if ( item )
2937+
{
2938+
mLayerInput = dynamic_cast<QgsGrassModuleInput *>( item );
2939+
connect( mLayerInput, SIGNAL( valueChanged() ), this, SLOT( updateFields() ) );
2940+
}
29212941
}
29222942

29232943
QHBoxLayout *l = new QHBoxLayout( this );

‎src/plugins/grass/qgsgrassmodule.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ class QgsGrassModuleStandardOptions: QWidget, public QgsGrassModuleOptions
256256
// ! Get item by ID
257257
QgsGrassModuleItem *item( QString id );
258258

259+
// ! Get item by key
260+
QgsGrassModuleItem *itemByKey( QString key );
261+
259262
// Reimplemented methods from QgsGrassModuleOptions
260263
QStringList checkOutput();
261264
void freezeOutput();
@@ -749,7 +752,7 @@ class QgsGrassModuleField: public QgsGrassModuleGroupBoxItem
749752
QgsGrassModuleStandardOptions *mModuleStandardOptions;
750753

751754
//! Layer key
752-
QString mLayerId;
755+
QString mLayerKey;
753756

754757
//! Pointer to layer input
755758
QgsGrassModuleInput *mLayerInput;

0 commit comments

Comments
 (0)
Please sign in to comment.