Subversion Repositories Scribus

Rev

Rev 4038 | Go to most recent revision | Details | 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
        //progressBars=new QDict<QProgressBar>();
28
        //progressLabels=new QDict<QLabel>();
29
        //progressBars.setAutoDelete(true);
30
        //progressLabels.setAutoDelete(true);
31
}
32
 
33
MultiProgressDialog::MultiProgressDialog(const QString& titleText, const QString & cancelButtonText, QWidget* parent, const char*name, bool modal, WFlags f)
34
: MultiProgressDialogBase(parent, name, modal, f)
35
{
36
        setCaption(titleText);
37
        buttonCancel->setText(cancelButtonText);
38
}
39
 
40
MultiProgressDialog::~MultiProgressDialog()
41
{
42
        //delete progressBars;
43
        //delete progressLabels;
44
}
45
 
46
void MultiProgressDialog::removeExtraProgressBars()
47
{
48
        progressBars.clear();
49
        progressLabels.clear();
50
}
51
 
52
bool MultiProgressDialog::addExtraProgressBars(const QStringList &barsList, const QStringList &barsTexts)
53
{
54
        uint barCount=barsList.count();
55
        if (barCount==0)
56
                return false;
57
        int gridLayoutRow=gridLayout->numRows();
58
        for (uint i=0; i<barCount; ++i)
59
        {
60
                QString barName(barsList[i]);
61
                if(progressBarTitles.contains(barName))
62
                        continue;
63
                progressBarTitles.append(barName);
64
                progressBars.insert(barName, new QProgressBar(this, barName));
65
                progressLabels.insert(barName, new QLabel(barsTexts[i], this, barName));
66
                gridLayout->addWidget(progressLabels[barName], gridLayoutRow, 0);
67
                gridLayout->addWidget(progressBars[barName], gridLayoutRow, 1);
68
                ++gridLayoutRow;
69
        }
70
        return true;
71
}
72
 
73
bool MultiProgressDialog::setLabel(const QString &barName, const QString & newLabel)
74
{
75
        if (progressLabels.contains(barName))
76
        {
77
                progressLabels[barName]->setText(newLabel);
78
                return true;
79
        }
80
        return false;
81
}
82
 
83
bool MultiProgressDialog::setTotalSteps(const QString &barName, int totalSteps)
84
{
85
        if (progressBars.contains(barName))
86
        {
87
                progressBars[barName]->setTotalSteps(totalSteps);
88
                return true;
89
        }
90
        return false;
91
}
92
 
93
bool MultiProgressDialog::setProgress(const QString &barName, int progress)
94
{
95
        if (progressBars.contains(barName))
96
        {
97
                progressBars[barName]->setProgress(progress);
98
                return true;
99
        }
100
        return false;
101
}
102
 
103
bool MultiProgressDialog::setProgress(const QString &barName, int progress, int totalSteps)
104
{
105
        if (progressBars.contains(barName))
106
        {
107
                progressBars[barName]->setProgress(progress, totalSteps);
108
                return true;
109
        }
110
        return false;
111
}
112
 
113
bool MultiProgressDialog::setupBar(const QString &barName, const QString & barText, int progress, int totalSteps)
114
{
115
        if (progressLabels.contains(barName))
116
                progressLabels[barName]->setText(barText);
117
        else
118
                return false;
119
        if (progressBars.contains(barName))
120
        {
121
                progressBars[barName]->setProgress(progress, totalSteps);
122
                return true;
123
        }
124
        return false;
125
}
126
 
127
 
128
void MultiProgressDialog::setCancelButtonText(const QString & cancelButtonText)
129
{
130
        buttonCancel->setText(cancelButtonText);
131
}
132
 
133
bool MultiProgressDialog::setOverallTotalSteps(int totalSteps)
134
{
135
        overallProgressBar->setTotalSteps(totalSteps);
136
}
137
 
138
bool MultiProgressDialog::setOverallProgress(int progress)
139
{
140
        overallProgressBar->setProgress(progress);
141
}
142
 
143
bool MultiProgressDialog::setOverallProgress(int progress, int totalSteps)
144
{
145
        overallProgressBar->setProgress(progress, totalSteps);
146
}