Skip to content

Commit fc0843c

Browse files
committed
[GRASS] field option without layer
1 parent ef1be5c commit fc0843c

File tree

3 files changed

+68
-17
lines changed

3 files changed

+68
-17
lines changed

src/plugins/grass/qgsgrassmoduleoptions.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,22 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
254254
}
255255
else if ( optionType == "field" )
256256
{
257-
QgsGrassModuleField *mi = new QgsGrassModuleField(
258-
mModule, this, key, confDomElement,
259-
descDocElem, gnode, mDirect, this );
260-
layout->addWidget( mi );
261-
mParams.append( mi );
257+
if ( confDomElement.hasAttribute( "layer" ) )
258+
{
259+
QgsGrassModuleVectorField *mi = new QgsGrassModuleVectorField(
260+
mModule, this, key, confDomElement,
261+
descDocElem, gnode, mDirect, this );
262+
layout->addWidget( mi );
263+
mParams.append( mi );
264+
}
265+
else
266+
{
267+
QgsGrassModuleField *mi = new QgsGrassModuleField(
268+
mModule, key, confDomElement,
269+
descDocElem, gnode, mDirect, this );
270+
layout->addWidget( mi );
271+
mParams.append( mi );
272+
}
262273
}
263274
else if ( optionType == "selection" )
264275
{

src/plugins/grass/qgsgrassmoduleparam.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,24 @@ QgsGrassModuleGdalInput::~QgsGrassModuleGdalInput()
10701070
}
10711071

10721072
/***************** QgsGrassModuleField *********************/
1073+
QgsGrassModuleField::QgsGrassModuleField( QgsGrassModule *module, QString key,
1074+
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent )
1075+
: QgsGrassModuleOption( module, key, qdesc, gdesc, gnode, direct, parent )
1076+
{
1077+
QRegExp rx( "^[a-zA-Z_][a-zA-Z0-9_]*$" );
1078+
foreach ( QLineEdit *lineEdit, mLineEdits )
1079+
{
1080+
lineEdit->setValidator( new QRegExpValidator( rx, this ) );
1081+
}
1082+
}
1083+
1084+
QgsGrassModuleField::~QgsGrassModuleField()
1085+
{
1086+
}
10731087

1074-
QgsGrassModuleField::QgsGrassModuleField(
1088+
/***************** QgsGrassModuleVectorField *********************/
1089+
1090+
QgsGrassModuleVectorField::QgsGrassModuleVectorField(
10751091
QgsGrassModule *module, QgsGrassModuleStandardOptions *options,
10761092
QString key, QDomElement &qdesc,
10771093
QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent )
@@ -1114,7 +1130,7 @@ QgsGrassModuleField::QgsGrassModuleField(
11141130
updateFields();
11151131
}
11161132

1117-
void QgsGrassModuleField::updateFields()
1133+
void QgsGrassModuleVectorField::updateFields()
11181134
{
11191135
QgsDebugMsg( "entered" );
11201136

@@ -1141,7 +1157,7 @@ void QgsGrassModuleField::updateFields()
11411157
}
11421158
}
11431159

1144-
QStringList QgsGrassModuleField::options()
1160+
QStringList QgsGrassModuleVectorField::options()
11451161
{
11461162
QStringList list;
11471163

@@ -1154,7 +1170,7 @@ QStringList QgsGrassModuleField::options()
11541170
return list;
11551171
}
11561172

1157-
QgsGrassModuleField::~QgsGrassModuleField()
1173+
QgsGrassModuleVectorField::~QgsGrassModuleVectorField()
11581174
{
11591175
}
11601176

src/plugins/grass/qgsgrassmoduleparam.h

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ class QgsGrassModuleOption : public QgsGrassModuleGroupBoxItem
257257
// Browse output
258258
void browse( bool checked );
259259

260+
protected:
261+
//! Line
262+
QList<QLineEdit*> mLineEdits;
263+
260264
private:
261265
//! Control type
262266
ControlType mControlType;
@@ -280,9 +284,6 @@ class QgsGrassModuleOption : public QgsGrassModuleGroupBoxItem
280284
//! Check boxes
281285
QList<QgsGrassModuleCheckBox*> mCheckBoxes;
282286

283-
//! Line
284-
QList<QLineEdit*> mLineEdits;
285-
286287
//! True if this option is GRASS output
287288
bool mIsOutput;
288289

@@ -385,12 +386,13 @@ class QgsGrassModuleGdalInput : public QgsGrassModuleGroupBoxItem
385386
bool mRequired;
386387
};
387388

389+
388390
/*********************** QgsGrassModuleField **********************/
389391

390392
/** \class QgsGrassModuleField
391-
* \brief GRASS vector attribute column.
393+
* \brief GRASS column, not existing column of input vector, may be output column or input column from a table not linked to layer
392394
*/
393-
class QgsGrassModuleField : public QgsGrassModuleGroupBoxItem
395+
class QgsGrassModuleField : public QgsGrassModuleOption
394396
{
395397
Q_OBJECT
396398

@@ -399,14 +401,36 @@ class QgsGrassModuleField : public QgsGrassModuleGroupBoxItem
399401
* \param qdesc option element in QGIS module description XML file
400402
* \param gdesc GRASS module XML description file
401403
*/
402-
QgsGrassModuleField( QgsGrassModule *module,
403-
QgsGrassModuleStandardOptions *options,
404-
QString key,
404+
QgsGrassModuleField( QgsGrassModule *module, QString key,
405405
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
406406
bool direct, QWidget * parent = 0 );
407407

408408
//! Destructor
409409
~QgsGrassModuleField();
410+
};
411+
412+
/*********************** QgsGrassModuleVectorField **********************/
413+
414+
/** \class QgsGrassModuleVectorField
415+
* \brief GRASS vector attribute column.
416+
*/
417+
class QgsGrassModuleVectorField : public QgsGrassModuleGroupBoxItem
418+
{
419+
Q_OBJECT
420+
421+
public:
422+
/** \brief Constructor
423+
* \param qdesc option element in QGIS module description XML file
424+
* \param gdesc GRASS module XML description file
425+
*/
426+
QgsGrassModuleVectorField( QgsGrassModule *module,
427+
QgsGrassModuleStandardOptions *options,
428+
QString key,
429+
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
430+
bool direct, QWidget * parent = 0 );
431+
432+
//! Destructor
433+
~QgsGrassModuleVectorField();
410434

411435
//! Retruns list of options which will be passed to module
412436
virtual QStringList options() override;

0 commit comments

Comments
 (0)