]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinsearchoptionsconfigurator.h
Fix visual artefacts for tooltips, if compositing has been disabled. Thanks to Maciej...
[dolphin.git] / src / search / dolphinsearchoptionsconfigurator.h
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
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 DOLPHINSEARCHOPTIONSCONFIGURATOR_H
21 #define DOLPHINSEARCHOPTIONSCONFIGURATOR_H
22
23 #include <kurl.h>
24 #define DISABLE_NEPOMUK_LEGACY
25 #include <nepomuk/query.h>
26 #include <QList>
27 #include <QString>
28 #include <QWidget>
29
30 class KComboBox;
31 class SearchCriterionSelector;
32 class QPushButton;
33 class QVBoxLayout;
34
35 /**
36 * @brief Allows the user to configure a search query for Nepomuk.
37 */
38 class DolphinSearchOptionsConfigurator : public QWidget
39 {
40 Q_OBJECT
41
42 public:
43 DolphinSearchOptionsConfigurator(QWidget* parent = 0);
44 virtual ~DolphinSearchOptionsConfigurator();
45
46 QString customSearchQuery() const;
47 KUrl directory() const;
48
49 /**
50 * Returns the sum of the configured options and the
51 * custom search query as Nepomuk conform search URL. If the
52 * query is invalid, an empty URL is returned.
53 * @see DolphinSearchOptionsConfigurator::setCustomSearchQuery()
54 */
55 KUrl nepomukSearchUrl() const;
56
57 public slots:
58 /**
59 * Sets a custom search query that is added to the
60 * search query defined by the search options configurator.
61 * This is useful if a custom search user interface is
62 * offered outside the search options configurator.
63 */
64 void setCustomSearchQuery(const QString& searchQuery);
65
66 /**
67 * Sets the directory that is used when the
68 * "From Here"-location-filter is used. URLs that represent
69 * already a Nepomuk search URL will be ignored.
70 */
71 void setDirectory(const KUrl& dir);
72
73 signals:
74 void searchOptionsChanged();
75
76 protected:
77 virtual void showEvent(QShowEvent* event);
78
79 private slots:
80 void slotAddSelectorButtonClicked();
81 void removeCriterion();
82
83 /**
84 * Saves the current query by adding it as Places entry.
85 */
86 void saveQuery();
87
88 /**
89 * Enables the enabled property of the search-, save-button and the
90 * add-selector button.
91 */
92 void updateButtons();
93
94 private:
95 /**
96 * Adds the new search description selector to the bottom
97 * of the layout.
98 */
99 void addCriterion(SearchCriterionSelector* selector);
100
101 /**
102 * Returns the sum of the configured options and the
103 * custom search query as Nepomuk confrom query.
104 * @see DolphinSearchOptionsConfigurator::setCustomSearchQuery()
105 */
106 Nepomuk::Query::Query nepomukQuery() const;
107
108 private:
109 bool m_initialized;
110 KUrl m_directory;
111 KComboBox* m_locationBox;
112 KComboBox* m_whatBox;
113 QPushButton* m_addSelectorButton;
114 QPushButton* m_searchButton;
115 QPushButton* m_saveButton;
116 QVBoxLayout* m_vBoxLayout;
117 QList<SearchCriterionSelector*> m_criteria;
118 QString m_customSearchQuery;
119 };
120
121 #endif