Clean up ProgressLogger state handling:

- use better names for member functions
- don't emit aborted() when exiting a successful log


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20844 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2009-05-02 18:40:04 +00:00
parent b10ba5e8b3
commit 7cfdd47587
11 changed files with 83 additions and 66 deletions

View file

@ -25,7 +25,7 @@ ProgressLoggerGui::ProgressLoggerGui(QWidget* parent): ProgressloggerInterface(p
downloadProgress->setModal(true);
dp.setupUi(downloadProgress);
dp.listProgress->setAlternatingRowColors(true);
connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
setRunning();
}
void ProgressLoggerGui::addItem(const QString &text)
@ -87,23 +87,40 @@ void ProgressLoggerGui::setProgressVisible(bool b)
}
void ProgressLoggerGui::abort()
{
dp.buttonAbort->setText(tr("&Ok"));
dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/go-next.png")));
disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
emit aborted();
}
void ProgressLoggerGui::undoAbort()
/** Set logger into "running" state -- the reporting process is still running.
* Display "Abort" and emit the aborted() signal on button press.
*/
void ProgressLoggerGui::setRunning()
{
dp.buttonAbort->setText(tr("&Abort"));
dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/process-stop.png")));
connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
// make sure to not close the window on button press.
disconnect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
// emit aborted() once button is pressed but not closed().
disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(aborted()));
}
/** Set logger into "finished" state -- the reporting process is finished.
* Display "Ok". Don't emit aborted() as there is nothing running left.
* Close logger on button press and emit closed().
*/
void ProgressLoggerGui::setFinished()
{
dp.buttonAbort->setText(tr("&Ok"));
dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/go-next.png")));
// close the window on button press.
connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
// emit closed() once button is pressed but not aborted().
disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(aborted()));
connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
}
void ProgressLoggerGui::close()
{
downloadProgress->close();