Commit cef117db authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Relax the Tasks view during updates that contain StandardUpdaters

Make it possible to selectively hide the transactions that are part of the
update
parent ad0c705a
......@@ -30,7 +30,7 @@ Kirigami.BasicListItem {
readonly property var v1: Connections {
target: TransactionModel
onTransactionAdded: {
if(listItem.enabled && progressModel.applicationAt(trans.resource)<0) {
if(listItem.enabled && trans.visible && progressModel.applicationAt(trans.resource)<0) {
progressModel.append({ transaction: trans })
}
}
......
......@@ -118,3 +118,16 @@ QVariant Transaction::icon() const
{
return m_resource->icon();
}
bool Transaction::isVisible() const
{
return m_visible;
}
void Transaction::setVisible(bool visible)
{
if (m_visible != visible) {
m_visible = visible;
Q_EMIT visibleChanged(visible);
}
}
......@@ -50,6 +50,7 @@ class DISCOVERCOMMON_EXPORT Transaction : public QObject
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(bool isCancellable READ isCancellable NOTIFY cancellableChanged)
Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
public:
enum Status {
......@@ -144,6 +145,9 @@ public:
/** @returns an icon that describes the transaction */
virtual QVariant icon() const;
bool isVisible() const;
void setVisible(bool v);
private:
AbstractResource * const m_resource;
const Role m_role;
......@@ -151,6 +155,7 @@ private:
const AddonList m_addons;
bool m_isCancellable;
int m_progress;
bool m_visible = true;
Q_SIGNALS:
/**
......@@ -176,6 +181,8 @@ Q_SIGNALS:
void proceedRequest(const QString &title, const QString &description);
void passiveMessage(const QString &message);
void visibleChanged(bool visible);
};
#endif // TRANSACTION_H
......@@ -45,6 +45,7 @@ public:
bool cancelable = false;
foreach(auto updater, parent->updaters()) {
connect(updater, &AbstractBackendUpdater::progressingChanged, this, &UpdateTransaction::slotProgressingChanged);
connect(updater, &AbstractBackendUpdater::progressChanged, this, &UpdateTransaction::slotUpdateProgress);
connect(updater, &AbstractBackendUpdater::passiveMessage, this, &Transaction::passiveMessage);
connect(updater, &AbstractBackendUpdater::proceedRequest, this, &UpdateTransaction::processProceedRequest);
cancelable |= updater->isCancelable();
......@@ -88,6 +89,15 @@ public:
}
}
void slotUpdateProgress()
{
qreal total = 0;
foreach(AbstractBackendUpdater* updater, m_allUpdaters) {
total += updater->progress();
}
setProgress(total / m_allUpdaters.count());
}
QVariant icon() const override { return QStringLiteral("update-low"); }
QString name() const override { return i18n("Update"); }
......@@ -116,7 +126,6 @@ void ResourcesUpdatesModel::init()
foreach(AbstractResourcesBackend* b, backends) {
AbstractBackendUpdater* updater = b->backendUpdater();
if(updater && !m_updaters.contains(updater)) {
connect(updater, &AbstractBackendUpdater::progressChanged, this, &ResourcesUpdatesModel::progressChanged);
connect(updater, &AbstractBackendUpdater::statusMessageChanged, this, &ResourcesUpdatesModel::message);
connect(updater, &AbstractBackendUpdater::statusDetailChanged, this, &ResourcesUpdatesModel::message);
connect(updater, &AbstractBackendUpdater::remainingTimeChanged, this, &ResourcesUpdatesModel::etaChanged);
......@@ -143,18 +152,6 @@ void ResourcesUpdatesModel::updaterDestroyed(QObject* obj)
m_updaters.removeAll(static_cast<AbstractBackendUpdater*>(obj));
}
qreal ResourcesUpdatesModel::progress() const
{
if (m_updaters.isEmpty())
return -1;
qreal total = 0;
foreach(AbstractBackendUpdater* updater, m_updaters) {
total += updater->progress();
}
return total / m_updaters.count();
}
void ResourcesUpdatesModel::message(const QString& msg)
{
if(msg.isEmpty())
......@@ -207,7 +204,7 @@ QString ResourcesUpdatesModel::remainingTime() const
bool ResourcesUpdatesModel::isProgressing() const
{
return m_transaction && m_transaction->status()<Transaction::DoneStatus;
return m_transaction && m_transaction->status() < Transaction::DoneStatus;
}
QList<AbstractResource*> ResourcesUpdatesModel::toUpdate() const
......
......@@ -37,7 +37,6 @@ class UpdateTransaction;
class DISCOVERCOMMON_EXPORT ResourcesUpdatesModel : public QStandardItemModel
{
Q_OBJECT
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(QString remainingTime READ remainingTime NOTIFY etaChanged)
Q_PROPERTY(bool isProgressing READ isProgressing NOTIFY progressingChanged)
Q_PROPERTY(QDateTime lastUpdate READ lastUpdate NOTIFY progressingChanged)
......@@ -45,7 +44,6 @@ class DISCOVERCOMMON_EXPORT ResourcesUpdatesModel : public QStandardItemModel
public:
explicit ResourcesUpdatesModel(QObject* parent = nullptr);
qreal progress() const;
QString remainingTime() const;
quint64 downloadSpeed() const;
Q_SCRIPTABLE void prepare();
......@@ -61,7 +59,6 @@ class DISCOVERCOMMON_EXPORT ResourcesUpdatesModel : public QStandardItemModel
Q_SIGNALS:
void downloadSpeedChanged();
void progressChanged();
void etaChanged();
void progressingChanged();
void finished();
......
......@@ -61,12 +61,13 @@ void StandardBackendUpdater::start()
{
m_settingUp = true;
emit progressingChanged(true);
setProgress(-1);
Q_EMIT progressingChanged(true);
setProgress(0);
foreach(AbstractResource* res, m_toUpgrade) {
m_pendingResources += res;
TransactionModel::global()->addTransaction(m_backend->installApplication(res));
auto t = m_backend->installApplication(res);
t->setVisible(false);
TransactionModel::global()->addTransaction(t);
}
m_settingUp = false;
......
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