1/*
2 Copyright (c) 2013 Montel Laurent <montel@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20
21#include "progressindicatorlabel.h"
22#include "progressindicatorwidget.h"
23
24#include <QHBoxLayout>
25
26namespace KPIMUtils {
27class ProgressIndicatorLabelPrivate
28{
29public:
30 ProgressIndicatorLabelPrivate(const QString &_label, ProgressIndicatorLabel *qq)
31 : labelStr(_label),
32 q(qq)
33 {
34 QHBoxLayout *lay = new QHBoxLayout;
35 lay->setMargin(0);
36 q->setLayout(lay);
37 indicator = new ProgressIndicatorWidget;
38 lay->addWidget(indicator);
39 label = new QLabel;
40 lay->addWidget(label);
41 }
42
43 ~ProgressIndicatorLabelPrivate()
44 {
45 }
46
47 void setActiveLabel(const QString &str)
48 {
49 if (indicator->isActive()) {
50 label->setText(str);
51 }
52 }
53
54 void start()
55 {
56 indicator->start();
57 label->setText(labelStr);
58 }
59
60 void stop()
61 {
62 indicator->stop();
63 label->clear();
64 }
65
66 QString labelStr;
67 QLabel *label;
68 ProgressIndicatorWidget *indicator;
69 ProgressIndicatorLabel *q;
70};
71
72ProgressIndicatorLabel::ProgressIndicatorLabel(const QString &label, QWidget *parent)
73 : QWidget(parent),
74 d(new ProgressIndicatorLabelPrivate(label, this))
75{
76}
77
78ProgressIndicatorLabel::ProgressIndicatorLabel(QWidget *parent)
79 : QWidget(parent),
80 d(new ProgressIndicatorLabelPrivate(QString(), this))
81{
82}
83
84ProgressIndicatorLabel::~ProgressIndicatorLabel()
85{
86 delete d;
87}
88
89void ProgressIndicatorLabel::start()
90{
91 d->start();
92}
93
94void ProgressIndicatorLabel::stop()
95{
96 d->stop();
97}
98
99void ProgressIndicatorLabel::setActiveLabel(const QString &label)
100{
101 d->setActiveLabel(label);
102}
103
104}
105
106