]>
cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinsearchbox.h
781c592e16a9fa37719cf64db9d63adf39e5392f
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
;
33 class KMoreToolsMenuFactory
;
36 * @brief Input box for searching files with or without Baloo.
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 Baloo is available and the current folder is indexed, further
43 * options are offered.
45 class DolphinSearchBox
: public QWidget
{
49 explicit DolphinSearchBox(QWidget
* parent
= 0);
50 ~DolphinSearchBox() override
;
53 * Sets the text that should be used as input for
56 void setText(const QString
& text
);
59 * Returns the text that should be used as input
65 * Sets the current path that is used as root for
66 * searching files, if "From Here" has been selected.
68 void setSearchPath(const QUrl
& url
);
69 QUrl
searchPath() const;
71 /** @return URL that will start the searching of files. */
72 QUrl
urlForSearching() const;
75 * Extracts information from the given search \a url to
76 * initialize the search box properly.
78 void fromSearchUrl(const QUrl
& url
);
81 * Selects the whole text of the search box.
86 * Set the search box to the active mode, if \a active
87 * is true. The active mode is default. The inactive mode only differs
88 * visually from the active mode, no change of the behavior is given.
90 * Using the search box in the inactive mode is useful when having split views,
91 * where the inactive view is indicated by an search box visually.
93 void setActive(bool active
);
96 * @return True, if the search box is in the active mode.
97 * @see DolphinSearchBox::setActive()
99 bool isActive() const;
102 bool event(QEvent
* event
) override
;
103 void showEvent(QShowEvent
* event
) override
;
104 void hideEvent(QHideEvent
* event
) override
;
105 void keyReleaseEvent(QKeyEvent
* event
) override
;
106 bool eventFilter(QObject
* obj
, QEvent
* event
) override
;
110 * Is emitted when a searching should be triggered.
112 void searchRequest();
115 * Is emitted when the user has changed a character of
116 * the text that should be used as input for searching.
118 void searchTextChanged(const QString
& text
);
120 void returnPressed();
123 * Emitted as soon as the search box should get closed.
128 * Is emitted, if the searchbox has been activated by
129 * an user interaction
130 * @see DolphinSearchBox::setActive()
135 void emitSearchRequest();
136 void emitCloseRequest();
137 void slotConfigurationChanged();
138 void slotSearchTextChanged(const QString
& text
);
139 void slotReturnPressed();
140 void slotFacetsButtonToggled();
141 void slotFacetChanged();
142 void slotSearchSaved();
145 void initButton(QToolButton
* button
);
151 * @return URL that represents the Baloo query for starting the search.
153 QUrl
balooUrlForSearching() const;
156 * Extracts information from the given Baloo search \a url to
157 * initialize the search box properly.
159 void fromBalooSearchUrl(const QUrl
& url
);
161 void updateFacetsToggleButton();
164 bool m_startedSearching
;
167 QVBoxLayout
* m_topLayout
;
169 QLabel
* m_searchLabel
;
170 QLineEdit
* m_searchInput
;
171 QAction
* m_saveSearchAction
;
172 QScrollArea
* m_optionsScrollArea
;
173 QToolButton
* m_fileNameButton
;
174 QToolButton
* m_contentButton
;
175 KSeparator
* m_separator
;
176 QToolButton
* m_fromHereButton
;
177 QToolButton
* m_everywhereButton
;
178 QToolButton
* m_facetsToggleButton
;
179 DolphinFacetsWidget
* m_facetsWidget
;
182 QScopedPointer
<KMoreToolsMenuFactory
> m_menuFactory
;
184 QTimer
* m_startSearchTimer
;