Selaa lähdekoodia

Generalised creating a set property and value for file/image input/output

Matt Clarkson 12 vuotta sitten
vanhempi
commit
7112c04767

+ 20 - 16
Libs/CommandLineModules/Frontend/QtGui/Resources/ctkCmdLineModuleXmlToQtUi.xsl

@@ -59,10 +59,14 @@
   <xsl:param name="vectorValueProperty">text</xsl:param>
   <xsl:param name="enumerationValueProperty">currentEnumeration</xsl:param>
 
-  <xsl:param name="imageInputFilterProperty">filters</xsl:param>
-  <xsl:param name="imageOutputFilterProperty">filters</xsl:param>
-  <xsl:param name="fileInputFilterProperty">filters</xsl:param>
-  <xsl:param name="fileOutputFilterProperty">filters</xsl:param>
+  <xsl:param name="imageInputSetProperty">filters</xsl:param>
+  <xsl:param name="imageOutputSetProperty">filters</xsl:param>
+  <xsl:param name="fileInputSetProperty">filters</xsl:param>
+  <xsl:param name="fileOutputSetProperty">filters</xsl:param>
+  <xsl:param name="imageInputSetValue">ctkPathLineEdit::Files|ctkPathLineEdit::Readable</xsl:param>
+  <xsl:param name="imageOutputSetValue">ctkPathLineEdit::Files|ctkPathLineEdit::Writable</xsl:param>
+  <xsl:param name="fileInputSetValue">ctkPathLineEdit::Files|ctkPathLineEdit::Readable</xsl:param>
+  <xsl:param name="fileOutputSetValue">ctkPathLineEdit::Files|ctkPathLineEdit::Writable</xsl:param>
   
   <!--
   ===================================================================
@@ -432,9 +436,9 @@
           <widget class="{$imageInputWidget}"  name="parameter:{name}">
             <xsl:call-template name="commonWidgetProperties"/>
             <xsl:call-template name="createQtDesignerStringListProperty"/>
-            <xsl:if test="$imageInputFilterProperty != ''">
-              <property name="{$imageInputFilterProperty}">
-                <set>ctkPathLineEdit::Files|ctkPathLineEdit::Readable</set>
+            <xsl:if test="$imageInputSetProperty != ''">
+              <property name="{$imageInputSetProperty}">
+                <set>{$imageInputSetValue}</set>
               </property>
             </xsl:if>
           </widget>
@@ -443,9 +447,9 @@
           <widget class="{$imageOutputWidget}"  name="parameter:{name}">
             <xsl:call-template name="commonWidgetProperties"/>
             <xsl:call-template name="createQtDesignerStringListProperty"/>
-            <xsl:if test="$imageOutputFilterProperty != ''">
-              <property name="{$imageOutputFilterProperty}">
-                <set>ctkPathLineEdit::Files|ctkPathLineEdit::Writable</set>
+            <xsl:if test="$imageOutputSetProperty != ''">
+              <property name="{$imageOutputSetProperty}">
+                <set>{$imageOutputSetValue}</set>
               </property>
             </xsl:if>
           </widget>
@@ -468,9 +472,9 @@
           <widget class="{$fileInputWidget}"  name="parameter:{name}">
             <xsl:call-template name="commonWidgetProperties"/>
             <xsl:call-template name="createQtDesignerStringListProperty"/>
-            <xsl:if test="$fileInputFilterProperty != ''">
-              <property name="{$fileInputFilterProperty}">
-                <set>ctkPathLineEdit::Files|ctkPathLineEdit::Readable</set>
+            <xsl:if test="$fileInputSetProperty != ''">
+              <property name="{$fileInputSetProperty}">
+                <set>{$fileInputSetValue}</set>
               </property>
             </xsl:if>
           </widget>
@@ -479,9 +483,9 @@
           <widget class="{$fileOutputWidget}"  name="parameter:{name}">
             <xsl:call-template name="commonWidgetProperties"/>
             <xsl:call-template name="createQtDesignerStringListProperty"/>
-            <xsl:if test="$fileOutputFilterProperty != ''">
-              <property name="{$fileOutputFilterProperty}">
-                <set>ctkPathLineEdit::Files|ctkPathLineEdit::Writable</set>
+            <xsl:if test="$fileOutputSetProperty != ''">
+              <property name="{$fileOutputSetProperty}">
+                <set>{$fileOutputSetValue}</set>
               </property>
             </xsl:if>
           </widget>

+ 23 - 0
Libs/CommandLineModules/Frontend/QtGui/ctkCmdLineModuleFrontendQtGui.h

@@ -95,6 +95,29 @@ struct ctkCmdLineModuleFrontendQtGuiPrivate;
  * <tr><td>[unknown type]</td><td>unsupportedWidget</td><td>QLabel</td><td>n/a</td><td>n/a</td></tr>
  * </table>
  * \endhtmlonly
+ *
+ * In addition, for image and file, input and output, it is normally necessary to define a set property within
+ * the generated .ui file to contain various configuration flags to pass to the widget. For example, ctkPathLineEdit
+ * has a "filters" property that can be used to configure the dialog behaviour when the browse button is pressed.
+ * The following XSL parameters are available to create a set property and are also setable via
+ * ctkCmdLineModuleXslTransform::bindVariable(). If the empty string is bound to the Set Property Name,
+ * the set property will be omitted.
+ *
+ * \htmlonly
+ * <style type="text/css">
+ * table.xslparam { color:#333333; border-collapse:collapse; }
+ * table.xslparam td { border: 1px solid #666666; padding: 5px; }
+ * table.xslparam th { border: 1px solid #666666; padding: 5px; background-color: #dedede; font-weight: bold; }
+ * </style>
+ * <table class="xslparam">
+ * <tr><th rowspan="2">Parameter Type</th><th colspan="4" align="center">XSL Parameters</th></tr>
+ * <tr><th>Set Property Name</th><th>Default</th><th>Set Property Value</th><th>Default</th></tr>
+ * <tr><td>file (input channel)</td><td>fileInputSetProperty</td><td>filters</td><td>fileInputSetValue</td><td>ctkPathLineEdit::Files|ctkPathLineEdit::Readable</td></tr>
+ * <tr><td>file (output channel)</td><td>fileOutputSetProperty</td><td>filters</td><td>fileOutputSetValue</td><td>ctkPathLineEdit::Files|ctkPathLineEdit::Writable</td></tr>
+ * <tr><td>image (input channel)</td><td>imageInputSetProperty</td><td>filters</td><td>imageInputSetProperty</td><td>ctkPathLineEdit::Files|ctkPathLineEdit::Readable</td></tr>
+ * <tr><td>image (output channel)</td><td>imageOutputSetProperty</td><td>filters</td><td>imageOutputSetProperty</td><td>ctkPathLineEdit::Files|ctkPathLineEdit::Writable</td></tr>
+ * </table>
+ * \endhtmlonly
  */
 class CTK_CMDLINEMODULEQTGUI_EXPORT ctkCmdLineModuleFrontendQtGui : public ctkCmdLineModuleFrontend
 {