]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinfacetswidget.h
Build with QT_NO_KEYWORDS
[dolphin.git] / src / search / dolphinfacetswidget.h
1 /*
2 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef DOLPHINFACETSWIDGET_H
8 #define DOLPHINFACETSWIDGET_H
9
10 #include <QWidget>
11 #include <KCoreDirLister>
12
13 class QComboBox;
14 class QDate;
15 class QEvent;
16 class QToolButton;
17
18 /**
19 * @brief Allows to filter search-queries by facets.
20 *
21 * TODO: The current implementation is a temporary
22 * workaround for the 4.9 release and represents no
23 * real facets-implementation yet: There have been
24 * some Dolphin specific user-interface and interaction
25 * issues since 4.6 by embedding the Nepomuk facet-widget
26 * into a QDockWidget (this is unrelated to the
27 * Nepomuk facet-widget itself). Now in combination
28 * with the search-shortcuts in the Places Panel some
29 * existing issues turned into real showstoppers.
30 *
31 * So the longterm plan is to use the Nepomuk facets
32 * again as soon as possible.
33 */
34 class DolphinFacetsWidget : public QWidget
35 {
36 Q_OBJECT
37
38 public:
39 explicit DolphinFacetsWidget(QWidget* parent = nullptr);
40 ~DolphinFacetsWidget() override;
41
42 QStringList searchTerms() const;
43 QString facetType() const;
44
45 bool isSearchTerm(const QString& term) const;
46 void setSearchTerm(const QString& term);
47 void resetSearchTerms();
48
49 void setFacetType(const QString& type);
50
51 Q_SIGNALS:
52 void facetChanged();
53
54 protected:
55 void changeEvent(QEvent* event) override;
56
57 private Q_SLOTS:
58 void updateTagsMenu();
59 void updateTagsMenuItems(const QUrl&, const KFileItemList& items);
60
61 private:
62 void setRating(const int stars);
63 void setTimespan(const QDate& date);
64 void addSearchTag(const QString& tag);
65 void removeSearchTag(const QString& tag);
66
67 void initComboBox(QComboBox* combo);
68 void updateTagsSelector();
69
70 private:
71 QComboBox* m_typeSelector;
72 QComboBox* m_dateSelector;
73 QComboBox* m_ratingSelector;
74 QToolButton* m_tagsSelector;
75
76 QStringList m_searchTags;
77 KCoreDirLister m_tagsLister;
78 };
79
80 #endif