Changed repo structure
[mdictionary] / src / plugins / xdxf / XdxfCachingDialog.cpp
diff --git a/src/plugins/xdxf/XdxfCachingDialog.cpp b/src/plugins/xdxf/XdxfCachingDialog.cpp
new file mode 100644 (file)
index 0000000..3cf5bf3
--- /dev/null
@@ -0,0 +1,84 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file XdxfCachingDialog.cpp
+*/
+//Created by Mateusz Półrola
+
+#include "XdxfCachingDialog.h"
+#include "xdxfplugin.h"
+#include <QDebug>
+
+
+XdxfCachingDialog::XdxfCachingDialog(XdxfPlugin *parent) //:
+//    QDialog((QWidget*)parent)
+{
+    verticalLayout = new QVBoxLayout(this);
+    setLayout(verticalLayout);
+
+    setWindowTitle(tr("Caching dictionary, please wait"));
+    cachingProgressBar = new QProgressBar(this);
+    cachingProgressBar->setMinimum(0);
+    cachingProgressBar->setMaximum(100);
+    cachingProgressBar->setTextVisible(true);
+
+    cancelButton = new QPushButton(tr("Cancel"),this);
+
+
+    cachingLabel = new QLabel(this);
+    cachingLabel->hide();
+
+
+    verticalLayout->addWidget(cachingLabel);
+    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();
+}
+
+void XdxfCachingDialog::updateCachingProgress(int progress, int time) {
+    cachingProgressBar->setValue(progress);
+
+    if(!cachingLabel->isVisible())
+        cachingLabel->show();
+
+    int seconds = float((100 - progress)*time) / (5*1000);
+
+    cachingLabel->setText(tr("Estimated time left: ") +
+                     /*QString::number(seconds)*/  tr("%n second(s)", "", seconds));
+    if(progress >= 100)
+        this->hide();
+        
+
+}
+
+void XdxfCachingDialog::reject() {
+    return;
+}
+
+void XdxfCachingDialog::cancelButtonClicked(){
+    return;
+}