File indexing completed on 2024-04-28 05:45:14
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef DOLPHINFACETSWIDGET_H 0008 #define DOLPHINFACETSWIDGET_H 0009 0010 #include <KCoreDirLister> 0011 #include <QWidget> 0012 0013 class QComboBox; 0014 class QDate; 0015 class QEvent; 0016 class QToolButton; 0017 0018 /** 0019 * @brief Allows to filter search-queries by facets. 0020 * 0021 * TODO: The current implementation is a temporary 0022 * workaround for the 4.9 release and represents no 0023 * real facets-implementation yet: There have been 0024 * some Dolphin specific user-interface and interaction 0025 * issues since 4.6 by embedding the Nepomuk facet-widget 0026 * into a QDockWidget (this is unrelated to the 0027 * Nepomuk facet-widget itself). Now in combination 0028 * with the search-shortcuts in the Places Panel some 0029 * existing issues turned into real showstoppers. 0030 * 0031 * So the longterm plan is to use the Nepomuk facets 0032 * again as soon as possible. 0033 */ 0034 class DolphinFacetsWidget : public QWidget 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 explicit DolphinFacetsWidget(QWidget *parent = nullptr); 0040 ~DolphinFacetsWidget() override; 0041 0042 QStringList searchTerms() const; 0043 QString facetType() const; 0044 0045 bool isSearchTerm(const QString &term) const; 0046 void setSearchTerm(const QString &term); 0047 void resetSearchTerms(); 0048 0049 void setFacetType(const QString &type); 0050 0051 QSize minimumSizeHint() const override; 0052 0053 Q_SIGNALS: 0054 void facetChanged(); 0055 0056 protected: 0057 void changeEvent(QEvent *event) override; 0058 0059 private Q_SLOTS: 0060 void updateTagsMenu(); 0061 void updateTagsMenuItems(const QUrl &, const KFileItemList &items); 0062 0063 private: 0064 void setRating(const int stars); 0065 void setTimespan(const QDate &date); 0066 void addSearchTag(const QString &tag); 0067 void removeSearchTag(const QString &tag); 0068 void resetSearchTags(); 0069 0070 void initComboBox(QComboBox *combo); 0071 void updateTagsSelector(); 0072 0073 private: 0074 QComboBox *m_typeSelector; 0075 QComboBox *m_dateSelector; 0076 QComboBox *m_ratingSelector; 0077 QToolButton *m_tagsSelector; 0078 0079 QStringList m_searchTags; 0080 KCoreDirLister m_tagsLister; 0081 QAction *m_clearTagsAction; 0082 }; 0083 0084 #endif