Back to index

scribus-ng  1.3.4.dfsg+svn20071115
multiprogressdialog.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008 *   Copyright (C) 2005 by Craig Bradney                                   *
00009 *   cbradney@zip.com.au                                                   *
00010 *                                                                         *
00011 *   This program is free software; you can redistribute it and/or modify  *
00012 *   it under the terms of the GNU General Public License as published by  *
00013 *   the Free Software Foundation; either version 2 of the License, or     *
00014 *   (at your option) any later version.                                   *
00015 *                                                                         *
00016 *   This program is distributed in the hope that it will be useful,       *
00017 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00019 *   GNU General Public License for more details.                          *
00020 *                                                                         *
00021 *   You should have received a copy of the GNU General Public License     *
00022 *   along with this program; if not, write to the                         *
00023 *   Free Software Foundation, Inc.,                                       *
00024 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00025 ***************************************************************************/
00026 
00027 #include "multiprogressdialog.h"
00028 #include "multiprogressdialog.moc"
00029 
00030 MultiProgressDialog::MultiProgressDialog(QWidget* parent, const char*name, bool modal, WFlags f)
00031 : MultiProgressDialogBase(parent, name, modal, f)
00032 {
00033 }
00034 
00035 MultiProgressDialog::MultiProgressDialog(const QString& titleText, const QString & cancelButtonText, QWidget* parent, const char*name, bool modal, WFlags f)
00036 : MultiProgressDialogBase(parent, name, modal, f)
00037 {
00038        setCaption(titleText);
00039        buttonCancel->setText(cancelButtonText);
00040 }
00041 
00042 MultiProgressDialog::~MultiProgressDialog()
00043 {
00044 }
00045 
00046 void MultiProgressDialog::removeExtraProgressBars()
00047 {
00048        progressBars.clear();
00049        progressLabels.clear();
00050 }
00051 
00052 bool MultiProgressDialog::addExtraProgressBars(const QStringList &barsList, const QStringList &barsTexts, const QValueList<bool>& barsNumerical)
00053 {
00054        uint barCount=barsList.count();
00055        if (barCount==0)
00056               return false;
00057        int gridLayoutRow=gridLayout->numRows();
00058        for (uint i=0; i<barCount; ++i)
00059        {
00060               QString barName(barsList[i]);
00061               if(progressBarTitles.contains(barName))
00062                      continue;
00063               progressBarTitles.append(barName);
00064               progressBars.insert(barName, new ScProgressBar(barsNumerical[i], this, barName));
00065               progressLabels.insert(barName, new QLabel(barsTexts[i], this, barName));
00066               gridLayout->addWidget(progressLabels[barName], gridLayoutRow, 0);
00067               gridLayout->addWidget(progressBars[barName], gridLayoutRow, 1);
00068               ++gridLayoutRow;
00069        }
00070        return true;
00071 }
00072 
00073 bool MultiProgressDialog::setLabel(const QString &barName, const QString & newLabel)
00074 {
00075        if (progressLabels.contains(barName))
00076        {
00077               progressLabels[barName]->setText(newLabel);
00078               return true;
00079        }
00080        return false;
00081 }
00082 
00083 bool MultiProgressDialog::setTotalSteps(const QString &barName, int totalSteps)
00084 {
00085        if (progressBars.contains(barName))
00086        {
00087               progressBars[barName]->setTotalSteps(totalSteps);
00088               return true;
00089        }
00090        return false;
00091 }
00092 
00093 bool MultiProgressDialog::setProgress(const QString &barName, int progress)
00094 {
00095        if (progressBars.contains(barName))
00096        {
00097               progressBars[barName]->setProgress(progress);
00098               return true;
00099        }
00100        return false;
00101 }
00102 
00103 bool MultiProgressDialog::setProgress(const QString &barName, int progress, int totalSteps)
00104 {
00105        if (progressBars.contains(barName))
00106        {
00107               progressBars[barName]->setProgress(progress, totalSteps);
00108               return true;
00109        }
00110        return false;
00111 }
00112 
00113 bool MultiProgressDialog::setupBar(const QString &barName, const QString & barText, int progress, int totalSteps)
00114 {
00115        if (progressLabels.contains(barName))
00116               progressLabels[barName]->setText(barText);
00117        else
00118               return false;
00119        if (progressBars.contains(barName))
00120        {
00121               progressBars[barName]->setProgress(progress, totalSteps);
00122               return true;
00123        }
00124        return false;
00125 }
00126 
00127 
00128 void MultiProgressDialog::setCancelButtonText(const QString & cancelButtonText)
00129 {
00130        buttonCancel->setText(cancelButtonText);
00131 }
00132 
00133 void MultiProgressDialog::setOverallTotalSteps(int totalSteps)
00134 {
00135        overallProgressBar->setTotalSteps(totalSteps);
00136 }
00137 
00138 void MultiProgressDialog::setOverallProgress(int progress)
00139 {
00140        overallProgressBar->setProgress(progress);
00141 }
00142 
00143 void MultiProgressDialog::setOverallProgress(int progress, int totalSteps)
00144 {
00145        overallProgressBar->setProgress(progress, totalSteps);
00146 }