]>
cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinsearchbox.h
2 * SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef DOLPHINSEARCHBOX_H
8 #define DOLPHINSEARCHBOX_H
13 class DolphinFacetsWidget
;
23 * @brief Input box for searching files with or without Baloo.
25 * The widget allows to specify:
26 * - Where to search: Everywhere or below the current directory
27 * - What to search: Filenames or content
29 * If Baloo is available and the current folder is indexed, further
30 * options are offered.
32 class DolphinSearchBox
: public QWidget
37 explicit DolphinSearchBox(QWidget
*parent
= nullptr);
38 ~DolphinSearchBox() override
;
41 * Sets the text that should be used as input for
44 void setText(const QString
&text
);
47 * Returns the text that should be used as input
53 * Sets the current path that is used as root for searching files.
54 * If @url is the Home dir, "From Here" is selected instead.
56 void setSearchPath(const QUrl
&url
);
57 QUrl
searchPath() const;
59 /** @return URL that will start the searching of files. */
60 QUrl
urlForSearching() const;
63 * Extracts information from the given search \a url to
64 * initialize the search box properly.
66 void fromSearchUrl(const QUrl
&url
);
69 * Selects the whole text of the search box.
74 * Set the search box to the active mode, if \a active
75 * is true. The active mode is default. The inactive mode only differs
76 * visually from the active mode, no change of the behavior is given.
78 * Using the search box in the inactive mode is useful when having split views,
79 * where the inactive view is indicated by an search box visually.
81 void setActive(bool active
);
84 * @return True, if the search box is in the active mode.
85 * @see DolphinSearchBox::setActive()
87 bool isActive() const;
90 bool event(QEvent
*event
) override
;
91 void showEvent(QShowEvent
*event
) override
;
92 void hideEvent(QHideEvent
*event
) override
;
93 void keyReleaseEvent(QKeyEvent
*event
) override
;
94 bool eventFilter(QObject
*obj
, QEvent
*event
) override
;
98 * Is emitted when a searching should be triggered.
100 void searchRequest();
103 * Is emitted when the user has changed a character of
104 * the text that should be used as input for searching.
106 void searchTextChanged(const QString
&text
);
109 * Emitted as soon as the search box should get closed.
114 * Is emitted when the search box should be opened.
119 * Is emitted, if the searchbox has been activated by
120 * an user interaction
121 * @see DolphinSearchBox::setActive()
124 void focusViewRequest();
127 void emitSearchRequest();
128 void emitCloseRequest();
129 void slotConfigurationChanged();
130 void slotSearchTextChanged(const QString
&text
);
131 void slotReturnPressed();
132 void slotFacetChanged();
133 void slotSearchSaved();
136 void initButton(QToolButton
*button
);
142 * @return URL that represents the Baloo query for starting the search.
144 QUrl
balooUrlForSearching() const;
147 * Sets the searchbox UI with the parameters established by the \a query
149 void updateFromQuery(const DolphinQuery
&query
);
151 void updateFacetsVisible();
153 bool isIndexingEnabled() const;
156 QString
queryTitle(const QString
&text
) const;
158 bool m_startedSearching
;
161 QVBoxLayout
*m_topLayout
;
163 QLineEdit
*m_searchInput
;
164 QAction
*m_saveSearchAction
;
165 QScrollArea
*m_optionsScrollArea
;
166 QToolButton
*m_fileNameButton
;
167 QToolButton
*m_contentButton
;
168 KSeparator
*m_separator
;
169 QToolButton
*m_fromHereButton
;
170 QToolButton
*m_everywhereButton
;
171 DolphinFacetsWidget
*m_facetsWidget
;
175 QTimer
*m_startSearchTimer
;