Skip to content

Commit

Permalink
[GRASS] field option without layer
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Sep 9, 2015
1 parent ef1be5c commit fc0843c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 17 deletions.
21 changes: 16 additions & 5 deletions src/plugins/grass/qgsgrassmoduleoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,22 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
}
else if ( optionType == "field" )
{
QgsGrassModuleField *mi = new QgsGrassModuleField(
mModule, this, key, confDomElement,
descDocElem, gnode, mDirect, this );
layout->addWidget( mi );
mParams.append( mi );
if ( confDomElement.hasAttribute( "layer" ) )
{
QgsGrassModuleVectorField *mi = new QgsGrassModuleVectorField(
mModule, this, key, confDomElement,
descDocElem, gnode, mDirect, this );
layout->addWidget( mi );
mParams.append( mi );
}
else
{
QgsGrassModuleField *mi = new QgsGrassModuleField(
mModule, key, confDomElement,
descDocElem, gnode, mDirect, this );
layout->addWidget( mi );
mParams.append( mi );
}
}
else if ( optionType == "selection" )
{
Expand Down
24 changes: 20 additions & 4 deletions src/plugins/grass/qgsgrassmoduleparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,24 @@ QgsGrassModuleGdalInput::~QgsGrassModuleGdalInput()
}

/***************** QgsGrassModuleField *********************/
QgsGrassModuleField::QgsGrassModuleField( QgsGrassModule *module, QString key,
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent )
: QgsGrassModuleOption( module, key, qdesc, gdesc, gnode, direct, parent )
{
QRegExp rx( "^[a-zA-Z_][a-zA-Z0-9_]*$" );
foreach ( QLineEdit *lineEdit, mLineEdits )
{
lineEdit->setValidator( new QRegExpValidator( rx, this ) );
}
}

QgsGrassModuleField::~QgsGrassModuleField()
{
}

QgsGrassModuleField::QgsGrassModuleField(
/***************** QgsGrassModuleVectorField *********************/

QgsGrassModuleVectorField::QgsGrassModuleVectorField(
QgsGrassModule *module, QgsGrassModuleStandardOptions *options,
QString key, QDomElement &qdesc,
QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent )
Expand Down Expand Up @@ -1114,7 +1130,7 @@ QgsGrassModuleField::QgsGrassModuleField(
updateFields();
}

void QgsGrassModuleField::updateFields()
void QgsGrassModuleVectorField::updateFields()
{
QgsDebugMsg( "entered" );

Expand All @@ -1141,7 +1157,7 @@ void QgsGrassModuleField::updateFields()
}
}

QStringList QgsGrassModuleField::options()
QStringList QgsGrassModuleVectorField::options()
{
QStringList list;

Expand All @@ -1154,7 +1170,7 @@ QStringList QgsGrassModuleField::options()
return list;
}

QgsGrassModuleField::~QgsGrassModuleField()
QgsGrassModuleVectorField::~QgsGrassModuleVectorField()
{
}

Expand Down
40 changes: 32 additions & 8 deletions src/plugins/grass/qgsgrassmoduleparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ class QgsGrassModuleOption : public QgsGrassModuleGroupBoxItem
// Browse output
void browse( bool checked );

protected:
//! Line
QList<QLineEdit*> mLineEdits;

private:
//! Control type
ControlType mControlType;
Expand All @@ -280,9 +284,6 @@ class QgsGrassModuleOption : public QgsGrassModuleGroupBoxItem
//! Check boxes
QList<QgsGrassModuleCheckBox*> mCheckBoxes;

//! Line
QList<QLineEdit*> mLineEdits;

//! True if this option is GRASS output
bool mIsOutput;

Expand Down Expand Up @@ -385,12 +386,13 @@ class QgsGrassModuleGdalInput : public QgsGrassModuleGroupBoxItem
bool mRequired;
};


/*********************** QgsGrassModuleField **********************/

/** \class QgsGrassModuleField
* \brief GRASS vector attribute column.
* \brief GRASS column, not existing column of input vector, may be output column or input column from a table not linked to layer
*/
class QgsGrassModuleField : public QgsGrassModuleGroupBoxItem
class QgsGrassModuleField : public QgsGrassModuleOption
{
Q_OBJECT

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

//! Destructor
~QgsGrassModuleField();
};

/*********************** QgsGrassModuleVectorField **********************/

/** \class QgsGrassModuleVectorField
* \brief GRASS vector attribute column.
*/
class QgsGrassModuleVectorField : public QgsGrassModuleGroupBoxItem
{
Q_OBJECT

public:
/** \brief Constructor
* \param qdesc option element in QGIS module description XML file
* \param gdesc GRASS module XML description file
*/
QgsGrassModuleVectorField( QgsGrassModule *module,
QgsGrassModuleStandardOptions *options,
QString key,
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
bool direct, QWidget * parent = 0 );

//! Destructor
~QgsGrassModuleVectorField();

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

0 comments on commit fc0843c

Please sign in to comment.