Partialy refactorized, fixed some bugs
[mdictionary] / trunk / src / base / gui / SearchBarWidget.cpp
index 4f4f84a..6c62be5 100644 (file)
@@ -19,7 +19,8 @@
 
 *******************************************************************************/
 
-//Created by Mateusz Półrola
+//! \file SearchBarWidget.cpp
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 
 #include "SearchBarWidget.h"
@@ -34,7 +35,7 @@ SearchBarWidget::SearchBarWidget(QWidget *parent) :
     initializeUI();
 
 
-    _isSearching = false;
+    busy = false;
 
     connect(searchPushButton, SIGNAL(clicked()),
             this, SLOT(searchPushButtonClicked()));
@@ -64,6 +65,7 @@ SearchBarWidget::SearchBarWidget(QWidget *parent) :
     historyPrevToolButton->setEnabled(false);
     historyNextToolButton->setEnabled(false);
     historyShowToolButton->setEnabled(false);
+
     setEnabled(true);
 }
 
@@ -142,7 +144,6 @@ void SearchBarWidget::initializeUI() {
     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);
@@ -218,7 +219,7 @@ void SearchBarWidget::initializeUI() {
 
 
 void SearchBarWidget::searchPushButtonClicked() {
-    if(_isSearching) {
+    if(busy) {
         Q_EMIT stopSearching();
     }
     else {
@@ -228,7 +229,7 @@ void SearchBarWidget::searchPushButtonClicked() {
 
 
 void SearchBarWidget::search(QString word) {
-    if(!_isSearching && !word.isEmpty()) {
+    if(!busy && !word.isEmpty()) {
         completerModel->insertRow(completerModel->rowCount());
         QModelIndex index =
                 completerModel->index(completerModel->rowCount() -1);
@@ -242,7 +243,7 @@ void SearchBarWidget::search(QString word) {
 }
 
 void SearchBarWidget::searchDelay(QString word) {
-    if(!_isSearching && !word.isEmpty()) {
+    if(!busy && !word.isEmpty()) {
         searchWordLineEdit->setText(word);
 
 
@@ -257,7 +258,7 @@ void SearchBarWidget::searchDelay(QString word) {
 
 void SearchBarWidget::delaySearchTimeout() {
     delayTimer.stop();
-    if(!_isSearching) {
+    if(!busy) {
         Q_EMIT searchForTranslations(delayString);
     }
 }
@@ -273,19 +274,19 @@ void SearchBarWidget::setEnabled(bool enabled) {
 }
 
 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();
 }
 
@@ -297,7 +298,7 @@ void SearchBarWidget::clearSearchWordToolButtonClicked() {
 
 
 void SearchBarWidget::updateHistoryButtons(bool prev, bool next, bool list) {
-    if(!_isSearching) {
+    if(!busy) {
         historyPrevToolButton->setEnabled(prev);
         historyNextToolButton->setEnabled(next);
         historyShowToolButton->setEnabled(list);
@@ -305,11 +306,11 @@ void SearchBarWidget::updateHistoryButtons(bool prev, bool next, bool 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
 }