Copyright 2010 Comarch S.A.
*******************************************************************************/
+/*!
+ \file XdxfDictDownloadProgressDialog.cpp
+ \brief Shows downloading progress bar.
-//Created by Mateusz Półrola
+ \author Mateusz Półrola <mateusz.polrola@comarch.com>
+*/
#include "XdxfDictDownloadProgressDialog.h"
XdxfDictDownloadProgressDialog::XdxfDictDownloadProgressDialog(QWidget*parent):
QDialog(parent) {
+#ifndef Q_WS_MAEMO_5
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/XdxfDictDownloader.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+ view->setWindowTitle(tr("Progres Dialog"));
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(this, SIGNAL(setValue(QVariant)),
+ rootObject, SLOT(setValue(QVariant)));
+ connect(this, SIGNAL(setTextt(QVariant)),
+ rootObject, SLOT(setText(QVariant)));
+ connect(this, SIGNAL(setMaximumValue(QVariant)),
+ rootObject, SLOT(setMaximumValue(QVariant)));
+
+ connect(rootObject, SIGNAL(cancelDownloading()),
+ this, SLOT(reject()));
+
+#else
verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
connect(cancelButton, SIGNAL(clicked()),
this, SIGNAL(cancelDownloading()));
-
#ifndef Q_WS_MAEMO_5
downloadLabel = new QLabel(this);
verticalLayout->addWidget(downloadLabel, 0, Qt::AlignCenter);
verticalLayout->addWidget(downloadProgressBar);
verticalLayout->addWidget(cancelButton);
-
setModal(true);
#ifndef Q_WS_MAEMO_5
setMinimumWidth(350);
#endif
+#endif
+}
+
+
+void XdxfDictDownloadProgressDialog::show() {
+#ifndef Q_WS_MAEMO_5
+ emit setMaximumValue(0);
+ maximumValue=0;
+#else
+ downloadProgressBar->setMaximum(0);
+ QDialog::show();
+#endif
+ QDialog::show();
}
void XdxfDictDownloadProgressDialog::setText(QString text) {
+#ifndef Q_WS_MAEMO_5
+ emit setTextt(text);
+#else
setWindowTitle(text);
- #ifndef Q_WS_MAEMO_5
- downloadLabel->setText(text);
- #endif
+#endif
+}
+
+
+void XdxfDictDownloadProgressDialog::updateProgress(float progress) {
+#ifndef Q_WS_MAEMO_5
+ if(maximumValue == 0) {
+ emit setMaximumValue(100);
+ }
+ emit setValue((int)(progress*100));
+#else
+ if(downloadProgressBar->maximum() == 0) {
+ downloadProgressBar->setMaximum(100);
+ }
+ downloadProgressBar->setValue(progress*100);
+#endif
}
+
void XdxfDictDownloadProgressDialog::reject() {
- return;
+ #ifndef Q_WS_MAEMO_5
+ emit cancelDownloading();
+ emit setValue(-1);
+ #else
+ return;
+ #endif
}