LibEngsas
|
Represents an sql table.This class is used with ESqlInit to define database schemas. More...
#include <esqltable.h>
Public Types | |
enum | FkAction { NoAction, SetNull, Cascade, Restrict } |
Actions, which are done, if an foreign key is changed. More... | |
Public Member Functions | |
ESqlTable (QString name="") | |
~ESqlTable () | |
bool | isValid () |
QString | name () |
void | setName (QString name) |
QList< ESqlField * > | fields () |
void | appendField (ESqlField *append) |
ESqlField * | appendField (QString name="", ESqlField::Type type=ESqlField::NoType, bool notNull=false, bool autoIncrement=false) |
Adds a new field (also called column) to the table. More... | |
void | appendFieldId (QString name="id") |
ESqlField * | appendFieldVarchar (QString name="", uint length=45, bool notNull=false) |
Appends a field of type ESqlField::Varchar with lenght length . More... | |
bool | appendValues (QStringList value) |
QList< QStringList > | values () |
void | addForeignKey (QString fieldName, QString refTable, QString refFieldName="id", ESqlTable::FkAction del=ESqlTable::NoAction, ESqlTable::FkAction update=ESqlTable::NoAction) |
Changes column fieldName from this table to reference another table. More... | |
void | addForeignKey (ESqlField *ourField, ESqlTable *refTable, ESqlTable::FkAction del=ESqlTable::NoAction, ESqlTable::FkAction update=ESqlTable::NoAction) |
Changes ourField to reference another table. More... | |
void | addForeignKey (ESqlTable *refTable, QString newFieldName=QString(), ESqlTable::FkAction del=ESqlTable::NoAction, ESqlTable::FkAction update=ESqlTable::NoAction, QString idFieldName="id") |
Adds renamed field from refTable to reference that table. More... | |
QString | sqlConstraintsString (EngSaS::SQL::DatabaseType type=EngSaS::SQL::Other) |
void | addIndex (QString fieldName, unsigned int length=0, Qt::SortOrder order=Qt::AscendingOrder) |
void | addIndex (ESqlField *field, unsigned int length=0, Qt::SortOrder order=Qt::AscendingOrder) |
QString | indizes () |
QString | createStatement (QString dbName, EngSaS::SQL::DatabaseType type) |
Creates the SQL statements which are needed to create this table. More... | |
![]() | |
EObject (QObject *parent=0) | |
virtual | ~EObject () |
void | connectByPass (QObject *object) |
Private Attributes | |
QString | tableName |
QList< ESqlField * > | myFields |
QList< QStringList > | myValues |
QList< QStringList > | constraints |
QStringList | myIndizes |
QMultiHash < ESqlTable::FkAction, QString > | fkActionMap |
Additional Inherited Members | |
![]() | |
virtual void | reloadSettings () |
Used to reload the settings. More... | |
![]() | |
void | error (const QString &message) |
void | warning (const QString &message) |
void | information (const QString &message) |
void | reloadEnableActions () |
Request reloading of enabled actions in EMainWindow. More... | |
void | addMenu (QMenu *newMenu, const QString &parent, QString before=QString()) |
void | addAction (QAction *newAction, const QString &parent, QString before=QString()) |
void | addToolBar (QToolBar *newToolBar, Qt::ToolBarArea area=Qt::TopToolBarArea) |
void | addNewDockWidget (QDockWidget *widget, const Qt::DockWidgetArea &area) |
void | setCentralWidget (QWidget *centralWidget) |
void | showSettings () |
void | showHelp (const QString &page) |
void | showStatusWidget (QWidget *widget) |
void | reloadSettingsRequest () |
Indicates, that a reload of the settings is needed. More... | |
void | doReloadSettings () |
Emitted to bring the reload request back to the farest child. More... | |
![]() | |
static void | connectByPass (QObject *parent, QObject *child) |
![]() | |
virtual void | errorByPass (const QString &message) |
virtual void | warningByPass (const QString &message) |
virtual void | informationByPass (const QString &message) |
virtual void | reloadEnableActionsByPass () |
virtual void | addMenuByPass (QMenu *newMenu, const QString &parent, QString before=QString()) |
virtual void | addActionByPass (QAction *newAction, const QString &parent, QString before=QString()) |
virtual void | addToolBarByPass (QToolBar *newToolBar, Qt::ToolBarArea area=Qt::TopToolBarArea) |
virtual void | addNewDockWidgetByPass (QDockWidget *widget, const Qt::DockWidgetArea &area) |
virtual void | setCentralWidgetByPass (QWidget *centralWidget) |
virtual void | showSettingsByPass () |
virtual void | showHelpByPass (const QString &page) |
virtual void | showStatusWidgetByPass (QWidget *widget) |
virtual void | reloadSettingsRequestByPass () |
![]() | |
void | addManagedDockWidget (QDockWidget *widget, const Qt::DockWidgetArea &area, QString actionLabel=QString(), QString actionParent=QString()) |
Adds an dock widget via addNewDockWidget() and adds widget to the list of managed dock widgets. More... | |
Represents an sql table.
This class is used with ESqlInit to define database schemas.
enum ESqlTable::FkAction |
ESqlTable::ESqlTable | ( | QString | name = "" | ) |
ESqlTable::~ESqlTable | ( | ) |
void ESqlTable::addForeignKey | ( | QString | fieldName, |
QString | refTable, | ||
QString | refFieldName = "id" , |
||
ESqlTable::FkAction | del = ESqlTable::NoAction , |
||
ESqlTable::FkAction | update = ESqlTable::NoAction |
||
) |
Changes column fieldName
from this table to reference another table.
The added column will have the name fieldName
and references the field refFieldName
at the table refTable
. With del
and update
, you can specify actions on deletion and update of the referenced field.
void ESqlTable::addForeignKey | ( | ESqlField * | ourField, |
ESqlTable * | refTable, | ||
ESqlTable::FkAction | del = ESqlTable::NoAction , |
||
ESqlTable::FkAction | update = ESqlTable::NoAction |
||
) |
Changes ourField
to reference another table.
The field ourField
at this table is changed to reference the standard id field of the table refTable
. With del
and update
, you can specify actions on deletion and update of the referenced field.
void ESqlTable::addForeignKey | ( | ESqlTable * | refTable, |
QString | newFieldName = QString() , |
||
ESqlTable::FkAction | del = ESqlTable::NoAction , |
||
ESqlTable::FkAction | update = ESqlTable::NoAction , |
||
QString | idFieldName = "id" |
||
) |
Adds renamed field from refTable
to reference that table.
Tries to add a copy of the id field of refTable
to this table. It renames the field to "refTableNameId" or if given to newFieldName
. Also an foreignkey entry is added for the newly added field. With del
and update
, you can specify actions on deletion and update of the referenced field. With idFieldName
, the name of the used field name in refTable
can be changed from the default value into another value.
void ESqlTable::addIndex | ( | QString | fieldName, |
unsigned int | length = 0 , |
||
Qt::SortOrder | order = Qt::AscendingOrder |
||
) |
overlaods addIndex(field length, order), to use it without ESqlFields
void ESqlTable::addIndex | ( | ESqlField * | field, |
unsigned int | length = 0 , |
||
Qt::SortOrder | order = Qt::AscendingOrder |
||
) |
adds an Index to field field
The Index gets the length length
, if length is greater null. The used sortorder is order
void ESqlTable::appendField | ( | ESqlField * | append | ) |
ESqlField * ESqlTable::appendField | ( | QString | name = "" , |
ESqlField::Type | type = ESqlField::NoType , |
||
bool | notNull = false , |
||
bool | autoIncrement = false |
||
) |
Adds a new field (also called column) to the table.
To add fields of type ESqlField::Varchar, you may want to use appendFieldVarchar().
void ESqlTable::appendFieldId | ( | QString | name = "id" | ) |
append's the id standard field name: id type: unsigned integer autoincremented, not null
ESqlField * ESqlTable::appendFieldVarchar | ( | QString | name = "" , |
uint | length = 45 , |
||
bool | notNull = false |
||
) |
Appends a field of type ESqlField::Varchar with lenght length
.
It's a shorter form for
bool ESqlTable::appendValues | ( | QStringList | value | ) |
QString ESqlTable::createStatement | ( | QString | dbName, |
EngSaS::SQL::DatabaseType | type | ||
) |
Creates the SQL statements which are needed to create this table.
With dbName
a database can be given, in which the table should be created. If sqlite
is set to true, it respects sqlite specific behaviour.
QList< ESqlField * > ESqlTable::fields | ( | ) |
QString ESqlTable::indizes | ( | ) |
bool ESqlTable::isValid | ( | ) |
QString ESqlTable::name | ( | ) |
void ESqlTable::setName | ( | QString | name | ) |
QString ESqlTable::sqlConstraintsString | ( | EngSaS::SQL::DatabaseType | type = EngSaS::SQL::Other | ) |
QList< QStringList > ESqlTable::values | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |