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 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
25 #ifndef SEARCHBARWIDGET_H
26 #define SEARCHBARWIDGET_H
30 #include "../backbone/backbone.h"
31 #include "../../common/History.h"
33 //! Displays search bar
35 Contains line edit field to input word which user would like to find
36 and buttons to start/stop search and browse search history.
37 Line edit and history buttons are disabled when search is ongoing,
38 only start/stop button stays active. When searching it also displays
41 class SearchBarWidget : public QWidget {
44 explicit SearchBarWidget(QWidget *parent = 0);
48 //! Requests to search for list of words matching word passed as
50 void searchForTranslations(QString);
52 //! Requests to stop all active searchings
55 //! Requests to show previous translation in history
58 //! Requests to show next translation in history
61 //! Requests to show history list
63 \param p this argument is used only on desktop, it defines place on
64 which popup with history will be shown
66 void historyShow(QPoint p = QPoint(-1,-1));
68 //! Requests to refresh state of history buttons
69 void refreshHistoryButtons();
72 //! Enables or disables search word line edit and history buttons
74 While searching it disables only history button and line edit.
75 Search/Stop button is always enabled.
77 void setEnabled(bool);
80 //! Sets search bar in busy state
82 Displays "busy" bar and disables search word text edit and history buttons
86 //! Sets search bar in idle state
88 Hides "busy" bar and enables all widgets, refreshes state of history buttons
89 by emitting refreshHistoryButtons signal
93 //! Searches for given word
95 Sets word as text in search word line edit
97 void search(QString word);
99 //! Starts to search for given word after 500 ms delay
101 Sets word as text in search word line edit, and waits 500 ms to start
102 search. If in meanwhile this slot is called again it will stop previous
105 void searchDelay(QString word);
107 //! Updates state of history buttons
109 \param prev if set to true, the history have some previous words
110 \param next if set to true, the history have some next words
111 \param list if set to true, the history can show word list
113 void updateHistoryButtons(bool prev, bool next, bool list);
116 //! Clears search word line edit
117 void clearSearchWordToolButtonClicked();
119 //! Starts to search for given words
120 void searchPushButtonClicked();
122 //! starts to search word wich was passed to searchDelay
123 void delaySearchTimeout();
126 void showHistoryButtonClicked();
130 QLineEdit* searchWordLineEdit;
131 QCompleter* lineEditCompleter;
132 QStringListModel* completerModel;
133 QToolButton* clearSearchWordToolButton;
134 QPushButton* searchPushButton;
135 QToolButton* historyPrevToolButton;
136 QToolButton* historyNextToolButton;
137 QToolButton* historyShowToolButton;
138 QToolButton* fullScreenToolButton;
139 QHBoxLayout* horizontalLayout;
140 QProgressBar* searchingProgressBar;
143 //! generates icon for maemo (some of icons we use don't have inactive
144 //! pixmaps, so we generate them
146 \param oryginal oryginal icon
147 \param rotation rotation of resulting icon
149 QIcon generateIcon(QIcon oryginal, qreal rotation=0);
151 QVBoxLayout* verticalLayout;
161 #endif // SEARCHBARWIDGET_H