]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinsearchoptionsconfigurator.h
I'm very sorry for breaking the build: I forgot to add the new files :-(
[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 #include <QList>
25 #include <QString>
26 #include <QWidget>
27
28 class KComboBox;
29 class SearchCriterionSelector;
30 class QPushButton;
31 class QVBoxLayout;
32
33 /**
34 * @brief Allows the user to configure a search query for Nepomuk.
35 */
36 class DolphinSearchOptionsConfigurator : public QWidget
37 {
38 Q_OBJECT
39
40 public:
41 DolphinSearchOptionsConfigurator(QWidget* parent = 0);
42 virtual ~DolphinSearchOptionsConfigurator();
43
44 /**
45 * Returns the sum of the configured options and the
46 * custom search query as Nepomuk URL.
47 * @see DolphinSearchOptionsConfigurator::setCustomSearchQuery()
48 */
49 KUrl nepomukUrl() const;
50
51 public slots:
52 /**
53 * Sets a custom search query that is added to the
54 * search query defined by the search options configurator.
55 * This is useful if a custom search user interface is
56 * offered outside the search options configurator.
57 */
58 void setCustomSearchQuery(const QString& searchQuery);
59
60 signals:
61 void searchOptionsChanged();
62
63 protected:
64 virtual void showEvent(QShowEvent* event);
65
66 private slots:
67 void slotAddSelectorButtonClicked();
68 void slotCriterionChanged();
69 void removeCriterion();
70
71 /**
72 * Updates the 'enabled' property of the selector button
73 * dependent from the number of existing selectors.
74 */
75 void updateSelectorButton();
76
77 /**
78 * Saves the current query by adding it as Places entry.
79 */
80 void saveQuery();
81
82 private:
83 /**
84 * Adds the new search description selector to the bottom
85 * of the layout.
86 */
87 void addCriterion(SearchCriterionSelector* selector);
88
89 /**
90 * Returns true, DolphinSearchOptionsConfigurator::nepomukUrl()
91 * contains at least 1 search parameter.
92 */
93 bool hasSearchParameters() const;
94
95 private:
96 bool m_initialized;
97 KComboBox* m_locationBox;
98 KComboBox* m_whatBox;
99 QPushButton* m_addSelectorButton;
100 QPushButton* m_searchButton;
101 QPushButton* m_saveButton;
102 QVBoxLayout* m_vBoxLayout;
103 QList<SearchCriterionSelector*> m_criterions;
104 QString m_customSearchQuery;
105 };
106
107 #endif