Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/resources/ResourcesUpdatesModel.h
Show All 36 Lines | 35 | { | |||
---|---|---|---|---|---|
37 | Q_PROPERTY(bool isProgressing READ isProgressing NOTIFY progressingChanged) | 37 | Q_PROPERTY(bool isProgressing READ isProgressing NOTIFY progressingChanged) | ||
38 | Q_PROPERTY(QDateTime lastUpdate READ lastUpdate NOTIFY progressingChanged) | 38 | Q_PROPERTY(QDateTime lastUpdate READ lastUpdate NOTIFY progressingChanged) | ||
39 | Q_PROPERTY(qint64 secsToLastUpdate READ secsToLastUpdate NOTIFY progressingChanged) | 39 | Q_PROPERTY(qint64 secsToLastUpdate READ secsToLastUpdate NOTIFY progressingChanged) | ||
40 | Q_PROPERTY(Transaction* transaction READ transaction NOTIFY progressingChanged) | 40 | Q_PROPERTY(Transaction* transaction READ transaction NOTIFY progressingChanged) | ||
41 | Q_PROPERTY(bool needsReboot READ needsReboot NOTIFY needsRebootChanged) | 41 | Q_PROPERTY(bool needsReboot READ needsReboot NOTIFY needsRebootChanged) | ||
42 | public: | 42 | public: | ||
43 | explicit ResourcesUpdatesModel(QObject* parent = nullptr); | 43 | explicit ResourcesUpdatesModel(QObject* parent = nullptr); | ||
44 | 44 | | |||
45 | quint64 downloadSpeed() const; | | |||
46 | Q_SCRIPTABLE void prepare(); | 45 | Q_SCRIPTABLE void prepare(); | ||
47 | 46 | | |||
48 | bool isProgressing() const; | 47 | bool isProgressing() const; | ||
49 | QList<AbstractResource*> toUpdate() const; | 48 | QList<AbstractResource*> toUpdate() const; | ||
50 | QDateTime lastUpdate() const; | 49 | QDateTime lastUpdate() const; | ||
51 | double updateSize() const; | 50 | double updateSize() const; | ||
52 | void addResources(const QList<AbstractResource*>& resources); | 51 | void addResources(const QList<AbstractResource*>& resources); | ||
53 | void removeResources(const QList<AbstractResource*>& resources); | 52 | void removeResources(const QList<AbstractResource*>& resources); | ||
54 | 53 | | |||
55 | qint64 secsToLastUpdate() const; | 54 | qint64 secsToLastUpdate() const; | ||
56 | QVector<AbstractBackendUpdater*> updaters() const { return m_updaters; } | 55 | QVector<AbstractBackendUpdater*> updaters() const { return m_updaters; } | ||
57 | Transaction* transaction() const; | 56 | Transaction* transaction() const; | ||
58 | bool needsReboot() const; | 57 | bool needsReboot() const; | ||
59 | 58 | | |||
60 | Q_SIGNALS: | 59 | Q_SIGNALS: | ||
61 | void downloadSpeedChanged(); | 60 | void downloadSpeedChanged(); | ||
62 | void progressingChanged(); | 61 | void progressingChanged(); | ||
63 | void finished(); | 62 | void finished(); | ||
64 | void resourceProgressed(AbstractResource* resource, qreal progress, AbstractBackendUpdater::State state); | 63 | void resourceProgressed(AbstractResource* resource, qreal progress, AbstractBackendUpdater::State state); | ||
65 | void passiveMessage(const QString &message); | 64 | void passiveMessage(const QString &message); | ||
66 | void needsRebootChanged(); | 65 | void needsRebootChanged(); | ||
66 | void fetchingUpdatesProgressChanged(int percent); | ||||
67 | 67 | | |||
68 | public Q_SLOTS: | 68 | public Q_SLOTS: | ||
69 | void updateAll(); | 69 | void updateAll(); | ||
70 | 70 | | |||
71 | private Q_SLOTS: | 71 | private Q_SLOTS: | ||
72 | void updaterDestroyed(QObject* obj); | 72 | void updaterDestroyed(QObject* obj); | ||
73 | void message(const QString& msg); | 73 | void message(const QString& msg); | ||
74 | 74 | | |||
75 | private: | 75 | private: | ||
76 | void init(); | 76 | void init(); | ||
77 | void updateFinished(); | | |||
78 | void setTransaction(UpdateTransaction* transaction); | 77 | void setTransaction(UpdateTransaction* transaction); | ||
79 | 78 | | |||
80 | QVector<AbstractBackendUpdater*> m_updaters; | 79 | QVector<AbstractBackendUpdater*> m_updaters; | ||
81 | bool m_lastIsProgressing; | 80 | bool m_lastIsProgressing; | ||
82 | QPointer<UpdateTransaction> m_transaction; | 81 | QPointer<UpdateTransaction> m_transaction; | ||
83 | }; | 82 | }; | ||
84 | 83 | | |||
85 | #endif // RESOURCESUPDATESMODEL_H | 84 | #endif // RESOURCESUPDATESMODEL_H |