Browse Source

Allow QTimeEdit to be instantiated from XML

Neal Wilson 8 years ago
parent
commit
094dee3aa0
1 changed files with 43 additions and 0 deletions
  1. 43
    0
      src/typica.w

+ 43
- 0
src/typica.w View File

4571
                          QStack<QLayout *> *layoutStack);
4571
                          QStack<QLayout *> *layoutStack);
4572
 void addSpinBoxToLayout(QDomElement element, QStack<QWidget *> *widgetStack,
4572
 void addSpinBoxToLayout(QDomElement element, QStack<QWidget *> *widgetStack,
4573
                         QStack<QLayout *> *layoutStack);
4573
                         QStack<QLayout *> *layoutStack);
4574
+void addTimeEditToLayout(QDomElement element, QStack<QWidget *> *widgetStack,
4575
+                         QStack<QLayout *> *layoutStack);
4574
 
4576
 
4575
 @ The functions for creating windows must be made available to the scripting
4577
 @ The functions for creating windows must be made available to the scripting
4576
 engine.
4578
 engine.
5050
             {
5052
             {
5051
                 addCalendarToLayout(currentElement, widgetStack, layoutStack);
5053
                 addCalendarToLayout(currentElement, widgetStack, layoutStack);
5052
             }
5054
             }
5055
+            else if(currentElement.tagName() == "timeedit")
5056
+            {
5057
+	            addTimeEditToLayout(currentElement, widgetStack, layoutStack);
5058
+            }
5053
             else if(currentElement.tagName() == "decoration")
5059
             else if(currentElement.tagName() == "decoration")
5054
             {
5060
             {
5055
                 addDecorationToLayout(currentElement, widgetStack,
5061
                 addDecorationToLayout(currentElement, widgetStack,
6203
 QScriptValue QDateTimeEdit_year(QScriptContext *context, QScriptEngine *engine);
6209
 QScriptValue QDateTimeEdit_year(QScriptContext *context, QScriptEngine *engine);
6204
 QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext *context, QScriptEngine *engine);
6210
 QScriptValue QDateTimeEdit_setToCurrentTime(QScriptContext *context, QScriptEngine *engine);
6205
 
6211
 
6212
+@ Sometimes it can be useful to allow editing a time or duration value without
6213
+a date field. For this, a |QTimeEdit| can be used.
6214
+
6215
+@<Functions for scripting@>=
6216
+void addTimeEditToLayout(QDomElement element, QStack<QWidget *> *,@|
6217
+                         QStack<QLayout *> *layoutStack)
6218
+{
6219
+	QTimeEdit *edit = new QTimeEdit;
6220
+	if(element.hasAttribute("displayFormat"))
6221
+	{
6222
+		edit->setDisplayFormat(element.attribute("displayFormat"));
6223
+	}
6224
+	else
6225
+	{
6226
+		edit->setDisplayFormat("mm:ss.zzz");
6227
+	}
6228
+	if(element.hasAttribute("id"))
6229
+	{
6230
+		edit->setObjectName(element.attribute("id"));
6231
+	}
6232
+	QBoxLayout *layout = qobject_cast<QBoxLayout *>(layoutStack->top());
6233
+	layout->addWidget(edit);
6234
+}
6235
+
6236
+@ Additional properties are added as a |QTimeEdit| is a |QDateTimeEdit|.
6237
+
6238
+@<Functions for scripting@>=
6239
+void setQTimeEditProperties(QScriptValue value, QScriptEngine *engine)
6240
+{
6241
+	setQDateTimeEditProperties(value, engine);
6242
+}
6243
+
6244
+@ A function prototype is needed.
6245
+
6246
+@<Function prototypes for scripting@>=
6247
+void setQTimeEditProperties(QScriptValue value, QScriptEngine *engine);
6248
+
6206
 @ In order to get to objects created from the XML description, it is necessary
6249
 @ In order to get to objects created from the XML description, it is necessary
6207
 to provide a function that can be called to retrieve children of a given widget.
6250
 to provide a function that can be called to retrieve children of a given widget.
6208
 When providing such an object to the script, it is necessary to determine the
6251
 When providing such an object to the script, it is necessary to determine the

Loading…
Cancel
Save