QDjango: QDjangoMetaModel Class Reference

QDjango

Public Member Functions | List of all members
QDjangoMetaModel Class Reference

The QDjangoMetaModel class holds the database schema for a model. More...

`#include <QDjangoMetaModel.h>`

## Public Member Functions
| QDjangoMetaModel (const QMetaObject *model=0)
| Constructs a new QDjangoMetaModel by inspecting the given meta model.
| QDjangoMetaModel (const QDjangoMetaModel &other)
| Constructs a copy of other.
| ~QDjangoMetaModel ()
| Destroys the meta model.
QDjangoMetaModel & | operator= (const QDjangoMetaModel &other)
| Assigns other to this meta model.
bool | isValid () const
| Determine whether this is a valid model, or just default constructed.
bool | createTable () const
| Creates the database table for this QDjangoMetaModel. More...
QStringList | createTableSql () const
| Returns the SQL queries to create the database table for this QDjangoMetaModel.
bool | dropTable () const
| Drops the database table for this QDjangoMetaModel. More...
void | load (QObject *model, const QVariantList &props, int &pos, const QStringList &relatedFields=QStringList()) const
| Loads the given properties into a model instance.
bool | remove (QObject *model) const
| Removes the given model instance from the database.
bool | save (QObject *model) const
| Saves the given model instance to the database. More...
QObject * | foreignKey (const QObject *model, const char *name) const
| Retrieves the QDjangoModel pointed to by the given foreign-key. More...
void | setForeignKey (QObject *model, const char *name, QObject *value) const
| Sets the QDjangoModel pointed to by the given foreign-key. More...
QString | className () const
QDjangoMetaField | localField (const char *name) const
| Return the local field with the specified name.
QList< QDjangoMetaField > | localFields () const
| Returns the list of local fields.
QMap< QByteArray, QByteArray > | foreignFields () const
| Returns the foreign field mapping.
QByteArray | primaryKey () const
| Returns the name of the primary key for the current QDjangoMetaModel.
QString | table () const
| Returns the name of the database table.

## Detailed Description

The QDjangoMetaModel class holds the database schema for a model.

It manages table creation and deletion operations as well as row serialisation, deserialisation and deletion operations.

## Member Function Documentation

## ◆ createTable()

bool QDjangoMetaModel::createTable | ( |  | ) | const

Creates the database table for this QDjangoMetaModel.

Returns
  true if the table was created, false otherwise.

## ◆ dropTable()

bool QDjangoMetaModel::dropTable | ( |  | ) | const

Drops the database table for this QDjangoMetaModel.

Returns
  true if the table was dropped or did not exist, false otherwise.

## ◆ foreignKey()

QObject * QDjangoMetaModel::foreignKey | ( | const QObject * | model,
|  | const char * | name
| ) |  | const

Retrieves the QDjangoModel pointed to by the given foreign-key.

Parameters

  model |
  name |

## ◆ save()

bool QDjangoMetaModel::save | ( | QObject * | model | ) | const

Saves the given model instance to the database.

Returns
  true if saving succeeded, false otherwise

## ◆ setForeignKey()

void QDjangoMetaModel::setForeignKey | ( | QObject * | model,
|  | const char * | name,
|  | QObject * | value
| ) |  | const

Sets the QDjangoModel pointed to by the given foreign-key.

Parameters

  model |
  name |
  value |

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

- QDjangoMetaModel.h
- QDjangoMetaModel.cpp