]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinfacetswidget.h
[dolphin/search] Search by (multiple) tags
[dolphin.git] / src / search / dolphinfacetswidget.h
1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef DOLPHINFACETSWIDGET_H
21 #define DOLPHINFACETSWIDGET_H
22
23 #include <QWidget>
24 #include <KCoreDirLister>
25
26 class QComboBox;
27 class QDate;
28 class QEvent;
29 class QToolButton;
30
31 /**
32 * @brief Allows to filter search-queries by facets.
33 *
34 * TODO: The current implementation is a temporary
35 * workaround for the 4.9 release and represents no
36 * real facets-implementation yet: There have been
37 * some Dolphin specific user-interface and interaction
38 * issues since 4.6 by embedding the Nepomuk facet-widget
39 * into a QDockWidget (this is unrelated to the
40 * Nepomuk facet-widget itself). Now in combination
41 * with the search-shortcuts in the Places Panel some
42 * existing issues turned into real showstoppers.
43 *
44 * So the longterm plan is to use the Nepomuk facets
45 * again as soon as possible.
46 */
47 class DolphinFacetsWidget : public QWidget
48 {
49 Q_OBJECT
50
51 public:
52 explicit DolphinFacetsWidget(QWidget* parent = nullptr);
53 ~DolphinFacetsWidget() override;
54
55 void resetOptions();
56
57 QString ratingTerm() const;
58 QString facetType() const;
59
60 bool isRatingTerm(const QString& term) const;
61 void setRatingTerm(const QString& term);
62
63 void setFacetType(const QString& type);
64
65 signals:
66 void facetChanged();
67
68 protected:
69 void changeEvent(QEvent* event) override;
70
71 private slots:
72 void updateTagsMenu();
73 void updateTagsMenuItems(const QUrl&, const KFileItemList& items);
74
75 private:
76 void setRating(const int stars);
77 void setTimespan(const QDate& date);
78 void addSearchTag(const QString& tag);
79 void removeSearchTag(const QString& tag);
80
81 void initComboBox(QComboBox* combo);
82 void updateTagsSelector();
83
84 private:
85 QComboBox* m_typeSelector;
86 QComboBox* m_dateSelector;
87 QComboBox* m_ratingSelector;
88 QToolButton* m_tagsSelector;
89
90 QStringList m_searchTags;
91 KCoreDirLister m_tagsLister;
92 };
93
94 #endif