forked from len0rd/rockbox
Convert uninstallation to use signals / slots for logging.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26782 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f2e048493e
commit
a1209350d4
4 changed files with 30 additions and 28 deletions
|
|
@ -26,30 +26,27 @@ Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent)
|
||||||
m_mountpoint = mountpoint;
|
m_mountpoint = mountpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uninstaller::deleteAll(ProgressloggerInterface* dp)
|
void Uninstaller::deleteAll(void)
|
||||||
{
|
{
|
||||||
m_dp = dp;
|
|
||||||
QString rbdir(m_mountpoint + ".rockbox/");
|
QString rbdir(m_mountpoint + ".rockbox/");
|
||||||
m_dp->addItem(tr("Starting Uninstallation"),LOGINFO);
|
emit logItem(tr("Starting Uninstallation"), LOGINFO);
|
||||||
m_dp->setProgressMax(0);
|
emit logProgress(0, 0);
|
||||||
Utils::recursiveRmdir(rbdir);
|
Utils::recursiveRmdir(rbdir);
|
||||||
m_dp->setProgressMax(1);
|
emit logProgress(1, 1);
|
||||||
m_dp->setProgressValue(1);
|
emit logItem(tr("Finished Uninstallation"), LOGOK);
|
||||||
m_dp->addItem(tr("Finished Uninstallation"),LOGOK);
|
emit logFinished();
|
||||||
m_dp->setFinished();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uninstaller::uninstall(ProgressloggerInterface* dp)
|
void Uninstaller::uninstall(void)
|
||||||
{
|
{
|
||||||
m_dp = dp;
|
emit logProgress(0, 0);
|
||||||
m_dp->setProgressMax(0);
|
emit logItem(tr("Starting Uninstallation"), LOGINFO);
|
||||||
m_dp->addItem(tr("Starting Uninstallation"),LOGINFO);
|
|
||||||
|
|
||||||
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
|
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
|
||||||
|
|
||||||
for(int i=0; i< uninstallSections.size() ; i++)
|
for(int i=0; i< uninstallSections.size() ; i++)
|
||||||
{
|
{
|
||||||
m_dp->addItem(tr("Uninstalling %1...").arg(uninstallSections.at(i)), LOGINFO);
|
emit logItem(tr("Uninstalling %1...").arg(uninstallSections.at(i)), LOGINFO);
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
// create list of all other install sections
|
// create list of all other install sections
|
||||||
QStringList sections = installlog.childGroups();
|
QStringList sections = installlog.childGroups();
|
||||||
|
|
@ -80,8 +77,8 @@ void Uninstaller::uninstall(ProgressloggerInterface* dp)
|
||||||
if(toDelete.isFile()) // if it is a file remove it
|
if(toDelete.isFile()) // if it is a file remove it
|
||||||
{
|
{
|
||||||
if(deleteFile && !QFile::remove(toDelete.filePath()))
|
if(deleteFile && !QFile::remove(toDelete.filePath()))
|
||||||
m_dp->addItem(tr("Could not delete %1")
|
emit logItem(tr("Could not delete %1")
|
||||||
.arg(toDelete.filePath()),LOGWARNING);
|
.arg(toDelete.filePath()), LOGWARNING);
|
||||||
installlog.remove(toDeleteList.at(j));
|
installlog.remove(toDeleteList.at(j));
|
||||||
qDebug() << "deleted: " << toDelete.filePath() ;
|
qDebug() << "deleted: " << toDelete.filePath() ;
|
||||||
}
|
}
|
||||||
|
|
@ -108,10 +105,9 @@ void Uninstaller::uninstall(ProgressloggerInterface* dp)
|
||||||
}
|
}
|
||||||
uninstallSections.clear();
|
uninstallSections.clear();
|
||||||
installlog.sync();
|
installlog.sync();
|
||||||
m_dp->setProgressMax(1);
|
emit logProgress(1, 1);
|
||||||
m_dp->setProgressValue(1);
|
emit logItem(tr("Uninstallation finished"), LOGOK);
|
||||||
m_dp->addItem(tr("Uninstallation finished"),LOGOK);
|
emit logFinished();
|
||||||
m_dp->setFinished();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Uninstaller::getAllSections()
|
QStringList Uninstaller::getAllSections()
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ public:
|
||||||
Uninstaller(QObject* parent,QString mountpoint) ;
|
Uninstaller(QObject* parent,QString mountpoint) ;
|
||||||
~Uninstaller(){}
|
~Uninstaller(){}
|
||||||
|
|
||||||
void deleteAll(ProgressloggerInterface* dp);
|
void deleteAll(void);
|
||||||
void uninstall(ProgressloggerInterface* dp);
|
void uninstall(void);
|
||||||
|
|
||||||
bool uninstallPossible();
|
bool uninstallPossible();
|
||||||
|
|
||||||
|
|
@ -44,6 +44,10 @@ public:
|
||||||
|
|
||||||
void setSections(QStringList sections) {uninstallSections = sections;}
|
void setSections(QStringList sections) {uninstallSections = sections;}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void logItem(QString, int); //! set logger item
|
||||||
|
void logProgress(int, int); //! set progress bar.
|
||||||
|
void logFinished(void);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
@ -52,8 +56,6 @@ private:
|
||||||
QString m_mountpoint;
|
QString m_mountpoint;
|
||||||
|
|
||||||
QStringList uninstallSections;
|
QStringList uninstallSections;
|
||||||
|
|
||||||
ProgressloggerInterface* m_dp;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -899,7 +899,8 @@ void RbUtilQt::installVoice()
|
||||||
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QDate date = QDate::fromString(ServerInfo::value(ServerInfo::DailyDate).toString(),Qt::ISODate);
|
QDate date = QDate::fromString(
|
||||||
|
ServerInfo::value(ServerInfo::DailyDate).toString(), Qt::ISODate);
|
||||||
QString model = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
|
QString model = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
|
||||||
// replace placeholder in voice url
|
// replace placeholder in voice url
|
||||||
voiceurl.replace("%DATE%", date.toString("yyyyMMdd"));
|
voiceurl.replace("%DATE%", date.toString("yyyyMMdd"));
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,11 @@ UninstallWindow::UninstallWindow(QWidget *parent) : QDialog(parent)
|
||||||
QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
|
QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
|
||||||
|
|
||||||
uninstaller = new Uninstaller(this,mountpoint);
|
uninstaller = new Uninstaller(this,mountpoint);
|
||||||
|
logger = new ProgressLoggerGui(this);
|
||||||
|
connect(uninstaller, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
|
||||||
|
connect(uninstaller, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
|
||||||
|
connect(uninstaller, SIGNAL(logFinished(void)), logger, SLOT(setFinished(void)));
|
||||||
|
connect(logger, SIGNAL(closed()), this, SLOT(close()));
|
||||||
|
|
||||||
// disable smart uninstall, if not possible
|
// disable smart uninstall, if not possible
|
||||||
if(!uninstaller->uninstallPossible())
|
if(!uninstaller->uninstallPossible())
|
||||||
|
|
@ -50,17 +55,15 @@ UninstallWindow::UninstallWindow(QWidget *parent) : QDialog(parent)
|
||||||
|
|
||||||
void UninstallWindow::accept()
|
void UninstallWindow::accept()
|
||||||
{
|
{
|
||||||
logger = new ProgressLoggerGui(this);
|
|
||||||
logger->show();
|
logger->show();
|
||||||
|
|
||||||
connect(logger,SIGNAL(closed()),this,SLOT(close()));
|
|
||||||
if(ui.CompleteRadioBtn->isChecked())
|
if(ui.CompleteRadioBtn->isChecked())
|
||||||
{
|
{
|
||||||
uninstaller->deleteAll(logger);
|
uninstaller->deleteAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uninstaller->uninstall(logger);
|
uninstaller->uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue