]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/searchcriterionvalue.cpp
Get back names, and use "using" keyword to keep GCC silent on "method foo on base...
[dolphin.git] / src / search / searchcriterionvalue.cpp
index 7bf83e94fff19c347da305817b40dda270cb7651..065100e4ed626905ffb7708c55265094b3170576 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) :
@@ -59,9 +65,31 @@ DateValue::~DateValue()
 {
 }
 
-QString DateValue::value() const
+Nepomuk::Query::LiteralTerm DateValue::value() const
 {
-    return m_dateWidget->date().toString(Qt::ISODate);
+    const QDateTime dateTime(m_dateWidget->date());
+    return Nepomuk::Query::LiteralTerm(dateTime);
+}
+
+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);
 }
 
 // -------------------------------------------------------------------------
@@ -85,9 +113,9 @@ TagValue::~TagValue()
 {
 }
 
-QString TagValue::value() const
+Nepomuk::Query::LiteralTerm TagValue::value() const
 {
-    return m_tags->currentText();
+    return Nepomuk::Query::LiteralTerm(m_tags->currentText());
 }
 
 void TagValue::showEvent(QShowEvent* event)
@@ -138,9 +166,31 @@ SizeValue::~SizeValue()
 {
 }
 
-QString SizeValue::value() const
+Nepomuk::Query::LiteralTerm SizeValue::value() const
+{
+    return Nepomuk::Query::LiteralTerm(); // TODO
+}
+
+// -------------------------------------------------------------------------
+
+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()
+{
+}
+
+Nepomuk::Query::LiteralTerm RatingValue::value() const
 {
-    return QString();
+    return Nepomuk::Query::LiteralTerm(m_ratingWidget->rating());
 }
 
 #include "searchcriterionvalue.moc"