Skip to content

Commit

Permalink
added support for advanced options and example use in v.out.ascii
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12671 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Jan 5, 2010
1 parent cc028be commit cae7b9a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/plugins/grass/modules-common/v.out.ascii.qgm
Expand Up @@ -5,4 +5,5 @@
<option key="input" />
<option key="format"/>
<file key="output" type="new" />
<option key="fs" advanced="yes" />
</qgisgrassmodule>
49 changes: 48 additions & 1 deletion src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -372,14 +372,45 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
//transfers frame ownership so no need to call delete
mypScrollArea->setWidget( mypInnerFrame );
mypScrollArea->setWidgetResizable( true );
QVBoxLayout *layout = new QVBoxLayout( mypInnerFrame );
QVBoxLayout *mypInnerFrameLayout = new QVBoxLayout( mypInnerFrame );
// Add frames for simple/advanced options
QFrame * mypSimpleFrame = new QFrame();
mypSimpleFrame->setFrameShape( QFrame::NoFrame );
mypSimpleFrame->setFrameShadow( QFrame::Plain );
mAdvancedFrame.setFrameShape( QFrame::NoFrame );
mAdvancedFrame.setFrameShadow( QFrame::Plain );

QFrame * mypAdvancedPushButtonFrame = new QFrame();
QHBoxLayout *mypAdvancedPushButtonFrameLayout = new QHBoxLayout( mypAdvancedPushButtonFrame );
connect( &mAdvancedPushButton, SIGNAL( clicked() ), this, SLOT( switchAdvanced() ) );
mypAdvancedPushButtonFrameLayout->addWidget( &mAdvancedPushButton );
mypAdvancedPushButtonFrameLayout->addStretch(1);

mypInnerFrameLayout->addWidget( mypSimpleFrame );
mypInnerFrameLayout->addWidget( mypAdvancedPushButtonFrame );
mypInnerFrameLayout->addWidget( &mAdvancedFrame );
mypInnerFrameLayout->addStretch(1);

// Hide advanced and set butto next
switchAdvanced();

QVBoxLayout *mypSimpleLayout = new QVBoxLayout( mypSimpleFrame );
QVBoxLayout *mypAdvancedLayout = new QVBoxLayout( &mAdvancedFrame );
QVBoxLayout *layout;
while ( !n.isNull() )
{
QDomElement e = n.toElement();
if ( !e.isNull() )
{
QString optionType = e.tagName();
QgsDebugMsg( "optionType = " + optionType );

if ( e.attribute( "advanced", "no" ) == "yes" )
{
layout = mypAdvancedLayout;
} else {
layout = mypSimpleLayout;
}

QString key = e.attribute( "key" );
QgsDebugMsg( "key = " + key );
Expand Down Expand Up @@ -474,6 +505,11 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
}
n = n.nextSibling();
}

if ( mypAdvancedLayout->count() == 0 )
{
mypAdvancedPushButtonFrame->hide();
}

// Create list of flags
n = gDocElem.firstChild();
Expand All @@ -498,6 +534,17 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
layout->addStretch();
}

void QgsGrassModuleStandardOptions::switchAdvanced()
{
if ( mAdvancedFrame.isHidden() ) {
mAdvancedFrame.show();
mAdvancedPushButton.setText ( tr("<< Hide advanced options") );
} else {
mAdvancedFrame.hide();
mAdvancedPushButton.setText ( tr("Show advanced options >>") );
}
}

QStringList QgsGrassModuleStandardOptions::arguments()
{
QStringList arg;
Expand Down
14 changes: 13 additions & 1 deletion src/plugins/grass/qgsgrassmodule.h
Expand Up @@ -235,8 +235,10 @@ class QgsGrassModuleOptions
* \brief Widget with GRASS standard options.
*
*/
class QgsGrassModuleStandardOptions: public QgsGrassModuleOptions, QWidget
class QgsGrassModuleStandardOptions: QWidget, public QgsGrassModuleOptions
{
Q_OBJECT

public:
//! Constructor
QgsGrassModuleStandardOptions(
Expand Down Expand Up @@ -266,6 +268,10 @@ class QgsGrassModuleStandardOptions: public QgsGrassModuleOptions, QWidget
bool inputRegion( struct Cell_head *window, bool all );
QStringList flagNames() { return mFlagNames; }

public slots:
// ! Show/hide advanced options
void switchAdvanced();

private:
//! Name of module executable
QString mXName;
Expand All @@ -281,6 +287,12 @@ class QgsGrassModuleStandardOptions: public QgsGrassModuleOptions, QWidget

//! Use of region defined in qgm
bool mUsesRegion;

// ! Advanced options switch button
QPushButton mAdvancedPushButton;

// ! Advanced options frame
QFrame mAdvancedFrame;
};

/****************** QgsGrassModuleGroupBoxItem ************************/
Expand Down

0 comments on commit cae7b9a

Please sign in to comment.