Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
added QML doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Skycoder42 committed Nov 16, 2018
1 parent bb61809 commit b6cfbc6
Show file tree
Hide file tree
Showing 18 changed files with 543 additions and 21 deletions.
3 changes: 2 additions & 1 deletion doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ ALIASES = "accessors{1}=<table><tr><th colspan= 2>Accessors</th><
storedAc{1}=<tr><td><b>STORED</b></td><td>\1</td></tr> \
userAc{1}=<tr><td><b>USER</b></td><td>\1</td></tr> \
"constantAc=<tr><td colspan= 2><b>CONSTANT</b></td></tr>" \
"readonlyAc=<tr><td colspan= 2><b>READ ONLY</b></td></tr>" \
"finalAc=<tr><td colspan= 2><b>FINAL</b></td></tr>" \
"default{1}=<b>Default:</b> \1 <br>" \
"readAcFn{1}=READ accessor for \1" \
Expand Down Expand Up @@ -894,7 +895,6 @@ RECURSIVE = YES
# run.

EXCLUDE = ../src/3rdparty \
../src/imports \
../src/plugins

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
Expand Down Expand Up @@ -929,6 +929,7 @@ EXCLUDE_PATTERNS = moc_* \

EXCLUDE_SYMBOLS = QtDataSync::__helpertypes::* \
QtDataSync::JsonObject \
QtDataSyncDeclarativeModule \
\
QAbstractAspect \
QAbstractXmlReceiver \
Expand Down
2 changes: 1 addition & 1 deletion doc/datastore.dox
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ completed. This of course only applies to pointer classes, as gadgets are used a
*/

/*!
@fn QtDataSync::DataStore::setupName
@fn QtDataSync::DataStore::setupName() const
@returns The name of the setup
@sa QtDataSync::Setup
*/
Expand Down
8 changes: 4 additions & 4 deletions doc/eventcursor.dox
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ EventCursor::isEventLogActive
/*!
@fn QtDataSync::EventCursor::first(const QString &, QObject*)
@param setupName The name of the setup to create the cursor for
@copydetails EventCursor::first(QObject*)
@copydetails QtDataSync::EventCursor::first(QObject*)
*/

/*!
Expand All @@ -208,7 +208,7 @@ EventCursor::isEventLogActive
/*!
@fn QtDataSync::EventCursor::last(const QString &, QObject*)
@param setupName The name of the setup to create the cursor for
@copydetails EventCursor::last(QObject*)
@copydetails QtDataSync::EventCursor::last(QObject*)
*/

/*!
Expand All @@ -229,7 +229,7 @@ EventCursor::isEventLogActive
/*!
@fn QtDataSync::EventCursor::create(quint64, const QString &, QObject*)
@param setupName The name of the setup to create the cursor for
@copydetails EventCursor::create(quint64, QObject*)
@copydetails QtDataSync::EventCursor::create(quint64, QObject*)
*/

/*!
Expand Down Expand Up @@ -260,7 +260,7 @@ EventCursor::isEventLogActive, EventCursor::save, EventCursor::skipObsolete
/*!
@fn QtDataSync::EventCursor::load(const QByteArray &, const QString &, QObject*)
@param setupName The name of the setup to create the cursor for
@copydetails EventCursor::load(const QByteArray &, QObject*)
@copydetails QtDataSync::EventCursor::load(const QByteArray &, QObject*)
*/

/*!
Expand Down
22 changes: 22 additions & 0 deletions doc/qtdatasync.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*!
@namespace de::skycoder42::QtDataSync
@brief The QML import for the QtDataSync QML module

<b>Current Version</b><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.2

<b>Available Types</b>
- @ref QtDataSync::DeviceInfo "DeviceInfo" (uncreatable)
- @ref QtDataSync::LoginRequest "LoginRequest" (uncreatable)
- @ref QtDataSync::UserInfo "UserInfo" (uncreatable)
- @ref QtDataSync::EventCursor "EventCursor" (uncreatable)
- DataStore
- DataStoreModel
- SyncManager
- AccountManager
- UserExchangeManager
- EventLog (singleton)
- @ref QtDataSync::AndroidSyncControl "AndroidSyncControl"
- @ref QtDataSync::IosSyncDelegate "IosSyncDelegate" (uncreatable)
- IosSyncSingleton (singleton)
*/
4 changes: 2 additions & 2 deletions doc/syncmanager.dox
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ information about it's state etc.
*/

/*!
@fn QtDataSync::SyncManager::runOnDownloaded
@fn QtDataSync::SyncManager::runOnDownloaded(const std::function<void(SyncState)> &, bool)

@param resultFn The function to be called as soon as a target state is reached
@param triggerSync Trigger a synchronisation in case the engine is currently synchronized
Expand All @@ -133,7 +133,7 @@ of waiting for the uploads as well.
*/

