]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinfacetswidget.h
Apply 1 suggestion(s) to 1 file(s)
[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 <KCoreDirLister>
11 #include <QWidget>
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 QSize minimumSizeHint() const override;
52
53 Q_SIGNALS:
54 void facetChanged();
55
56 protected:
57 void changeEvent(QEvent *event) override;
58
59 private Q_SLOTS:
60 void updateTagsMenu();
61 void updateTagsMenuItems(const QUrl &, const KFileItemList &items);
62
63 private:
64 void setRating(const int stars);
65 void setTimespan(const QDate &date);
66 void addSearchTag(const QString &tag);
67 void removeSearchTag(const QString &tag);
68 void resetSearchTags();
69
70 void initComboBox(QComboBox *combo);
71 void updateTagsSelector();
72
73 private:
74 QComboBox *m_typeSelector;
75 QComboBox *m_dateSelector;
76 QComboBox *m_ratingSelector;
77 QToolButton *m_tagsSelector;
78
79 QStringList m_searchTags;
80 KCoreDirLister m_tagsLister;
81 QAction *m_clearTagsAction;
82 };
83
84 #endif