]>
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
26 class DolphinFacetsWidget
;
35 * @brief Input box for searching files with or without Baloo.
37 * The widget allows to specify:
38 * - Where to search: Everywhere or below the current directory
39 * - What to search: Filenames or content
41 * If Baloo is available and the current folder is indexed, further
42 * options are offered.
44 class DolphinSearchBox
: public QWidget
{
48 explicit DolphinSearchBox(QWidget
* parent
= 0);
49 virtual ~DolphinSearchBox();
52 * Sets the text that should be used as input for
55 void setText(const QString
& text
);
58 * Returns the text that should be used as input
64 * Sets the current path that is used as root for
65 * searching files, if "From Here" has been selected.
67 void setSearchPath(const QUrl
& url
);
68 QUrl
searchPath() const;
70 /** @return URL that will start the searching of files. */
71 QUrl
urlForSearching() const;
74 * Extracts information from the given search \a url to
75 * initialize the search box properly.
77 void fromSearchUrl(const QUrl
& url
);
80 * Selects the whole text of the search box.
85 * Set the search box to the active mode, if \a active
86 * is true. The active mode is default. The inactive mode only differs
87 * visually from the active mode, no change of the behavior is given.
89 * Using the search box in the inactive mode is useful when having split views,
90 * where the inactive view is indicated by an search box visually.
92 void setActive(bool active
);
95 * @return True, if the search box is in the active mode.
96 * @see DolphinSearchBox::setActive()
98 bool isActive() const;
101 virtual bool event(QEvent
* event
) Q_DECL_OVERRIDE
;
102 virtual void showEvent(QShowEvent
* event
) Q_DECL_OVERRIDE
;
103 virtual void keyReleaseEvent(QKeyEvent
* event
) Q_DECL_OVERRIDE
;
104 virtual bool eventFilter(QObject
* obj
, QEvent
* event
) Q_DECL_OVERRIDE
;
108 * Is emitted when a searching should be triggered.
110 void searchRequest();
113 * Is emitted when the user has changed a character of
114 * the text that should be used as input for searching.
116 void searchTextChanged(const QString
& text
);
118 void returnPressed();
121 * Emitted as soon as the search box should get closed.
126 * Is emitted, if the searchbox has been activated by
127 * an user interaction
128 * @see DolphinSearchBox::setActive()
133 void emitSearchRequest();
134 void emitCloseRequest();
135 void slotConfigurationChanged();
136 void slotSearchTextChanged(const QString
& text
);
137 void slotReturnPressed();
138 void slotFacetsButtonToggled();
139 void slotFacetChanged();
142 void initButton(QToolButton
* button
);
148 * @return URL that represents the Baloo query for starting the search.
150 QUrl
balooUrlForSearching() const;
153 * Extracts information from the given Baloo search \a url to
154 * initialize the search box properly.
156 void fromBalooSearchUrl(const QUrl
& url
);
158 void updateFacetsToggleButton();
161 bool m_startedSearching
;
164 QVBoxLayout
* m_topLayout
;
166 QLabel
* m_searchLabel
;
167 QLineEdit
* 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
;
179 QTimer
* m_startSearchTimer
;