[QGIS Commit] r12671 - in trunk/qgis/src/plugins/grass: . modules-common

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Jan 5 08:32:39 EST 2010


Author: rblazek
Date: 2010-01-05 08:32:37 -0500 (Tue, 05 Jan 2010)
New Revision: 12671

Modified:
   trunk/qgis/src/plugins/grass/modules-common/v.out.ascii.qgm
   trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
   trunk/qgis/src/plugins/grass/qgsgrassmodule.h
Log:
added support for advanced options and example use in v.out.ascii

Modified: trunk/qgis/src/plugins/grass/modules-common/v.out.ascii.qgm
===================================================================
--- trunk/qgis/src/plugins/grass/modules-common/v.out.ascii.qgm	2010-01-04 14:43:23 UTC (rev 12670)
+++ trunk/qgis/src/plugins/grass/modules-common/v.out.ascii.qgm	2010-01-05 13:32:37 UTC (rev 12671)
@@ -5,4 +5,5 @@
 	<option key="input" />
 	<option key="format"/>
 	<file key="output" type="new" />
+	<option key="fs" advanced="yes" />
 </qgisgrassmodule>

Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2010-01-04 14:43:23 UTC (rev 12670)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2010-01-05 13:32:37 UTC (rev 12671)
@@ -372,7 +372,31 @@
   //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();
@@ -380,6 +404,13 @@
     {
       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 @@
     }
     n = n.nextSibling();
   }
+  
+  if ( mypAdvancedLayout->count() == 0 ) 
+  {
+    mypAdvancedPushButtonFrame->hide();
+  }
 
   // Create list of flags
   n = gDocElem.firstChild();
@@ -498,6 +534,17 @@
   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;

Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.h
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.h	2010-01-04 14:43:23 UTC (rev 12670)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.h	2010-01-05 13:32:37 UTC (rev 12671)
@@ -235,8 +235,10 @@
  *  \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 @@
     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 @@
 
     //! Use of region defined in qgm
     bool mUsesRegion;
+
+    // ! Advanced options switch button
+    QPushButton mAdvancedPushButton;
+
+    // ! Advanced options frame
+    QFrame mAdvancedFrame;
 };
 
 /****************** QgsGrassModuleGroupBoxItem ************************/



More information about the QGIS-commit mailing list