X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ebba84fbdd1effc828f88e08966dad5982371ecc..7eeb8dba6aeba09aa3dfa7fa5f0b00840d4d8317:/src/search/searchcriterionvalue.cpp diff --git a/src/search/searchcriterionvalue.cpp b/src/search/searchcriterionvalue.cpp index 531db3e01..065100e4e 100644 --- a/src/search/searchcriterionvalue.cpp +++ b/src/search/searchcriterionvalue.cpp @@ -20,13 +20,16 @@ #include "searchcriterionvalue.h" +#include #include #include +#include #include #include -#include +#include +#include #include #include #include @@ -40,26 +43,53 @@ SearchCriterionValue::~SearchCriterionValue() { } +void SearchCriterionValue::initializeValue(const QString& valueType) +{ + Q_UNUSED(valueType); +} + // ------------------------------------------------------------------------- DateValue::DateValue(QWidget* parent) : SearchCriterionValue(parent), - m_dateEdit(0) + m_dateWidget(0) { - m_dateEdit = new QDateEdit(this); + m_dateWidget = new KDateWidget(QDate::currentDate(), this); QHBoxLayout* layout = new QHBoxLayout(this); layout->setMargin(0); - layout->addWidget(m_dateEdit); + layout->addWidget(m_dateWidget); } DateValue::~DateValue() { } -QString DateValue::value() const +Nepomuk::Query::LiteralTerm DateValue::value() const +{ + const QDateTime dateTime(m_dateWidget->date()); + return Nepomuk::Query::LiteralTerm(dateTime); +} + +void DateValue::initializeValue(const QString& valueType) { - return QString(); + 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); } // ------------------------------------------------------------------------- @@ -74,15 +104,18 @@ TagValue::TagValue(QWidget* parent) : QHBoxLayout* layout = new QHBoxLayout(this); layout->setMargin(0); layout->addWidget(m_tags); + + connect(m_tags, SIGNAL(activated(QString)), + this, SIGNAL(valueChanged(QString))); } TagValue::~TagValue() { } -QString TagValue::value() const +Nepomuk::Query::LiteralTerm TagValue::value() const { - return QString(); + return Nepomuk::Query::LiteralTerm(m_tags->currentText()); } void TagValue::showEvent(QShowEvent* event) @@ -109,6 +142,8 @@ SizeValue::SizeValue(QWidget* parent) : { m_lineEdit = new KLineEdit(this); m_lineEdit->setClearButtonShown(true); + m_lineEdit->setValidator(new QIntValidator(this)); + m_lineEdit->setAlignment(Qt::AlignRight); m_units = new QComboBox(this); // TODO: check the KByte vs. KiByte dilemma :-/ @@ -117,6 +152,10 @@ SizeValue::SizeValue(QWidget* parent) : m_units->addItem(i18nc("@label", "MByte")); m_units->addItem(i18nc("@label", "GByte")); + // set 1 MByte as default + m_lineEdit->setText("1"); + m_units->setCurrentIndex(2); + QHBoxLayout* layout = new QHBoxLayout(this); layout->setMargin(0); layout->addWidget(m_lineEdit); @@ -127,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"