starDict dialog in qml
[mdictionary] / src / plugins / xdxf / XdxfCachingDialog.cpp
index 3cf5bf3..bc73a32 100644 (file)
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
+/*!
+    \file XdxfCachingDialog.cpp
+    \brief Shows dialog with progress of dictionary caching
 
-/*! \file XdxfCachingDialog.cpp
+    \author Mateusz Półrola
 */
-//Created by Mateusz Półrola
 
 #include "XdxfCachingDialog.h"
 #include "xdxfplugin.h"
 #include <QDebug>
 
 
-XdxfCachingDialog::XdxfCachingDialog(XdxfPlugin *parent) //:
-//    QDialog((QWidget*)parent)
-{
+XdxfCachingDialog::XdxfCachingDialog(QWidget *parent): QDialog(parent) {
     verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
@@ -41,44 +41,37 @@ XdxfCachingDialog::XdxfCachingDialog(XdxfPlugin *parent) //:
     cachingProgressBar->setTextVisible(true);
 
     cancelButton = new QPushButton(tr("Cancel"),this);
+    cachingTimeLabel = new QLabel(this);
+    cachingTimeLabel->hide();
 
+    #ifndef Q_WS_MAEMO_5
+            cachingLabel = new QLabel(this);
+            cachingLabel->setText(tr("Caching dictionary, please wait"));
+            verticalLayout->addWidget(cachingLabel, 0, Qt::AlignCenter);
+    #endif
 
-    cachingLabel = new QLabel(this);
-    cachingLabel->hide();
-
-
-    verticalLayout->addWidget(cachingLabel);
+    verticalLayout->addWidget(cachingTimeLabel);
     verticalLayout->addWidget(cachingProgressBar);
     verticalLayout->addWidget(cancelButton);
 
     connect(cancelButton, SIGNAL(clicked()),
             this, SIGNAL(cancelCaching()));
 
-   connect(parent, SIGNAL(updateCachingProgress(int, int)),
-           this, SLOT(updateCachingProgress(int, int)));
     time.start();
+    setModal(true);
 }
 
+
 void XdxfCachingDialog::updateCachingProgress(int progress, int time) {
     cachingProgressBar->setValue(progress);
 
-    if(!cachingLabel->isVisible())
-        cachingLabel->show();
+    if(!cachingTimeLabel->isVisible())
+        cachingTimeLabel->show();
 
     int seconds = float((100 - progress)*time) / (5*1000);
 
-    cachingLabel->setText(tr("Estimated time left: ") +
-                     /*QString::number(seconds)*/  tr("%n second(s)", "", seconds));
+    cachingTimeLabel->setText(tr("Estimated time left: ") +
+                          tr("%n second(s)", "", seconds));
     if(progress >= 100)
-        this->hide();
-        
-
-}
-
-void XdxfCachingDialog::reject() {
-    return;
-}
-
-void XdxfCachingDialog::cancelButtonClicked(){
-    return;
+        this->accept();
 }