Skip to content
Permalink
Browse files
added support for advanced options and example use in v.out.ascii
git-svn-id: http://svn.osgeo.org/qgis/trunk@12671 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Jan 5, 2010
1 parent e51df5c commit 362de6b0f48e7dd2cb5f661f83577701775e266d
@@ -5,4 +5,5 @@
<option key="input" />
<option key="format"/>
<file key="output" type="new" />
<option key="fs" advanced="yes" />
</qgisgrassmodule>
@@ -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 );
@@ -474,6 +505,11 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
}
n = n.nextSibling();
}

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

// Create list of flags
n = gDocElem.firstChild();
@@ -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;
@@ -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(
@@ -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;
@@ -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 ************************/

0 comments on commit 362de6b

Please sign in to comment.