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 Implements search bar
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
26 #ifndef SEARCHBARWIDGET_H
27 #define SEARCHBARWIDGET_H
31 #include "../backbone/backbone.h"
32 #include "../../includes/History.h"
34 //! Displays search bar
36 Contains line edit field to input word which user would like to find
37 and buttons to start/stop search and browse search history.
38 Line edit and history buttons are disabled when search is ongoing,
39 only start/stop button stays active. When searching it also displays
42 class SearchBarWidget : public QWidget {
45 explicit SearchBarWidget(QWidget *parent = 0);
49 //! Requests to search for list of words matching word passed as
51 void searchForTranslations(QString);
53 //! Requests to stop all active searchings
56 //! Requests to show previous translation in history
59 //! Requests to show next translation in history
62 //! Requests to show history list
64 \param p this argument is used only on desktop, it defines place on
65 which popup with history will be shown
67 void historyShow(QPoint p = QPoint(-1,-1));
69 //! Requests to refresh state of history buttons
70 void refreshHistoryButtons();
73 //! Enables or disables search word line edit and history buttons
75 While searching it disables only history button and line edit.
76 Search/Stop button is always enabled.
78 void setEnabled(bool);
81 //! Sets search bar in busy state
83 Displays "busy" bar and disables search word text edit and history buttons
87 //! Sets search bar in idle state
89 Hides "busy" bar and enables all widgets, refreshes state of history buttons
90 by emitting refreshHistoryButtons signal
94 //! Searches for given word
96 Sets word as text in search word line edit
98 void search(QString word);
100 //! Starts to search for given word after 500 ms delay
102 Sets word as text in search word line edit, and waits 500 ms to start
103 search. If in meanwhile this slot is called again it will stop previous
106 void searchDelay(QString word);
108 //! Updates state of history buttons
110 \param prev if set to true, the history have some previous words
111 \param next if set to true, the history have some next words
112 \param list if set to true, the history can show word list
114 void updateHistoryButtons(bool prev, bool next, bool list);
117 //! Clears search word line edit
118 void clearSearchWordToolButtonClicked();
120 //! Starts to search for given words
121 void searchPushButtonClicked();
123 //! starts to search word wich was passed to searchDelay
124 void delaySearchTimeout();
127 void showHistoryButtonClicked();
131 QLineEdit* searchWordLineEdit;
132 QCompleter* lineEditCompleter;
133 QStringListModel* completerModel;
134 QToolButton* clearSearchWordToolButton;
135 QPushButton* searchPushButton;
136 QToolButton* historyPrevToolButton;
137 QToolButton* historyNextToolButton;
138 QToolButton* historyShowToolButton;
139 QToolButton* fullScreenToolButton;
140 QHBoxLayout* horizontalLayout;
141 QProgressBar* searchingProgressBar;
144 //! generates icon for maemo
145 QIcon generateIcon(QIcon oryginal, qreal rotation=0);
147 QVBoxLayout* verticalLayout;
157 #endif // SEARCHBARWIDGET_H