22 #include <QtGui/QProgressBar>
23 #include <QtGui/QPushButton>
24 #include <QtGui/QLabel>
25 #include <QtGui/QLayout>
32 setFrameStyle(QFrame::NoFrame);
33 m_pb =
new QProgressBar();
35 m_pb->setMaximum(100);
38 m_pbdetails->setFixedWidth(32);
40 m_pbdetails->setEnabled(
false);
42 QHBoxLayout *hbox =
new QHBoxLayout(
this);
44 hbox->addWidget(m_pbdetails);
45 hbox->addWidget(m_pb);
48 m_details->setWindowFlags(Qt::Popup);
51 m_detailsvbox =
new QVBoxLayout(m_details);
53 connect(m_pbdetails, SIGNAL(clicked()), SLOT(
slotClicked()));
58 QPoint indicatorpos = mapToGlobal(pos());
59 m_details->move(indicatorpos.x(), indicatorpos.y());
61 if (m_details->isVisible())
71 m_progress[message] = percentage;
73 if (!m_progresswidgets.contains(message)) {
78 urlLabel->setText(message);
81 pb =
new QProgressBar(pbcontainer);
84 m_progresswidgets.insert(message, pb);
88 pbcancel->setFixedWidth(32);
89 pbcancel->setIcon(
SmallIcon(
"dialog-cancel"));
91 QGridLayout *layout =
new QGridLayout(pbcontainer);
92 layout->addWidget(urlLabel, 0, 0, 1, 2);
93 layout->addWidget(pbcancel, 1, 0);
94 layout->addWidget(pb, 1, 1);
96 m_detailsvbox->addWidget(pbcontainer);
100 pb = m_progresswidgets[message];
103 pb->setValue(percentage);
105 if (m_progress.count() > 0)
106 m_pbdetails->setEnabled(
true);
108 if (percentage == 100)
116 m_progress.remove(message);
118 if (m_progresswidgets[message]) {
119 delete m_progresswidgets[message]->parentWidget();
120 m_progresswidgets.remove(message);
123 if (m_progress.count() == 0) {
124 m_pbdetails->setEnabled(
false);
131 void QProgressIndicator::calculateAverage()
133 if (m_progress.count() == 0) {
139 QHashIterator<QString, int> it(m_progress);
140 while (it.hasNext()) {
142 average += it.value();
144 average = (average / m_progress.count());
146 m_pb->setValue(average);
149 #include "qprogressindicator.moc"
QProgressIndicator(QWidget *parent)
void addProgress(const QString &message, int percentage)
QPixmap SmallIcon(const QString &name, int force_size, int state, const QStringList &overlays)
void removeProgress(const QString &message)