1.1 --- a/XSLForms/XSL/QtDesigner.xsl Mon Oct 17 23:50:33 2005 +0000
1.2 +++ b/XSLForms/XSL/QtDesigner.xsl Fri Oct 21 17:06:12 2005 +0000
1.3 @@ -21,6 +21,7 @@
1.4 <xsl:stylesheet version="1.0"
1.5 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1.6 xmlns:set="http://exslt.org/sets"
1.7 + xmlns:math="http://exslt.org/math"
1.8 xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
1.9
1.10 <xsl:output indent="yes"/>
1.11 @@ -52,24 +53,67 @@
1.12 <table xmlns="http://www.w3.org/1999/xhtml">
1.13 <!-- Get the row numbers in ascending order. -->
1.14 <xsl:for-each select="set:distinct($grid/*/@row)">
1.15 - <xsl:sort select="." order="ascending"/>
1.16 + <xsl:sort select="." data-type="number" order="ascending"/>
1.17 <xsl:variable name="row" select="."/>
1.18 <tr>
1.19 <!-- Get all elements in the row, ordered by column number. -->
1.20 - <xsl:for-each select="$grid/*[@row=$row]">
1.21 - <xsl:sort select="@column" order="ascending"/>
1.22 - <td>
1.23 - <!-- Add colspan and rowspan details. -->
1.24 - <xsl:apply-templates select="@colspan|@rowspan"/>
1.25 - <!-- Transform the element. -->
1.26 - <xsl:apply-templates select="."/>
1.27 - </td>
1.28 - </xsl:for-each>
1.29 + <xsl:call-template name="grid-column">
1.30 + <xsl:with-param name="column" select="math:min($grid/*[@row=$row]/@column)"/>
1.31 + <xsl:with-param name="row" select="$row"/>
1.32 + <xsl:with-param name="grid" select="$grid"/>
1.33 + <xsl:with-param name="last-column">-1</xsl:with-param>
1.34 + </xsl:call-template>
1.35 </tr>
1.36 </xsl:for-each>
1.37 </table>
1.38 </xsl:template>
1.39
1.40 + <xsl:template name="grid-column">
1.41 + <xsl:param name="column"/>
1.42 + <xsl:param name="row"/>
1.43 + <xsl:param name="grid"/>
1.44 + <xsl:param name="last-column"/>
1.45 + <xsl:param name="last-colspan">1</xsl:param>
1.46 + <!-- Insert missing cells. -->
1.47 + <!-- NOTE: This does not handle rowspan usage. -->
1.48 + <xsl:if test="$column != $last-column + $last-colspan">
1.49 + <td colspan="{$column - $last-column - $last-colspan}" xmlns="http://www.w3.org/1999/xhtml">
1.50 + </td>
1.51 + </xsl:if>
1.52 + <!-- Remember useful information. -->
1.53 + <xsl:variable name="this-column" select="$grid/*[@row=$row and @column=$column]"/>
1.54 + <xsl:variable name="this-colspan" select="$this-column/@colspan"/>
1.55 + <!-- Insert this cell. -->
1.56 + <td xmlns="http://www.w3.org/1999/xhtml">
1.57 + <!-- Add colspan and rowspan details. -->
1.58 + <xsl:apply-templates select="$this-colspan|$this-column/@rowspan"/>
1.59 + <!-- Transform the element. -->
1.60 + <xsl:apply-templates select="$this-column"/>
1.61 + </td>
1.62 + <!-- Find remaining cells in this row. -->
1.63 + <xsl:if test="count($grid/*[@row=$row and @column > $column]) > 0">
1.64 + <xsl:choose>
1.65 + <xsl:when test="$this-colspan">
1.66 + <xsl:call-template name="grid-column">
1.67 + <xsl:with-param name="column" select="math:min($grid/*[@row=$row and @column > $column]/@column)"/>
1.68 + <xsl:with-param name="row" select="$row"/>
1.69 + <xsl:with-param name="grid" select="$grid"/>
1.70 + <xsl:with-param name="last-column" select="$column"/>
1.71 + <xsl:with-param name="last-colspan" select="$this-colspan"/>
1.72 + </xsl:call-template>
1.73 + </xsl:when>
1.74 + <xsl:otherwise>
1.75 + <xsl:call-template name="grid-column">
1.76 + <xsl:with-param name="column" select="math:min($grid/*[@row=$row and @column > $column]/@column)"/>
1.77 + <xsl:with-param name="row" select="$row"/>
1.78 + <xsl:with-param name="grid" select="$grid"/>
1.79 + <xsl:with-param name="last-column" select="$column"/>
1.80 + </xsl:call-template>
1.81 + </xsl:otherwise>
1.82 + </xsl:choose>
1.83 + </xsl:if>
1.84 + </xsl:template>
1.85 +
1.86 <xsl:template match="spacer">
1.87 </xsl:template>
1.88
1.89 @@ -112,6 +156,12 @@
1.90 </option>
1.91 </xsl:template>
1.92
1.93 + <xsl:template match="widget[@class='QLabel']">
1.94 + <xsl:variable name="value-prop" select="property[@name='text']"/>
1.95 + <!-- NOTE: Permitting element generation from the text. -->
1.96 + <xsl:value-of disable-output-escaping="yes" select="$value-prop/string/text()"/>
1.97 + </xsl:template>
1.98 +
1.99 <xsl:template match="widget[@class='QPushButton']">
1.100 <input xmlns="http://www.w3.org/1999/xhtml" type="submit">
1.101 <xsl:variable name="name-prop" select="property[@name='name']"/>