]>
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 virtual bool event(QEvent
* event
);
92 virtual void showEvent(QShowEvent
* event
);
93 virtual void keyReleaseEvent(QKeyEvent
* event
);
97 * Is emitted when a searching should be triggered.
102 * Is emitted when the user has changed a character of
103 * the text that should be used as input for searching.
105 void searchTextChanged(const QString
& text
);
107 void returnPressed(const QString
& text
);
110 * Emitted as soon as the search box should get closed.
115 void emitSearchRequest();
116 void emitCloseRequest();
117 void slotConfigurationChanged();
118 void slotSearchTextChanged(const QString
& text
);
119 void slotReturnPressed(const QString
& text
);
120 void slotFacetsButtonToggled();
121 void slotFacetChanged();
124 void initButton(QToolButton
* button
);
130 * @return URL that represents the Nepomuk query for starting the search.
132 KUrl
nepomukUrlForSearching() const;
134 void applyReadOnlyState();
136 void updateFacetsToggleButton();
138 bool m_startedSearching
;
141 QVBoxLayout
* m_topLayout
;
143 QLabel
* m_searchLabel
;
144 KLineEdit
* m_searchInput
;
145 QScrollArea
* m_optionsScrollArea
;
146 QToolButton
* m_fileNameButton
;
147 QToolButton
* m_contentButton
;
148 KSeparator
* m_separator
;
149 QToolButton
* m_fromHereButton
;
150 QToolButton
* m_everywhereButton
;
151 QToolButton
* m_facetsToggleButton
;
152 DolphinFacetsWidget
* m_facetsWidget
;
155 KUrl m_readOnlyQuery
;
157 QTimer
* m_startSearchTimer
;