QtMvvm  1.1.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Properties | List of all members
QtMvvm::NetworkExchangeViewModel Class Reference

A viewmodel to show a dialog to exchange account data via the QtDataSync::UserExchangeManager. More...

#include <networkexchangeviewmodel.h>

+ Inheritance diagram for QtMvvm::NetworkExchangeViewModel:

Public Slots

void exportTo (int sortedIndex)
 Start en export of user data to the device with the given index in the sorted model. More...
 
void setPort (quint16 port)
 WRITE accessor for NetworkExchangeViewModel::port.
 
void setDeviceName (QString deviceName)
 WRITE accessor for NetworkExchangeViewModel::deviceName.
 
void setActive (bool active)
 WRITE accessor for NetworkExchangeViewModel::active.
 
- Public Slots inherited from QtMvvm::ViewModel

Signals

void ready (QPrivateSignal)
 Is emitted as soon as all the user exchange manager has been initialized.
 
void userExchangeManagerChanged (QtDataSync::UserExchangeManager *userExchangeManager, QPrivateSignal)
 NOTIFY accessor for NetworkExchangeViewModel::userExchangeManager.
 
void portChanged (quint16 port, QPrivateSignal)
 NOTIFY accessor for NetworkExchangeViewModel::port.
 
void deviceNameChanged (QString deviceName, QPrivateSignal)
 NOTIFY accessor for NetworkExchangeViewModel::deviceName.
 
void activeChanged (bool active, QPrivateSignal)
 NOTIFY accessor for NetworkExchangeViewModel::active.
 
- Signals inherited from QtMvvm::ViewModel
void resultReady (const QVariant &result)
 Should be emitted when the viewmodels result is ready. More...
 
QTMVVM_REVISION_1 void instanceInvoked (const QVariantHash &params, QPrivateSignal)
 Is emitted on single instance viewmodels when they get shown again. More...
 

Public Member Functions

Q_INVOKABLE NetworkExchangeViewModel (QObject *parent=nullptr)
 Invokable constructor.
 
QtDataSync::UserExchangeManageruserExchangeManager () const
 READ accessor for NetworkExchangeViewModel::userExchangeManager.
 
quint16 port () const
 READ accessor for NetworkExchangeViewModel::port.
 
QString deviceName () const
 READ accessor for NetworkExchangeViewModel::deviceName.
 
bool isActive () const
 READ accessor for NetworkExchangeViewModel::active.
 
Q_DECL_DEPRECATED bool active () const
 
ExchangeDevicesModeldeviceModel () const
 READ accessor for NetworkExchangeViewModel::deviceModel.
 
QSortFilterProxyModelsortedModel () const
 READ accessor for NetworkExchangeViewModel::sortedModel.
 
- Public Member Functions inherited from QtMvvm::ViewModel
 ViewModel (QObject *parent=nullptr)
 Default constructor with parent.
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
virtual void * qt_metacast (const char *)
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectList & children () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 

Static Public Member Functions

static QVariantHash showParams (const QString &setup)
 Generates show parameter to show a network exchange viewmodel via ViewModel::show. More...
 
static QVariantHash showParams (QtDataSync::AccountManager *accountManager)
 Generates show parameter to show a network exchange viewmodel via ViewModel::show. More...
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Static Public Attributes

static const QString paramSetup
 The parameter for a setup name for the onInit() method. More...
 
static const QString paramAccountManager
 The parameter for an QtDataSync::AccountManager for the onInit() method. More...
 

Protected Member Functions

void onInit (const QVariantHash &params) override
 Called by the presenter to initialize the viewmodel. More...
 
void onResult (quint32 requestCode, const QVariant &result) override
 Called by the presenter when a result of a showed viewmodel is ready. More...
 
- Protected Member Functions inherited from QtMvvm::ViewModel
template<typename TViewModel >
void show (const QVariantHash &params={}) const
 Show another viewmodel as a child of this one. More...
 
