A viewmodel to show a overview of the datasync status and account. More...
#include <datasyncviewmodel.h>
Public Types | |
using | ColorMap = QMap< QtDataSync::SyncManager::SyncState, QColor > |
A mapping from sync states to a text color. | |
Public Slots | |
void | syncOrConnect () |
Synchronizes or reconnects with the server. | |
void | showDeviceInfo () |
Show and edit information about this current device. | |
void | startExport () |
Start an export to a file. | |
void | startImport () |
Start an import from a file. | |
void | performReset () |
Show a confirmation dialog to reset the account (and then reset) | |
void | changeRemote () |
Show a dialog to change the remote server connected to. | |
void | startNetworkExchange () |
Start a network exchange by showing the NetworkExchangeViewModel. | |
void | removeDevice (int sortedIndex) |
Remove the with the given index in the sorted model from the account. More... | |
void | setColorMap (ColorMap colorMap) |
WRITE accessor for DataSyncViewModel::colorMap. | |
void | resetColorMap () |
RESET accessor for DataSyncViewModel::colorMap. | |
Public Slots inherited from QtMvvm::ViewModel |
Signals | |
void | syncManagerChanged (QtDataSync::SyncManager *syncManager, QPrivateSignal) |
NOTIFY accessor for DataSyncViewModel::syncManager. | |
void | accountManagerChanged (QtDataSync::AccountManager *accountManager, QPrivateSignal) |
NOTIFY accessor for DataSyncViewModel::accountManager. | |
void | colorMapChanged (ColorMap colorMap, QPrivateSignal) |
NOTIFY accessor for DataSyncViewModel::colorMap. | |
void | statusStringChanged (QPrivateSignal) |
NOTIFY accessor for DataSyncViewModel::statusString. | |
void | ready (QPrivateSignal) |
Is emitted as soon as all the datasync managers have been initialized. | |
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 ¶ms, QPrivateSignal) |
Is emitted on single instance viewmodels when they get shown again. More... | |
Public Member Functions | |
Q_INVOKABLE | DataSyncViewModel (QObject *parent=nullptr) |
Invokable constructor. | |
QtDataSync::SyncManager * | syncManager () const |
READ accessor for DataSyncViewModel::syncManager. | |
QtDataSync::AccountManager * | accountManager () const |
READ accessor for DataSyncViewModel::accountManager. | |
ColorMap | colorMap () const |
READ accessor for DataSyncViewModel::colorMap. | |
QString | statusString () const |
READ accessor for DataSyncViewModel::statusString. | |
AccountModel * | accountModel () const |
READ accessor for DataSyncViewModel::accountModel. | |
QSortFilterProxyModel * | sortedModel () const |
READ accessor for DataSyncViewModel::sortedModel. | |
Public Member Functions inherited from QtMvvm::ViewModel | |
ViewModel (QObject *parent=nullptr) | |
Default constructor with parent. | |
Public Member Functions inherited from QObject | |
virtual const QMetaObject * | metaObject () 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) |
QThread * | thread () 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) |
T | 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 ®Exp, 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< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () 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 datasync viewmodel via ViewModel::show. More... | |
static QVariantHash | showParams (QRemoteObjectNode *node) |
Generates show parameter to show a datasync viewmodel via ViewModel::show. More... | |
static Q_INVOKABLE QString | formatFingerPrint (const QByteArray &fingerPrint) |
Converts a binary fingerprint to a human readable string. 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 | paramReplicaNode |
The parameter for a QRemoteObjectNode for the onInit() method. More... | |
Protected Member Functions | |
void | onInit (const QVariantHash ¶ms) 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 ¶ms={}) const |
Show another viewmodel as a child of this one. More... | |
void | show (const char *viewModelName, const QVariantHash ¶ms={}) const |
Show another viewmodel as a child of this one. More... | |
void | show (const QMetaObject *viewMetaObject, const QVariantHash ¶ms={}) const |
Show another viewmodel as a child of this one. More... | |
template<typename TViewModel > | |
void | showForResult (quint32 requestCode, const QVariantHash ¶ms={}) const |
Show another viewmodel as a child of this one and expect its result. More... | |
void | showForResult (quint32 requestCode, const char *viewModelName, const QVariantHash ¶ms={}) const |
Show another viewmodel as a child of this one and expect its result. More... | |
void | showForResult (quint32 requestCode, const QMetaObject *viewMetaObject, const QVariantHash ¶ms={}) const |
Show another viewmodel as a child of this one and expect its result. More... | |
Protected Member Functions inherited from QObject | |
QObject * | sender () 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::SyncManager | syncManager |
The sync manager the viewmodel operates on. More... | |
QtDataSync::AccountManager | accountManager |
The account manager the viewmodel operates on. More... | |
ColorMap | colorMap |
A mapping of sync states to text colors. More... | |
QString | statusString |
A styles string describing the current sync status. More... | |
QtMvvm::AccountModel | accountModel |
The account model to be used to display account devices. More... | |
QSortFilterProxyModel | sortedModel |
A sorted version of the account model. More... | |
Properties inherited from QObject | |
objectName | |
A viewmodel to show a overview of the datasync status and account.
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:
Definition at line 22 of file datasyncviewmodel.h.
|
static |
Converts a binary fingerprint to a human readable string.
fingerPrint | The fingerprint as a binary string |
The returned string will be of the format:
|
overrideprotectedvirtual |
Called by the presenter to initialize the viewmodel.
params | The 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.
Reimplemented from QtMvvm::ViewModel.
|
overrideprotectedvirtual |
Called by the presenter when a result of a showed viewmodel is ready.
requestCode | The request code of the show request for the viewmodel that triggered the result |
result | The 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.
Reimplemented from QtMvvm::ViewModel.
|
slot |
Remove the with the given index in the sorted model from the account.
sortedIndex | The index in the sorted model to be removed |
|
static |
Generates show parameter to show a datasync viewmodel via ViewModel::show.
setup | The name of the QtDataSync::Setup to create the viewmodel for |
It's a shortcut to generate parameters for the show methods to show a datasync viewmodel. Use them as:
|
static |
Generates show parameter to show a datasync viewmodel via ViewModel::show.
node | The node to use to get the replicas for the managers |
It's a shortcut to generate parameters for the show methods to show a datasync viewmodel. Use them as:
|
static |
The parameter for a QRemoteObjectNode for the onInit() method.
Value: "node"
Definition at line 48 of file datasyncviewmodel.h.
|
static |
The parameter for a setup name for the onInit() method.
Value: "setup"
Definition at line 46 of file datasyncviewmodel.h.
|
read |
The account manager the viewmodel operates on.
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 | |
---|---|
READ | accountManager() |
NOTIFY | accountManagerChanged() |
Definition at line 29 of file datasyncviewmodel.h.
|
read |
The account model to be used to display account devices.
Default: An account model
An unsorted model with all the devices of the current account. Automatically initialized and managed by the viewmodel.
Accessors | |
---|---|
READ | accountModel() |
CONSTANT |
Definition at line 37 of file datasyncviewmodel.h.
|
readwrite |
A mapping of sync states to text colors.
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 | |
---|---|
READ | colorMap() |
WRITE | setColorMap() |
RESET | resetColorMap() |
NOTIFY | colorMapChanged() |
Definition at line 32 of file datasyncviewmodel.h.
|
read |
A sorted version of the account model.
Default: The accountModel, sorted
A sorted proxy to the DataSyncViewModel::accountModel. You should prefer this sorted version when binding views to the viewmodel.
Accessors | |
---|---|
READ | sortedModel() |
CONSTANT |
Definition at line 39 of file datasyncviewmodel.h.
|
read |
A styles string describing the current sync status.
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 | |
---|---|
READ | statusString() |
NOTIFY | statusStringChanged() |
Definition at line 34 of file datasyncviewmodel.h.
|
read |
The sync manager the viewmodel operates on.
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 | |
---|---|
READ | syncManager() |
NOTIFY | syncManagerChanged() |
Definition at line 27 of file datasyncviewmodel.h.