|
9 | 9 | namespace QtDataSync { |
10 | 10 |
|
11 | 11 | class MigrationHelperPrivate; |
| 12 | +//! A helper class to migrate data from DataSync 3.0 to this version |
12 | 13 | class Q_DATASYNC_EXPORT MigrationHelper : public QObject |
13 | 14 | { |
14 | 15 | Q_OBJECT |
15 | 16 |
|
16 | 17 | public: |
| 18 | + //! Flags to configure what and how should be migrated |
17 | 19 | enum MigrationFlag { |
18 | | - MigrateData = 0x01, |
19 | | - MigrateChanged = (0x02 | MigrateData), |
20 | | - MigrateRemoteConfig = 0x04, |
21 | | - MigrateAll = (MigrateData | MigrateChanged | MigrateRemoteConfig), |
22 | | - |
23 | | - MigrateWithCleanup = 0x08, |
24 | | - MigrateOverwriteConfig = 0x10, |
25 | | - MigrateOverwriteData = 0x20 |
| 20 | + MigrateData = 0x01, //!< Migrate actual stored data |
| 21 | + MigrateChanged = (0x02 | MigrateData), //!< Migrate the changed state of that data |
| 22 | + MigrateRemoteConfig = 0x04, //!< Migrate the connection configuration |
| 23 | + |
| 24 | + MigrateWithCleanup = 0x08, //!< Remove all old data after a successful migration |
| 25 | + MigrateOverwriteConfig = 0x10, //!< Overwrite existing configurations with the migrated remote config |
| 26 | + MigrateOverwriteData = 0x20, //!< Overwrite existing data with the migrated data |
| 27 | + |
| 28 | + MigrateDefault = (MigrateData | MigrateRemoteConfig | MigrateWithCleanup) //!< The default flags when leaving out the parameter |
26 | 29 | }; |
27 | 30 | Q_DECLARE_FLAGS(MigrationFlags, MigrationFlag) |
28 | 31 | Q_FLAG(MigrationFlags) |
29 | 32 |
|
| 33 | + //! The previous default path where data was stored |
30 | 34 | static const QString DefaultOldStorageDir; |
31 | 35 |
|
| 36 | + //! Default constructor, uses the default setup |
32 | 37 | explicit MigrationHelper(QObject *parent = nullptr); |
| 38 | + //! Constructor with an explicit setup |
33 | 39 | explicit MigrationHelper(const QString &setupName, QObject *parent = nullptr); |
34 | 40 | ~MigrationHelper(); |
35 | 41 |
|
36 | 42 | public Q_SLOTS: |
37 | | - void startMigration(const QString &storageDir = DefaultOldStorageDir, MigrationFlags flags = MigrationFlags(MigrateAll) | MigrateWithCleanup); |
| 43 | + //! Start the migration process from the given directory with flags |
| 44 | + void startMigration(const QString &storageDir = DefaultOldStorageDir, MigrationFlags flags = MigrateDefault); |
38 | 45 |
|
39 | 46 | Q_SIGNALS: |
| 47 | + //! Is emitted when the number of migrate operations has been determined |
40 | 48 | void migrationPrepared(int operations); |
| 49 | + //! Is emitted for every successful migration step done to give a progress |
41 | 50 | void migrationProgress(int current); |
| 51 | + //! Is emitted when the migration has been finished |
42 | 52 | void migrationDone(bool ok); |
43 | 53 |
|
44 | 54 | private: |
|
0 commit comments