Browse Source

Add Lifetime option to date range selector

Neal Wilson 11 years ago
parent
commit
066e2f90a4
1 changed files with 29 additions and 1 deletions
  1. 29
    1
      src/daterangeselector.w

+ 29
- 1
src/daterangeselector.w View File

@@ -44,7 +44,9 @@ class DateRangeSelector : public QWidget
44 44
 		void setCustomRange(QVariant range);
45 45
 		Q_INVOKABLE QVariant currentRange();@/
46 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 50
 	@[signals@]:@/
49 51
 		void rangeUpdated(QVariant);
50 52
 	@[private slots@]:@/
@@ -301,6 +303,7 @@ quickSelector->addItem("Last 365 Days", QVariant(QStringList() <<
301 303
 	currentDate.addDays(-364).toString(Qt::ISODate) <<
302 304
 	currentDate.toString(Qt::ISODate)));
303 305
 quickSelector->insertSeparator(quickSelector->count());
306
+quickSelector->addItem("Lifetime");
304 307
 quickSelector->addItem("Custom");
305 308
 
306 309
 @ Special handling of the Custom range is required because it is possible to
@@ -407,6 +410,31 @@ void DateRangeSelector::setCurrentIndex(int index)
407 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 438
 @ To use this new control in Typica, we should provide a way to create it from
411 439
 the XML description of a window.
412 440
 

Loading…
Cancel
Save