QString criterion = comp.prefix + descr.identifier() + comp.operation;
if (!m_valueWidget->value().isEmpty()) {
- criterion += '"' + m_valueWidget->value() + '"';
+ const QString value = m_valueWidget->value();
+ if (value.contains(' ')) {
+ criterion += '"' + value + '"';
+ } else {
+ // Don't surround the value by " if no space is part of the value.
+ // This increases the readability of the search-URL.
+ criterion += value;
+ }
}
return criterion;
}
"lastModified",
dateComps,
dateValue);
+ Q_ASSERT(static_cast<int>(SearchCriterionSelector::Date) == 0);
+ m_descriptions.append(date);
// add "Size" description
QList<SearchCriterionDescription::Comparator> sizeComps = defaultComps;
"contentSize",
sizeComps,
sizeValue);
+ Q_ASSERT(static_cast<int>(SearchCriterionSelector::Size) == 1);
+ m_descriptions.append(size);
// add "Tag" description
QList<SearchCriterionDescription::Comparator> tagComps;
tagComps.append(SearchCriterionDescription::Comparator(i18nc("@label All (tags)", "All")));
- tagComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "Equal to"), ":"));
+ tagComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "Equal to"), ":", "+"));
+ tagComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "Not Equal to"), ":", "-"));
TagValue* tagValue = new TagValue(this);
tagValue->hide();
"tag",
tagComps,
tagValue);
-
- Q_ASSERT(static_cast<int>(SearchCriterionSelector::Date) == 0);
- Q_ASSERT(static_cast<int>(SearchCriterionSelector::Size) == 1);
Q_ASSERT(static_cast<int>(SearchCriterionSelector::Tag) == 2);
- m_descriptions.append(date);
- m_descriptions.append(size);
m_descriptions.append(tag);
+ // add "Rating" description
+ QList<SearchCriterionDescription::Comparator> ratingComps = defaultComps;
+ ratingComps.insert(0, SearchCriterionDescription::Comparator(i18nc("@label Any (rating)", "Any")));
+
+ RatingValue* ratingValue = new RatingValue(this);
+ ratingValue->hide();
+ SearchCriterionDescription rating(i18nc("@label", "Rating:"),
+ "rating",
+ ratingComps,
+ ratingValue);
+ Q_ASSERT(static_cast<int>(SearchCriterionSelector::Rating) == 3);
+ m_descriptions.append(rating);
+
// add all descriptions to the combo box and connect the value widgets
int i = 0;
foreach (const SearchCriterionDescription& desc, m_descriptions) {
#include <klineedit.h>
#include <klocale.h>
+#include <nepomuk/kratingwidget.h>
#include <nepomuk/tag.h>
#include <QComboBox>
void DateValue::initializeValue(const QString& valueType)
{
- if (valueType.isEmpty()) {
- return;
- }
-
- QDate date;
- if (valueType == "today") {
+ QDate date;
+ if (valueType.isEmpty() || (valueType == "today")) {
date = QDate::currentDate();
} else if (valueType == "thisWeek") {
const QDate today = QDate::currentDate();
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"