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);
65 //! Requests to search for a list of words matching a word passed as
67 void searchForTranslations(QString);
69 //! Requests to stop all active searchings
72 //! Requests to show previous translation in history
75 //! Requests to show next translation in history
78 //! Requests to show history list
80 \param p this argument is used only on desktop, it defines place on
81 which a popup with history will be shown
83 void historyShow(QPoint p = QPoint(-1,-1));
85 //! Requests to refresh state of history buttons
86 void refreshHistoryButtons();
90 void updateBusyTimer();
92 void searchButtonClicked(QString text);
94 //! Enables or disables search word line edit and history buttons
96 While searching it disables only history button and line edit.
97 Search/Stop button is always enabled.
99 void setEnabled(bool);
102 //! Sets search bar in busy state
104 Displays "busy" bar and disables search word text edit and history buttons
108 //! Sets search bar in idle state
110 Hides "busy" bar and enables all widgets, refreshes state of history buttons
111 by emitting refreshHistoryButtons signal
115 //! Searches for a given word
117 Sets word as text in search word line edit
119 void search(QString word);
121 //! Starts to search for a given word after 500 ms delay
123 Sets word as text in search word line edit, and waits 500 ms to start
124 search. If in the meantime this slot is called again it will stop previous
127 void searchDelay(QString word);
129 //! Updates state of history buttons
131 \param prev if set to true, the history has some previous words
132 \param next if set to true, the history has some next words
133 \param list if set to true, the history can show word list
135 void updateHistoryButtons(bool prev, bool next, bool list);
140 //! Clears search word line edit
141 void clearSearchWordToolButtonClicked();
143 //! Starts to search for given words
144 void searchPushButtonClicked();
146 //! starts to search word which was passed to searchDelay
147 void delaySearchTimeout();
150 void showHistoryButtonClicked();
152 void textChange(QString text);
154 void nextCompleter();
156 void prevCompleter();
160 QVBoxLayout* mainLayout;
161 QDeclarativeView *view;
162 QDeclarativeView *progressBar;
165 QDeclarativeContext *ctxt;
166 QStringList* completerModel;
167 QCompleter* lineEditCompleter;
168 QString preferedCompliter;
169 QString actualString;
170 QStringList completerActualList;
172 QLineEdit* searchWordLineEdit;
173 QToolButton* clearSearchWordToolButton;
174 QPushButton* searchPushButton;
175 QToolButton* historyPrevToolButton;
176 QToolButton* historyNextToolButton;
177 QToolButton* historyShowToolButton;
178 QToolButton* fullScreenToolButton;
179 QHBoxLayout* horizontalLayout;
180 QProgressBar* searchingProgressBar;
183 //! generates icon for maemo (some of icons we use don't have inactive
184 //! pixmaps, so we generate them)
186 \param original original icon
187 \param rotation rotation of resulting icon
189 QIcon generateIcon(QIcon original, qreal rotation=0);
191 QVBoxLayout* verticalLayout;
201 #endif // SEARCHBARWIDGET_H