|
| 1 | +/*! |
| 2 | +@class QtMvvm::DataSyncViewModel |
| 3 | + |
| 4 | +The viewmodel provides data to show a ui that gives access to all of the important datasync |
| 5 | +account features and the synchronization status. The uis should show: |
| 6 | + |
| 7 | +- The sync status as string (DataSyncViewModel::statusString) |
| 8 | +- A sync progress when actively syncing (QtDataSync::SyncManager::syncProgress) |
| 9 | +- A possible error string, if an error occurs (QtDataSync::SyncManager::lastError) |
| 10 | +- A list of all devices of the account (DataSyncViewModel::sortedModel) |
| 11 | +- Actions to: |
| 12 | + - Synchronize (syncOrConnect()) |
| 13 | + - Toggle synchronization (QtDataSync::SyncManager::syncEnabled) |
| 14 | + - Edit the identity (showDeviceInfo()) |
| 15 | + - Reload the list of devices (QtDataSync::AccountManager::listDevices) |
| 16 | + - Remove devices (removeDevice()) |
| 17 | + - Update the exchange key (QtDataSync::AccountManager::updateExchangeKey) |
| 18 | + - Change the remote server (changeRemote()) |
| 19 | + - Reset the account (performReset()) |
| 20 | + - Export the account data (startExport()) |
| 21 | + - Import the account data (startImport()) |
| 22 | + - Show the exchange viewmodel (startNetworkExchange()) |
| 23 | + |
| 24 | +@sa QtDataSync, NetworkExchangeViewModel |
| 25 | +*/ |
| 26 | + |
| 27 | +/*! |
| 28 | +@property QtMvvm::DataSyncViewModel::syncManager |
| 29 | + |
| 30 | +@default{`nullptr` (Is initialized by onInit())} |
| 31 | + |
| 32 | +A reference to the sync manager the view model internally uses. Is owned by the viewmodel, but |
| 33 | +can be used to get properties for the ui. |
| 34 | + |
| 35 | +@accessors{ |
| 36 | + @readAc{syncManager()} |
| 37 | + @notifyAc{syncManagerChanged()} |
| 38 | +} |
| 39 | + |
| 40 | +@sa DataSyncViewModel::accountManager |
| 41 | +*/ |
| 42 | + |
| 43 | +/*! |
| 44 | +@property QtMvvm::DataSyncViewModel::accountManager |
| 45 | + |
| 46 | +@default{`nullptr` (Is initialized by onInit())} |
| 47 | + |
| 48 | +A reference to the account manager the view model internally uses. Is owned by the viewmodel, |
| 49 | +but can be used to get properties for the ui. |
| 50 | + |
| 51 | +@accessors{ |
| 52 | + @readAc{accountManager()} |
| 53 | + @notifyAc{accountManagerChanged()} |
| 54 | +} |
| 55 | + |
| 56 | +@sa DataSyncViewModel::syncManager |
| 57 | +*/ |
| 58 | + |
| 59 | +/*! |
| 60 | +@property QtMvvm::DataSyncViewModel::colorMap |
| 61 | + |
| 62 | +@default{A map inizialized as:} |
| 63 | + Key | Value |
| 64 | +----------------------------------------|------- |
| 65 | +QtDataSync::SyncManager::Initializing | Qt::darkCyan |
| 66 | +QtDataSync::SyncManager::Downloading | Qt::darkCyan |
| 67 | +QtDataSync::SyncManager::Uploading | Qt::darkCyan |
| 68 | +QtDataSync::SyncManager::Synchronized | Qt::darkGreen |
| 69 | +QtDataSync::SyncManager::Error | Qt::darkRed |
| 70 | +QtDataSync::SyncManager::Disconnected | Qt::darkYellow |
| 71 | + |
| 72 | +This map is used by the DataSyncViewModel::statusString property to determine the color of the |
| 73 | +status string, based of the state itself. You can change this property if you need different |
| 74 | +colors for your theme. |
| 75 | + |
| 76 | +@accessors{ |
| 77 | + @readAc{colorMap()} |
| 78 | + @writeAc{setColorMap()} |
| 79 | + @resetAc{resetColorMap()} |
| 80 | + @notifyAc{colorMapChanged()} |
| 81 | +} |
| 82 | + |
| 83 | +@sa DataSyncViewModel::statusString, DataSyncViewModel::ColorMap |
| 84 | +*/ |
| 85 | + |
| 86 | +/*! |
| 87 | +@property QtMvvm::DataSyncViewModel::statusString |
| 88 | + |
| 89 | +@default{`Disconnected`} |
| 90 | + |
| 91 | +A localized string to display the sync state as a single, simple string. The string is styled |
| 92 | +with different colors based of the DataSyncViewModel::colorMap property. |
| 93 | + |
| 94 | +@accessors{ |
| 95 | + @readAc{statusString()} |
| 96 | + @notifyAc{statusStringChanged()} |
| 97 | +} |
| 98 | + |
| 99 | +@sa DataSyncViewModel::colorMap, QtDataSync::SyncManager::syncState |
| 100 | +*/ |
| 101 | + |
| 102 | +/*! |
| 103 | +@property QtMvvm::DataSyncViewModel::accountModel |
| 104 | + |
| 105 | +@default{<i>An account model</i>} |
| 106 | + |
| 107 | +An unsorted model with all the devices of the current account. Automatically initialized and |
| 108 | +managed by the viewmodel. |
| 109 | + |
| 110 | +@note You should use the DataSyncViewModel::sortedModel property when creating views. It is |
| 111 | +a sorted version of this model, which is better for users. |
| 112 | + |
| 113 | +@accessors{ |
| 114 | + @readAc{accountModel()} |
| 115 | + @constantAc |
| 116 | +} |
| 117 | + |
| 118 | +@sa DataSyncViewModel::sortedModel |
| 119 | +*/ |
| 120 | + |
| 121 | +/*! |
| 122 | +@property QtMvvm::DataSyncViewModel::sortedModel |
| 123 | + |
| 124 | +@default{<i>The accountModel, sorted</i>} |
| 125 | + |
| 126 | +A sorted proxy to the DataSyncViewModel::accountModel. You should prefer this sorted version |
| 127 | +when binding views to the viewmodel. |
| 128 | + |
| 129 | +@accessors{ |
| 130 | + @readAc{sortedModel()} |
| 131 | + @constantAc |
| 132 | +} |
| 133 | + |
| 134 | +@sa DataSyncViewModel::accountModel |
| 135 | +*/ |
| 136 | + |
| 137 | +/*! |
| 138 | +@var QtMvvm::DataSyncViewModel::paramSetup |
| 139 | + |
| 140 | +<b>Value:</b> `"setup"` |
| 141 | + |
| 142 | +@sa DataSyncViewModel::showParams |
| 143 | +*/ |
| 144 | + |
| 145 | +/*! |
| 146 | +@var QtMvvm::DataSyncViewModel::paramReplicaNode |
| 147 | + |
| 148 | +<b>Value:</b> `"node"` |
| 149 | + |
| 150 | +@sa DataSyncViewModel::showParams |
| 151 | +*/ |
| 152 | + |
| 153 | +/*! |
| 154 | +@fn QtMvvm::DataSyncViewModel::showParams(const QString &) |
| 155 | + |
| 156 | +@param setup The name of the QtDataSync::Setup to create the viewmodel for |
| 157 | +@return A paramater hash to be passed to ViewModel::show |
| 158 | + |
| 159 | +It's a shortcut to generate parameters for the show methods to show a datasync viewmodel. Use |
| 160 | +them as: |
| 161 | + |
| 162 | +@code{.cpp} |
| 163 | +show<QtMvvm::DataSyncViewModel>(QtMvvm::DataSyncViewModel::showParams(...)); |
| 164 | +@endcode |
| 165 | + |
| 166 | +@note Unless you need to explicitly set the setup or node a normal show without any parameters |
| 167 | +will just do fine. |
| 168 | + |
| 169 | +@sa ViewModel::show, DataSyncViewModel::paramSetup |
| 170 | +*/ |
| 171 | + |
| 172 | +/*! |
| 173 | +@fn QtMvvm::DataSyncViewModel::showParams(QRemoteObjectNode*) |
| 174 | + |
| 175 | +@param node The node to use to get the replicas for the managers |
| 176 | +@return A paramater hash to be passed to ViewModel::show |
| 177 | + |
| 178 | +It's a shortcut to generate parameters for the show methods to show a datasync viewmodel. Use |
| 179 | +them as: |
| 180 | + |
| 181 | +@code{.cpp} |
| 182 | +show<QtMvvm::DataSyncViewModel>(QtMvvm::DataSyncViewModel::showParams(...)); |
| 183 | +@endcode |
| 184 | + |
| 185 | +@note Unless you need to explicitly set the setup or node a normal show without any parameters |
| 186 | +will just do fine. |
| 187 | + |
| 188 | +@sa ViewModel::show, DataSyncViewModel::paramReplicaNode |
| 189 | +*/ |
| 190 | + |
| 191 | +/*! |
| 192 | +@fn QtMvvm::DataSyncViewModel::formatFingerPrint |
| 193 | + |
| 194 | +@param fingerPrint The fingerprint as a binary string |
| 195 | +@return A human readable string in hex format |
| 196 | + |
| 197 | +The returned string will be of the format: |
| 198 | +@code |
| 199 | +AB:CD:EF:01:02:03:... |
| 200 | +@endcode |
| 201 | + |
| 202 | +@sa QtDataSync::AccountManager::deviceFingerprint, QtDataSync::DeviceInfo::fingerprint |
| 203 | +*/ |
| 204 | + |
| 205 | +/*! |
| 206 | +@fn QtMvvm::DataSyncViewModel::removeDevice |
| 207 | + |
| 208 | +@param sortedIndex The index in the sorted model to be removed |
| 209 | + |
| 210 | +@warning The passed index **must** be an index from the DataSyncViewModel::sortedModel! It is |
| 211 | +translated to an account model index and the passed to AccountModel::removeDevice. If you do |
| 212 | +not use the sorted model, use the account model remove directly. If you use the sorted model |
| 213 | +(as recommended) use this method. |
| 214 | + |
| 215 | +@sa AccountModel::removeDevice, DataSyncViewModel::sortedModel |
| 216 | +*/ |
0 commit comments