QtAutoUpdater  3.0.0
A Qt library to automatically check for updates and install them
updateinstaller.h
1 #ifndef QTAUTOUPDATER_UPDATEINSTALLER_H
2 #define QTAUTOUPDATER_UPDATEINSTALLER_H
3 
4 #include <QtCore/qobject.h>
5 #include <QtCore/quuid.h>
6 #include <QtCore/qabstractitemmodel.h>
7 
8 #include "QtAutoUpdaterCore/qtautoupdatercore_global.h"
9 #include "QtAutoUpdaterCore/updateinfo.h"
10 
11 namespace QtAutoUpdater {
12 
13 class ComponentModel;
14 
15 class UpdateInstallerPrivate;
17 class Q_AUTOUPDATERCORE_EXPORT UpdateInstaller : public QObject
18 {
19  Q_OBJECT
20 
22  Q_PROPERTY(QtAutoUpdater::UpdateInstaller::Features features READ features CONSTANT)
24  Q_PROPERTY(QList<QtAutoUpdater::UpdateInfo> components READ components WRITE setComponents NOTIFY componentsChanged)
26  Q_PROPERTY(QAbstractItemModel* componentModel READ componentModel CONSTANT)
28  Q_PROPERTY(QAbstractItemModel* progressModel READ progressModel CONSTANT)
29 
30 public:
32  enum class Feature {
33  None = 0x00,
34  SelectComponents = 0x01,
35  DetailedProgress = 0x02,
36  CanCancel = 0x04
37  };
38  Q_DECLARE_FLAGS(Features, Feature)
39  Q_FLAG(Features)
40 
41 
42  virtual Features features() const = 0;
44  virtual QList<UpdateInfo> components() const;
46  virtual QAbstractItemModel *componentModel() const;
48  virtual QAbstractItemModel *progressModel() const;
49 
50 public Q_SLOTS:
52  virtual void startInstall();
54  virtual void cancelInstall();
56  virtual void eulaHandled(const QVariant &id, bool accepted) = 0;
57 
59  virtual void restartApplication();
60 
62  virtual void setComponents(QList<QtAutoUpdater::UpdateInfo> components);
63 
64 Q_SIGNALS:
66  void updateGlobalProgress(double progress, const QString &status = {});
68  void updateComponentProgress(const QVariant &id, double progress, const QString &status = {});
70  void showEula(const QVariant &id, const QString &htmlText, bool required);
72  void installSucceeded(bool shouldRestart);
74  void installFailed(const QString &errorMessage);
75 
77  void componentsChanged();
78 
79 protected:
81  explicit UpdateInstaller(QObject *parent = nullptr);
83  explicit UpdateInstaller(UpdateInstallerPrivate &dd, QObject *parent = nullptr);
84 
86  virtual void startInstallImpl() = 0;
87 
89  virtual void setComponentEnabled(const QVariant &id, bool enabled);
90 
91 private:
92  Q_DECLARE_PRIVATE(UpdateInstaller)
93  Q_DISABLE_COPY(UpdateInstaller)
94  friend class QtAutoUpdater::ComponentModel;
95 };
96 
97 }
98 
99 Q_DECLARE_OPERATORS_FOR_FLAGS(QtAutoUpdater::UpdateInstaller::Features)
100 Q_DECLARE_METATYPE(QtAutoUpdater::UpdateInstaller*)
101 
102 #endif // QTAUTOUPDATER_UPDATEINSTALLER_H
QtAutoUpdater::UpdateInfo
Provides information about updates for components.
Definition: updateinfo.h:14
QtAutoUpdater::UpdateInstaller::Feature
Feature
Various features an installer may or may not support.
Definition: updateinstaller.h:32
QList
QString
QtAutoUpdater::UpdateInstaller
An interface to implement and consume custom in-process installer.
Definition: updateinstaller.h:17
QVariant
QObject
QtAutoUpdater
The QtAutoUpdater namespace holds all classes that are related with the updater.
Definition: adminauthoriser.h:9
QAbstractItemModel