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
;
35 * @brief Input box for searching files with or without Nepomuk.
37 * The widget allows to specify:
38 * - Where to search: Everywhere or below the current directory
39 * - What to search: Filenames or content
41 * If Nepomuk is available and the current folder is indexed, further
42 * options are offered.
44 class DolphinSearchBox
: public QWidget
{
48 explicit DolphinSearchBox(QWidget
* parent
= 0);
49 virtual ~DolphinSearchBox();
52 * Returns the text that should be used as input
58 * Sets the current path that is used as root for
59 * searching files, if "From Here" has been selected.
61 void setSearchPath(const KUrl
& url
);
62 KUrl
searchPath() const;
64 /** @return URL that will start the searching of files. */
65 KUrl
urlForSearching() const;
68 * Selects the whole text of the search box.
73 virtual bool event(QEvent
* event
);
74 virtual void showEvent(QShowEvent
* event
);
75 virtual void keyReleaseEvent(QKeyEvent
* event
);
79 * Is emitted when a searching should be triggered
80 * and provides the text that should be used as input
83 void search(const QString
& text
);
86 * Is emitted when the user has changed a character of
87 * the text that should be used as input for searching.
89 void searchTextChanged(const QString
& text
);
91 void returnPressed(const QString
& text
);
94 * Emitted as soon as the search box should get closed.
99 void emitSearchSignal();
100 void slotConfigurationChanged();
101 void slotSearchTextChanged(const QString
& text
);
102 void slotReturnPressed(const QString
& text
);
105 void initButton(QPushButton
* button
);
111 * @return URL that represents the Nepomuk query for starting the search.
113 KUrl
nepomukUrlForSearching() const;
116 bool m_startedSearching
;
117 bool m_nepomukActivated
;
119 QVBoxLayout
* m_topLayout
;
121 KLineEdit
* m_searchInput
;
122 QPushButton
* m_fileNameButton
;
123 QPushButton
* m_contentButton
;
124 KSeparator
* m_separator
;
125 QPushButton
* m_fromHereButton
;
126 QPushButton
* m_everywhereButton
;
130 QTimer
* m_startSearchTimer
;