Flag EOF and empty buffer conditions as UNLIKELY in JPEG decoder.
[kugel-rb.git] / rbutil / rbutilqt / progressloggergui.cpp
blob0358d75096cef59c56befddfd8991b8a3751b86a
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 setRunning();
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 /** Set logger into "running" state -- the reporting process is still running.
91 * Display "Abort" and emit the aborted() signal on button press.
93 void ProgressLoggerGui::setRunning()
95 dp.buttonAbort->setText(tr("&Abort"));
96 dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/process-stop.png")));
98 // make sure to not close the window on button press.
99 disconnect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
100 // emit aborted() once button is pressed but not closed().
101 disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
102 connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(aborted()));
107 /** Set logger into "finished" state -- the reporting process is finished.
108 * Display "Ok". Don't emit aborted() as there is nothing running left.
109 * Close logger on button press and emit closed().
111 void ProgressLoggerGui::setFinished()
113 dp.buttonAbort->setText(tr("&Ok"));
114 dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/go-next.png")));
116 // close the window on button press.
117 connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
118 // emit closed() once button is pressed but not aborted().
119 disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(aborted()));
120 connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
124 void ProgressLoggerGui::close()
126 downloadProgress->close();
129 void ProgressLoggerGui::show()
131 downloadProgress->show();