]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/searchcriterionselector.h
Fix visual artefacts for tooltips, if compositing has been disabled. Thanks to Maciej...
[dolphin.git] / src / search / searchcriterionselector.h
1 /***************************************************************************
2 * Copyright (C) 2009 by Adam Kidder <thekidder@gmail.com> *
3 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef SEARCHCRITERIONSELECTOR_H
22 #define SEARCHCRITERIONSELECTOR_H
23
24 #include <QList>
25 #include <QString>
26 #include <QWidget>
27
28 #define DISABLE_NEPOMUK_LEGACY
29 #include <nepomuk/term.h>
30 #include <search/searchcriteriondescription.h>
31
32 class SearchCriterionValue;
33 class QComboBox;
34 class QHBoxLayout;
35 class QPushButton;
36
37 /**
38 * @brief Allows the user to select a search criterion.
39 * The widget represents one row of the DolphinSearchOptionsConfigurator.
40 * Example: [File Size] [greater than] [10] [Byte]
41 *
42 * @see DolphinSearchOptionsConfigurator.
43 */
44 class SearchCriterionSelector : public QWidget
45 {
46 Q_OBJECT
47
48 public:
49 enum Type { Date, Size, Tag, Rating };
50
51 SearchCriterionSelector(Type type, QWidget* parent = 0);
52 virtual ~SearchCriterionSelector();
53
54 /** Returns the query-term for the criterion. */
55 Nepomuk::Query::Term queryTerm() const;
56
57 Type type() const;
58
59 signals:
60 /**
61 * Is emitted if the criterion selector should be removed
62 * because the user clicked the "Remove" button.
63 */
64 void removeCriterion();
65
66 /** Is emitted if the user has changed the search criterion. */
67 void criterionChanged();
68
69 private slots:
70 void slotDescriptionChanged(int index);
71 void slotComparatorChanged(int index);
72
73 private:
74 /**
75 * Creates all available search criterion descriptions m_descriptions
76 * and adds them into the combobox m_descriptionsBox.
77 */
78 void createDescriptions();
79
80 private:
81 QHBoxLayout* m_layout;
82 QComboBox* m_descriptionsBox; // has items like "File Size", "Date Modified", ...
83 QComboBox* m_comparatorBox; // has items like "greater than", "less than", ...
84 SearchCriterionValue* m_valueWidget; // contains the value of a file size or a date
85 QPushButton* m_removeButton; // requests a removing of the search criterion instance
86
87 QList<SearchCriterionDescription> m_descriptions;
88 };
89
90 #endif // SEARCHCRITERIONSELECTOR_H