Subversion Repositories Scribus

Rev

Rev 17635 | Rev 18194 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
4028 cbradney 7
/***************************************************************************
8
*   Copyright (C) 2005 by Craig Bradney                                   *
9
*   cbradney@zip.com.au                                                   *
10
*                                                                         *
11
*   This program is free software; you can redistribute it and/or modify  *
12
*   it under the terms of the GNU General Public License as published by  *
13
*   the Free Software Foundation; either version 2 of the License, or     *
14
*   (at your option) any later version.                                   *
15
*                                                                         *
16
*   This program is distributed in the hope that it will be useful,       *
17
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
19
*   GNU General Public License for more details.                          *
20
*                                                                         *
21
*   You should have received a copy of the GNU General Public License     *
22
*   along with this program; if not, write to the                         *
23
*   Free Software Foundation, Inc.,                                       *
18122 mrdocs 24
*   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
4028 cbradney 25
***************************************************************************/
26
 
27
#include "multiprogressdialog.h"
28
 
10508 cbradney 29
MultiProgressDialog::MultiProgressDialog(QWidget* parent, Qt::WFlags f)
30
: QDialog(parent, f)
4028 cbradney 31
{
8524 subik 32
        setupUi(this);
8560 subik 33
        connect(buttonCancel, SIGNAL(clicked()), this, SLOT(emitCancel()));
4028 cbradney 34
}
35
 
10508 cbradney 36
MultiProgressDialog::MultiProgressDialog(const QString& titleText, const QString & cancelButtonText, QWidget* parent, Qt::WFlags f)
37
: QDialog(parent, f)
4028 cbradney 38
{
8524 subik 39
        setupUi(this);
10495 cbradney 40
        setWindowTitle(titleText);
4028 cbradney 41
        buttonCancel->setText(cancelButtonText);
8560 subik 42
        connect(buttonCancel, SIGNAL(clicked()), this, SLOT(emitCancel()));
4028 cbradney 43
}
44
 
45
MultiProgressDialog::~MultiProgressDialog()
46
{
47
}
48
 
8559 subik 49
void MultiProgressDialog::emitCancel()
50
{
51
        emit canceled();
52
}
53
 
4028 cbradney 54
void MultiProgressDialog::removeExtraProgressBars()
55
{
56
        progressBars.clear();
57
        progressLabels.clear();
58
}
59
 
9729 cbradney 60
bool MultiProgressDialog::addExtraProgressBars(const QStringList &barsList, const QStringList &barsTexts, const QList<bool>& barsNumerical)
4028 cbradney 61
{
62
        uint barCount=barsList.count();
63
        if (barCount==0)
64
                return false;
10508 cbradney 65
        int gridLayoutRow=gridLayout->rowCount();
4028 cbradney 66
        for (uint i=0; i<barCount; ++i)
67
        {
68
                QString barName(barsList[i]);
69
                if(progressBarTitles.contains(barName))
70
                        continue;
71
                progressBarTitles.append(barName);
9951 cbradney 72
                progressBars.insert(barName, new QProgressBar(this));
73
                if (barsNumerical[i])
74
                        progressBars[barName]->setFormat(tr("%v of %m"));
10825 fschmid 75
                progressBars[barName]->setMinimumWidth(150);
10508 cbradney 76
                progressLabels.insert(barName, new QLabel(barsTexts[i], this));
4028 cbradney 77
                gridLayout->addWidget(progressLabels[barName], gridLayoutRow, 0);
78
                gridLayout->addWidget(progressBars[barName], gridLayoutRow, 1);
79
                ++gridLayoutRow;
80
        }
81
        return true;
82
}
83
 
13873 jghali 84
int MultiProgressDialog::overallProgress() const
85
{
86
        return overallProgressBar->value();
87
}
88
 
89
int MultiProgressDialog::progress(const QString &barName) const
90
{
91
        int progress = 0;
92
        if (progressBars.contains(barName))
93
                progress = progressBars[barName]->value();
17635 jghali 94
        return progress;
13873 jghali 95
}
96
 
4028 cbradney 97
bool MultiProgressDialog::setLabel(const QString &barName, const QString & newLabel)
98
{
99
        if (progressLabels.contains(barName))
100
        {
101
                progressLabels[barName]->setText(newLabel);
102
                return true;
103
        }
104
        return false;
105
}
106
 
16729 fschmid 107
bool MultiProgressDialog::setBusyIndicator(const QString &barName)
108
{
109
        if (progressBars.contains(barName))
110
        {
111
                progressBars[barName]->setMaximum(0);
112
                progressBars[barName]->setMinimum(0);
113
                return true;
114
        }
115
        return false;
116
}
117
 
4028 cbradney 118
bool MultiProgressDialog::setTotalSteps(const QString &barName, int totalSteps)
119
{
120
        if (progressBars.contains(barName))
121
        {
9951 cbradney 122
                progressBars[barName]->setMaximum(totalSteps);
4028 cbradney 123
                return true;
124
        }
125
        return false;
126
}
127
 
128
bool MultiProgressDialog::setProgress(const QString &barName, int progress)
129
{
130
        if (progressBars.contains(barName))
131
        {
9951 cbradney 132
                progressBars[barName]->setValue(progress);
4028 cbradney 133
                return true;
134
        }
135
        return false;
136
}
137
 
138
bool MultiProgressDialog::setProgress(const QString &barName, int progress, int totalSteps)
139
{
140
        if (progressBars.contains(barName))
141
        {
9951 cbradney 142
                progressBars[barName]->setMaximum(totalSteps);
143
                progressBars[barName]->setValue(progress);
4028 cbradney 144
                return true;
145
        }
146
        return false;
147
}
148
 
149
bool MultiProgressDialog::setupBar(const QString &barName, const QString & barText, int progress, int totalSteps)
150
{
151
        if (progressLabels.contains(barName))
152
                progressLabels[barName]->setText(barText);
153
        else
154
                return false;
155
        if (progressBars.contains(barName))
156
        {
9951 cbradney 157
                progressBars[barName]->setMaximum(totalSteps);
158
                progressBars[barName]->setValue(progress);
4028 cbradney 159
                return true;
160
        }
161
        return false;
162
}
163
 
164
 
165
void MultiProgressDialog::setCancelButtonText(const QString & cancelButtonText)
166
{
167
        buttonCancel->setText(cancelButtonText);
168
}
169
 
4038 cbradney 170
void MultiProgressDialog::setOverallTotalSteps(int totalSteps)
4028 cbradney 171
{
9913 cbradney 172
        overallProgressBar->setMaximum(totalSteps);
4028 cbradney 173
}
174
 
4038 cbradney 175
void MultiProgressDialog::setOverallProgress(int progress)
4028 cbradney 176
{
9913 cbradney 177
        overallProgressBar->setValue(progress);
4028 cbradney 178
}
179
 
4038 cbradney 180
void MultiProgressDialog::setOverallProgress(int progress, int totalSteps)
4028 cbradney 181
{
9913 cbradney 182
        overallProgressBar->setMaximum(totalSteps);
183
        overallProgressBar->setValue(progress);
4028 cbradney 184
}