Browse Source

Support initial date range specification in XML

Neal Wilson 11 years ago
parent
commit
c1c8cba96b
1 changed files with 16 additions and 4 deletions
  1. 16
    4
      src/daterangeselector.w

+ 16
- 4
src/daterangeselector.w View File

43
 		DateRangeSelector(QWidget *parent = NULL);
43
 		DateRangeSelector(QWidget *parent = NULL);
44
 		void setCustomRange(QVariant range);
44
 		void setCustomRange(QVariant range);
45
 		Q_INVOKABLE QVariant currentRange();@/
45
 		Q_INVOKABLE QVariant currentRange();@/
46
+	@[public slots@]:@/
47
+		void setCurrentIndex(int index);@/
46
 	@[signals@]:@/
48
 	@[signals@]:@/
47
 		void rangeUpdated(QVariant);
49
 		void rangeUpdated(QVariant);
48
 	@[private slots@]:@/
50
 	@[private slots@]:@/
397
 	return quickSelector->itemData(lastIndex);
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
 @ To use this new control in Typica, we should provide a way to create it from
410
 @ To use this new control in Typica, we should provide a way to create it from
401
 the XML description of a window.
411
 the XML description of a window.
402
 
412
 
407
 }
417
 }
408
 
418
 
409
 @ The method for adding a date range selector to a layout is currently trivial.
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
 @<Functions for scripting@>=
423
 @<Functions for scripting@>=
416
 void addDateRangeToLayout(QDomElement element, QStack<QWidget *> *,@|
424
 void addDateRangeToLayout(QDomElement element, QStack<QWidget *> *,@|
421
 	{
429
 	{
422
 		widget->setObjectName(element.attribute("id"));
430
 		widget->setObjectName(element.attribute("id"));
423
 	}
431
 	}
432
+	if(element.hasAttribute("initial"))
433
+	{
434
+		widget->setCurrentIndex(element.attribute("initial").toInt());
435
+	}
424
 	QBoxLayout *layout = qobject_cast<QBoxLayout *>(layoutStack->top());
436
 	QBoxLayout *layout = qobject_cast<QBoxLayout *>(layoutStack->top());
425
 	layout->addWidget(widget);
437
 	layout->addWidget(widget);
426
 }
438
 }

Loading…
Cancel
Save