Skycoder42
7 years ago
9 changed files with 520 additions and 13 deletions
@ -0,0 +1,216 @@ |
|||||
|
/*! |
||||
|
@class QtMvvm::DataSyncViewModel |
||||
|
|
||||
|
The viewmodel provides data to show a ui that gives access to all of the important datasync |
||||
|
account features and the synchronization status. The uis should show: |
||||
|
|
||||
|
- The sync status as string (DataSyncViewModel::statusString) |
||||
|
- A sync progress when actively syncing (QtDataSync::SyncManager::syncProgress) |
||||
|
- A possible error string, if an error occurs (QtDataSync::SyncManager::lastError) |
||||
|
- A list of all devices of the account (DataSyncViewModel::sortedModel) |
||||
|
- Actions to: |
||||
|
- Synchronize (syncOrConnect()) |
||||
|
- Toggle synchronization (QtDataSync::SyncManager::syncEnabled) |
||||
|
- Edit the identity (showDeviceInfo()) |
||||
|
- Reload the list of devices (QtDataSync::AccountManager::listDevices) |
||||
|
- Remove devices (removeDevice()) |
||||
|
- Update the exchange key (QtDataSync::AccountManager::updateExchangeKey) |
||||
|
- Change the remote server (changeRemote()) |
||||
|
- Reset the account (performReset()) |
||||
|
- Export the account data (startExport()) |
||||
|
- Import the account data (startImport()) |
||||
|
- Show the exchange viewmodel (startNetworkExchange()) |
||||
|
|
||||
|
@sa QtDataSync, NetworkExchangeViewModel |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::DataSyncViewModel::syncManager |
||||
|
|
||||
|
@default{`nullptr` (Is initialized by onInit())} |
||||
|
|
||||
|
A reference to the sync manager the view model internally uses. Is owned by the viewmodel, but |
||||
|
can be used to get properties for the ui. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{syncManager()} |
||||
|
@notifyAc{syncManagerChanged()} |
||||
|
} |
||||
|
|
||||
|
@sa DataSyncViewModel::accountManager |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::DataSyncViewModel::accountManager |
||||
|
|
||||
|
@default{`nullptr` (Is initialized by onInit())} |
||||
|
|
||||
|
A reference to the account manager the view model internally uses. Is owned by the viewmodel, |
||||
|
but can be used to get properties for the ui. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{accountManager()} |
||||
|
@notifyAc{accountManagerChanged()} |
||||
|
} |
||||
|
|
||||
|
@sa DataSyncViewModel::syncManager |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::DataSyncViewModel::colorMap |
||||
|
|
||||
|
@default{A map inizialized as:} |
||||
|
Key | Value |
||||
|
----------------------------------------|------- |
||||
|
QtDataSync::SyncManager::Initializing | Qt::darkCyan |
||||
|
QtDataSync::SyncManager::Downloading | Qt::darkCyan |
||||
|
QtDataSync::SyncManager::Uploading | Qt::darkCyan |
||||
|
QtDataSync::SyncManager::Synchronized | Qt::darkGreen |
||||
|
QtDataSync::SyncManager::Error | Qt::darkRed |
||||
|
QtDataSync::SyncManager::Disconnected | Qt::darkYellow |
||||
|
|
||||
|
This map is used by the DataSyncViewModel::statusString property to determine the color of the |
||||
|
status string, based of the state itself. You can change this property if you need different |
||||
|
colors for your theme. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{colorMap()} |
||||
|
@writeAc{setColorMap()} |
||||
|
@resetAc{resetColorMap()} |
||||
|
@notifyAc{colorMapChanged()} |
||||
|
} |
||||
|
|
||||
|
@sa DataSyncViewModel::statusString, DataSyncViewModel::ColorMap |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::DataSyncViewModel::statusString |
||||
|
|
||||
|
@default{`Disconnected`} |
||||
|
|
||||
|
A localized string to display the sync state as a single, simple string. The string is styled |
||||
|
with different colors based of the DataSyncViewModel::colorMap property. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{statusString()} |
||||
|
@notifyAc{statusStringChanged()} |
||||
|
} |
||||
|
|
||||
|
@sa DataSyncViewModel::colorMap, QtDataSync::SyncManager::syncState |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::DataSyncViewModel::accountModel |
||||
|
|
||||
|
@default{<i>An account model</i>} |
||||
|
|
||||
|
An unsorted model with all the devices of the current account. Automatically initialized and |
||||
|
managed by the viewmodel. |
||||
|
|
||||
|
@note You should use the DataSyncViewModel::sortedModel property when creating views. It is |
||||
|
a sorted version of this model, which is better for users. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{accountModel()} |
||||
|
@constantAc |
||||
|
} |
||||
|
|
||||
|
@sa DataSyncViewModel::sortedModel |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::DataSyncViewModel::sortedModel |
||||
|
|
||||
|
@default{<i>The accountModel, sorted</i>} |
||||
|
|
||||
|
A sorted proxy to the DataSyncViewModel::accountModel. You should prefer this sorted version |
||||
|
when binding views to the viewmodel. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{sortedModel()} |
||||
|
@constantAc |
||||
|
} |
||||
|
|
||||
|
@sa DataSyncViewModel::accountModel |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@var QtMvvm::DataSyncViewModel::paramSetup |
||||
|
|
||||
|
<b>Value:</b> `"setup"` |
||||
|
|
||||
|
@sa DataSyncViewModel::showParams |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@var QtMvvm::DataSyncViewModel::paramReplicaNode |
||||
|
|
||||
|
<b>Value:</b> `"node"` |
||||
|
|
||||
|
@sa DataSyncViewModel::showParams |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@fn QtMvvm::DataSyncViewModel::showParams(const QString &) |
||||
|
|
||||
|
@param setup The name of the QtDataSync::Setup to create the viewmodel for |
||||
|
@return A paramater hash to be passed to ViewModel::show |
||||
|
|
||||
|
It's a shortcut to generate parameters for the show methods to show a datasync viewmodel. Use |
||||
|
them as: |
||||
|
|
||||
|
@code{.cpp} |
||||
|
show<QtMvvm::DataSyncViewModel>(QtMvvm::DataSyncViewModel::showParams(...)); |
||||
|
@endcode |
||||
|
|
||||
|
@note Unless you need to explicitly set the setup or node a normal show without any parameters |
||||
|
will just do fine. |
||||
|
|
||||
|
@sa ViewModel::show, DataSyncViewModel::paramSetup |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@fn QtMvvm::DataSyncViewModel::showParams(QRemoteObjectNode*) |
||||
|
|
||||
|
@param node The node to use to get the replicas for the managers |
||||
|
@return A paramater hash to be passed to ViewModel::show |
||||
|
|
||||
|
It's a shortcut to generate parameters for the show methods to show a datasync viewmodel. Use |
||||
|
them as: |
||||
|
|
||||
|
@code{.cpp} |
||||
|
show<QtMvvm::DataSyncViewModel>(QtMvvm::DataSyncViewModel::showParams(...)); |
||||
|
@endcode |
||||
|
|
||||
|
@note Unless you need to explicitly set the setup or node a normal show without any parameters |
||||
|
will just do fine. |
||||
|
|
||||
|
@sa ViewModel::show, DataSyncViewModel::paramReplicaNode |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@fn QtMvvm::DataSyncViewModel::formatFingerPrint |
||||
|
|
||||
|
@param fingerPrint The fingerprint as a binary string |
||||
|
@return A human readable string in hex format |
||||
|
|
||||
|
The returned string will be of the format: |
||||
|
@code |
||||
|
AB:CD:EF:01:02:03:... |
||||
|
@endcode |
||||
|
|
||||
|
@sa QtDataSync::AccountManager::deviceFingerprint, QtDataSync::DeviceInfo::fingerprint |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@fn QtMvvm::DataSyncViewModel::removeDevice |
||||
|
|
||||
|
@param sortedIndex The index in the sorted model to be removed |
||||
|
|
||||
|
@warning The passed index **must** be an index from the DataSyncViewModel::sortedModel! It is |
||||
|
translated to an account model index and the passed to AccountModel::removeDevice. If you do |
||||
|
not use the sorted model, use the account model remove directly. If you use the sorted model |
||||
|
(as recommended) use this method. |
||||
|
|
||||
|
@sa AccountModel::removeDevice, DataSyncViewModel::sortedModel |
||||
|
*/ |
@ -0,0 +1,174 @@ |
|||||
|
/*! |
||||
|
@class QtMvvm::NetworkExchangeViewModel |
||||
|
|
||||
|
The viewmodel provides data to show a ui that allows you to exchange your user data with |
||||
|
another device in the same local network. |
||||
|
|
||||
|
@sa QtDataSync::UserExchangeManager, DataSyncViewModel |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::NetworkExchangeViewModel::userExchangeManager |
||||
|
|
||||
|
@default{`nullptr` (Is initialized by onInit())} |
||||
|
|
||||
|
A reference to the user exchange manager the view model internally uses. Is owned by the |
||||
|
viewmodel, but can be used to get properties for the ui. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{userExchangeManager()} |
||||
|
@notifyAc{userExchangeManagerChanged()} |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::NetworkExchangeViewModel::port |
||||
|
|
||||
|
@default{`QtDataSync::UserExchangeManager::DataExchangePort`} |
||||
|
|
||||
|
This port is passed to the exchange manager when activated to set the port. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{port()} |
||||
|
@writeAc{setPort()} |
||||
|
@notifyAc{portChanged()} |
||||
|
} |
||||
|
|
||||
|
@sa NetworkExchangeViewModel::active, QtDataSync::UserExchangeManager::startExchange, |
||||
|
QtDataSync::UserExchangeManager::port |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::NetworkExchangeViewModel::deviceName |
||||
|
|
||||
|
@default{`QtDataSync::AccountManager::deviceName`} |
||||
|
|
||||
|
This property is simply a forwarding of the QtDataSync::AccountManager::deviceName property. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{deviceName()} |
||||
|
@writeAc{setDeviceName()} |
||||
|
@notifyAc{deviceNameChanged()} |
||||
|
} |
||||
|
|
||||
|
@sa QtDataSync::AccountManager::deviceName |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::NetworkExchangeViewModel::active |
||||
|
|
||||
|
@default{`false`} |
||||
|
|
||||
|
Changing this property will trigger start and stop actions on the underlying manager, using |
||||
|
the other information provided from this viewmodel. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{active()} |
||||
|
@writeAc{setActive()} |
||||
|
@notifyAc{activeChanged()} |
||||
|
} |
||||
|
|
||||
|
@sa QtDataSync::AccountManager::startExchange, QtDataSync::AccountManager::stopExchange, |
||||
|
NetworkExchangeViewModel::port |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::NetworkExchangeViewModel::deviceModel |
||||
|
|
||||
|
@default{<i>An exchange device model</i>} |
||||
|
|
||||
|
An unsorted model with all the devices available for exchange. Automatically initialized and |
||||
|
managed by the viewmodel. |
||||
|
|
||||
|
@note You should use the NetworkExchangeViewModel::sortedModel property when creating views. |
||||
|
It is a sorted version of this model, which is better for users. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{deviceModel()} |
||||
|
@constantAc |
||||
|
} |
||||
|
|
||||
|
@sa NetworkExchangeViewModel::sortedModel |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@property QtMvvm::NetworkExchangeViewModel::sortedModel |
||||
|
|
||||
|
@default{<i>The deviceModel, sorted</i>} |
||||
|
|
||||
|
A sorted proxy to the NetworkExchangeViewModel::deviceModel. You should prefer this sorted |
||||
|
version when binding views to the viewmodel. |
||||
|
|
||||
|
@accessors{ |
||||
|
@readAc{sortedModel()} |
||||
|
@constantAc |
||||
|
} |
||||
|
|
||||
|
@sa NetworkExchangeViewModel::deviceModel |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@var QtMvvm::NetworkExchangeViewModel::paramSetup |
||||
|
|
||||
|
<b>Value:</b> `"setup"` |
||||
|
|
||||
|
@sa NetworkExchangeViewModel::showParams |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@var QtMvvm::NetworkExchangeViewModel::paramAccountManager |
||||
|
|
||||
|
<b>Value:</b> `"accountManager"` |
||||
|
|
||||
|
@sa NetworkExchangeViewModel::showParams |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@fn QtMvvm::NetworkExchangeViewModel::showParams(const QString &) |
||||
|
|
||||
|
@param setup The name of the QtDataSync::Setup to create the viewmodel for |
||||
|
@return A paramater hash to be passed to ViewModel::show |
||||
|
|
||||
|
It's a shortcut to generate parameters for the show methods to show an exchange viewmodel. Use |
||||
|
them as: |
||||
|
|
||||
|
@code{.cpp} |
||||
|
show<QtMvvm::NetworkExchangeViewModel>(QtMvvm::NetworkExchangeViewModel::showParams(...)); |
||||
|
@endcode |
||||
|
|
||||
|
@note Unless you need to explicitly set the setup or node a normal show without any parameters |
||||
|
will just do fine. |
||||
|
|
||||
|
@sa ViewModel::show, NetworkExchangeViewModel::paramSetup |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@fn QtMvvm::NetworkExchangeViewModel::showParams(QtDataSync::AccountManager*) |
||||
|
|
||||
|
@param accountManager The account manager to create the exchange manager of |
||||
|
@return A paramater hash to be passed to ViewModel::show |
||||
|
|
||||
|
It's a shortcut to generate parameters for the show methods to show an exchange viewmodel. Use |
||||
|
them as: |
||||
|
|
||||
|
@code{.cpp} |
||||
|
show<QtMvvm::NetworkExchangeViewModel>(QtMvvm::NetworkExchangeViewModel::showParams(...)); |
||||
|
@endcode |
||||
|
|
||||
|
@note Unless you need to explicitly set the setup or node a normal show without any parameters |
||||
|
will just do fine. |
||||
|
|
||||
|
@sa ViewModel::show, NetworkExchangeViewModel::paramAccountManager |
||||
|
*/ |
||||
|
|
||||
|
/*! |
||||
|
@fn QtMvvm::NetworkExchangeViewModel::exportTo |
||||
|
|
||||
|
@param sortedIndex The index in the sorted model of the device to export to |
||||
|
|
||||
|
@warning The passed index **must** be an index from the NetworkExchangeViewModel::sortedModel! |
||||
|
It is translated to an exchange model index and the passed to ExchangeDevicesModel::infoAt to |
||||
|
get the user info of the device to export the data to. |
||||
|
|
||||
|
@sa ExchangeDevicesModel::infoAt, NetworkExchangeViewModel::sortedModel |
||||
|
*/ |
Loading…
Reference in new issue