]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/search/searchpanel.h
Add search modes for the Search Panel
[dolphin.git] / src / panels / search / searchpanel.h
1 /***************************************************************************
2 * Copyright (C) 2010 by Sebastian Trueg <trueg@kde.org> *
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 SEARCHPANEL_H
21 #define SEARCHPANEL_H
22
23 #include <Nepomuk/Query/Query>
24 #include <panels/panel.h>
25
26 class KJob;
27
28 namespace Nepomuk {
29 namespace Utils {
30 class FacetWidget;
31 }
32 }
33
34 /**
35 * @brief Allows to search for files by enabling generic search patterns (= facets).
36 *
37 * For example it is possible to search for images, documents or specific tags.
38 * The search panel can be adjusted to search only from the current folder or everywhere.
39 */
40 class SearchPanel : public Panel
41 {
42 Q_OBJECT
43
44 public:
45 enum SearchMode
46 {
47 Everywhere,
48 FromCurrentDir
49 };
50
51 SearchPanel(QWidget* parent = 0);
52 virtual ~SearchPanel();
53
54 /**
55 * Specifies whether a searching is done in all folders (= Everywhere)
56 * or from the current directory (= FromCurrentDir). The current directory
57 * is automatically determined when setUrl() has been called.
58 */
59 void setSearchMode(SearchMode mode);
60 SearchMode searchMode() const;
61
62 signals:
63 void urlActivated(const KUrl& url);
64
65 protected:
66 /** @see Panel::urlChanged() */
67 virtual bool urlChanged();
68
69 /** @see QWidget::showEvent() */
70 virtual void showEvent(QShowEvent* event);
71
72 /** @see QWidget::hideEvent() */
73 virtual void hideEvent(QHideEvent* event);
74
75 /** @see QWidget::contextMenuEvent() */
76 virtual void contextMenuEvent(QContextMenuEvent* event);
77
78 private slots:
79 void slotSetUrlStatFinished(KJob*);
80 void slotQueryTermChanged(const Nepomuk::Query::Term& term);
81
82 private:
83 void setQuery(const Nepomuk::Query::Query& query);
84
85 private:
86 bool m_initialized;
87 SearchMode m_searchMode;
88 KJob* m_lastSetUrlStatJob;
89
90 KUrl m_startedFromDir;
91 Nepomuk::Utils::FacetWidget* m_facetWidget;
92 Nepomuk::Query::Query m_unfacetedRestQuery;
93 };
94
95 #endif // SEARCHPANEL_H