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

@ -36,7 +36,7 @@ void Uninstaller::deleteAll(ProgressloggerInterface* dp)
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
m_dp->addItem(tr("Finished Uninstallation"),LOGOK);
m_dp->abort();
m_dp->setFinished();
}
void Uninstaller::uninstall(ProgressloggerInterface* dp)
@ -110,7 +110,7 @@ void Uninstaller::uninstall(ProgressloggerInterface* dp)
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
m_dp->addItem(tr("Uninstallation finished"),LOGOK);
m_dp->abort();
m_dp->setFinished();
}
QStringList Uninstaller::getAllSections()

View file

@ -96,7 +96,7 @@ void Install::accept()
// show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort();
logger->setFinished();
return;
}
@ -141,7 +141,7 @@ void Install::accept()
== QMessageBox::Abort)
{
logger->addItem(tr("Aborted!"),LOGERROR);
logger->abort();
logger->setFinished();
return;
}
}
@ -170,7 +170,7 @@ void Install::accept()
else
{
logger->addItem(tr("Backup failed!"),LOGERROR);
logger->abort();
logger->setFinished();
return;
}
}
@ -212,7 +212,7 @@ void Install::done(bool error)
if(error)
{
logger->abort();
logger->setFinished();
return;
}

View file

@ -84,7 +84,7 @@ void InstallTalkWindow::accept()
if(!QFileInfo(folderToTalk).isDir())
{
logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
logger->abort();
logger->setFinished();
return;
}

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();

View file

@ -46,10 +46,10 @@ public slots:
virtual void addItem(const QString &text, int flag); //! add a string to the list
virtual void setProgress(int, int); //! set progress bar
virtual void abort();
virtual void undoAbort();
virtual void close();
virtual void show();
virtual void setRunning();
virtual void setFinished();
private:
Ui::ProgressLoggerFrm dp;

View file

@ -49,10 +49,10 @@ public slots:
virtual void addItem(const QString &text)=0; //! add a string to the progress
virtual void addItem(const QString &text, int flag)=0; //! add a string to the list, with icon
virtual void abort()=0;
virtual void undoAbort()=0;
virtual void close()=0;
virtual void show()=0;
virtual void setRunning()=0;
virtual void setFinished()=0;
private:

View file

@ -393,7 +393,7 @@ void RbUtilQt::completeInstall()
if(smallInstallInner())
return;
logger->undoAbort();
logger->setRunning();
// Fonts
m_error = false;
m_installed = false;
@ -406,7 +406,7 @@ void RbUtilQt::completeInstall()
QApplication::processEvents();
}
if(m_error) return;
logger->undoAbort();
logger->setRunning();
// Doom
if(hasDoom())
@ -459,7 +459,7 @@ bool RbUtilQt::smallInstallInner()
// show dialog with error if mount point is wrong
if(!QFileInfo(mountpoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort();
logger->setFinished();
return true;
}
// Bootloader
@ -469,7 +469,7 @@ bool RbUtilQt::smallInstallInner()
m_installed = false;
m_auto = true;
if(!installBootloaderAuto()) {
logger->abort();
logger->setFinished();
return true;
}
else
@ -480,7 +480,7 @@ bool RbUtilQt::smallInstallInner()
}
m_auto = false;
if(m_error) return true;
logger->undoAbort();
logger->setRunning();
}
// Rockbox
@ -533,7 +533,7 @@ bool RbUtilQt::installAuto()
QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort) == QMessageBox::Abort)
{
logger->addItem(tr("Aborted!"), LOGERROR);
logger->abort();
logger->setFinished();
return false;
}
}
@ -568,7 +568,7 @@ bool RbUtilQt::installAuto()
else
{
logger->addItem(tr("Backup failed!"),LOGERROR);
logger->abort();
logger->setFinished();
return false;
}
}
@ -647,7 +647,7 @@ void RbUtilQt::installBootloader()
}
else {
logger->addItem(tr("No install method known."), LOGERROR);
logger->abort();
logger->setFinished();
return;
}
@ -749,7 +749,7 @@ void RbUtilQt::installBootloader()
// the bootloader install class does NOT use any GUI stuff.
// All messages are passed via signals.
connect(bl, SIGNAL(done(bool)), logger, SLOT(abort()));
connect(bl, SIGNAL(done(bool)), logger, SLOT(setFinished()));
connect(bl, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
@ -762,7 +762,7 @@ void RbUtilQt::installBootloader()
tr("Could not create backup file. Continue?"),
QMessageBox::No | QMessageBox::Yes)
== QMessageBox::No) {
logger->abort();
logger->setFinished();
return;
}
}
@ -990,7 +990,7 @@ void RbUtilQt::uninstallBootloader(void)
}
else {
logger->addItem(tr("No uninstall method known."), LOGERROR);
logger->abort();
logger->setFinished();
return;
}
@ -1011,7 +1011,7 @@ void RbUtilQt::uninstallBootloader(void)
int result;
result = bl->uninstall();
logger->abort();
logger->setFinished();
}
@ -1079,7 +1079,7 @@ void RbUtilQt::installPortable(void)
// check mountpoint
if(!QFileInfo(settings->value(RbSettings::Mountpoint).toString()).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort();
logger->setFinished();
return;
}
@ -1093,7 +1093,7 @@ void RbUtilQt::installPortable(void)
settings->value(RbSettings::Mountpoint).toString()
+ "/RockboxUtility.exe")) {
logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
logger->abort();
logger->setFinished();
return;
}
logger->addItem(tr("Installing user configuration"), LOGINFO);
@ -1101,11 +1101,11 @@ void RbUtilQt::installPortable(void)
settings->value(RbSettings::Mountpoint).toString()
+ "/RockboxUtility.ini")) {
logger->addItem(tr("Error installing user configuration"), LOGERROR);
logger->abort();
logger->setFinished();
return;
}
logger->addItem(tr("Successfully installed Rockbox Utility."), LOGOK);
logger->abort();
logger->setFinished();
logger->setProgressMax(1);
logger->setProgressValue(1);

