oopapidocs  2.0
metadataloaderprogresswidget.cpp
00001 #include <QtGui>
00002 #include "abstractmetadataloader.h"
00003 #include "metadataloaderprogresswidget.h"
00004 
00005 
00006 MetaDataLoaderProgressWidget::MetaDataLoaderProgressWidget(Abstract::MetaDataLoader *mdl, QWidget *parent) :
00007     QWidget(parent)
00008 {
00009     QHBoxLayout *hbox = new QHBoxLayout(this);
00010     setLayout(hbox);
00011     m_progressBar = new QProgressBar;
00012     m_progressBar->setTextVisible(true);
00013     m_cancelButton=new QToolButton();
00014     m_cancelButton->setIcon(QIcon(":/icons/cancel.png"));
00015     hbox->addWidget(m_cancelButton);
00016     hbox->addWidget(m_progressBar);
00017     
00018     if (mdl == 0) mdl = Abstract::MetaDataLoader::instance();
00019     hookup(mdl);
00020     setVisible(false);
00021 }
00022 void MetaDataLoaderProgressWidget::hookup(Abstract::MetaDataLoader* mdl) {
00023         
00024     connect (mdl, SIGNAL(progressRangeChanged(int,int)),
00025              this, SLOT(updateRange(int, int)), Qt::QueuedConnection);
00026     connect (mdl, SIGNAL(progressRangeChanged(int,int)),
00027              this, SLOT(show()), Qt::QueuedConnection);
00028     connect (mdl, SIGNAL(finished()),
00029              this, SLOT(hide()), Qt::QueuedConnection);
00030 
00031     connect (mdl, SIGNAL(progressValueChanged(int)),
00032              m_progressBar, SLOT(setValue(int)), Qt::QueuedConnection);
00033     connect (mdl, SIGNAL(progressRangeChanged(int,int)),
00034              m_progressBar, SLOT(setRange(int,int)), Qt::QueuedConnection);
00035     connect (m_cancelButton, SIGNAL(triggered(QAction*)),
00036              mdl, SLOT(cancel()));
00037     connect (mdl, SIGNAL(fetched(MetaDataValue)), this, SLOT(updateStatus(MetaDataValue)));
00038 }
00039 
00040 void MetaDataLoaderProgressWidget::updateStatus(const MetaDataValue &v) {
00041     lastValue = v;
00042 }
00043 
00044 void MetaDataLoaderProgressWidget::updateRange(int min, int max) {
00045     show();
00046     m_progressBar->setRange(min, max);
00047 }
 All Classes Namespaces Functions Enumerations