blob: 700cfc84a7ad7e81241cbecc5d87db6e02a7d8c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/***************************************************************************
* Copyright (C) 2010 by Sebastian Trueg <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef SEARCHPANEL_H
#define SEARCHPANEL_H
#include <Nepomuk/Query/Query>
#include <panels/panel.h>
class KJob;
namespace Nepomuk {
namespace Utils {
class FacetWidget;
}
}
/**
* @brief Allows to search for files by enabling generic search patterns (= facets).
*
* For example it is possible to search for images, documents or specific tags.
* The search panel can be adjusted to search only from the current folder or everywhere.
*/
class SearchPanel : public Panel
{
Q_OBJECT
public:
enum SearchMode
{
Everywhere,
FromCurrentDir
};
SearchPanel(QWidget* parent = 0);
virtual ~SearchPanel();
/**
* Specifies whether a searching is done in all folders (= Everywhere)
* or from the current directory (= FromCurrentDir). The current directory
* is automatically determined when setUrl() has been called.
*/
void setSearchMode(SearchMode mode);
SearchMode searchMode() const;
signals:
void urlActivated(const KUrl& url);
protected:
/** @see Panel::urlChanged() */
virtual bool urlChanged();
/** @see QWidget::showEvent() */
virtual void showEvent(QShowEvent* event);
/** @see QWidget::contextMenuEvent() */
virtual void contextMenuEvent(QContextMenuEvent* event);
private slots:
void slotSetUrlStatFinished(KJob*);
void slotQueryTermChanged(const Nepomuk::Query::Term& term);
private:
void setQuery(const Nepomuk::Query::Query& query);
private:
bool m_initialized;
SearchMode m_searchMode;
KJob* m_lastSetUrlStatJob;
KUrl m_startedFromDir;
Nepomuk::Utils::FacetWidget* m_facetWidget;
Nepomuk::Query::Query m_unfacetedRestQuery;
};
#endif // SEARCHPANEL_H
|