fix red and remove tabs
[kugel-rb.git] / rbutil / rbutilqt / progressloggergui.cpp
blobb66ec89a25843f90227af2192878ccba14b1967c
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id$
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "progressloggergui.h"
22 ProgressLoggerGui::ProgressLoggerGui(QObject* parent): ProgressloggerInterface(parent)
24 downloadProgress = new QDialog();
25 downloadProgress->setModal(true);
26 dp.setupUi(downloadProgress);
27 dp.listProgress->setAlternatingRowColors(true);
28 connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
31 void ProgressLoggerGui::addItem(const QString &text)
33 addItem(text, LOGNOICON);
36 void ProgressLoggerGui::addItem(const QString &text, int flag)
38 QListWidgetItem* item = new QListWidgetItem(text);
40 switch(flag)
42 case LOGNOICON:
43 break;
44 case LOGOK:
45 item->setIcon(QIcon(":/icons/go-next.png"));
46 break;
47 case LOGINFO:
48 item->setIcon(QIcon(":/icons/dialog-information.png"));
49 break;
50 case LOGWARNING:
51 item->setIcon(QIcon(":/icons/dialog-warning.png"));
52 break;
53 case LOGERROR:
54 item->setIcon(QIcon(":/icons/dialog-error.png"));
55 break;
58 dp.listProgress->addItem(item);
59 dp.listProgress->scrollToItem(item);
62 void ProgressLoggerGui::setProgressValue(int value)
64 dp.progressBar->setValue(value);
67 void ProgressLoggerGui::setProgressMax(int max)
69 dp.progressBar->setMaximum(max);
72 int ProgressLoggerGui::getProgressMax()
74 return dp.progressBar->maximum();
77 void ProgressLoggerGui::abort()
79 dp.buttonAbort->setText(tr("&Ok"));
80 dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/go-next.png")));
81 disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
82 connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
83 connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
84 emit aborted();
87 void ProgressLoggerGui::undoAbort()
89 dp.buttonAbort->setText(tr("&Abort"));
90 dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/process-stop.png")));
91 connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
94 void ProgressLoggerGui::close()
96 downloadProgress->close();
99 void ProgressLoggerGui::show()
101 downloadProgress->show();