From 4f627c733d5adfee5da8f997136e7023d254c118 Mon Sep 17 00:00:00 2001 From: Skycoder42 Date: Wed, 14 Mar 2018 11:58:08 +0100 Subject: [PATCH] completed datasync core doc --- doc/datasyncviewmodel.dox | 216 ++++++++++++++++++ doc/networkexchangeviewmodel.dox | 174 ++++++++++++++ doc/qtmvvm.dox | 9 + src/imports/mvvmdatasynccore/plugins.qmltypes | 14 ++ src/mvvmdatasynccore/accountmodel.h | 16 +- src/mvvmdatasynccore/datasyncviewmodel.h | 48 +++- src/mvvmdatasynccore/exchangedevicesmodel.h | 20 +- .../networkexchangeviewmodel.cpp | 6 + .../networkexchangeviewmodel.h | 30 +++ 9 files changed, 520 insertions(+), 13 deletions(-) create mode 100644 doc/datasyncviewmodel.dox create mode 100644 doc/networkexchangeviewmodel.dox diff --git a/doc/datasyncviewmodel.dox b/doc/datasyncviewmodel.dox new file mode 100644 index 0000000..b2f7e6a --- /dev/null +++ b/doc/datasyncviewmodel.dox @@ -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{An account model} + +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{The accountModel, sorted} + +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 + +Value: `"setup"` + +@sa DataSyncViewModel::showParams +*/ + +/*! +@var QtMvvm::DataSyncViewModel::paramReplicaNode + +Value: `"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::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::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 +*/ diff --git a/doc/networkexchangeviewmodel.dox b/doc/networkexchangeviewmodel.dox new file mode 100644 index 0000000..51eeba2 --- /dev/null +++ b/doc/networkexchangeviewmodel.dox @@ -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{An exchange device model} + +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{The deviceModel, sorted} + +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 + +Value: `"setup"` + +@sa NetworkExchangeViewModel::showParams +*/ + +/*! +@var QtMvvm::NetworkExchangeViewModel::paramAccountManager + +Value: `"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::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::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 +*/ diff --git a/doc/qtmvvm.dox b/doc/qtmvvm.dox index 554704d..62a8b0a 100644 --- a/doc/qtmvvm.dox +++ b/doc/qtmvvm.dox @@ -94,6 +94,15 @@ The following list shows which classes belong to which Qt module, in alphabetica Current Version
        1.0 + +Available Types +- @ref QtMvvm::AccountModel "AccountModel" +- @ref QtMvvm::ExchangeDevicesModel "ExchangeDevicesModel" +- @ref QtMvvm::DataSyncViewModel "DataSyncViewModel" (uncreatable) +- @ref QtMvvm::NetworkExchangeViewModel "NetworkExchangeViewModel" (uncreatable) +- PChangeRemoteViewModel (uncreatable, internal) +- PExportSetupViewModel (uncreatable, internal) +- PIdentityEditViewModel (uncreatable, internal) */ /*! diff --git a/src/imports/mvvmdatasynccore/plugins.qmltypes b/src/imports/mvvmdatasynccore/plugins.qmltypes index 99f5d0a..cdfe0cc 100644 --- a/src/imports/mvvmdatasynccore/plugins.qmltypes +++ b/src/imports/mvvmdatasynccore/plugins.qmltypes @@ -265,12 +265,26 @@ Module { ] isCreatable: false exportMetaObjectRevisions: [0] + Property { + name: "userExchangeManager" + type: "QtDataSync::UserExchangeManager" + isReadonly: true + isPointer: true + } Property { name: "port"; type: "ushort" } Property { name: "deviceName"; type: "string" } Property { name: "active"; type: "bool" } Property { name: "deviceModel"; type: "ExchangeDevicesModel"; isReadonly: true; isPointer: true } Property { name: "sortedModel"; type: "QSortFilterProxyModel"; isReadonly: true; isPointer: true } Signal { name: "ready" } + Signal { + name: "userExchangeManagerChanged" + Parameter { + name: "userExchangeManager" + type: "QtDataSync::UserExchangeManager" + isPointer: true + } + } Signal { name: "portChanged" Parameter { name: "port"; type: "ushort" } diff --git a/src/mvvmdatasynccore/accountmodel.h b/src/mvvmdatasynccore/accountmodel.h index aa766f8..e095d46 100644 --- a/src/mvvmdatasynccore/accountmodel.h +++ b/src/mvvmdatasynccore/accountmodel.h @@ -12,35 +12,47 @@ namespace QtMvvm { class AccountModelPrivate; +//! A list model implementation for QtDataSync::DeviceInfo via a QtDataSync::AccountManager class Q_MVVMDATASYNCCORE_EXPORT AccountModel : public QAbstractListModel { Q_OBJECT public: + //! The model roles this model provides enum Roles { - NameRole = Qt::DisplayRole, - FingerPrintRole = Qt::UserRole + 1 + NameRole = Qt::DisplayRole, //!< The users name. The role name is `name` + FingerPrintRole = Qt::UserRole + 1 //!< The cryptopgraphic fingerprint of the users keys. The role name is `fingerPrint` }; Q_ENUM(Roles) + //! Default constructor explicit AccountModel(QObject *parent = nullptr); ~AccountModel(); + //! Setups up the model to use the account and a sync manager. Automatically loads devices Q_INVOKABLE void setup(QtDataSync::AccountManager *accountManager, QtDataSync::SyncManager *syncManager); + //! @inherit{QAbstractListModel::headerData} QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + //! @inherit{QAbstractListModel::rowCount} int rowCount(const QModelIndex &parent = QModelIndex()) const override; + //! @inherit{QAbstractListModel::columnCount} int columnCount(const QModelIndex &parent = QModelIndex()) const override; + //! @inherit{QAbstractListModel::data} QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + //! @inherit{QAbstractListModel::roleNames} QHash roleNames() const override; + //! Removes the device with the given index from the account Q_INVOKABLE bool removeDevice(const QModelIndex &index); + //! @copybrief removeDevice(const QModelIndex &) Q_INVOKABLE inline bool removeDevice(int row) { return removeDevice(index(row)); } public Q_SLOTS: + //! Reload the device list void reload(); private Q_SLOTS: diff --git a/src/mvvmdatasynccore/datasyncviewmodel.h b/src/mvvmdatasynccore/datasyncviewmodel.h index de28a5e..4703396 100644 --- a/src/mvvmdatasynccore/datasyncviewmodel.h +++ b/src/mvvmdatasynccore/datasyncviewmodel.h @@ -18,73 +18,107 @@ namespace QtMvvm { class DataSyncViewModelPrivate; +//! A viewmodel to show a overview of the datasync status and account class Q_MVVMDATASYNCCORE_EXPORT DataSyncViewModel : public ViewModel { Q_OBJECT + //! The sync manager the viewmodel operates on Q_PROPERTY(QtDataSync::SyncManager* syncManager READ syncManager NOTIFY syncManagerChanged) + //! The account manager the viewmodel operates on Q_PROPERTY(QtDataSync::AccountManager* accountManager READ accountManager NOTIFY accountManagerChanged) + //! A mapping of sync states to text colors Q_PROPERTY(ColorMap colorMap READ colorMap WRITE setColorMap RESET resetColorMap NOTIFY colorMapChanged) + //! A styles string describing the current sync status Q_PROPERTY(QString statusString READ statusString NOTIFY statusStringChanged) + //! The account model to be used to display account devices Q_PROPERTY(QtMvvm::AccountModel* accountModel READ accountModel CONSTANT) + //! A sorted version of the account model Q_PROPERTY(QSortFilterProxyModel* sortedModel READ sortedModel CONSTANT) public: + //! A mapping from sync states to a text color typedef QMap ColorMap; + //! The parameter for a setup name for the onInit() method static const QString paramSetup; + //! The parameter for a QRemoteObjectNode for the onInit() method static const QString paramReplicaNode; + //! Generates show parameter to show a datasync viewmodel via ViewModel::show static QVariantHash showParams(const QString &setup); + //! @copybrief showParams(const QString &) static QVariantHash showParams(QRemoteObjectNode *node); + //! Invokable constructor Q_INVOKABLE explicit DataSyncViewModel(QObject *parent = nullptr); ~DataSyncViewModel(); + //! @readAcFn{DataSyncViewModel::syncManager} QtDataSync::SyncManager* syncManager() const; + //! @readAcFn{DataSyncViewModel::accountManager} QtDataSync::AccountManager* accountManager() const; + //! @readAcFn{DataSyncViewModel::colorMap} ColorMap colorMap() const; + //! @readAcFn{DataSyncViewModel::statusString} QString statusString() const; - + //! @readAcFn{DataSyncViewModel::accountModel} AccountModel *accountModel() const; + //! @readAcFn{DataSyncViewModel::sortedModel} QSortFilterProxyModel* sortedModel() const; + //! Converts a binary fingerprint to a human readable string Q_INVOKABLE static QString formatFingerPrint(const QByteArray &fingerPrint); public Q_SLOTS: + //! Synchronizes or reconnects with the server void syncOrConnect(); + //! Show and edit information about this current device void showDeviceInfo(); + //! Start an export to a file void startExport(); + //! Start an import from a file void startImport(); + //! Show a confirmation dialog to reset the account (and then reset) void performReset(); + //! Show a dialog to change the remote server connected to void changeRemote(); + //! Start a network exchange by showing the NetworkExchangeViewModel void startNetworkExchange(); + //! Remove the with the given index in the sorted model from the account void removeDevice(int sortedIndex); + //! @writeAcFn{DataSyncViewModel::colorMap} void setColorMap(ColorMap colorMap); + //! @resetAcFn{DataSyncViewModel::colorMap} void resetColorMap(); -private Q_SLOTS: - void showImportDialog(QtDataSync::LoginRequest request); - void showImportAccepted(); - void showAccessGranted(const QUuid &id); - void triggerGranted(const QList &devices); - Q_SIGNALS: + //! @notifyAcFn{DataSyncViewModel::syncManager} void syncManagerChanged(QtDataSync::SyncManager* syncManager); + //! @notifyAcFn{DataSyncViewModel::accountManager} void accountManagerChanged(QtDataSync::AccountManager* accountManager); + //! @notifyAcFn{DataSyncViewModel::colorMap} void colorMapChanged(ColorMap colorMap); + //! @notifyAcFn{DataSyncViewModel::statusString} void statusStringChanged(); + //! Is emitted as soon as all the datasync managers have been initialized void ready(); protected: void onInit(const QVariantHash ¶ms) override; void onResult(quint32 requestCode, const QVariant &result) override; +private Q_SLOTS: + void showImportDialog(QtDataSync::LoginRequest request); + void showImportAccepted(); + void showAccessGranted(const QUuid &id); + void triggerGranted(const QList &devices); + private: QScopedPointer d; }; diff --git a/src/mvvmdatasynccore/exchangedevicesmodel.h b/src/mvvmdatasynccore/exchangedevicesmodel.h index 690c6de..217ad44 100644 --- a/src/mvvmdatasynccore/exchangedevicesmodel.h +++ b/src/mvvmdatasynccore/exchangedevicesmodel.h @@ -11,35 +11,47 @@ namespace QtMvvm { class ExchangeDevicesModelPrivate; +//! A list model implementation to show all devices available by the QtDataSync::UserExchangeManager class Q_MVVMDATASYNCCORE_EXPORT ExchangeDevicesModel : public QAbstractListModel { Q_OBJECT public: + //! The model roles this model provides enum Roles { - NameRole = Qt::DisplayRole, - HostRole = Qt::UserRole + 1, - PortRole, - AddressRole + NameRole = Qt::DisplayRole, //!< The local name of the device. The role name is `name` + HostRole = Qt::UserRole + 1, //!< The host name (IP address) of the device. The role name is `host` + PortRole, //!< The port the device is bound to. The role name is `port` + AddressRole //!< A full, readable address of the device (Host+Port). The role name is `address` }; Q_ENUM(Roles) + //! Default constructor explicit ExchangeDevicesModel(QObject *parent = nullptr); ~ExchangeDevicesModel(); + //! Setups up the model to use the exchange manager. Automatically displays all devices of the manager Q_INVOKABLE void setup(QtDataSync::UserExchangeManager *exchangeManager); + //! Returns the user info at the given index Q_INVOKABLE QtDataSync::UserInfo infoAt(const QModelIndex &index) const; + //! @copybrief infoAt(const QModelIndex &) const Q_INVOKABLE inline QtDataSync::UserInfo infoAt(int row) const { return infoAt(index(row)); } + //! @inherit{QAbstractListModel::headerData} QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + //! @inherit{QAbstractListModel::rowCount} int rowCount(const QModelIndex &parent = QModelIndex()) const override; + //! @inherit{QAbstractListModel::columnCount} int columnCount(const QModelIndex &parent) const override; + //! @inherit{QAbstractListModel::data} QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + //! @inherit{QAbstractListModel::roleNames} QHash roleNames() const override; + //! returns a localized string of the user infos address and port, combined to one static QString fullAddress(const QtDataSync::UserInfo &userInfo); private Q_SLOTS: diff --git a/src/mvvmdatasynccore/networkexchangeviewmodel.cpp b/src/mvvmdatasynccore/networkexchangeviewmodel.cpp index 9461cf9..0358fd0 100644 --- a/src/mvvmdatasynccore/networkexchangeviewmodel.cpp +++ b/src/mvvmdatasynccore/networkexchangeviewmodel.cpp @@ -43,6 +43,11 @@ NetworkExchangeViewModel::NetworkExchangeViewModel(QObject *parent) : NetworkExchangeViewModel::~NetworkExchangeViewModel() {} +UserExchangeManager *NetworkExchangeViewModel::userExchangeManager() const +{ + return d->exchangeManager; +} + quint16 NetworkExchangeViewModel::port() const { return d->port; @@ -135,6 +140,7 @@ void NetworkExchangeViewModel::onInit(const QVariantHash ¶ms) connect(d->exchangeManager, &UserExchangeManager::activeChanged, this, &NetworkExchangeViewModel::activeChanged); + emit userExchangeManagerChanged(d->exchangeManager); emit deviceNameChanged(deviceName()); d->deviceModel->setup(d->exchangeManager); diff --git a/src/mvvmdatasynccore/networkexchangeviewmodel.h b/src/mvvmdatasynccore/networkexchangeviewmodel.h index 070470a..e6a9531 100644 --- a/src/mvvmdatasynccore/networkexchangeviewmodel.h +++ b/src/mvvmdatasynccore/networkexchangeviewmodel.h @@ -14,45 +14,75 @@ namespace QtMvvm { class NetworkExchangeViewModelPrivate; +//! A viewmodel to show a dialog to exchange account data via the QtDataSync::UserExchangeManager class Q_MVVMDATASYNCCORE_EXPORT NetworkExchangeViewModel : public ViewModel { Q_OBJECT + //! The user exchange manager the viewmodel operates on + Q_PROPERTY(QtDataSync::UserExchangeManager* userExchangeManager READ userExchangeManager NOTIFY userExchangeManagerChanged) + //! The port to run the exchange on Q_PROPERTY(quint16 port READ port WRITE setPort NOTIFY portChanged) + //! The name of your current device Q_PROPERTY(QString deviceName READ deviceName WRITE setDeviceName NOTIFY deviceNameChanged) + //! Start or stop the network exchange Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) + //! The devices model to be used to display found exchange devices Q_PROPERTY(ExchangeDevicesModel* deviceModel READ deviceModel CONSTANT) + //! A sorted version of the devices model Q_PROPERTY(QSortFilterProxyModel* sortedModel READ sortedModel CONSTANT) public: + //! The parameter for a setup name for the onInit() method static const QString paramSetup; + //! The parameter for an QtDataSync::AccountManager for the onInit() method static const QString paramAccountManager; + //! Generates show parameter to show a network exchange viewmodel via ViewModel::show static QVariantHash showParams(const QString &setup); + //! @copybrief showParams(const QString &) static QVariantHash showParams(QtDataSync::AccountManager *accountManager); + //! Invokable constructor Q_INVOKABLE explicit NetworkExchangeViewModel(QObject *parent = nullptr); ~NetworkExchangeViewModel(); + //! @readAcFn{NetworkExchangeViewModel::userExchangeManager} + QtDataSync::UserExchangeManager* userExchangeManager() const; + //! @readAcFn{NetworkExchangeViewModel::port} quint16 port() const; + //! @readAcFn{NetworkExchangeViewModel::deviceName} QString deviceName() const; + //! @readAcFn{NetworkExchangeViewModel::active} bool active() const; + //! @readAcFn{NetworkExchangeViewModel::deviceModel} ExchangeDevicesModel* deviceModel() const; + //! @readAcFn{NetworkExchangeViewModel::sortedModel} QSortFilterProxyModel* sortedModel() const; public Q_SLOTS: + //! Start en export of user data to the device with the given index in the sorted model void exportTo(int sortedIndex); + //! @writeAcFn{NetworkExchangeViewModel::port} void setPort(quint16 port); + //! @writeAcFn{NetworkExchangeViewModel::deviceName} void setDeviceName(QString deviceName); + //! @writeAcFn{NetworkExchangeViewModel::active} void setActive(bool active); Q_SIGNALS: + //! Is emitted as soon as all the user exchange manager has been initialized void ready(); + //! @notifyAcFn{NetworkExchangeViewModel::userExchangeManager} + void userExchangeManagerChanged(QtDataSync::UserExchangeManager* userExchangeManager); + //! @notifyAcFn{NetworkExchangeViewModel::port} void portChanged(quint16 port); + //! @notifyAcFn{NetworkExchangeViewModel::deviceName} void deviceNameChanged(QString deviceName); + //! @notifyAcFn{NetworkExchangeViewModel::active} void activeChanged(bool active); protected: