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 "../../include/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 a list of words matching a 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 a 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 a given word
95 Sets word as text in search word line edit
97 void search(QString word);
99 //! Starts to search for a 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 the meantime 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 has some previous words
110 \param next if set to true, the history has 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);
118 //! Clears search word line edit
119 void clearSearchWordToolButtonClicked();
121 //! Starts to search for given words
122 void searchPushButtonClicked();
124 //! starts to search word which was passed to searchDelay
125 void delaySearchTimeout();
128 void showHistoryButtonClicked();
132 QLineEdit* searchWordLineEdit;
133 QCompleter* lineEditCompleter;
134 QStringListModel* completerModel;
135 QToolButton* clearSearchWordToolButton;
136 QPushButton* searchPushButton;
137 QToolButton* historyPrevToolButton;
138 QToolButton* historyNextToolButton;
139 QToolButton* historyShowToolButton;
140 QToolButton* fullScreenToolButton;
141 QHBoxLayout* horizontalLayout;
142 QProgressBar* searchingProgressBar;
145 //! generates icon for maemo (some of icons we use don't have inactive
146 //! pixmaps, so we generate them)
148 \param original original icon
149 \param rotation rotation of resulting icon
151 QIcon generateIcon(QIcon original, qreal rotation=0);
153 QVBoxLayout* verticalLayout;
163 #endif // SEARCHBARWIDGET_H