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 "../backbone/backbone.h"
34 #include "../../include/History.h"
37 Contains line edit field to input word which user would like to find
38 and buttons to start/stop search and browse search history.
39 Line edit and history buttons are disabled when search is ongoing,
40 only start/stop button stays active. When searching it also displays
43 class SearchBarWidget : public QWidget {
46 explicit SearchBarWidget(QWidget *parent = 0);
50 //! Requests to search for a list of words matching a word passed as
52 void searchForTranslations(QString);
54 //! Requests to stop all active searchings
57 //! Requests to show previous translation in history
60 //! Requests to show next translation in history
63 //! Requests to show history list
65 \param p this argument is used only on desktop, it defines place on
66 which a popup with history will be shown
68 void historyShow(QPoint p = QPoint(-1,-1));
70 //! Requests to refresh state of history buttons
71 void refreshHistoryButtons();
74 //! Enables or disables search word line edit and history buttons
76 While searching it disables only history button and line edit.
77 Search/Stop button is always enabled.
79 void setEnabled(bool);
82 //! Sets search bar in busy state
84 Displays "busy" bar and disables search word text edit and history buttons
88 //! Sets search bar in idle state
90 Hides "busy" bar and enables all widgets, refreshes state of history buttons
91 by emitting refreshHistoryButtons signal
95 //! Searches for a given word
97 Sets word as text in search word line edit
99 void search(QString word);
101 //! Starts to search for a given word after 500 ms delay
103 Sets word as text in search word line edit, and waits 500 ms to start
104 search. If in the meantime this slot is called again it will stop previous
107 void searchDelay(QString word);
109 //! Updates state of history buttons
111 \param prev if set to true, the history has some previous words
112 \param next if set to true, the history has some next words
113 \param list if set to true, the history can show word list
115 void updateHistoryButtons(bool prev, bool next, bool list);
120 //! Clears search word line edit
121 void clearSearchWordToolButtonClicked();
123 //! Starts to search for given words
124 void searchPushButtonClicked();
126 //! starts to search word which was passed to searchDelay
127 void delaySearchTimeout();
130 void showHistoryButtonClicked();
134 QLineEdit* searchWordLineEdit;
135 QCompleter* lineEditCompleter;
136 QStringListModel* completerModel;
137 QToolButton* clearSearchWordToolButton;
138 QPushButton* searchPushButton;
139 QToolButton* historyPrevToolButton;
140 QToolButton* historyNextToolButton;
141 QToolButton* historyShowToolButton;
142 QToolButton* fullScreenToolButton;
143 QHBoxLayout* horizontalLayout;
144 QProgressBar* searchingProgressBar;
147 //! generates icon for maemo (some of icons we use don't have inactive
148 //! pixmaps, so we generate them)
150 \param original original icon
151 \param rotation rotation of resulting icon
153 QIcon generateIcon(QIcon original, qreal rotation=0);
155 QVBoxLayout* verticalLayout;
165 #endif // SEARCHBARWIDGET_H