QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches

qx::QxModelService<T, S> : provides an easy way to connect your model to the QxService module (all queries are executed over network using client/server communication) More...

#include <QxModelService.h>

Inheritance diagram for qx::QxModelService< T, S, B >:
qx::QxModel< T, qx::IxModel > qx::IxModel

Public Types

typedef qx::QxModel< T, B >::type_ptr type_ptr
 
typedef qx::QxModel< T, B >::type_primary_key type_primary_key
 
typedef qx::QxModel< T, B >::type_collection type_collection
 
typedef std::shared_ptr< type_collectiontype_collection_ptr
 
typedef B type_base_class
 
- Public Types inherited from qx::QxModel< T, qx::IxModel >
enum  
 
typedef std::shared_ptr< T > type_ptr
 
typedef qx::trait::get_primary_key< T >::type type_primary_key
 
typedef qx::QxCollection< type_primary_key, type_ptrtype_collection
 
typedef qx::IxModel type_base_class
 
- Public Types inherited from qx::IxModel
enum  e_auto_update_database { e_no_auto_update , e_auto_update_on_field_change }
 
typedef QHash< QString, IxModel * > type_relation_by_name
 
typedef QList< type_relation_by_nametype_lst_relation_by_name
 
typedef QHash< IxModel *, QPair< int, QString > > type_child_to_its_relation
 

Public Member Functions

 QxModelService (QObject *parent=0)
 
 QxModelService (qx::IxModel *other, QObject *parent)
 
virtual ~QxModelService ()
 
virtual long qxCount (const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL)
 Return the number of lines in the table (database) mapped to the C++ class T (registered into QxOrm context) and filtered by a user SQL query.
 
virtual QSqlError qxCount (long &lCount, const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL)
 Return the number of lines in the table (database) mapped to the C++ class T (registered into QxOrm context) and filtered by a user SQL query.
 
