]>
cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinsearchbox.h
1 /***************************************************************************
2 * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef DOLPHINSEARCHBOX_H
21 #define DOLPHINSEARCHBOX_H
27 class DolphinFacetsWidget
;
36 * @brief Input box for searching files with or without Nepomuk.
38 * The widget allows to specify:
39 * - Where to search: Everywhere or below the current directory
40 * - What to search: Filenames or content
42 * If Nepomuk is available and the current folder is indexed, further
43 * options are offered.
45 class DolphinSearchBox
: public QWidget
{
59 explicit DolphinSearchBox(QWidget
* parent
= 0);
60 virtual ~DolphinSearchBox();
63 * Sets the text that should be used as input for
66 void setText(const QString
& text
);
69 * Returns the text that should be used as input
75 * Sets the current path that is used as root for
76 * searching files, if "From Here" has been selected.
78 void setSearchPath(const KUrl
& url
);
79 KUrl
searchPath() const;
81 /** @return URL that will start the searching of files. */
82 KUrl
urlForSearching() const;
85 * Selects the whole text of the search box.
90 * @param readOnly If set to true the searchbox cannot be modified
91 * by the user and acts as visual indicator for
92 * an externally triggered search query.
93 * @param query If readOnly is true this URL will be used
94 * to show a human readable information about the
97 void setReadOnly(bool readOnly
, const KUrl
& query
= KUrl());
98 bool isReadOnly() const;
101 virtual bool event(QEvent
* event
);
102 virtual void showEvent(QShowEvent
* event
);
103 virtual void keyReleaseEvent(QKeyEvent
* event
);
107 * Is emitted when a searching should be triggered
108 * and provides the text that should be used as input
111 void search(const QString
& text
);
114 * Is emitted when the user has changed a character of
115 * the text that should be used as input for searching.
117 void searchTextChanged(const QString
& text
);
119 void returnPressed(const QString
& text
);
122 * Is emitted if the search location has been changed by the user.
124 void searchLocationChanged(SearchLocation location
);
127 * Is emitted if the search context has been changed by the user.
129 void searchContextChanged(SearchContext context
);
132 * Emitted as soon as the search box should get closed.
137 void emitSearchSignal();
138 void slotSearchLocationChanged();
139 void slotSearchContextChanged();
140 void slotConfigurationChanged();
141 void slotSearchTextChanged(const QString
& text
);
142 void slotReturnPressed(const QString
& text
);
143 void slotFacetsButtonToggled();
146 void initButton(QToolButton
* button
);
152 * @return URL that represents the Nepomuk query for starting the search.
154 KUrl
nepomukUrlForSearching() const;
156 void applyReadOnlyState();
158 void updateFacetsToggleButtonIcon();
161 bool m_startedSearching
;
164 QVBoxLayout
* m_topLayout
;
166 QLabel
* m_searchLabel
;
167 KLineEdit
* m_searchInput
;
168 QScrollArea
* m_optionsScrollArea
;
169 QToolButton
* m_fileNameButton
;
170 QToolButton
* m_contentButton
;
171 KSeparator
* m_separator
;
172 QToolButton
* m_fromHereButton
;
173 QToolButton
* m_everywhereButton
;
174 QToolButton
* m_facetsToggleButton
;
175 DolphinFacetsWidget
* m_facetsWidget
;
178 KUrl m_readOnlyQuery
;
180 QTimer
* m_startSearchTimer
;