View file

@ -47,7 +47,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
{
m_logger->addItem(errStr.trimmed(),LOGERROR);
m_logger->addItem(tr("Init of TTS engine failed"),LOGERROR);
m_logger->abort();
m_logger->setFinished();
return false;
}
@ -58,7 +58,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
if(!m_enc->start())
{
m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR);
m_logger->abort();
m_logger->setFinished();
m_tts->stop();
return false;
}
@ -147,7 +147,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
m_logger->addItem(tr("Finished creating Talk files"),LOGOK);
m_logger->setProgressMax(1);
m_logger->setProgressValue(1);
m_logger->abort();
m_logger->setFinished();
return true;
}
@ -182,7 +182,7 @@ void TalkFileCreator::doAbort(QStringList cleanupList)
cleanup(cleanupList);
m_logger->setProgressMax(1);
m_logger->setProgressValue(0);
m_logger->abort();
m_logger->setFinished();
m_tts->stop();
m_enc->stop();
}

View file

@ -101,7 +101,7 @@ void ThemesInstallWindow::downloadDone(bool error)
"Please check your network and proxy settings.")
.arg(getter->errorString()), LOGERROR);
getter->abort();
logger->abort();
logger->setFinished();
disconnect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
connect(logger, SIGNAL(closed()), this, SLOT(close()));
return;
@ -111,12 +111,12 @@ void ThemesInstallWindow::downloadDone(bool error)
qDebug() << "error!";
logger->addItem(tr("the following error occured:\n%1")
.arg(iniDetails.value("error/description", "unknown error").toString()), LOGERROR);
logger->abort();
logger->setFinished();
connect(logger, SIGNAL(closed()), this, SLOT(close()));
return;
}
logger->addItem(tr("done."), LOGOK);
logger->abort();
logger->setFinished();
logger->close();
// setup list
@ -289,7 +289,7 @@ void ThemesInstallWindow::show()
void ThemesInstallWindow::abort()
{
igetter.abort();
logger->abort();
logger->setFinished();
this->close();
}
@ -326,7 +326,7 @@ void ThemesInstallWindow::accept()
// show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort();
logger->setFinished();
return;
}

View file