void show (const char *viewModelName, const QVariantHash &params={}) const
 Show another viewmodel as a child of this one. More...
 
void show (const QMetaObject *viewMetaObject, const QVariantHash &params={}) const
 Show another viewmodel as a child of this one. More...
 
template<typename TViewModel >
void showForResult (quint32 requestCode, const QVariantHash &params={}) const
 Show another viewmodel as a child of this one and expect its result. More...
 
void showForResult (quint32 requestCode, const char *viewModelName, const QVariantHash &params={}) const
 Show another viewmodel as a child of this one and expect its result. More...
 
void showForResult (quint32 requestCode, const QMetaObject *viewMetaObject, const QVariantHash &params={}) const
 Show another viewmodel as a child of this one and expect its result. More...
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Properties

QtDataSync::UserExchangeManager userExchangeManager
 The user exchange manager the viewmodel operates on. More...
 
quint16 port
 The port to run the exchange on. More...
 
QString deviceName
 The name of your current device. More...
 
bool active
 Start or stop the network exchange. More...
 
ExchangeDevicesModel deviceModel
 The devices model to be used to display found exchange devices. More...
 
QSortFilterProxyModel sortedModel
 A sorted version of the devices model. More...
 
- Properties inherited from QObject
 objectName
 

Detailed Description

A viewmodel to show a dialog to exchange account data via the QtDataSync::UserExchangeManager.

The viewmodel provides data to show a ui that allows you to exchange your user data with another device in the same local network.

See also
QtDataSync::UserExchangeManager, DataSyncViewModel

Definition at line 18 of file networkexchangeviewmodel.h.

Member Function Documentation

◆ exportTo

QtMvvm::NetworkExchangeViewModel::exportTo ( int  sortedIndex)
slot

Start en export of user data to the device with the given index in the sorted model.

Parameters
sortedIndexThe 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.
See also
ExchangeDevicesModel::infoAt, NetworkExchangeViewModel::sortedModel

◆ onInit()

void QtMvvm::NetworkExchangeViewModel::onInit ( const QVariantHash &  params)
overrideprotectedvirtual

Called by the presenter to initialize the viewmodel.

Parameters
paramsThe parameters to initialize the viewmodel with

This method is called by the presenter right after creating the view and reparenting the viewmodel to the view. The parameters are the ones that have been passed to the show method called to show this viewmodel instance. Reimplement this method if you need to perform initializations after beeing assigned to a viewmodel or if you want to support a parametrized viewmodel.

See also
ViewModel::show, ViewModel::showForResult, CoreApp::show

Reimplemented from QtMvvm::ViewModel.

◆ onResult()

void QtMvvm::NetworkExchangeViewModel::onResult ( quint32  requestCode,
const QVariant result 
)
overrideprotectedvirtual

Called by the presenter when a result of a showed viewmodel is ready.

Parameters
requestCodeThe request code of the show request for the viewmodel that triggered the result
resultThe result passed from the viewmodel

When showing a child viewmodel via showForResult(), then the result of that show request is reported back via this function. The requestCode is the one that was passed to the showForResult() method, and the result what the viewmodel reported back. If the showed viewmodel emitted resultReady() before beeing destroyed, this value passed to that signal is whats reported as result. If the child viewmodel gets destroyed without ever emitting that signal, this method is still called, but with an invalid QVariant as result.

See also
ViewModel::showForResult, ViewModel::resultReady

Reimplemented from QtMvvm::ViewModel.

◆ showParams() [1/2]

QtMvvm::NetworkExchangeViewModel::showParams ( const QString setup)
static

Generates show parameter to show a network exchange viewmodel via ViewModel::show.

Parameters
setupThe name of the QtDataSync::Setup to create the viewmodel for
Returns
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:

show<QtMvvm::NetworkExchangeViewModel>(QtMvvm::NetworkExchangeViewModel::showParams(...));
Note
Unless you need to explicitly set the setup or node a normal show without any parameters will just do fine.
See also
ViewModel::show, NetworkExchangeViewModel::paramSetup

