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 AbstractSearchFilterWidget
;
37 * @brief Input box for searching files with or without Nepomuk.
39 * The widget allows to specify:
40 * - Where to search: Everywhere or below the current directory
41 * - What to search: Filenames or content
43 * If Nepomuk is available and the current folder is indexed, further
44 * options are offered.
46 class DolphinSearchBox
: public QWidget
{
60 explicit DolphinSearchBox(QWidget
* parent
= 0);
61 virtual ~DolphinSearchBox();
64 * Sets the text that should be used as input for
67 void setText(const QString
& text
);
70 * Returns the text that should be used as input
76 * Sets the current path that is used as root for
77 * searching files, if "From Here" has been selected.
79 void setSearchPath(const KUrl
& url
);
80 KUrl
searchPath() const;
82 /** @return URL that will start the searching of files. */
83 KUrl
urlForSearching() const;
86 * Selects the whole text of the search box.
91 * @param readOnly If set to true the searchbox cannot be modified
92 * by the user and acts as visual indicator for
93 * an externally triggered search query.
94 * @param query If readOnly is true this URL will be used
95 * to show a human readable information about the
98 void setReadOnly(bool readOnly
, const KUrl
& query
= KUrl());
99 bool isReadOnly() const;
102 virtual bool event(QEvent
* event
);
103 virtual void showEvent(QShowEvent
* event
);
104 virtual void keyReleaseEvent(QKeyEvent
* event
);
108 * Is emitted when a searching should be triggered
109 * and provides the text that should be used as input
112 void search(const QString
& text
);
115 * Is emitted when the user has changed a character of
116 * the text that should be used as input for searching.
118 void searchTextChanged(const QString
& text
);
120 void returnPressed(const QString
& text
);
123 * Is emitted if the search location has been changed by the user.
125 void searchLocationChanged(SearchLocation location
);
128 * Is emitted if the search context has been changed by the user.
130 void searchContextChanged(SearchContext context
);
133 * Emitted as soon as the search box should get closed.
138 void emitSearchSignal();
139 void slotSearchLocationChanged();
140 void slotSearchContextChanged();
141 void slotConfigurationChanged();
142 void slotSearchTextChanged(const QString
& text
);
143 void slotReturnPressed(const QString
& text
);
146 void initButton(QToolButton
* button
);
152 * @return URL that represents the Nepomuk query for starting the search.
154 KUrl
nepomukUrlForSearching() const;
156 void applyReadOnlyState();
159 bool m_startedSearching
;
162 QVBoxLayout
* m_topLayout
;
164 QLabel
* m_searchLabel
;
165 KLineEdit
* m_searchInput
;
166 QScrollArea
* m_optionsScrollArea
;
167 QToolButton
* m_fileNameButton
;
168 QToolButton
* m_contentButton
;
169 KSeparator
* m_separator
;
170 QToolButton
* m_fromHereButton
;
171 QToolButton
* m_everywhereButton
;
174 KUrl m_readOnlyQuery
;
176 QTimer
* m_startSearchTimer
;