┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/search/searchcriterionvalue.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-11-13 22:48:07 +0000
committerPeter Penz <[email protected]>2009-11-13 22:48:07 +0000
commit3d7b54b21a47e98d1d02c7d21061a6bd43b8d1c7 (patch)
tree24a1db2c4b375d6f4d3ecc4ef2a4de6506374134 /src/search/searchcriterionvalue.cpp
parentbd30bb6ca98374b37db20d14a41542c21acdd5e0 (diff)
Implemented initialization of value-widgets. This allows e.g. to apply dates like "today", "last week", ... to the date-value-widgets just by specifying a search criterion.
svn path=/trunk/KDE/kdebase/apps/; revision=1048771
Diffstat (limited to 'src/search/searchcriterionvalue.cpp')
-rw-r--r--src/search/searchcriterionvalue.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/search/searchcriterionvalue.cpp b/src/search/searchcriterionvalue.cpp
index 7bf83e94f..7d8e2d8cd 100644
--- a/src/search/searchcriterionvalue.cpp
+++ b/src/search/searchcriterionvalue.cpp
@@ -42,6 +42,11 @@ SearchCriterionValue::~SearchCriterionValue()
{
}
+void SearchCriterionValue::initializeValue(const QString& valueType)
+{
+ Q_UNUSED(valueType);
+}
+
// -------------------------------------------------------------------------
DateValue::DateValue(QWidget* parent) :
@@ -64,6 +69,31 @@ QString DateValue::value() const
return m_dateWidget->date().toString(Qt::ISODate);
}
+void DateValue::initializeValue(const QString& valueType)
+{
+ if (valueType.isEmpty()) {
+ return;
+ }
+
+ QDate date;
+ if (valueType == "today") {
+ date = QDate::currentDate();
+ } else if (valueType == "thisWeek") {
+ const QDate today = QDate::currentDate();
+ const int dayOfWeek = today.dayOfWeek();
+ date = today.addDays(-dayOfWeek);
+ } else if (valueType == "thisMonth") {
+ const QDate today = QDate::currentDate();
+ date = QDate(today.year(), today.month(), 1);
+ } else if (valueType == "thisYear") {
+ date = QDate(QDate::currentDate().year(), 1, 1);
+ } else {
+ // unknown value-type
+ Q_ASSERT(false);
+ }
+ m_dateWidget->setDate(date);
+}
+
// -------------------------------------------------------------------------
TagValue::TagValue(QWidget* parent) :