◆ showParams() [2/2]

QtMvvm::NetworkExchangeViewModel::showParams ( QtDataSync::AccountManager accountManager)
static

Generates show parameter to show a network exchange viewmodel via ViewModel::show.

Parameters
accountManagerThe account manager to create the exchange manager of
Returns
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:

show<QtMvvm::NetworkExchangeViewModel>(QtMvvm::NetworkExchangeViewModel::showParams(...));
Note
Unless you need to explicitly set the setup or node a normal show without any parameters will just do fine.
See also
ViewModel::show, NetworkExchangeViewModel::paramAccountManager

Member Data Documentation

◆ paramAccountManager

QtMvvm::NetworkExchangeViewModel::paramAccountManager
static

The parameter for an QtDataSync::AccountManager for the onInit() method.

Value: "accountManager"

See also
NetworkExchangeViewModel::showParams

Definition at line 40 of file networkexchangeviewmodel.h.

◆ paramSetup

QtMvvm::NetworkExchangeViewModel::paramSetup
static

The parameter for a setup name for the onInit() method.

Value: "setup"

See also
NetworkExchangeViewModel::showParams

Definition at line 38 of file networkexchangeviewmodel.h.

Property Documentation

◆ active

QtMvvm::NetworkExchangeViewModel::active
readwrite

Start or stop the network exchange.

Default: false

Changing this property will trigger start and stop actions on the underlying manager, using the other information provided from this viewmodel.

Accessors
READisActive()
WRITEsetActive()
NOTIFYactiveChanged()
See also
QtDataSync::AccountManager::startExchange, QtDataSync::AccountManager::stopExchange, NetworkExchangeViewModel::port

Definition at line 29 of file networkexchangeviewmodel.h.

◆ deviceModel

QtMvvm::NetworkExchangeViewModel::deviceModel
read

The devices model to be used to display found exchange devices.

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
READdeviceModel()
CONSTANT
See also
NetworkExchangeViewModel::sortedModel

Definition at line 32 of file networkexchangeviewmodel.h.

◆ deviceName

QtMvvm::NetworkExchangeViewModel::deviceName
readwrite

The name of your current device.

Default: QtDataSync::AccountManager::deviceName

This property is simply a forwarding of the QtDataSync::AccountManager::deviceName property.

Accessors
READdeviceName()
WRITEsetDeviceName()
NOTIFYdeviceNameChanged()
See also
QtDataSync::AccountManager::deviceName

Definition at line 27 of file networkexchangeviewmodel.h.

◆ port

QtMvvm::NetworkExchangeViewModel::port
readwrite

The port to run the exchange on.

Default: QtDataSync::UserExchangeManager::DataExchangePort

This port is passed to the exchange manager when activated to set the port.

Accessors
READport()
WRITEsetPort()
NOTIFYportChanged()
See also
NetworkExchangeViewModel::active, QtDataSync::UserExchangeManager::startExchange, QtDataSync::UserExchangeManager::port

Definition at line 25 of file networkexchangeviewmodel.h.

◆ sortedModel

QtMvvm::NetworkExchangeViewModel::sortedModel
read

A sorted version of the devices model.

Default: The deviceModel, sorted

A sorted proxy to the NetworkExchangeViewModel::deviceModel. You should prefer this sorted version when binding views to the viewmodel.

Accessors
READsortedModel()
CONSTANT
See also
NetworkExchangeViewModel::deviceModel

Definition at line 34 of file networkexchangeviewmodel.h.

◆ userExchangeManager

QtMvvm::NetworkExchangeViewModel::userExchangeManager
read

The user exchange manager the viewmodel operates on.

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
READuserExchangeManager()
NOTIFYuserExchangeManagerChanged()

Definition at line 23 of file networkexchangeviewmodel.h.


The documentation for this class was generated from the following files: