New game plugin by Joshua Simmons FS#7369: Goban plugin, Go/Igo/Weiqi/Baduk game...
[kugel-rb.git] / rbutil / rbutilqt / progressloggergui.cpp
bloba96778bc11c3282a69e7fe73f164632eaa48c8bc
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(QWidget* parent): ProgressloggerInterface(parent)
24 downloadProgress = new QDialog(parent);
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::setProgress(int value, int max)
64 setProgressValue(value);
65 setProgressMax(max);
69 void ProgressLoggerGui::setProgressValue(int value)
71 dp.progressBar->setValue(value);
74 void ProgressLoggerGui::setProgressMax(int max)
76 dp.progressBar->setMaximum(max);
79 int ProgressLoggerGui::getProgressMax()
81 return dp.progressBar->maximum();
84 void ProgressLoggerGui::setProgressVisible(bool b)
86 dp.progressBar->setVisible(b);
90 void ProgressLoggerGui::abort()
92 dp.buttonAbort->setText(tr("&Ok"));
93 dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/go-next.png")));
94 disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
95 connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
96 connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
97 emit aborted();
100 void ProgressLoggerGui::undoAbort()
102 dp.buttonAbort->setText(tr("&Abort"));
103 dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/process-stop.png")));
104 connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
107 void ProgressLoggerGui::close()
109 downloadProgress->close();
112 void ProgressLoggerGui::show()
114 downloadProgress->show();