*******************************************************************************/
-//Created by Mateusz Półrola
+//! \file SearchBarWidget.cpp
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
#include "SearchBarWidget.h"
initializeUI();
- _isSearching = false;
+ busy = false;
connect(searchPushButton, SIGNAL(clicked()),
this, SLOT(searchPushButtonClicked()));
historyPrevToolButton->setEnabled(false);
historyNextToolButton->setEnabled(false);
historyShowToolButton->setEnabled(false);
+
setEnabled(true);
}
clearSearchWordToolButton = new QToolButton;
#ifdef Q_WS_MAEMO_5
clearSearchWordToolButton->setIcon(QIcon::fromTheme("general_stop"));
- //tool buttons will have size 2 times smaller
clearSearchWordToolButton->setMaximumSize(
clearSearchWordToolButton->sizeHint().height()/2,
clearSearchWordToolButton->sizeHint().height()/2);
void SearchBarWidget::searchPushButtonClicked() {
- if(_isSearching) {
+ if(busy) {
Q_EMIT stopSearching();
}
else {
void SearchBarWidget::search(QString word) {
- if(!_isSearching && !word.isEmpty()) {
+ if(!busy && !word.isEmpty()) {
completerModel->insertRow(completerModel->rowCount());
QModelIndex index =
completerModel->index(completerModel->rowCount() -1);
}
void SearchBarWidget::searchDelay(QString word) {
- if(!_isSearching && !word.isEmpty()) {
+ if(!busy && !word.isEmpty()) {
searchWordLineEdit->setText(word);
void SearchBarWidget::delaySearchTimeout() {
delayTimer.stop();
- if(!_isSearching) {
+ if(!busy) {
Q_EMIT searchForTranslations(delayString);
}
}
}
void SearchBarWidget::setBusy() {
- if(_isSearching) return;
+ if(busy) return;
searchingProgressBar->show();
searchPushButton->setText(tr("Stop"));
setEnabled(false);
- _isSearching = true;
+ busy = true;
}
void SearchBarWidget::setIdle() {
- if(!_isSearching) return;
+ if(!busy) return;
searchingProgressBar->hide();
searchPushButton->setText(tr("Search"));
setEnabled(true);
- _isSearching = false;
+ busy = false;
Q_EMIT refreshHistoryButtons();
}
void SearchBarWidget::updateHistoryButtons(bool prev, bool next, bool list) {
- if(!_isSearching) {
+ if(!busy) {
historyPrevToolButton->setEnabled(prev);
historyNextToolButton->setEnabled(next);
historyShowToolButton->setEnabled(list);
}
void SearchBarWidget::showHistoryButtonClicked() {
- #ifndef Q_WS_MAEMO_5
+ #ifdef Q_WS_MAEMO_5
+ emit historyShow();
+ #else
QPoint p = historyShowToolButton->pos();
p.setY(p.y());
emit historyShow(mapToGlobal(p));
- #else
- emit historyShow();
#endif
}