diff options
| author | Felix Ernst <[email protected]> | 2025-04-07 21:09:00 +0000 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2025-04-07 21:09:00 +0000 |
| commit | 4102ccb80457eea44ea280f0ace2a419602bc34b (patch) | |
| tree | 841e039cf9864276c968a397a2ae75c363199342 /src/search/dolphinsearchbox.h | |
| parent | bfc177d3d1bc5a4a241e35d59086e4824e7c0bd3 (diff) | |
Rewrite search integration
This huge commit is a nearly complete rewrite of the Dolphin search
code. It implements most of the improved Dolphin search UI/UX as
designed and discussed in a collaborative effort by Kristen McWilliam,
Jin Liu, Andy Betts, Tagwerk, a few others and me.
See https://invent.kde.org/system/dolphin/-/issues/46.
# Notable changes
- A toggle to change the search tool is provided as most contributors
deemed that useful in
https://invent.kde.org/system/dolphin/-/merge_requests/642#note_985112.
- The default search is changed to filenamesearch for maximum
reliability.
- Removing all search parameters will take users back to the view state
prior to starting a search instead of keeping the search results open.
- The UI for choosing file types or modification dates has been made
more powerful with more granularity and more options.
- Most search parameters can be configured from a popup menu which
gives us extra space for extra clarity.
- Labels and help buttons as well as hyperlinks to settings makes sure
the user always knows why some search parameters are unavailable in
some contexts.
- Chips show important search parameters while the popup is closed.
They allow quickly removing filters.
- The titles of the search and the input field placeholder message
change to make clear whether file names or file contents are searched.
- When the user actively switches the search tool, whether content
should be searched, or whether to search everywhere, this is preserved
for the initial state of the search bar when the user opens it the next
time after restarting Dolphin.
# Architecture
- The new DolphinQuery class is independent of the UI and contains all
search parameters modifiable in Dolphin as easy setters and getters.
- DolphinQuery objects are also used to update the states of every
component in the search UI. There is now a clear separation of UI and
search configuration/DolphinQuery.
- DolphinQuery is responsible for exporting to and importing from
search URLs.
- The search UI always reflects the currently configured DolphinQuery
no matter if the user changed the UI to change the DolphinQuery or
loaded a DolphinQuery/older search URL which then is reflected in the
UI.
- I tried to simplify all classes and their interaction between each
other as much as possible.
- I added some tests
BUG: 386754
CCBUG: 435119
CCBUG: 458761
BUG: 446387
BUG: 470136
CCBUG: 471556
CCBUG: 475439
CCBUG: 477969
BUG: 480001
BUG: 483578
BUG: 488047
BUG: 488845
BUG: 500103
FIXED-IN: 25.08
Diffstat (limited to 'src/search/dolphinsearchbox.h')
| -rw-r--r-- | src/search/dolphinsearchbox.h | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h deleted file mode 100644 index 6a847ba57..000000000 --- a/src/search/dolphinsearchbox.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2010 Peter Penz <[email protected]> - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef DOLPHINSEARCHBOX_H -#define DOLPHINSEARCHBOX_H - -#include "animatedheightwidget.h" - -#include <QUrl> - -class DolphinFacetsWidget; -class DolphinQuery; -class QLineEdit; -class KSeparator; -class QToolButton; -class QScrollArea; -class QLabel; -class QVBoxLayout; - -/** - * @brief Input box for searching files with or without Baloo. - * - * The widget allows to specify: - * - Where to search: Everywhere or below the current directory - * - What to search: Filenames or content - * - * If Baloo is available and the current folder is indexed, further - * options are offered. - */ -class DolphinSearchBox : public AnimatedHeightWidget -{ - Q_OBJECT - -public: - explicit DolphinSearchBox(QWidget *parent = nullptr); - ~DolphinSearchBox() override; - - /** - * Sets the text that should be used as input for - * searching. - */ - void setText(const QString &text); - - /** - * Returns the text that should be used as input - * for searching. - */ - QString text() const; - - /** - * Sets the current path that is used as root for searching files. - * If @url is the Home dir, "From Here" is selected instead. - */ - void setSearchPath(const QUrl &url); - QUrl searchPath() const; - - /** @return URL that will start the searching of files. */ - QUrl urlForSearching() const; - - /** - * Extracts information from the given search \a url to - * initialize the search box properly. - */ - void fromSearchUrl(const QUrl &url); - - /** - * Selects the whole text of the search box. - */ - void selectAll(); - - /** - * Set the search box to the active mode, if \a active - * is true. The active mode is default. The inactive mode only differs - * visually from the active mode, no change of the behavior is given. - * - * Using the search box in the inactive mode is useful when having split views, - * where the inactive view is indicated by an search box visually. - */ - void setActive(bool active); - - /** - * @return True, if the search box is in the active mode. - * @see DolphinSearchBox::setActive() - */ - bool isActive() const; - - /* - * @see AnimatedHeightWidget::setVisible() - * @see QWidget::setVisible() - */ - void setVisible(bool visible, Animated animated); - -protected: - void showEvent(QShowEvent *event) override; - void hideEvent(QHideEvent *event) override; - void keyReleaseEvent(QKeyEvent *event) override; - bool eventFilter(QObject *obj, QEvent *event) override; - -Q_SIGNALS: - /** - * Is emitted when a searching should be triggered. - */ - void searchRequest(); - - /** - * Is emitted when the user has changed a character of - * the text that should be used as input for searching. - */ - void searchTextChanged(const QString &text); - - /** - * Emitted as soon as the search box should get closed. - */ - void closeRequest(); - - /** - * Is emitted when the search box should be opened. - */ - void openRequest(); - - /** - * Is emitted, if the searchbox has been activated by - * an user interaction - * @see DolphinSearchBox::setActive() - */ - void activated(); - void focusViewRequest(); - -private Q_SLOTS: - void emitSearchRequest(); - void emitCloseRequest(); - void slotConfigurationChanged(); - void slotSearchTextChanged(const QString &text); - void slotReturnPressed(); - void slotFacetChanged(); - void slotSearchSaved(); - -private: - void initButton(QToolButton *button); - void loadSettings(); - void saveSettings(); - void init(); - - /** - * @return URL that represents the Baloo query for starting the search. - */ - QUrl balooUrlForSearching() const; - - /** - * Sets the searchbox UI with the parameters established by the \a query - */ - void updateFromQuery(const DolphinQuery &query); - - void updateFacetsVisible(); - - bool isIndexingEnabled() const; - - /** @see AnimatedHeightWidget::preferredHeight() */ - int preferredHeight() const override; - -private: - QString queryTitle(const QString &text) const; - - bool m_startedSearching; - bool m_active; - - QVBoxLayout *m_topLayout; - - QLineEdit *m_searchInput; - QAction *m_saveSearchAction; - QScrollArea *m_optionsScrollArea; - QToolButton *m_fileNameButton; - QToolButton *m_contentButton; - KSeparator *m_separator; - QToolButton *m_fromHereButton; - QToolButton *m_everywhereButton; - DolphinFacetsWidget *m_facetsWidget; - - QUrl m_searchPath; - - QTimer *m_startSearchTimer; - - bool m_initialized; -}; - -#endif |
