summaryrefslogtreecommitdiffstats
path: root/qtjava/designer/juic/common/classes.xsl
blob: c6acbfa4399e396aedc18261acb265b3243437ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?xml version="1.0" encoding="utf-8"?>
<!--
  ** Author: Marco Ladermann
  ** Date:   Wed Jan 29 08:41:56 CET 2003 @362 /Internet Time/
  ** Purpose:  Convert tags in the UI file to Qt classes 
  ** Changed:
  **
  ** This software is free software. It is released under the terms of the
  ** GNU Lesser General Public Licence (LGPL)
  ** see http://www.gnu.org/copyleft/lesser.html
  **
  ** These stylesheets are distributed in the hope that they will be useful,
  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  -->
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:kde="http://kde.org/functions"
>

      <!--
      ** Start of mode 'classes'
      ** The patterns with mode "classes" construct a
      ** result tree fragment of "class" elements with the 
      ** Qt classes that should be used for a ui tag.
      -->
    <xsl:template match="action" mode="classes">
        <class>QAction</class>
        <class>QKeySequence</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>
  
    <xsl:template match="actiongroup" mode="classes">
        <class>QActionGroup</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>
  
    <xsl:template match="color" mode="classes">
        <class>QColor</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="cursor" mode="classes">
        <class>QCursor</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="font" mode="classes">
        <class>QFont</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="grid" mode="classes">
        <class>QGridLayout</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="hbox" mode="classes">
        <class>QHBoxLayout</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="iconset" mode="classes">
        <class>QIconSet</class>
        <class>QPixmap</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="item" mode="classes">
        <xsl:if test="name(..) = 'widget'">
            <class><xsl:value-of select="concat(../@class, 'Item')"/></class>
        </xsl:if>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="menubar" mode="classes">
        <class>QMenuBar</class>
        <class>QPopupMenu</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="pixmap" mode="classes">
        <class>QPixmap</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="rect" mode="classes">
        <class>QRect</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="size" mode="classes">
        <xsl:if test="not(name(../..) = 'spacer')">
            <class>QSize</class>
        </xsl:if>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="sizepolicy" mode="classes">
        <class>QSizePolicy</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="spacer" mode="classes">
        <class>QSpacerItem</class>
        <class>QSizePolicy</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="toolbar" mode="classes">
        <class>QToolBar</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="vbox" mode="classes">
        <class>QVBoxLayout</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>
  
    <xsl:template match="palette" mode="classes">
        <class>QPalette</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="active|disabled|inactive" mode="classes">
        <class>QColorGroup</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="signal|slot" mode="classes">
        <xsl:message>Check <xsl:value-of select="name()"/>: <xsl:value-of select="."/></xsl:message>
        <xsl:call-template name="kde:classes-in-signature">
            <xsl:with-param name="signature" select="."/>
        </xsl:call-template>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="widget" mode="classes">
        <xsl:choose>
            <xsl:when test="@class = 'QLayoutWidget'">
                <class>QWidget</class>
            </xsl:when>
            <xsl:when test="@class = 'QDataBrowser'">
                <class>QDataBrowser</class>
                <class>QSqlForm</class>
            </xsl:when>
            <xsl:otherwise>
                <class><xsl:value-of select="@class"/></class>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="property[@name = 'accel']" mode="classes">
        <class>QKeySequence</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="property[@name = 'toolTip']" mode="classes">
        <class>QToolTip</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="property[@name = 'whatsThis']" mode="classes">
        <class>QWhatsThis</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="property[@name = 'database']" mode="classes">
        <class>QSqlDatabase</class>
        <class>QSqlCursor</class>
        <xsl:apply-templates mode="classes"/>
    </xsl:template>

    <xsl:template match="text()|@*" mode="classes"/>
    
    <!--
      ** End of mode 'classes'
      -->

    <!--
      ** A mode to get classes corresponding to the tag names. This templates
      ** do not recurse and return a simple text value
      -->
    <xsl:template match="action" mode="toClass">
        <xsl:text>QAction</xsl:text>
    </xsl:template>
    <xsl:template match="actiongroup" mode="toClass">
        <xsl:text>QActionGroup</xsl:text>
    </xsl:template>
    <xsl:template match="grid" mode="toClass">
        <xsl:text>QGridLayout</xsl:text>
    </xsl:template>
    <xsl:template match="hbox" mode="toClass">
        <xsl:text>QHBoxLayout</xsl:text>
    </xsl:template>
    <xsl:template match="iconset" mode="toClass">
        <xsl:text>QIconSet</xsl:text>
    </xsl:template>
    <xsl:template match="menubar" mode="toClass">
        <xsl:text>QMenuBar</xsl:text>
    </xsl:template>
    <xsl:template match="pixmap" mode="toClass">
        <xsl:text>QPixmap</xsl:text>
    </xsl:template>
    <xsl:template match="spacer" mode="toClass">
        <xsl:text>QSpacerItem</xsl:text>
    </xsl:template>
    <xsl:template match="toolbar" mode="toClass">
        <xsl:text>QToolBar</xsl:text>
    </xsl:template>
    <xsl:template match="vbox" mode="toClass">
        <xsl:text>QVBoxLayout</xsl:text>
    </xsl:template>
    <xsl:template match="widget" mode="toClass">
        <xsl:choose>
            <xsl:when test="@class = 'QLayoutWidget'">
                <class>QWidget</class>
            </xsl:when>
            <xsl:otherwise>
                <class><xsl:value-of select="@class"/></class>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="*" mode="toClass">
        <xsl:message terminate="yes">Upps! Which class? <xsl:value-of select="name(.)"/></xsl:message>
    </xsl:template>
    
</xsl:stylesheet>