]>
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
;
21 class KMoreToolsMenuFactory
;
24 * @brief Input box for searching files with or without Baloo.
26 * The widget allows to specify:
27 * - Where to search: Everywhere or below the current directory
28 * - What to search: Filenames or content
30 * If Baloo is available and the current folder is indexed, further
31 * options are offered.
33 class DolphinSearchBox
: public QWidget
38 explicit DolphinSearchBox(QWidget
*parent
= nullptr);
39 ~DolphinSearchBox() override
;
42 * Sets the text that should be used as input for
45 void setText(const QString
&text
);
48 * Returns the text that should be used as input
54 * Sets the current path that is used as root for searching files.
55 * If @url is the Home dir, "From Here" is selected instead.
57 void setSearchPath(const QUrl
&url
);
58 QUrl
searchPath() const;
60 /** @return URL that will start the searching of files. */
61 QUrl
urlForSearching() const;
64 * Extracts information from the given search \a url to
65 * initialize the search box properly.
67 void fromSearchUrl(const QUrl
&url
);
70 * Selects the whole text of the search box.
75 * Set the search box to the active mode, if \a active
76 * is true. The active mode is default. The inactive mode only differs
77 * visually from the active mode, no change of the behavior is given.
79 * Using the search box in the inactive mode is useful when having split views,
80 * where the inactive view is indicated by an search box visually.
82 void setActive(bool active
);
85 * @return True, if the search box is in the active mode.
86 * @see DolphinSearchBox::setActive()
88 bool isActive() const;
91 bool event(QEvent
*event
) override
;
92 void showEvent(QShowEvent
*event
) override
;
93 void hideEvent(QHideEvent
*event
) override
;
94 void keyReleaseEvent(QKeyEvent
*event
) override
;
95 bool eventFilter(QObject
*obj
, QEvent
*event
) override
;
99 * Is emitted when a searching should be triggered.
101 void searchRequest();
104 * Is emitted when the user has changed a character of
105 * the text that should be used as input for searching.
107 void searchTextChanged(const QString
&text
);
110 * Emitted as soon as the search box should get closed.
115 * Is emitted, if the searchbox has been activated by
116 * an user interaction
117 * @see DolphinSearchBox::setActive()
120 void focusViewRequest();
123 void emitSearchRequest();
124 void emitCloseRequest();
125 void slotConfigurationChanged();
126 void slotSearchTextChanged(const QString
&text
);
127 void slotReturnPressed();
128 void slotFacetChanged();
129 void slotSearchSaved();
132 void initButton(QToolButton
*button
);
138 * @return URL that represents the Baloo query for starting the search.
140 QUrl
balooUrlForSearching() const;
143 * Sets the searchbox UI with the parameters established by the \a query
145 void updateFromQuery(const DolphinQuery
&query
);
147 void updateFacetsVisible();
149 bool isIndexingEnabled() const;
152 QString
queryTitle(const QString
&text
) const;
154 bool m_startedSearching
;
157 QVBoxLayout
*m_topLayout
;
159 QLineEdit
*m_searchInput
;
160 QAction
*m_saveSearchAction
;
161 QScrollArea
*m_optionsScrollArea
;
162 QToolButton
*m_fileNameButton
;
163 QToolButton
*m_contentButton
;
164 KSeparator
*m_separator
;
165 QToolButton
*m_fromHereButton
;
166 QToolButton
*m_everywhereButton
;
167 DolphinFacetsWidget
*m_facetsWidget
;
170 QScopedPointer
<KMoreToolsMenuFactory
> m_menuFactory
;
172 QTimer
*m_startSearchTimer
;