Commit b4a763a7 authored by Lukas Appelhans's avatar Lukas Appelhans

Show progress of current package... at least it's better than before

parent 14983bf3
......@@ -133,13 +133,15 @@ void QueueOperation::validationFinished(bool valid)
emit finished();
return;
}
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(progressChanged(int)), SLOT(showProgress(int)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(progressChanged(int)), SLOT(showProgress()));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(packageProgressChanged(Akabei::Package*,int)), SLOT(packageProgressChanged(Akabei::Package*,int)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(finished()), SLOT(transationFinished()));
AkabeiClient::Backend::instance()->transactionHandler()->process();
}
void QueueOperation::showProgress(int progress)
void QueueOperation::showProgress()
{
int progress = AkabeiClient::Backend::instance()->transactionHandler()->progress();
QTextStream out(stdout);
out.reset();
switch (AkabeiClient::Backend::instance()->transactionHandler()->phase()) {
......@@ -168,9 +170,15 @@ void QueueOperation::showProgress(int progress)
out << i18n("Finished");
break;
};
out << " [";
for (int i = 1; i != 11; i++) {
if (progress / i >= 10) {
QHash<Akabei::Package*, int>::iterator i = m_progresses.begin();
QHash<Akabei::Package*, int>::iterator end = m_progresses.end();
for (; i != end; i++) {
out << ' ' << i.key()->name() << " (" << i.value() << "%)";
}
out << ' ' << i18n("Total progress:") << " [";
int columns = 20;
for (int i = 1; i != columns + 1; i++) {
if (progress / i >= 100 / columns) {
out << "#";
} else {
out << "-";
......@@ -185,6 +193,16 @@ void QueueOperation::showProgress(int progress)
out.flush();
}
void QueueOperation::packageProgressChanged(Akabei::Package* package, int progress)
{
foreach (Akabei::Package * p, m_progresses.keys()) { //TODO: Optimize... only execute like once in a while ;)s
if (AkabeiClient::Backend::instance()->transactionHandler()->processedPackages().contains(p))
m_progresses.remove(p);
}
m_progresses.insert(package, progress);
showProgress();
}
void QueueOperation::transationFinished()
{
QTextStream out(stdout);
......
......@@ -28,10 +28,11 @@ public:
private slots:
void validationFinished(bool valid);
void showProgress(int);
void showProgress();
void errors(QList<Akabei::Error*>& errors);
void transactionMessage(const QString &message);
void transationFinished();
void packageProgressChanged(Akabei::Package*,int);
signals:
void finished();
......@@ -40,6 +41,7 @@ private:
AkabeiClient::PackageAction m_action;
Akabei::ProcessingOptions m_processingOptions;
QList<APM::Operation> m_operations;
QHash<Akabei::Package*, int> m_progresses;
};
#endif // QUEUEOPERATION_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment