]>
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
{
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, if the searchbox has been activated by
115 * an user interaction
116 * @see DolphinSearchBox::setActive()
119 void focusViewRequest();
122 void emitSearchRequest();
123 void emitCloseRequest();
124 void slotConfigurationChanged();
125 void slotSearchTextChanged(const QString
& text
);
126 void slotReturnPressed();
127 void slotFacetChanged();
128 void slotSearchSaved();
131 void initButton(QToolButton
* button
);
137 * @return URL that represents the Baloo query for starting the search.
139 QUrl
balooUrlForSearching() const;
142 * Sets the searchbox UI with the parameters established by the \a query
144 void updateFromQuery(const DolphinQuery
& query
);
146 void updateFacetsVisible();
148 bool isIndexingEnabled() const;
151 QString
queryTitle(const QString
& text
) const;
153 bool m_startedSearching
;
156 QVBoxLayout
* m_topLayout
;
158 QLineEdit
* m_searchInput
;
159 QAction
* m_saveSearchAction
;
160 QScrollArea
* m_optionsScrollArea
;
161 QToolButton
* m_fileNameButton
;
162 QToolButton
* m_contentButton
;
163 KSeparator
* m_separator
;
164 QToolButton
* m_fromHereButton
;
165 QToolButton
* m_everywhereButton
;
166 DolphinFacetsWidget
* m_facetsWidget
;
169 QScopedPointer
<KMoreToolsMenuFactory
> m_menuFactory
;
171 QTimer
* m_startSearchTimer
;