/*!
@fn QtDataSync::SyncManager::runOnSynchronized
@fn QtDataSync::SyncManager::runOnSynchronized(const std::function<void(SyncState)> &, bool)

@param resultFn The function to be called as soon as a target state is reached
@param triggerSync Trigger a synchronisation in case the engine is currently synchronized
Expand Down
4 changes: 2 additions & 2 deletions doc/userexchangemanager.dox
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ UserExchangeManager::exportTo, AccountManager::exportAccountTrusted
*/

/*!
@fn QtDataSync::UserExchangeManager::importFrom
@fn QtDataSync::UserExchangeManager::importFrom(const QtDataSync::UserInfo &, const std::function<void(bool,QString)> &, bool)

@param userInfo The user to that sent the data to import
@param completedFn A function that is called once the import has been finished
Expand All @@ -214,7 +214,7 @@ UserExchangeManager::importTrustedFrom, AccountManager::importAccount
*/

/*!
@fn QtDataSync::UserExchangeManager::importTrustedFrom
@fn QtDataSync::UserExchangeManager::importTrustedFrom(const QtDataSync::UserInfo &, const QString &, const std::function<void(bool,QString)> &, bool)

@param userInfo The user to that sent the data to import
@param password The password used to decrypt the imported data with. Must be the same as used
Expand Down
8 changes: 4 additions & 4 deletions src/datasync/eventcursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ class Q_DATASYNC_EXPORT EventCursor : public QObject

//! Create a cursor positioned on the oldest change event
static EventCursor *first(QObject *parent = nullptr);
//! @copybrief EventCursor::first(QObject*)
//! @copybrief QtDataSync::EventCursor::first(QObject*)
static EventCursor *first(const QString &setupName, QObject *parent = nullptr);
//! Create a cursor positioned on the newest change event
static EventCursor *last(QObject *parent = nullptr);
//! @copybrief EventCursor::last(QObject*)
//! @copybrief QtDataSync::EventCursor::last(QObject*)
static EventCursor *last(const QString &setupName, QObject *parent = nullptr);
//! Create a cursor positioned on the given index, if it is a valid index
static EventCursor *create(quint64 index, QObject *parent = nullptr);
//! @copybrief EventCursor::create(quint64, QObject*)
//! @copybrief QtDataSync::EventCursor::create(quint64, QObject*)
static EventCursor *create(quint64 index, const QString &setupName, QObject *parent = nullptr);
//! Create a cursor positioned on the index provided by the previously stored data, if still valid
static EventCursor *load(const QByteArray &data, QObject *parent = nullptr);
//! @copybrief EventCursor::load(const QByteArray &, QObject*)
//! @copybrief QtDataSync::EventCursor::load(const QByteArray &, QObject*)
static EventCursor *load(const QByteArray &data, const QString &setupName, QObject *parent = nullptr);
//! Returns encoded position data of the cursor to be loaded again
Q_INVOKABLE QByteArray save() const;
Expand Down
9 changes: 8 additions & 1 deletion src/imports/datasync/plugins.qmltypes
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import QtQuick.tooling 1.2
// 'qmlplugindump -nonrelocatable de.skycoder42.QtDataSync 4.2'

Module {
dependencies: ["QtQuick 2.8"]
dependencies: ["QtQml 2.2", "QtQml.Models 2.2"]
Component { name: "QAbstractTableModel"; prototype: "QAbstractItemModel" }
Component {
name: "QtDataSync::AccountManager"
Expand Down Expand Up @@ -337,6 +337,13 @@ Module {
type: "QVariantList"
Parameter { name: "typeName"; type: "string" }
}
Method {
name: "contains"
revision: 2
type: "bool"
Parameter { name: "typeName"; type: "string" }
Parameter { name: "key"; type: "string" }
}
Method {
name: "load"
type: "QVariant"
Expand Down
2 changes: 2 additions & 0 deletions src/imports/datasync/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ module de.skycoder42.QtDataSync
plugin declarative_datasync
classname QtDataSyncDeclarativeModule
typeinfo plugins.qmltypes
depends QtQml 2.2
depends QtQml.Models 2.2
77 changes: 76 additions & 1 deletion src/imports/datasync/qqmlaccountmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,117 @@

#include <QtDataSync/accountmanager.h>

#ifdef DOXYGEN_RUN
namespace de::skycoder42::QtDataSync {

/*! @brief The QML binding of ::QtDataSync::AccountManager
*
* @since 4.0
*
* @sa QtDataSync::AccountManager
*/
class AccountManager : public ::QtDataSync::AccountManager
#else
namespace QtDataSync {

class QQmlAccountManager : public AccountManager, public QQmlParserStatus
#endif
{
Q_OBJECT
Q_DISABLE_COPY(QQmlAccountManager)
Q_INTERFACES(QQmlParserStatus)

/*! @brief Holds the name of the setup this manager operates on.
*
* @default{`QtDataSync::DefaultSetup`}
*
* Allows you to specify the name of the setup that this manager should use
*
* @warning This property must only ever be set on construction of the object
* and must not be changed afterwards. Do not set both, this property and node
*
* @accessors{
* @memberAc{setupName}
* @notifyAc{setupNameChanged()}
* }
*
* @sa ::QtDataSync::AccountManager::setupName, AccountManager::node, AccountManager::valid
*/
Q_PROPERTY(QString setupName READ setupName WRITE setSetupName NOTIFY setupNameChanged)
/*! @brief Allows to directly set the remote object node to use
*
* @default{`nullptr`}
*
* Instead of a setup name, you can directly specify the remote object node via this property.
*
* @warning This property must only ever be set on construction of the object
* and must not be changed afterwards. Do not set both, this property and setupName
*
* @accessors{
* @memberAc{node}
* @notifyAc{nodeChanged()}
* }
*
* @sa AccountManager::setupName, AccountManager::valid
*/
Q_PROPERTY(QRemoteObjectNode* node READ node WRITE setNode NOTIFY nodeChanged)
/*! @brief Specifies if the object was correctly initialized
*
* @default{`false`}
*
* Only becomes true if the given setup name resolves to a valid datasync
* instance or if the given node is valid
*
* @accessors{
* @memberAc{valid}
* @notifyAc{validChanged()}
* @readonlyAc
* }
*
* @sa AccountManager::setupName, AccountManager::node
*/
Q_PROPERTY(bool valid READ valid NOTIFY validChanged)

public:
//! @private
explicit QQmlAccountManager(QObject *parent = nullptr);

//! @private
void classBegin() override;
//! @private
void componentComplete() override;

//! @private
QString setupName() const;
//! @private
QRemoteObjectNode* node() const;
//! @private
bool valid() const;

//! @copydoc ::QtDataSync::AccountManager::isTrustedImport(const QJsonObject &)
Q_INVOKABLE bool isTrustedImport(const QJsonObject &importData) const;

//! @copydoc ::QtDataSync::AccountManager::exportAccount(bool, const std::function<void(QJsonObject)> &, const std::function<void(QString)> &)
Q_INVOKABLE void exportAccount(bool includeServer, const QJSValue &completedFn, const QJSValue &errorFn = {});
//! @copydoc ::QtDataSync::AccountManager::exportAccountTrusted(bool, const QString &, const std::function<void(QJsonObject)> &, const std::function<void(QString)> &)
Q_INVOKABLE void exportAccountTrusted(bool includeServer, const QString &password, const QJSValue &completedFn, const QJSValue &errorFn = {});
//! @copydoc ::QtDataSync::AccountManager::importAccount(const QJsonObject &, const std::function<void(bool,QString)> &, bool)
Q_INVOKABLE void importAccount(const QJsonObject &importData, const QJSValue &completedFn, bool keepData = false);
//! @copydoc ::QtDataSync::AccountManager::importAccountTrusted(const QJsonObject &, const QString &, const std::function<void(bool,QString)> &, bool)
Q_INVOKABLE void importAccountTrusted(const QJsonObject &importData, const QString &password, const QJSValue &completedFn, bool keepData = false);

public Q_SLOTS:
//! @private
void setSetupName(QString setupName);
//! @private
void setNode(QRemoteObjectNode* node);

Q_SIGNALS:
void setupNameChanged(QString setupName);
//! @notifyAcFn{AccountManager::setupName}
void setupNameChanged(const QString &setupName);
//! @notifyAcFn{AccountManager::node}
void nodeChanged(QRemoteObjectNode* node);
//! @notifyAcFn{AccountManager::valid}
void validChanged(bool valid);

private:
Expand Down
10 changes: 10 additions & 0 deletions src/imports/datasync/qqmldatastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ QVariantList QQmlDataStore::loadAll(const QString &typeName) const
}
}

bool QQmlDataStore::contains(const QString &typeName, const QString &key) const
{
try {
return DataStore::contains(QMetaType::type(typeName.toUtf8()), key);
} catch(Exception &e) {
qmlWarning(this) << e.what();
return false;
}
}

QVariant QQmlDataStore::load(const QString &typeName, const QString &key) const
{
try {
Expand Down
Loading

0 comments on commit b6cfbc6

Please sign in to comment.