瀏覽代碼

Add Lifetime option to date range selector

Neal Wilson 10 年之前
父節點
當前提交
066e2f90a4
共有 1 個文件被更改,包括 29 次插入1 次删除
  1. 29
    1
      src/daterangeselector.w

+ 29
- 1
src/daterangeselector.w 查看文件

44
 		void setCustomRange(QVariant range);
44
 		void setCustomRange(QVariant range);
45
 		Q_INVOKABLE QVariant currentRange();@/
45
 		Q_INVOKABLE QVariant currentRange();@/
46
 	@[public slots@]:@/
46
 	@[public slots@]:@/
47
-		void setCurrentIndex(int index);@/
47
+		void setCurrentIndex(int index);
48
+		void setLifetimeRange(QString startDate, QString endDate);
49
+		void removeIndex(int index);@/
48
 	@[signals@]:@/
50
 	@[signals@]:@/
49
 		void rangeUpdated(QVariant);
51
 		void rangeUpdated(QVariant);
50
 	@[private slots@]:@/
52
 	@[private slots@]:@/
301
 	currentDate.addDays(-364).toString(Qt::ISODate) <<
303
 	currentDate.addDays(-364).toString(Qt::ISODate) <<
302
 	currentDate.toString(Qt::ISODate)));
304
 	currentDate.toString(Qt::ISODate)));
303
 quickSelector->insertSeparator(quickSelector->count());
305
 quickSelector->insertSeparator(quickSelector->count());
306
+quickSelector->addItem("Lifetime");
304
 quickSelector->addItem("Custom");
307
 quickSelector->addItem("Custom");
305
 
308
 
306
 @ Special handling of the Custom range is required because it is possible to
309
 @ Special handling of the Custom range is required because it is possible to
407
 	quickSelector->setCurrentIndex(index);
410
 	quickSelector->setCurrentIndex(index);
408
 }
411
 }
409
 
412
 
413
+@ The Lifetime range is handled somewhat differently from other ranges as there
414
+is no general way to know what that range should be without making unsafe
415
+assumptions. As such, reports are expected to remove the option, provide a
416
+sensible range for it, or handle this selection in a special case. The expected
417
+source of the lifetime date range is the result of a database query so a method
418
+is provided that accepts string representations of the dates. Note that this
419
+method must not be called if the Lifetime option is no longer the second to
420
+last option in the combo box.
421
+
422
+@<DateRangeSelector implementation@>=
423
+void DateRangeSelector::setLifetimeRange(QString startDate, QString endDate)
424
+{
425
+	quickSelector->setItemData(quickSelector->count() - 2,
426
+		QVariant(QStringList() << startDate << endDate));
427
+}
428
+
429
+@ The |removeIndex()| method is intended for removing the Lifetime option in
430
+cases where this is not supported. Use of this method is strongly discouraged.
431
+
432
+@<DateRangeSelector implementation@>=
433
+void DateRangeSelector::removeIndex(int index)
434
+{
435
+	quickSelector->removeItem(index);
436
+}
437
+
410
 @ To use this new control in Typica, we should provide a way to create it from
438
 @ To use this new control in Typica, we should provide a way to create it from
411
 the XML description of a window.
439
 the XML description of a window.
412
 
440
 

Loading…
取消
儲存