TreeFrogFramework: src/tsqlobject.h Source File

1#pragma once

2#include <QDateTime>

3#include <QObject>

4#include <QSqlError>

5#include <QSqlRecord>

6#include <QStringList>

7#include <QVariantMap>

8#include <QSqlDatabase>

9#include <TGlobal>

10#include <TModelObject>

11

12

14 Q_OBJECT

15public:

20

21 virtual QString tableName() const;

25 void setRecord(const QSqlRecord &record, const QSqlError &error);

26 bool create() override;

27 bool update() override;

28 bool save() override;

29 bool remove() override;

30 bool reload();

31 bool isNull() const override { return QSqlRecord::isEmpty(); }

32 bool isNew() const { return QSqlRecord::isEmpty(); }

33 bool isModified() const;

34 void clear() override { QSqlRecord::clear(); }

35 QSqlError error() const { return sqlError; }

36

37protected:

38 void syncToSqlRecord();

39 void syncToObject();

40 QSqlDatabase &getDatabase();

41

43

44private:

45 QSqlDatabase _database;

46};

The TModelObject class provides an abstract base for model objects.

Definition tmodelobject.h:9

The TSqlObject class is the base class of ORM objects.

Definition tsqlobject.h:13

virtual int autoValueIndex() const

Returns the position of the auto-generated value field on the table.

Definition tsqlobject.h:23

bool isNull() const override

Returns true if there is no database record associated with the object; otherwise returns false.

Definition tsqlobject.h:31

virtual int databaseId() const

Returns the database ID.

Definition tsqlobject.h:24

QSqlError sqlError

Definition tsqlobject.h:42

bool isNew() const

Returns true if it is a new object, otherwise returns false.

Definition tsqlobject.h:32

void clear() override

Clears the contents of the object.

Definition tsqlobject.h:34

QSqlError error() const

Returns a QSqlError object which contains information about the last error that occurred on the datab...

Definition tsqlobject.h:35

virtual int primaryKeyIndex() const

Returns the position of the primary key field on the table.

Definition tsqlobject.h:22

virtual ~TSqlObject()

Definition tsqlobject.h:19

#define T_CORE_EXPORT

Definition tdeclexport.h:28