]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/searchcriterionvalue.cpp
I'm very sorry for breaking the build: I forgot to add the new files :-(
[dolphin.git] / src / search / searchcriterionvalue.cpp
index 7bf83e94fff19c347da305817b40dda270cb7651..9db19364b5693f2d7a32bd4982b8002fe3d693c3 100644 (file)
@@ -24,6 +24,7 @@
 #include <klineedit.h>
 #include <klocale.h>
 
+#include <nepomuk/kratingwidget.h>
 #include <nepomuk/tag.h>
 
 #include <QComboBox>
@@ -42,6 +43,11 @@ SearchCriterionValue::~SearchCriterionValue()
 {
 }
 
+void SearchCriterionValue::initializeValue(const QString& valueType)
+{
+    Q_UNUSED(valueType);
+}
+
 // -------------------------------------------------------------------------
 
 DateValue::DateValue(QWidget* parent) :
@@ -64,6 +70,27 @@ QString DateValue::value() const
     return m_dateWidget->date().toString(Qt::ISODate);
 }
 
+void DateValue::initializeValue(const QString& valueType)
+{
+    QDate date;    
+    if (valueType.isEmpty() || (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) :
@@ -143,4 +170,26 @@ QString SizeValue::value() const
     return QString();
 }
 
+// -------------------------------------------------------------------------
+
+RatingValue::RatingValue(QWidget* parent) :
+    SearchCriterionValue(parent),
+    m_ratingWidget(0)
+{
+    m_ratingWidget = new KRatingWidget(this);
+
+    QHBoxLayout* layout = new QHBoxLayout(this);
+    layout->setMargin(0);
+    layout->addWidget(m_ratingWidget);
+}
+
+RatingValue::~RatingValue()
+{
+}
+
+QString RatingValue::value() const
+{
+    return QString::number(m_ratingWidget->rating());
+}
+
 #include "searchcriterionvalue.moc"