1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
21 /*! \file SearchBarWidget.h
22 \brief Displays search bar
24 \author Mateusz Półrola <mateusz.polrola@comarch.pl>
28 #ifndef SEARCHBARWIDGET_H
29 #define SEARCHBARWIDGET_H
33 #include <QDeclarativeView>
35 #include "../backbone/backbone.h"
36 #include "../../include/History.h"
39 Contains line edit field to input word which user would like to find
40 and buttons to start/stop search and browse search history.
41 Line edit and history buttons are disabled when search is ongoing,
42 only start/stop button stays active. When searching it also displays
45 class SearchBarWidget : public QWidget {
48 explicit SearchBarWidget(QWidget *parent = 0);
53 void setEnableHistoryNext(QVariant enable);
54 void setEnableHistoryShow(QVariant enable);
55 void setEnableHistoryPrev(QVariant enable);
56 void setButtonText(QVariant text);
57 void setLineEditText(QVariant text);
58 void setLineEditEnables(QVariant enabled);
59 void progresSetMax(QVariant);
60 void progresSetMin(QVariant);
61 void progresSetValue(QVariant);
62 void progresSetValue2(QVariant);
63 void setCompleterText(QVariant);
66 //! Requests to search for a list of words matching a word passed as
68 void searchForTranslations(QString);
70 //! Requests to stop all active searchings
73 //! Requests to show previous translation in history
76 //! Requests to show next translation in history
79 //! Requests to show history list
81 \param p this argument is used only on desktop, it defines place on
82 which a popup with history will be shown
84 void historyShow(QPoint p = QPoint(-1,-1));
86 //! Requests to refresh state of history buttons
87 void refreshHistoryButtons();
91 void updateBusyTimer();
93 void searchButtonClicked(QString text);
95 //! Enables or disables search word line edit and history buttons
97 While searching it disables only history button and line edit.
98 Search/Stop button is always enabled.
100 void setEnabled(bool);
103 //! Sets search bar in busy state
105 Displays "busy" bar and disables search word text edit and history buttons
109 //! Sets search bar in idle state
111 Hides "busy" bar and enables all widgets, refreshes state of history buttons
112 by emitting refreshHistoryButtons signal
116 //! Searches for a given word
118 Sets word as text in search word line edit
120 void search(QString word);
122 //! Starts to search for a given word after 500 ms delay
124 Sets word as text in search word line edit, and waits 500 ms to start
125 search. If in the meantime this slot is called again it will stop previous
128 void searchDelay(QString word);
130 //! Updates state of history buttons
132 \param prev if set to true, the history has some previous words
133 \param next if set to true, the history has some next words
134 \param list if set to true, the history can show word list
136 void updateHistoryButtons(bool prev, bool next, bool list);
143 //! Clears search word line edit
144 void clearSearchWordToolButtonClicked();
146 //! Starts to search for given words
147 void searchPushButtonClicked();
149 //! starts to search word which was passed to searchDelay
150 void delaySearchTimeout();
153 void showHistoryButtonClicked();
155 void textChange(QString text);
157 void nextCompleter();
159 void prevCompleter();
164 QVBoxLayout* mainLayout;
165 QDeclarativeView *view;
166 QDeclarativeView *progressBar;
169 QDeclarativeContext *ctxt;
170 QStringList* completerModel;
171 QCompleter* lineEditCompleter;
172 QString preferedCompliter;
173 QString actualString;
174 QStringList completerActualList;
176 QLineEdit* searchWordLineEdit;
177 QToolButton* clearSearchWordToolButton;
178 QPushButton* searchPushButton;
179 QToolButton* historyPrevToolButton;
180 QToolButton* historyNextToolButton;
181 QToolButton* historyShowToolButton;
182 QToolButton* fullScreenToolButton;
183 QHBoxLayout* horizontalLayout;
184 QProgressBar* searchingProgressBar;
187 //! generates icon for maemo (some of icons we use don't have inactive
188 //! pixmaps, so we generate them)
190 \param original original icon
191 \param rotation rotation of resulting icon
193 QIcon generateIcon(QIcon original, qreal rotation=0);
195 QVBoxLayout* verticalLayout;
205 #endif // SEARCHBARWIDGET_H