Changeset View
Changeset View
Standalone View
Standalone View
src/search/dolphinfacetswidget.cpp
Show All 29 Lines | |||||
30 | #include <QMenu> | 30 | #include <QMenu> | ||
31 | #include <QToolButton> | 31 | #include <QToolButton> | ||
32 | 32 | | |||
33 | DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) : | 33 | DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) : | ||
34 | QWidget(parent), | 34 | QWidget(parent), | ||
35 | m_typeSelector(nullptr), | 35 | m_typeSelector(nullptr), | ||
36 | m_dateSelector(nullptr), | 36 | m_dateSelector(nullptr), | ||
37 | m_ratingSelector(nullptr), | 37 | m_ratingSelector(nullptr), | ||
38 | m_tagsSelector(nullptr) | 38 | m_tagsSelector(nullptr) | ||
meven: Maybe check that the first and last characters are quotes first before removing "
a tag could… | |||||
39 | { | 39 | { | ||
40 | m_typeSelector = new QComboBox(this); | 40 | m_typeSelector = new QComboBox(this); | ||
41 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("none")), i18nc("@item:inlistbox", "Any Type"), QString()); | 41 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("none")), i18nc("@item:inlistbox", "Any Type"), QString()); | ||
42 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("inode-directory")), i18nc("@item:inlistbox", "Folders") , QStringLiteral("Folder")); | 42 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("inode-directory")), i18nc("@item:inlistbox", "Folders") , QStringLiteral("Folder")); | ||
43 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("text-x-generic")), i18nc("@item:inlistbox", "Documents") , QStringLiteral("Document")); | 43 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("text-x-generic")), i18nc("@item:inlistbox", "Documents") , QStringLiteral("Document")); | ||
44 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("image-x-generic")), i18nc("@item:inlistbox", "Images") , QStringLiteral("Image")); | 44 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("image-x-generic")), i18nc("@item:inlistbox", "Images") , QStringLiteral("Image")); | ||
45 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("audio-x-generic")), i18nc("@item:inlistbox", "Audio Files"), QStringLiteral("Audio")); | 45 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("audio-x-generic")), i18nc("@item:inlistbox", "Audio Files"), QStringLiteral("Audio")); | ||
46 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("video-x-generic")), i18nc("@item:inlistbox", "Videos") , QStringLiteral("Video")); | 46 | m_typeSelector->addItem(QIcon::fromTheme(QStringLiteral("video-x-generic")), i18nc("@item:inlistbox", "Videos") , QStringLiteral("Video")); | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 119 | { | |||
126 | 126 | | |||
127 | if (m_dateSelector->currentIndex() > 0) { | 127 | if (m_dateSelector->currentIndex() > 0) { | ||
128 | const QDate date = m_dateSelector->currentData().toDate(); | 128 | const QDate date = m_dateSelector->currentData().toDate(); | ||
129 | terms << QStringLiteral("modified>=%1").arg(date.toString(Qt::ISODate)); | 129 | terms << QStringLiteral("modified>=%1").arg(date.toString(Qt::ISODate)); | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | if (!m_searchTags.isEmpty()) { | 132 | if (!m_searchTags.isEmpty()) { | ||
133 | for (auto const &tag : m_searchTags) { | 133 | for (auto const &tag : m_searchTags) { | ||
134 | if (tag.contains(QLatin1Char(' '))) { | ||||
135 | terms << QStringLiteral("tag:\"%1\"").arg(tag); | ||||
136 | } else { | ||||
134 | terms << QStringLiteral("tag:%1").arg(tag); | 137 | terms << QStringLiteral("tag:%1").arg(tag); | ||
135 | } | 138 | } | ||
136 | } | 139 | } | ||
140 | } | ||||
137 | 141 | | |||
138 | return terms; | 142 | return terms; | ||
139 | } | 143 | } | ||
140 | 144 | | |||
141 | QString DolphinFacetsWidget::facetType() const | 145 | QString DolphinFacetsWidget::facetType() const | ||
142 | { | 146 | { | ||
143 | return m_typeSelector->currentData().toString(); | 147 | return m_typeSelector->currentData().toString(); | ||
144 | } | 148 | } | ||
Show All 11 Lines | 159 | if (term.startsWith(searchToken)) { | |||
156 | return true; | 160 | return true; | ||
157 | } | 161 | } | ||
158 | } | 162 | } | ||
159 | return false; | 163 | return false; | ||
160 | } | 164 | } | ||
161 | 165 | | |||
162 | void DolphinFacetsWidget::setSearchTerm(const QString& term) | 166 | void DolphinFacetsWidget::setSearchTerm(const QString& term) | ||
163 | { | 167 | { | ||
164 | if (term.startsWith(QLatin1String("modified>="))) { | 168 | if (term.startsWith(QLatin1String("modified>="))) { | ||
165 | const QString value = term.mid(10); | 169 | const QString value = term.mid(10); | ||
IMHO the new helper function should only strip the quotes. I'd keep the QString::mid(10) logic here, because it's clear that we are removing the modified>= prefix. elvisangelaccio: IMHO the new helper function should only strip the quotes. I'd keep the `QString::mid(10)`… | |||||
Done. It's more clear indeed. iasensio: Done. It's more clear indeed.
I just kept `stripQuotes()` for the `tags`case, since it's not… | |||||
166 | const QDate date = QDate::fromString(value, Qt::ISODate); | 170 | const QDate date = QDate::fromString(value, Qt::ISODate); | ||
167 | setTimespan(date); | 171 | setTimespan(date); | ||
168 | } else if (term.startsWith(QLatin1String("rating>="))) { | 172 | } else if (term.startsWith(QLatin1String("rating>="))) { | ||
169 | const QString value = term.mid(8); | 173 | const QString value = term.mid(8); | ||
170 | const int stars = value.toInt() / 2; | 174 | const int stars = value.toInt() / 2; | ||
171 | setRating(stars); | 175 | setRating(stars); | ||
172 | } else if (term.startsWith(QLatin1String("tag:")) || | 176 | } else if (term.startsWith(QLatin1String("tag:")) || | ||
173 | term.startsWith(QLatin1String("tag="))) { | 177 | term.startsWith(QLatin1String("tag="))) { | ||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |
Maybe check that the first and last characters are quotes first before removing "
a tag could be 'my_documents"' (unlikely but...)