@ -54,7 +54,7 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger)
if(!info.open())
{
m_logger->addItem(tr("could not find rockbox-info.txt"),LOGERROR);
m_logger->abort();
m_logger->setFinished();
emit done(false);
return false;
}
@ -101,14 +101,14 @@ void VoiceFileCreator::downloadDone(bool error)
m_logger->setProgressValue(max);
if(getter->httpResponse() != 200 && !getter->isCached()) {
m_logger->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR);
m_logger->abort();
m_logger->setFinished();
emit done(false);
return;
}
if(getter->isCached()) m_logger->addItem(tr("Cached file used."), LOGINFO);
if(error) {
m_logger->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR);
m_logger->abort();
m_logger->setFinished();
emit done(false);
return;
}
@ -122,7 +122,7 @@ void VoiceFileCreator::downloadDone(bool error)
if(!genlang.open(QIODevice::ReadOnly))
{
m_logger->addItem(tr("failed to open downloaded file"),LOGERROR);
m_logger->abort();
m_logger->setFinished();
emit done(false);
return;
}
@ -136,7 +136,7 @@ void VoiceFileCreator::downloadDone(bool error)
{
m_logger->addItem(errStr,LOGERROR);
m_logger->addItem(tr("Init of TTS engine failed"),LOGERROR);
m_logger->abort();
m_logger->setFinished();
emit done(false);
return;
}
@ -149,7 +149,7 @@ void VoiceFileCreator::downloadDone(bool error)
{
m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR);
m_tts->stop();
m_logger->abort();
m_logger->setFinished();
emit done(false);
return;
}
@ -191,7 +191,7 @@ void VoiceFileCreator::downloadDone(bool error)
if(voicepairs.size() == 0)
{
m_logger->addItem(tr("The downloaded file was empty!"),LOGERROR);
m_logger->abort();
m_logger->setFinished();
m_tts->stop();
emit done(false);
return;
@ -207,7 +207,7 @@ void VoiceFileCreator::downloadDone(bool error)
if(m_abort)
{
m_logger->addItem("aborted.",LOGERROR);
m_logger->abort();
m_logger->setFinished();
m_tts->stop();
emit done(false);
return;
@ -256,7 +256,7 @@ void VoiceFileCreator::downloadDone(bool error)
if (ids2 == NULL)
{
m_logger->addItem(tr("Error opening downloaded file"),LOGERROR);
m_logger->abort();
m_logger->setFinished();
emit done(false);
return;
}
@ -287,7 +287,7 @@ void VoiceFileCreator::downloadDone(bool error)
m_logger->setProgressMax(100);
m_logger->setProgressValue(100);
m_logger->addItem(tr("successfully created."),LOGOK);
m_logger->abort();
m_logger->setFinished();
emit done(true);
}

View file

@ -59,7 +59,7 @@ void ZipInstaller::installContinue()
}
else {
m_dp->addItem(tr("Installation finished successfully."),LOGOK);
m_dp->abort();
m_dp->setFinished();
emit done(false);
return;
@ -112,14 +112,14 @@ void ZipInstaller::downloadDone(bool error)
m_dp->setProgressValue(max);
if(getter->httpResponse() != 200 && !getter->isCached()) {
m_dp->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR);
m_dp->abort();
m_dp->setFinished();
emit done(true);
return;
}
if(getter->isCached()) m_dp->addItem(tr("Cached file used."), LOGINFO);
if(error) {
m_dp->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR);
m_dp->abort();
m_dp->setFinished();
emit done(true);
return;
}
@ -143,7 +143,7 @@ void ZipInstaller::downloadDone(bool error)
.arg(uz.formatError(ec)),LOGERROR);
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
m_dp->abort();
m_dp->setFinished();
emit done(true);
return;
}
@ -153,7 +153,7 @@ void ZipInstaller::downloadDone(bool error)
// cluster sizes on the player).
if(filesystemFree(m_mountpoint) < (uz.totalSize() + 1000000)) {
m_dp->addItem(tr("Not enough disk space! Aborting."), LOGERROR);
m_dp->abort();
m_dp->setFinished();
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
emit done(true);
@ -164,7 +164,7 @@ void ZipInstaller::downloadDone(bool error)
if(ec != UnZip::Ok) {
m_dp->addItem(tr("Extracting failed: %1.")
.arg(uz.formatError(ec)),LOGERROR);
m_dp->abort();
m_dp->setFinished();
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
@ -188,7 +188,7 @@ void ZipInstaller::downloadDone(bool error)
QFile(m_mountpoint + m_target).remove();
if(!downloadFile->copy(m_mountpoint + m_target)) {
m_dp->addItem(tr("Installing file failed."), LOGERROR);
m_dp->abort();
m_dp->setFinished();
emit done(true);
return;
}