X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/64afe7b22622f79b34aafd54501b08120ab2fc5c..f65b0899c3666561cafac14f67ab0bb8a5bfa00a:/src/search/dolphinsearchbox.h diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h index 6dc09f19e..1bd21f17b 100644 --- a/src/search/dolphinsearchbox.h +++ b/src/search/dolphinsearchbox.h @@ -1,36 +1,24 @@ -/*************************************************************************** - * Copyright (C) 2010 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ +/* + * SPDX-FileCopyrightText: 2010 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #ifndef DOLPHINSEARCHBOX_H #define DOLPHINSEARCHBOX_H -#include -#include +#include #include class DolphinFacetsWidget; -class KLineEdit; +class DolphinQuery; +class QLineEdit; class KSeparator; class QToolButton; class QScrollArea; class QLabel; class QVBoxLayout; +class KMoreToolsMenuFactory; /** * @brief Input box for searching files with or without Baloo. @@ -46,8 +34,8 @@ class DolphinSearchBox : public QWidget { Q_OBJECT public: - explicit DolphinSearchBox(QWidget* parent = 0); - virtual ~DolphinSearchBox(); + explicit DolphinSearchBox(QWidget* parent = nullptr); + ~DolphinSearchBox() override; /** * Sets the text that should be used as input for @@ -62,30 +50,25 @@ public: QString text() const; /** - * Sets the current path that is used as root for - * searching files, if "From Here" has been selected. + * 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 KUrl& url); - KUrl searchPath() const; + void setSearchPath(const QUrl& url); + QUrl searchPath() const; /** @return URL that will start the searching of files. */ - KUrl urlForSearching() const; + QUrl urlForSearching() const; /** - * Selects the whole text of the search box. + * Extracts information from the given search \a url to + * initialize the search box properly. */ - void selectAll(); + void fromSearchUrl(const QUrl& url); /** - * @param readOnly If set to true the searchbox cannot be modified - * by the user and acts as visual indicator for - * an externally triggered search query. - * @param query If readOnly is true this URL will be used - * to show a human readable information about the - * query. + * Selects the whole text of the search box. */ - void setReadOnly(bool readOnly, const KUrl& query = KUrl()); - bool isReadOnly() const; + void selectAll(); /** * Set the search box to the active mode, if \a active @@ -104,12 +87,13 @@ public: bool isActive() const; protected: - virtual bool event(QEvent* event); - virtual void showEvent(QShowEvent* event); - virtual void keyReleaseEvent(QKeyEvent* event); - virtual bool eventFilter(QObject* obj, QEvent* event); + bool event(QEvent* event) override; + void showEvent(QShowEvent* event) override; + void hideEvent(QHideEvent* event) override; + void keyReleaseEvent(QKeyEvent* event) override; + bool eventFilter(QObject* obj, QEvent* event) override; -signals: +Q_SIGNALS: /** * Is emitted when a searching should be triggered. */ @@ -121,8 +105,6 @@ signals: */ void searchTextChanged(const QString& text); - void returnPressed(const QString& text); - /** * Emitted as soon as the search box should get closed. */ @@ -134,15 +116,16 @@ signals: * @see DolphinSearchBox::setActive() */ void activated(); + void focusViewRequest(); -private slots: +private Q_SLOTS: void emitSearchRequest(); void emitCloseRequest(); void slotConfigurationChanged(); void slotSearchTextChanged(const QString& text); - void slotReturnPressed(const QString& text); - void slotFacetsButtonToggled(); + void slotReturnPressed(); void slotFacetChanged(); + void slotSearchSaved(); private: void initButton(QToolButton* button); @@ -153,31 +136,37 @@ private: /** * @return URL that represents the Baloo query for starting the search. */ - KUrl balooUrlForSearching() const; + QUrl balooUrlForSearching() const; + + /** + * Sets the searchbox UI with the parameters established by the \a query + */ + void updateFromQuery(const DolphinQuery& query); + + void updateFacetsVisible(); - void applyReadOnlyState(); + bool isIndexingEnabled() const; - void updateFacetsToggleButton(); private: + QString queryTitle(const QString& text) const; + bool m_startedSearching; - bool m_readOnly; bool m_active; QVBoxLayout* m_topLayout; - QLabel* m_searchLabel; - KLineEdit* m_searchInput; + QLineEdit* m_searchInput; + QAction* m_saveSearchAction; QScrollArea* m_optionsScrollArea; QToolButton* m_fileNameButton; QToolButton* m_contentButton; KSeparator* m_separator; QToolButton* m_fromHereButton; QToolButton* m_everywhereButton; - QToolButton* m_facetsToggleButton; DolphinFacetsWidget* m_facetsWidget; - KUrl m_searchPath; - KUrl m_readOnlyQuery; + QUrl m_searchPath; + QScopedPointer m_menuFactory; QTimer* m_startSearchTimer; };