]>
cloud.milkyroute.net Git - dolphin.git/blob - src/search/dolphinsearchbox.h
1 /***************************************************************************
2 * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #ifndef DOLPHINSEARCHBOX_H
21 #define DOLPHINSEARCHBOX_H
27 class DolphinFacetsWidget
;
36 * @brief Input box for searching files with or without Nepomuk.
38 * The widget allows to specify:
39 * - Where to search: Everywhere or below the current directory
40 * - What to search: Filenames or content
42 * If Nepomuk is available and the current folder is indexed, further
43 * options are offered.
45 class DolphinSearchBox
: public QWidget
{
49 explicit DolphinSearchBox(QWidget
* parent
= 0);
50 virtual ~DolphinSearchBox();
53 * Sets the text that should be used as input for
56 void setText(const QString
& text
);
59 * Returns the text that should be used as input
65 * Sets the current path that is used as root for
66 * searching files, if "From Here" has been selected.
68 void setSearchPath(const KUrl
& url
);
69 KUrl
searchPath() const;
71 /** @return URL that will start the searching of files. */
72 KUrl
urlForSearching() const;
75 * Selects the whole text of the search box.
80 * @param readOnly If set to true the searchbox cannot be modified
81 * by the user and acts as visual indicator for
82 * an externally triggered search query.
83 * @param query If readOnly is true this URL will be used
84 * to show a human readable information about the
87 void setReadOnly(bool readOnly
, const KUrl
& query
= KUrl());
88 bool isReadOnly() const;
91 * Set the search box to the active mode, if \a active
92 * is true. The active mode is default. The inactive mode only differs
93 * visually from the active mode, no change of the behavior is given.
95 * Using the search box in the inactive mode is useful when having split views,
96 * where the inactive view is indicated by an search box visually.
98 void setActive(bool active
);
101 * @return True, if the search box is in the active mode.
102 * @see DolphinSearchBox::setActive()
104 bool isActive() const;
107 virtual bool event(QEvent
* event
);
108 virtual void showEvent(QShowEvent
* event
);
109 virtual void keyReleaseEvent(QKeyEvent
* event
);
110 virtual bool eventFilter(QObject
* obj
, QEvent
* event
);
114 * Is emitted when a searching should be triggered.
116 void searchRequest();
119 * Is emitted when the user has changed a character of
120 * the text that should be used as input for searching.
122 void searchTextChanged(const QString
& text
);
124 void returnPressed(const QString
& text
);
127 * Emitted as soon as the search box should get closed.
132 * Is emitted, if the searchbox has been activated by
133 * an user interaction
134 * @see DolphinSearchBox::setActive()
139 void emitSearchRequest();
140 void emitCloseRequest();
141 void slotConfigurationChanged();
142 void slotSearchTextChanged(const QString
& text
);
143 void slotReturnPressed(const QString
& text
);
144 void slotFacetsButtonToggled();
145 void slotFacetChanged();
148 void initButton(QToolButton
* button
);
154 * @return URL that represents the Nepomuk query for starting the search.
156 KUrl
nepomukUrlForSearching() const;
158 void applyReadOnlyState();
160 void updateFacetsToggleButton();
162 bool m_startedSearching
;
166 QVBoxLayout
* m_topLayout
;
168 QLabel
* m_searchLabel
;
169 KLineEdit
* m_searchInput
;
170 QScrollArea
* m_optionsScrollArea
;
171 QToolButton
* m_fileNameButton
;
172 QToolButton
* m_contentButton
;
173 KSeparator
* m_separator
;
174 QToolButton
* m_fromHereButton
;
175 QToolButton
* m_everywhereButton
;
176 QToolButton
* m_facetsToggleButton
;
177 DolphinFacetsWidget
* m_facetsWidget
;
180 KUrl m_readOnlyQuery
;
182 QTimer
* m_startSearchTimer
;