virtual QSqlError qxFetchById (const QVariant &id, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
 Clear the model and fetch an object (retrieve all its properties) of type T (registered into QxOrm context) mapped to a table in the database.
 
virtual QSqlError qxFetchAll (const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
 Clear the model and fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database.
 
virtual QSqlError qxFetchByQuery (const qx::QxSqlQuery &query, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
 Clear the model and fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database and filtered by a user SQL query.
 
virtual QSqlError qxFetchRow (int row, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
 Get an item in the model at line row and fetch all its properties mapped to a table in the database, then all views attached to this model are automatically updated.
 
virtual QSqlError qxInsert (const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
 Insert all items in the model into database.
 
virtual QSqlError qxInsertRow (int row, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
 Insert an item of the model at line row into database.
 
virtual QSqlError qxUpdate (const qx::QxSqlQuery &query=qx::QxSqlQuery(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
 Update all items in the model into database.
 
virtual QSqlError qxUpdateRow (int row, const qx::QxSqlQuery &query=qx::QxSqlQuery(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
 Update an item of the model at line row into database.
 
virtual QSqlError qxSave (const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
 Save all items (insert or update) in the model into database.
 
virtual QSqlError qxSaveRow (int row, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
 Save an item of the model at line row into database.
 
virtual QSqlError qxDeleteById (const QVariant &id, QSqlDatabase *pDatabase=NULL)
 Delete a line of a table (database) mapped to a C++ object of type T (registered into QxOrm context), if no error occurred then you should remove row from the model.
 
virtual QSqlError qxDeleteAll (QSqlDatabase *pDatabase=NULL)
 Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context), if no error occurred then you should clear the model.
 
virtual QSqlError qxDeleteByQuery (const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
 Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context) and filtered by a user SQL query, if no error occurred then you should refresh the model.
 
virtual QSqlError qxDeleteRow (int row, QSqlDatabase *pDatabase=NULL)
 Delete in database the item at line row in the model, if no error occurred then you should remove row from the model.
 
virtual QSqlError qxDestroyById (const QVariant &id, QSqlDatabase *pDatabase=NULL)
 Delete a line of a table (even if a logical delete is defined) mapped to a C++ object of type T (registered into QxOrm context), if no error occurred then you should remove row from the model.
 
virtual QSqlError qxDestroyAll (QSqlDatabase *pDatabase=NULL)
 Delete all lines of a table (even if a logical delete is defined) mapped to a C++ class T (registered into QxOrm context), if no error occurred then you should clear the model.
 
virtual QSqlError qxDestroyByQuery (const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
 Delete all lines of a table (even if a logical delete is defined) mapped to a C++ class T (registered into QxOrm context) and filtered by a user SQL query, if no error occurred then you should refresh the model.
 
virtual QSqlError qxDestroyRow (int row, QSqlDatabase *pDatabase=NULL)
 Delete in database (even if a logical delete is defined) the item at line row in the model, if no error occurred then you should remove row from the model.
 
virtual QSqlError qxExecuteQuery (qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
 
virtual qx_bool qxExist (const QVariant &id, QSqlDatabase *pDatabase=NULL)
 
virtual qx::QxInvalidValueX qxValidate (const QStringList &groups=QStringList())
 
virtual qx::QxInvalidValueX qxValidateRow (int row, const QStringList &groups=QStringList())
 
- Public Member Functions inherited from qx::QxModel< T, qx::IxModel >
 QxModel (QObject *parent=0)
 
 QxModel (qx::IxModel *other, QObject *parent)
 
virtual ~QxModel ()
 
virtual bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)
 
virtual bool getShowEmptyLine () const
 Can be useful when a model is displayed in a table (QTableView for example) to add automatically an empty row at the end of the table to insert quickly new items (for example, same style like QxEntityEditor list of properties/relationships)
 
virtual void setShowEmptyLine (bool b)
 
virtual QSqlError qxSaveRowData (int row, const QStringList &column=QStringList(), QSqlDatabase *pDatabase=NULL)
 Used internally by qx::IxModel::setData() method with e_auto_update_on_field_change option, save an item (even if it is the dirty row item) of the model at line row into database.
 
- Public Member Functions inherited from qx::IxModel
 IxModel (QObject *parent=0)
 
virtual ~IxModel ()
 
IxClassgetClass () const
 
IxClassgetModelClass () const
 
IxCollectiongetCollection () const
 
QSqlDatabase getDatabase () const
 
QSqlError getLastError () const
 
Q_INVOKABLE QString getLastErrorAsString () const
 
Q_INVOKABLE QStringList getListOfColumns () const
 
QHash< QString, QString > getListOfHeaders () const
 Obsolete : use headerData() instead.
 
IxDataMembergetDataMember (int column) const
 
Q_INVOKABLE QString getDataMemberKey (int column) const
 
Q_INVOKABLE int getRowCount () const
 
Q_INVOKABLE QVariant getModelValue (int row, const QString &column) const
 
Q_INVOKABLE int getColumnIndex (const QString &sColumnName) const
 
Q_INVOKABLE int getAutoUpdateDatabase_ () const
 
e_auto_update_database getAutoUpdateDatabase () const
 
Q_INVOKABLE QVariant getCustomProperty (const QString &key) const
 
Q_INVOKABLE QObject * getParentModel () const
 Can be used to figure out whether this model has a parent model (used only by nested models)
 
Q_INVOKABLE void dumpModel (bool bJsonFormat=true) const
 
Q_INVOKABLE QObject * cloneModel ()
 
void setDatabase (const QSqlDatabase &db)
 
Q_INVOKABLE void setListOfColumns (const QStringList &lst)
 
void setListOfHeaders (const QHash< QString, QString > &lst)
 Obsolete : use setHeaderData() instead.
 
Q_INVOKABLE bool setModelValue (int row, const QString &column, const QVariant &value)
 
void setParentModel (IxModel *pParent)
 
Q_INVOKABLE void setAutoUpdateDatabase_ (int i)
 
void setAutoUpdateDatabase (e_auto_update_database e)
 
Q_INVOKABLE void setCustomProperty (const QString &key, const QVariant &val)
 
Q_INVOKABLE QString toJson (int row=-1) const
 On QML side, use JSON.parse() to create a javascript object after calling this qx::IxModel::toJson() method.
 
Q_INVOKABLE bool fromJson (const QString &json, int row=-1)
 On QML side, use JSON.stringify() on a javascript object before calling this qx::IxModel::fromJson() method.
 
Q_INVOKABLE QVariant getRelationshipValues (int row, const QString &relation, bool bLoadFromDatabase=false, const QString &sAppendRelations=QString())
 Depending on relationship type (1-1, 1-n, n-1, n-n) : can return a QVariantMap type or a QVariantList type.
 
Q_INVOKABLE bool setRelationshipValues (int row, const QString &relation, const QVariant &values)
 Depending on relationship type (1-1, 1-n, n-1, n-n) : values parameter can be a QVariantMap type or a QVariantList type.
 
Q_INVOKABLE int qxCount_ (const QString &sQuery)
 
Q_INVOKABLE bool qxFetchById_ (const QVariant &id, const QStringList &relation=QStringList())
 
Q_INVOKABLE bool qxFetchAll_ (const QStringList &relation=QStringList())
 
Q_INVOKABLE bool qxFetchByQuery_ (const QString &sQuery, const QStringList &relation=QStringList())
 
Q_INVOKABLE bool qxFetchRow_ (int row, const QStringList &relation=QStringList())
 
Q_INVOKABLE bool qxInsert_ (const QStringList &relation=QStringList(), bool bUseExecBatch=false)
 
Q_INVOKABLE bool qxInsertRow_ (int row, const QStringList &relation=QStringList())
 
Q_INVOKABLE bool qxUpdate_ (const QString &sQuery, const QStringList &relation=QStringList(), bool bUseExecBatch=false)
 
Q_INVOKABLE bool qxUpdateRow_ (int row, const QString &sQuery, const QStringList &relation=QStringList())
 
Q_INVOKABLE bool qxSave_ (const QStringList &relation=QStringList())
 
Q_INVOKABLE bool qxSaveRow_ (int row, const QStringList &relation=QStringList())
 
Q_INVOKABLE bool qxDeleteById_ (const QVariant &id)
 
Q_INVOKABLE bool qxDeleteAll_ ()
 
Q_INVOKABLE bool qxDeleteByQuery_ (const QString &sQuery)
 
Q_INVOKABLE bool qxDeleteRow_ (int row)
 
Q_INVOKABLE bool qxDestroyById_ (const QVariant &id)
 
Q_INVOKABLE bool qxDestroyAll_ ()
 
Q_INVOKABLE bool qxDestroyByQuery_ (const QString &sQuery)
 
Q_INVOKABLE bool qxDestroyRow_ (int row)
 
Q_INVOKABLE bool qxExecuteQuery_ (const QString &sQuery)
 
Q_INVOKABLE bool qxExist_ (const QVariant &id)
 
Q_INVOKABLE QString qxValidate_ (const QStringList &groups=QStringList())
 
Q_INVOKABLE QString qxValidateRow_ (int row, const QStringList &groups=QStringList())
 
QSqlError saveChildRelations (IxModel *pChild)
 
QVariant getIdFromChild (IxModel *pChild) const
 Used to save foreign key in a nested model.
 
QPair< int, QString > getChildPosition (IxModel *pChild) const
 
Q_INVOKABLE void clear (bool bUpdateColumns=false)
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 
virtual QModelIndex parent (const QModelIndex &index) const
 
virtual bool hasChildren (const QModelIndex &parent=QModelIndex()) const
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const
 
virtual Qt::DropActions supportedDropActions () const
 
virtual bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
 
bool setHeaderData (const QString &sColumnName, const QVariant &value, int role=Qt::EditRole)
 
virtual QHash< int, QByteArray > roleNames () const
 
virtual Qt::DropActions supportedDragActions () const
 

Protected Member Functions

virtual QVariant getRelationshipValues_Helper (int row, const QString &relation, bool bLoadFromDatabase, const QString &sAppendRelations)
 
- Protected Member Functions inherited from qx::QxModel< T, qx::IxModel >
void init ()
 
void initFrom (qx::IxModel *pOther)
 
type_ptr getRowItemAt (int row) const
 
virtual void * getRowItemAsVoidPtr (int row) const
 
virtual void dumpModelImpl (bool bJsonFormat) const
 
virtual QObject * cloneModelImpl ()
 
virtual void updateShowEmptyLine ()
 
virtual bool isDirtyRow (int row) const
 
virtual void insertDirtyRowToModel ()
 
void addDirtyRow ()
 
void insertItem (int row, const type_ptr &pItem)
 
void updateKey (int row)
 
void updateAllKeys ()
 
virtual QString toJson_Helper (int row) const
 
virtual bool fromJson_Helper (const QString &json, int row)
 
virtual bool setRelationshipValues_Helper (int row, const QString &relation, const QVariant &values)
 
- Protected Member Functions inherited from qx::IxModel
void raiseEvent_headerDataChanged (Qt::Orientation orientation, int first, int last)
 
void raiseEvent_dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles=QVector< int >())
 
void raiseEvent_layoutAboutToBeChanged (const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
 
void raiseEvent_layoutChanged (const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
 
virtual void syncNestedModel (int row, const QStringList &relation)
 
virtual void syncAllNestedModel (const QStringList &relation)
 
void syncNestedModelRecursive (IxModel *pNestedModel, const QStringList &relation)
 
void generateRoleNames ()
 
QSqlDatabase * database (QSqlDatabase *other)
 
IxModelgetChild (long row, const QString &relation)
 
void insertChild (long row, const QString &relation, IxModel *pChild)
 
void removeListOfChild (long row)
 
bool removeRowsGeneric (int row, int count)
 
bool removeRowsAutoUpdateOnFieldChange (int row, int count)
 

Additional Inherited Members

- Protected Attributes inherited from qx::QxModel< T, qx::IxModel >
type_collection m_model
 Model associated to a class registered into QxOrm context.
 
std::shared_ptr< QPair< int, type_ptr > > m_pDirtyRow
 When displayed in a QTableView, this will cause an empty line awaiting user input to be displayed at the bottom (enabled with setShowEmptyLine() method)
 
- Protected Attributes inherited from qx::IxModel
IxClassm_pClass
 Class introspection registered into QxOrm context associated to the model.
 
IxClassm_pModelClass
 If model itself is registered into QxOrm context, then you can use this property to work with introspection engine.
 
IxDataMemberXm_pDataMemberX
 List of properties defined into QxOrm context.
 
IxDataMemberm_pDataMemberId
 Primary key (property id) defined into QxOrm context.
 
IxCollectionm_pCollection
 Interface to store a list of items.
 
QHash< int, QByteArray > m_lstRoleNames
 List of model's role names to expose data to QML.
 
QList< IxDataMember * > m_lstDataMember
 List of data member exposed by the model.
 
QHash< QString, int > m_lstDataMemberByKey
 List of data member key to get column index in model.
 
QHash< QString, QVariant > m_lstHeadersData
 List of headers data by role and data member key.
 
QStringList m_lstColumns
 List of columns exposed by the model (if empty, all columns)
 
QSqlDatabase m_database
 Database connexion to execute SQL queries (if empty, default database connexion)
 
QSqlError m_lastError
 Last SQL error.
 
IxModelm_pParent
 Parent model, NULL if current model is the root model.
 
type_lst_relation_by_name m_lstChild
 List of child model : QxEntityEditor uses this property to manage relationships and create complex data structure.
 
type_child_to_its_relation m_hChild
 Reverse link to m_lstChild, used in setData() to save relations.
 
e_auto_update_database m_eAutoUpdateDatabase
 Auto-update database on field change (detected by the setData() method)
 
IxDataMemberm_pDataMemberRelationToParent
 The data member holding relationship to its parent model (if one exists), used only by nested models.
 
long m_lManualInsertIndex
 Index to insert manually items to the collection.
 
QHash< QString, QVariant > m_hCustomProperties
 Use this generic hash-table to define extra-properties in your custom classes which inherit from qx::IxModel interface (instead of creating new properties) ==> this will ensure that sizeof(qx::IxModel) == sizeof(YourCustomClass), this is important with nested models feature.
 

Detailed Description

template<class T, class S, class B = qx::IxModel>
class qx::QxModelService< T, S, B >

qx::QxModelService<T, S> : provides an easy way to connect your model to the QxService module (all queries are executed over network using client/server communication)

T template parameter is a persistent class registered into QxOrm context S template parameter is a service class generated by QxEntityEditor (or your own service class providing all methods)

Definition at line 58 of file QxModelService.h.

Member Typedef Documentation

◆ type_base_class

template<class T , class S , class B = qx::IxModel>
typedef B qx::QxModelService< T, S, B >::type_base_class

Definition at line 67 of file QxModelService.h.

◆ type_collection

template<class T , class S , class B = qx::IxModel>
typedef qx::QxModel<T,B>::type_collection qx::QxModelService< T, S, B >::type_collection

Definition at line 65 of file QxModelService.h.

◆ type_collection_ptr

template<class T , class S , class B = qx::IxModel>
typedef std::shared_ptr<type_collection> qx::QxModelService< T, S, B >::type_collection_ptr

Definition at line 66 of file QxModelService.h.

◆ type_primary_key

template<class T , class S , class B = qx::IxModel>
typedef qx::QxModel<T,B>::type_primary_key qx::QxModelService< T, S, B >::type_primary_key

Definition at line 64 of file QxModelService.h.

◆ type_ptr

template<class T , class S , class B = qx::IxModel>
typedef qx::QxModel<T,B>::type_ptr qx::QxModelService< T, S, B >::type_ptr

Definition at line 63 of file QxModelService.h.

Constructor & Destructor Documentation

◆ QxModelService() [1/2]

template<class T , class S , class B = qx::IxModel>
qx::QxModelService< T, S, B >::QxModelService ( QObject * parent = 0)
inline

Definition at line 71 of file QxModelService.h.

◆ QxModelService() [2/2]

template<class T , class S , class B = qx::IxModel>
qx::QxModelService< T, S, B >::QxModelService ( qx::IxModel * other,
QObject * parent )
inline

Definition at line 72 of file QxModelService.h.

◆ ~QxModelService()

template<class T , class S , class B = qx::IxModel>
virtual qx::QxModelService< T, S, B >::~QxModelService ( )
inlinevirtual

Definition at line 73 of file QxModelService.h.

Member Function Documentation

◆ getRelationshipValues_Helper()

template<class T , class S , class B = qx::IxModel>
virtual QVariant qx::QxModelService< T, S, B >::getRelationshipValues_Helper ( int row,
const QString & relation,
bool bLoadFromDatabase,
const QString & sAppendRelations )
inlineprotectedvirtual

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 381 of file QxModelService.h.

◆ qxCount() [1/2]

template<class T , class S , class B = qx::IxModel>
virtual long qx::QxModelService< T, S, B >::qxCount ( const qx::QxSqlQuery & query = qx::QxSqlQuery(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Return the number of lines in the table (database) mapped to the C++ class T (registered into QxOrm context) and filtered by a user SQL query.

Parameters
queryDefine a user SQL query added to default SQL query builded by QxOrm library (optional parameter)
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 75 of file QxModelService.h.

◆ qxCount() [2/2]

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxCount ( long & lCount,
const qx::QxSqlQuery & query = qx::QxSqlQuery(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Return the number of lines in the table (database) mapped to the C++ class T (registered into QxOrm context) and filtered by a user SQL query.

Parameters
lCountOutput parameter with the number of lines in the table associated to the SQL query
queryDefine a user SQL query added to default SQL query builded by QxOrm library (optional parameter)
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 82 of file QxModelService.h.

◆ qxDeleteAll()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxDeleteAll ( QSqlDatabase * pDatabase = NULL)
inlinevirtual

Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context), if no error occurred then you should clear the model.

Parameters
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 262 of file QxModelService.h.

◆ qxDeleteById()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxDeleteById ( const QVariant & id,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Delete a line of a table (database) mapped to a C++ object of type T (registered into QxOrm context), if no error occurred then you should remove row from the model.

Parameters
idRow id to be deleted from database
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 249 of file QxModelService.h.

◆ qxDeleteByQuery()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxDeleteByQuery ( const qx::QxSqlQuery & query,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context) and filtered by a user SQL query, if no error occurred then you should refresh the model.

Parameters
queryDefine a user SQL query added to default SQL query builded by QxOrm library
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 270 of file QxModelService.h.

◆ qxDeleteRow()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxDeleteRow ( int row,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Delete in database the item at line row in the model, if no error occurred then you should remove row from the model.

Parameters
rowDelete in database the item in the model at line row
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 278 of file QxModelService.h.

◆ qxDestroyAll()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxDestroyAll ( QSqlDatabase * pDatabase = NULL)
inlinevirtual

Delete all lines of a table (even if a logical delete is defined) mapped to a C++ class T (registered into QxOrm context), if no error occurred then you should clear the model.

Parameters
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 302 of file QxModelService.h.

◆ qxDestroyById()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxDestroyById ( const QVariant & id,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Delete a line of a table (even if a logical delete is defined) mapped to a C++ object of type T (registered into QxOrm context), if no error occurred then you should remove row from the model.

Parameters
idRow id to be deleted from database
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 289 of file QxModelService.h.

◆ qxDestroyByQuery()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxDestroyByQuery ( const qx::QxSqlQuery & query,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Delete all lines of a table (even if a logical delete is defined) mapped to a C++ class T (registered into QxOrm context) and filtered by a user SQL query, if no error occurred then you should refresh the model.

Parameters
queryDefine a user SQL query added to default SQL query builded by QxOrm library
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 310 of file QxModelService.h.

◆ qxDestroyRow()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxDestroyRow ( int row,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Delete in database (even if a logical delete is defined) the item at line row in the model, if no error occurred then you should remove row from the model.

Parameters
rowDelete in database the item in the model at line row
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 318 of file QxModelService.h.

◆ qxExecuteQuery()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxExecuteQuery ( qx::QxSqlQuery & query,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 329 of file QxModelService.h.

◆ qxExist()

template<class T , class S , class B = qx::IxModel>
virtual qx_bool qx::QxModelService< T, S, B >::qxExist ( const QVariant & id,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 346 of file QxModelService.h.

◆ qxFetchAll()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxFetchAll ( const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Clear the model and fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database.

Parameters
relationList of relationships keys to be fetched (eager fetch instead of default lazy fetch for a relation) : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 111 of file QxModelService.h.

◆ qxFetchById()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxFetchById ( const QVariant & id,
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Clear the model and fetch an object (retrieve all its properties) of type T (registered into QxOrm context) mapped to a table in the database.

Parameters
idRow id to be fetched (retrieve all properties from database)
relationList of relationships keys to be fetched (eager fetch instead of default lazy fetch for a relation) : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 90 of file QxModelService.h.

◆ qxFetchByQuery()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxFetchByQuery ( const qx::QxSqlQuery & query,
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Clear the model and fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database and filtered by a user SQL query.

Parameters
queryDefine a user SQL query added to default SQL query builded by QxOrm library
relationList of relationships keys to be fetched (eager fetch instead of default lazy fetch for a relation) : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 128 of file QxModelService.h.

◆ qxFetchRow()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxFetchRow ( int row,
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Get an item in the model at line row and fetch all its properties mapped to a table in the database, then all views attached to this model are automatically updated.

Parameters
rowGet an item in the model at line row
relationList of relationships keys to be fetched (eager fetch instead of default lazy fetch for a relation) : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 145 of file QxModelService.h.

◆ qxInsert()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxInsert ( const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch = false )
inlinevirtual

Insert all items in the model into database.

Parameters
relationList of relationships keys to be inserted in others tables of database : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
bUseExecBatchIf true then use the QSqlQuery::execBatch() method to improve performance inserting a list of instances to database (but doesn't fill the last inserted identifier in the C++ instances)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 162 of file QxModelService.h.

◆ qxInsertRow()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxInsertRow ( int row,
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Insert an item of the model at line row into database.

Parameters
rowInsert an item in the model at line row
relationList of relationships keys to be inserted in others tables of database : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 177 of file QxModelService.h.

◆ qxSave()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxSave ( const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Save all items (insert or update) in the model into database.

Parameters
relationList of relationships keys to be inserted in others tables of database : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 220 of file QxModelService.h.

◆ qxSaveRow()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxSaveRow ( int row,
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Save an item of the model at line row into database.

Parameters
rowSave an item (insert or update) in the model at line row
relationList of relationships keys to be inserted in others tables of database : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 235 of file QxModelService.h.

◆ qxUpdate()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxUpdate ( const qx::QxSqlQuery & query = qx::QxSqlQuery(),
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch = false )
inlinevirtual

Update all items in the model into database.

Parameters
queryDefine a user SQL query added to default SQL query builded by QxOrm library
relationList of relationships keys to be inserted in others tables of database : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
bUseExecBatchIf true then use the QSqlQuery::execBatch() method to improve performance updating a list of instances in database
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 191 of file QxModelService.h.

◆ qxUpdateRow()

template<class T , class S , class B = qx::IxModel>
virtual QSqlError qx::QxModelService< T, S, B >::qxUpdateRow ( int row,
const qx::QxSqlQuery & query = qx::QxSqlQuery(),
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Update an item of the model at line row into database.

Parameters
rowUpdate an item in the model at line row
queryDefine a user SQL query added to default SQL query builded by QxOrm library
relationList of relationships keys to be inserted in others tables of database : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class (optional parameter)
Returns
Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 206 of file QxModelService.h.

◆ qxValidate()

template<class T , class S , class B = qx::IxModel>
virtual qx::QxInvalidValueX qx::QxModelService< T, S, B >::qxValidate ( const QStringList & groups = QStringList())
inlinevirtual

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 358 of file QxModelService.h.

◆ qxValidateRow()

template<class T , class S , class B = qx::IxModel>
virtual qx::QxInvalidValueX qx::QxModelService< T, S, B >::qxValidateRow ( int row,
const QStringList & groups = QStringList() )
inlinevirtual

Reimplemented from qx::QxModel< T, qx::IxModel >.

Definition at line 367 of file QxModelService.h.


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