Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
4028 cbradney 1
/***************************************************************************
2
*   Copyright (C) 2005 by Craig Bradney                                   *
3
*   cbradney@zip.com.au                                                   *
4
*                                                                         *
5
*   This program is free software; you can redistribute it and/or modify  *
6
*   it under the terms of the GNU General Public License as published by  *
7
*   the Free Software Foundation; either version 2 of the License, or     *
8
*   (at your option) any later version.                                   *
9
*                                                                         *
10
*   This program is distributed in the hope that it will be useful,       *
11
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
*   GNU General Public License for more details.                          *
14
*                                                                         *
15
*   You should have received a copy of the GNU General Public License     *
16
*   along with this program; if not, write to the                         *
17
*   Free Software Foundation, Inc.,                                       *
18
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19
***************************************************************************/
20
 
21
#include "multiprogressdialog.h"
22
#include "multiprogressdialog.moc"
23
 
24
MultiProgressDialog::MultiProgressDialog(QWidget* parent, const char*name, bool modal, WFlags f)
25
: MultiProgressDialogBase(parent, name, modal, f)
26
{
27
}
28
 
29
MultiProgressDialog::MultiProgressDialog(const QString& titleText, const QString & cancelButtonText, QWidget* parent, const char*name, bool modal, WFlags f)
30
: MultiProgressDialogBase(parent, name, modal, f)
31
{
32
        setCaption(titleText);
33
        buttonCancel->setText(cancelButtonText);
34
}
35
 
36
MultiProgressDialog::~MultiProgressDialog()
37
{
38
}
39
 
40
void MultiProgressDialog::removeExtraProgressBars()
41
{
42
        progressBars.clear();
43
        progressLabels.clear();
44
}
45
 
46
bool MultiProgressDialog::addExtraProgressBars(const QStringList &barsList, const QStringList &barsTexts)
47
{
48
        uint barCount=barsList.count();
49
        if (barCount==0)
50
                return false;
51
        int gridLayoutRow=gridLayout->numRows();
52
        for (uint i=0; i<barCount; ++i)
53
        {
54
                QString barName(barsList[i]);
55
                if(progressBarTitles.contains(barName))
56
                        continue;
57
                progressBarTitles.append(barName);
58
                progressBars.insert(barName, new QProgressBar(this, barName));
59
                progressLabels.insert(barName, new QLabel(barsTexts[i], this, barName));
60
                gridLayout->addWidget(progressLabels[barName], gridLayoutRow, 0);
61
                gridLayout->addWidget(progressBars[barName], gridLayoutRow, 1);
62
                ++gridLayoutRow;
63
        }
64
        return true;
65
}
66
 
67
bool MultiProgressDialog::setLabel(const QString &barName, const QString & newLabel)
68
{
69
        if (progressLabels.contains(barName))
70
        {
71
                progressLabels[barName]->setText(newLabel);
72
                return true;
73
        }
74
        return false;
75
}
76
 
77
bool MultiProgressDialog::setTotalSteps(const QString &barName, int totalSteps)
78
{
79
        if (progressBars.contains(barName))
80
        {
81
                progressBars[barName]->setTotalSteps(totalSteps);
82
                return true;
83
        }
84
        return false;
85
}
86
 
87
bool MultiProgressDialog::setProgress(const QString &barName, int progress)
88
{
89
        if (progressBars.contains(barName))
90
        {
91
                progressBars[barName]->setProgress(progress);
92
                return true;
93
        }
94
        return false;
95
}
96
 
97
bool MultiProgressDialog::setProgress(const QString &barName, int progress, int totalSteps)
98
{
99
        if (progressBars.contains(barName))
100
        {
101
                progressBars[barName]->setProgress(progress, totalSteps);
102
                return true;
103
        }
104
        return false;
105
}
106
 
107
bool MultiProgressDialog::setupBar(const QString &barName, const QString & barText, int progress, int totalSteps)
108
{
109
        if (progressLabels.contains(barName))
110
                progressLabels[barName]->setText(barText);
111
        else
112
                return false;
113
        if (progressBars.contains(barName))
114
        {
115
                progressBars[barName]->setProgress(progress, totalSteps);
116
                return true;
117
        }
118
        return false;
119
}
120
 
121
 
122
void MultiProgressDialog::setCancelButtonText(const QString & cancelButtonText)
123
{
124
        buttonCancel->setText(cancelButtonText);
125
}
126
 
4038 cbradney 127
void MultiProgressDialog::setOverallTotalSteps(int totalSteps)
4028 cbradney 128
{
129
        overallProgressBar->setTotalSteps(totalSteps);
130
}
131
 
4038 cbradney 132
void MultiProgressDialog::setOverallProgress(int progress)
4028 cbradney 133
{
134
        overallProgressBar->setProgress(progress);
135
}
136
 
4038 cbradney 137
void MultiProgressDialog::setOverallProgress(int progress, int totalSteps)
4028 cbradney 138
{
139
        overallProgressBar->setProgress(progress, totalSteps);
140
}