]>
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 #include <config-baloo.h>
28 class DolphinFacetsWidget
;
38 class NaturalQueryParser
;
42 * @brief Input box for searching files with or without Baloo.
44 * The widget allows to specify:
45 * - Where to search: Everywhere or below the current directory
46 * - What to search: Filenames or content
48 * If Baloo is available and the current folder is indexed, further
49 * options are offered.
51 class DolphinSearchBox
: public QWidget
{
55 explicit DolphinSearchBox(QWidget
* parent
= 0);
56 virtual ~DolphinSearchBox();
59 * Sets the text that should be used as input for
62 void setText(const QString
& text
);
65 * Returns the text that should be used as input
71 * Sets the current path that is used as root for
72 * searching files, if "From Here" has been selected.
74 void setSearchPath(const QUrl
& url
);
75 QUrl
searchPath() const;
77 /** @return URL that will start the searching of files. */
78 QUrl
urlForSearching() const;
81 * Extracts information from the given search \a url to
82 * initialize the search box properly.
84 void fromSearchUrl(const QUrl
& url
);
87 * Selects the whole text of the search box.
92 * Set the search box to the active mode, if \a active
93 * is true. The active mode is default. The inactive mode only differs
94 * visually from the active mode, no change of the behavior is given.
96 * Using the search box in the inactive mode is useful when having split views,
97 * where the inactive view is indicated by an search box visually.
99 void setActive(bool active
);
102 * @return True, if the search box is in the active mode.
103 * @see DolphinSearchBox::setActive()
105 bool isActive() const;
108 virtual bool event(QEvent
* event
) Q_DECL_OVERRIDE
;
109 virtual void showEvent(QShowEvent
* event
) Q_DECL_OVERRIDE
;
110 virtual void keyReleaseEvent(QKeyEvent
* event
) Q_DECL_OVERRIDE
;
111 virtual bool eventFilter(QObject
* obj
, QEvent
* event
) Q_DECL_OVERRIDE
;
115 * Is emitted when a searching should be triggered.
117 void searchRequest();
120 * Is emitted when the user has changed a character of
121 * the text that should be used as input for searching.
123 void searchTextChanged(const QString
& text
);
125 void returnPressed(const QString
& text
);
128 * Emitted as soon as the search box should get closed.
133 * Is emitted, if the searchbox has been activated by
134 * an user interaction
135 * @see DolphinSearchBox::setActive()
140 void emitSearchRequest();
141 void emitCloseRequest();
142 void slotConfigurationChanged();
143 void slotSearchTextChanged();
144 void slotReturnPressed();
145 void slotFacetsButtonToggled();
146 void slotFacetChanged();
147 void updateSearchInputParsing();
150 void initButton(QToolButton
* button
);
156 * @return URL that represents the Baloo query for starting the search.
158 QUrl
balooUrlForSearching() const;
161 * Extracts information from the given Baloo search \a url to
162 * initialize the search box properly.
164 void fromBalooSearchUrl(const QUrl
& url
);
166 void updateFacetsToggleButton();
168 bool m_startedSearching
;
171 QVBoxLayout
* m_topLayout
;
173 QLabel
* m_searchLabel
;
175 Baloo::QueryBuilder
* m_searchInput
;
176 QScopedPointer
<Baloo::NaturalQueryParser
> m_queryParser
;
178 QLineEdit
* m_searchInput
;
180 QScrollArea
* m_optionsScrollArea
;
181 QToolButton
* m_fileNameButton
;
182 QToolButton
* m_contentButton
;
183 KSeparator
* m_separator
;
184 QToolButton
* m_fromHereButton
;
185 QToolButton
* m_everywhereButton
;
186 QToolButton
* m_facetsToggleButton
;
187 DolphinFacetsWidget
* m_facetsWidget
;
191 QTimer
* m_startSearchTimer
;