|
@@ -43,6 +43,8 @@ class DateRangeSelector : public QWidget
|
43
|
43
|
DateRangeSelector(QWidget *parent = NULL);
|
44
|
44
|
void setCustomRange(QVariant range);
|
45
|
45
|
Q_INVOKABLE QVariant currentRange();@/
|
|
46
|
+ @[public slots@]:@/
|
|
47
|
+ void setCurrentIndex(int index);@/
|
46
|
48
|
@[signals@]:@/
|
47
|
49
|
void rangeUpdated(QVariant);
|
48
|
50
|
@[private slots@]:@/
|
|
@@ -397,6 +399,14 @@ QVariant DateRangeSelector::currentRange()
|
397
|
399
|
return quickSelector->itemData(lastIndex);
|
398
|
400
|
}
|
399
|
401
|
|
|
402
|
+@ Similarly, a method is provided to set the current index of the combo box.
|
|
403
|
+
|
|
404
|
+@<DateRangeSelector implementation@>=
|
|
405
|
+void DateRangeSelector::setCurrentIndex(int index)
|
|
406
|
+{
|
|
407
|
+ quickSelector->setCurrentIndex(index);
|
|
408
|
+}
|
|
409
|
+
|
400
|
410
|
@ To use this new control in Typica, we should provide a way to create it from
|
401
|
411
|
the XML description of a window.
|
402
|
412
|
|
|
@@ -407,10 +417,8 @@ else if(currentElement.tagName() == "daterange")
|
407
|
417
|
}
|
408
|
418
|
|
409
|
419
|
@ The method for adding a date range selector to a layout is currently trivial.
|
410
|
|
-Additional features may be added to this in the future to provide better
|
411
|
|
-support for specifying an initial default selection. At present the only
|
412
|
|
-supported attribute is the |"id"| attribute which is used to make the widget
|
413
|
|
-accessible to scripts.
|
|
420
|
+The |"id"| attribute is supported as usual, as is an |"initial"| attribute for
|
|
421
|
+setting the combo box index.
|
414
|
422
|
|
415
|
423
|
@<Functions for scripting@>=
|
416
|
424
|
void addDateRangeToLayout(QDomElement element, QStack<QWidget *> *,@|
|
|
@@ -421,6 +429,10 @@ void addDateRangeToLayout(QDomElement element, QStack<QWidget *> *,@|
|
421
|
429
|
{
|
422
|
430
|
widget->setObjectName(element.attribute("id"));
|
423
|
431
|
}
|
|
432
|
+ if(element.hasAttribute("initial"))
|
|
433
|
+ {
|
|
434
|
+ widget->setCurrentIndex(element.attribute("initial").toInt());
|
|
435
|
+ }
|
424
|
436
|
QBoxLayout *layout = qobject_cast<QBoxLayout *>(layoutStack->top());
|
425
|
437
|
layout->addWidget(widget);
|
426
|
438
|
}
|