mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-20 00:41:23 +00:00
* allow searching for ratings
* minor general cleanups svn path=/trunk/KDE/kdebase/apps/; revision=1048809
This commit is contained in:
parent
3d7b54b21a
commit
041a2f0594
|
@ -91,7 +91,14 @@ QString SearchCriterionSelector::toString() const
|
||||||
|
|
||||||
QString criterion = comp.prefix + descr.identifier() + comp.operation;
|
QString criterion = comp.prefix + descr.identifier() + comp.operation;
|
||||||
if (!m_valueWidget->value().isEmpty()) {
|
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;
|
return criterion;
|
||||||
}
|
}
|
||||||
|
@ -173,6 +180,8 @@ void SearchCriterionSelector::createDescriptions()
|
||||||
"lastModified",
|
"lastModified",
|
||||||
dateComps,
|
dateComps,
|
||||||
dateValue);
|
dateValue);
|
||||||
|
Q_ASSERT(static_cast<int>(SearchCriterionSelector::Date) == 0);
|
||||||
|
m_descriptions.append(date);
|
||||||
|
|
||||||
// add "Size" description
|
// add "Size" description
|
||||||
QList<SearchCriterionDescription::Comparator> sizeComps = defaultComps;
|
QList<SearchCriterionDescription::Comparator> sizeComps = defaultComps;
|
||||||
|
@ -184,11 +193,14 @@ void SearchCriterionSelector::createDescriptions()
|
||||||
"contentSize",
|
"contentSize",
|
||||||
sizeComps,
|
sizeComps,
|
||||||
sizeValue);
|
sizeValue);
|
||||||
|
Q_ASSERT(static_cast<int>(SearchCriterionSelector::Size) == 1);
|
||||||
|
m_descriptions.append(size);
|
||||||
|
|
||||||
// add "Tag" description
|
// add "Tag" description
|
||||||
QList<SearchCriterionDescription::Comparator> tagComps;
|
QList<SearchCriterionDescription::Comparator> tagComps;
|
||||||
tagComps.append(SearchCriterionDescription::Comparator(i18nc("@label All (tags)", "All")));
|
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* tagValue = new TagValue(this);
|
||||||
tagValue->hide();
|
tagValue->hide();
|
||||||
|
@ -196,14 +208,22 @@ void SearchCriterionSelector::createDescriptions()
|
||||||
"tag",
|
"tag",
|
||||||
tagComps,
|
tagComps,
|
||||||
tagValue);
|
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);
|
Q_ASSERT(static_cast<int>(SearchCriterionSelector::Tag) == 2);
|
||||||
m_descriptions.append(date);
|
|
||||||
m_descriptions.append(size);
|
|
||||||
m_descriptions.append(tag);
|
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
|
// add all descriptions to the combo box and connect the value widgets
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (const SearchCriterionDescription& desc, m_descriptions) {
|
foreach (const SearchCriterionDescription& desc, m_descriptions) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ class SearchCriterionSelector : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Type { Date, Size, Tag };
|
enum Type { Date, Size, Tag, Rating };
|
||||||
|
|
||||||
SearchCriterionSelector(Type type, QWidget* parent = 0);
|
SearchCriterionSelector(Type type, QWidget* parent = 0);
|
||||||
virtual ~SearchCriterionSelector();
|
virtual ~SearchCriterionSelector();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <klineedit.h>
|
#include <klineedit.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
|
|
||||||
|
#include <nepomuk/kratingwidget.h>
|
||||||
#include <nepomuk/tag.h>
|
#include <nepomuk/tag.h>
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
@ -71,12 +72,8 @@ QString DateValue::value() const
|
||||||
|
|
||||||
void DateValue::initializeValue(const QString& valueType)
|
void DateValue::initializeValue(const QString& valueType)
|
||||||
{
|
{
|
||||||
if (valueType.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDate date;
|
QDate date;
|
||||||
if (valueType == "today") {
|
if (valueType.isEmpty() || (valueType == "today")) {
|
||||||
date = QDate::currentDate();
|
date = QDate::currentDate();
|
||||||
} else if (valueType == "thisWeek") {
|
} else if (valueType == "thisWeek") {
|
||||||
const QDate today = QDate::currentDate();
|
const QDate today = QDate::currentDate();
|
||||||
|
@ -173,4 +170,26 @@ QString SizeValue::value() const
|
||||||
return QString();
|
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"
|
#include "searchcriterionvalue.moc"
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class KDateWidget;
|
class KDateWidget;
|
||||||
|
class KRatingWidget;
|
||||||
class KLineEdit;
|
class KLineEdit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,4 +112,18 @@ public:
|
||||||
QComboBox* m_units;
|
QComboBox* m_units;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @brief Allows to input a rating value as search criterion. */
|
||||||
|
class RatingValue : public SearchCriterionValue
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
RatingValue(QWidget* parent = 0);
|
||||||
|
virtual ~RatingValue();
|
||||||
|
virtual QString value() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
KRatingWidget* m_ratingWidget;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // SEARCHCRITERIONVALUE_H
|
#endif // SEARCHCRITERIONVALUE_H
|
||||||
|
|
Loading…
Reference in a new issue