@@ -1065,239 +1065,3 @@ void QgsGrassModule::setDirectLibraryPath( QProcessEnvironment & environment )
1065
1065
QgsDebugMsg ( pathVariable + " =" + lp );
1066
1066
}
1067
1067
1068
- /* ****************** QgsGrassModuleOption ****************************/
1069
-
1070
- QgsGrassModuleOption::QgsGrassModuleOption ( QgsGrassModule *module , QString key,
1071
- QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
1072
- bool direct, QWidget * parent )
1073
- : QgsGrassModuleGroupBoxItem( module , key, qdesc, gdesc, gnode, direct, parent )
1074
- , mControlType( NoControl )
1075
- , mValueType( String )
1076
- , mOutputType( None )
1077
- , mHaveLimits( false )
1078
- , mMin( INT_MAX )
1079
- , mMax( INT_MIN )
1080
- , mComboBox( 0 )
1081
- , mIsOutput( false )
1082
- , mValidator( 0 )
1083
- , mLayout( 0 )
1084
- , mUsesRegion( false )
1085
- {
1086
- QgsDebugMsg ( " called." );
1087
- setSizePolicy ( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
1088
-
1089
- if ( mHidden )
1090
- hide ();
1091
-
1092
- mLayout = new QVBoxLayout ();
1093
-
1094
- // Is it output?
1095
- QDomNode promptNode = gnode.namedItem ( " gisprompt" );
1096
- if ( !promptNode.isNull () )
1097
- {
1098
- QDomElement promptElem = promptNode.toElement ();
1099
- QString element = promptElem.attribute ( " element" );
1100
- QString age = promptElem.attribute ( " age" );
1101
-
1102
- if ( age == " new" )
1103
- {
1104
- mOutputElement = element;
1105
- mIsOutput = true ;
1106
-
1107
- if ( element == " vector" )
1108
- {
1109
- mOutputType = Vector;
1110
- }
1111
- else if ( element == " cell" )
1112
- {
1113
- mOutputType = Raster;
1114
- }
1115
- }
1116
- }
1117
-
1118
- // String without options
1119
- if ( !mHidden )
1120
- {
1121
- QDomElement gelem = gnode.toElement ();
1122
-
1123
- // Predefined values ?
1124
- QDomNode valuesNode = gnode.namedItem ( " values" );
1125
- QDomElement valuesElem = valuesNode.toElement (); // null if valuesNode is null
1126
-
1127
- if ( !valuesNode.isNull () && valuesNode.childNodes ().count () > 1 )
1128
- {
1129
- setLayout ( mLayout );
1130
- // predefined values -> ComboBox or CheckBox
1131
-
1132
- // one or many?
1133
- if ( gelem.attribute ( " multiple" ) == " yes" )
1134
- {
1135
- mControlType = CheckBoxes;
1136
- }
1137
- else
1138
- {
1139
- mControlType = ComboBox;
1140
- mComboBox = new QComboBox ( this );
1141
- mLayout ->addWidget ( mComboBox );
1142
- }
1143
-
1144
- // List of values to be excluded
1145
- QStringList exclude = qdesc.attribute ( " exclude" ).split ( ' ,' , QString::SkipEmptyParts );
1146
-
1147
- QDomNode valueNode = valuesElem.firstChild ();
1148
-
1149
- while ( !valueNode.isNull () )
1150
- {
1151
- QDomElement valueElem = valueNode.toElement ();
1152
-
1153
- if ( !valueElem.isNull () && valueElem.tagName () == " value" )
1154
- {
1155
-
1156
- QDomNode n = valueNode.namedItem ( " name" );
1157
- if ( !n.isNull () )
1158
- {
1159
- QDomElement e = n.toElement ();
1160
- QString val = e.text ().trimmed ();
1161
-
1162
- if ( exclude.contains ( val ) == 0 )
1163
- {
1164
- n = valueNode.namedItem ( " description" );
1165
- QString desc;
1166
- if ( !n.isNull () )
1167
- {
1168
- e = n.toElement ();
1169
- desc = e.text ().trimmed ();
1170
- }
1171
- else
1172
- {
1173
- desc = val;
1174
- }
1175
- desc.replace ( 0 , 1 , desc.left ( 1 ).toUpper () );
1176
-
1177
- if ( mControlType == ComboBox )
1178
- {
1179
- mComboBox ->addItem ( desc );
1180
- if ( mAnswer .length () > 0 && desc == mAnswer )
1181
- {
1182
- mComboBox ->setCurrentIndex ( mComboBox ->count () - 1 );
1183
- }
1184
- }
1185
- else
1186
- {
1187
- QgsGrassModuleCheckBox *cb = new QgsGrassModuleCheckBox ( desc, this );
1188
- mCheckBoxes .push_back ( cb );
1189
- mLayout ->addWidget ( cb );
1190
- }
1191
-
1192
- mValues .push_back ( val );
1193
- }
1194
- }
1195
- }
1196
-
1197
- valueNode = valueNode.nextSibling ();
1198
- }
1199
- }
1200
- else // No values
1201
- {
1202
- // Line edit
1203
- mControlType = LineEdit;
1204
-
1205
- if ( gelem.attribute ( " type" ) == " integer" )
1206
- {
1207
- mValueType = Integer;
1208
- }
1209
- else if ( gelem.attribute ( " type" ) == " float" )
1210
- {
1211
- mValueType = Double;
1212
- }
1213
-
1214
- QStringList minMax;
1215
- if ( valuesNode.childNodes ().count () == 1 )
1216
- {
1217
- QDomNode valueNode = valuesElem.firstChild ();
1218
-
1219
- QDomNode n = valueNode.namedItem ( " name" );
1220
- if ( !n.isNull () )
1221
- {
1222
- QDomElement e = n.toElement ();
1223
- QString val = e.text ().trimmed ();
1224
- minMax = val.split ( " -" );
1225
- if ( minMax.size () == 2 )
1226
- {
1227
- mHaveLimits = true ;
1228
- mMin = minMax.at ( 0 ).toDouble ();
1229
- mMax = minMax.at ( 1 ).toDouble ();
1230
- }
1231
- }
1232
- }
1233
-
1234
- QDomNode keydescNode = gnode.namedItem ( " keydesc" );
1235
- if ( !keydescNode.isNull () )
1236
- {
1237
- // fixed number of line edits
1238
- // Example:
1239
- // <keydesc>
1240
- // <item order="1">rows</item>
1241
- // <item order="2">columns</item>
1242
- // </keydesc>
1243
-
1244
- QDomNodeList keydescs = keydescNode.childNodes ();
1245
- for ( int k = 0 ; k < keydescs.count (); k++ )
1246
- {
1247
- QDomNode nodeItem = keydescs.at ( k );
1248
- QString itemDesc = nodeItem.toElement ().text ().trimmed ();
1249
- // QString itemDesc = nodeItem.firstChild().toText().data();
1250
- QgsDebugMsg ( " keydesc item = " + itemDesc );
1251
-
1252
- addLineEdit ();
1253
- }
1254
-
1255
- setLayout ( mLayout );
1256
- }
1257
- else if ( gelem.attribute ( " multiple" ) == " yes" )
1258
- {
1259
- // variable number of line edits
1260
- // add/delete buttons for multiple options
1261
- QHBoxLayout *l = new QHBoxLayout ( this );
1262
- QVBoxLayout *vl = new QVBoxLayout ();
1263
- l->insertLayout ( -1 , mLayout );
1264
- l->insertLayout ( -1 , vl );
1265
-
1266
- // TODO: how to keep both buttons on the top?
1267
- QPushButton *b = new QPushButton ( " +" , this );
1268
- connect ( b, SIGNAL ( clicked () ), this , SLOT ( addLineEdit () ) );
1269
- vl->addWidget ( b, 0 , Qt::AlignTop );
1270
-
1271
- b = new QPushButton ( " -" , this );
1272
- connect ( b, SIGNAL ( clicked () ), this , SLOT ( removeLineEdit () ) );
1273
- vl->addWidget ( b, 0 , Qt::AlignTop );
1274
-
1275
- // Don't enable this, it makes the group box expanding
1276
- // vl->addStretch();
1277
- }
1278
- else
1279
- {
1280
- // only one line edit
1281
- addLineEdit ();
1282
- setLayout ( mLayout );
1283
- }
1284
- }
1285
- }
1286
-
1287
- mUsesRegion = false ;
1288
- QString region = qdesc.attribute ( " region" );
1289
- if ( region.length () > 0 )
1290
- {
1291
- if ( region == " yes" )
1292
- mUsesRegion = true ;
1293
- }
1294
- else
1295
- {
1296
- QgsDebugMsg ( " \n\n\n\n **************************" );
1297
- QgsDebugMsg ( QString ( " isOutput = %1" ).arg ( isOutput () ) );
1298
- QgsDebugMsg ( QString ( " mOutputType = %1" ).arg ( mOutputType ) );
1299
- if ( isOutput () && mOutputType == Raster )
1300
- mUsesRegion = true ;
1301
- }
1302
- QgsDebugMsg ( QString ( " mUsesRegion = %1" ).arg ( mUsesRegion ) );
1303
- }
0 commit comments