KDbTableSchema

Search for usage in LXR

#include <KDbTableSchema.h>

Inheritance diagram for KDbTableSchema:

Public Member Functions

 KDbTableSchema (const KDbObject &object)
 
 KDbTableSchema (const KDbTableSchema &ts, bool copyId)
 
 KDbTableSchema (const KDbTableSchema &ts, int id)
 
 KDbTableSchema (const QString &name)
 
bool addIndex (KDbIndexSchema *index)
 
KDbFieldanyNonPKField ()
 
void clear () override
 
KDbIndexSchemacopyIndexFrom (const KDbIndexSchema &index)
 
QDebug debugFields (QDebug dbg) const
 
const QList< KDbIndexSchema * > * indices () const
 
const QList< KDbIndexSchema * >::ConstIterator indicesIterator () const
 
bool insertField (int index, KDbField *field) override
 
bool isInternal () const
 
QVector< KDbLookupFieldSchema * > lookupFields () const
 
KDbLookupFieldSchemalookupFieldSchema (const KDbField &field)
 
const KDbLookupFieldSchemalookupFieldSchema (const KDbField &field) const
 
KDbLookupFieldSchemalookupFieldSchema (const QString &fieldName)
 
KDbIndexSchemaprimaryKey ()
 
const KDbIndexSchemaprimaryKey () const
 
KDbQuerySchemaquery ()
 
bool removeField (KDbField *field) override
 
bool removeIndex (KDbIndexSchema *index)
 
bool setLookupFieldSchema (const QString &fieldName, KDbLookupFieldSchema *lookupFieldSchema)
 
void setPrimaryKey (KDbIndexSchema *pkey)
 
- Public Member Functions inherited from KDbFieldList
 KDbFieldList (bool owner=false)
 
 KDbFieldList (const KDbFieldList &fl, bool deepCopyFields=true)
 
virtual ~KDbFieldList ()
 
bool addField (KDbField *field)
 
KDbField::ListautoIncrementFields () const
 
virtual KDbFieldfield (const QString &name)
 
virtual const KDbFieldfield (const QString &name) const
 
virtual KDbFieldfield (int id)
 
virtual const KDbFieldfield (int id) const
 
int fieldCount () const
 
KDbField::Listfields ()
 
const KDbField::Listfields () const
 
KDbField::ListIterator fieldsIterator () const
 
KDbField::ListIterator fieldsIteratorConstEnd () const
 
bool hasField (const KDbField &field) const
 
int indexOf (const KDbField &field) const
 
bool isEmpty () const
 
bool isOwner () const
 
virtual bool moveField (KDbField *field, int newIndex)
 
QStringList names () const
 
bool renameField (const QString &oldName, const QString &newName)
 
bool renameField (KDbField *field, const QString &newName)
 
KDbEscapedString sqlFieldsList (KDbConnection *conn, const QString &separator=QLatin1String(","), const QString &tableOrAlias=QString(), KDb::IdentifierEscapingType escapingType=KDb::DriverEscaping) const
 
KDbFieldListsubList (const QList< int > &list)
 
KDbFieldListsubList (const QList< QByteArray > &list)
 
KDbFieldListsubList (const QString &n1, const QString &n2=QString(), const QString &n3=QString(), const QString &n4=QString(), const QString &n5=QString(), const QString &n6=QString(), const QString &n7=QString(), const QString &n8=QString(), const QString &n9=QString(), const QString &n10=QString(), const QString &n11=QString(), const QString &n12=QString(), const QString &n13=QString(), const QString &n14=QString(), const QString &n15=QString(), const QString &n16=QString(), const QString &n17=QString(), const QString &n18=QString())
 
KDbFieldListsubList (const QStringList &list)
 
- Public Member Functions inherited from KDbObject
 KDbObject (int type)
 
QString captionOrName () const
 

Protected Member Functions

 KDbTableSchema (KDbConnection *conn, const QString &name=QString())
 
KDbConnectionconnection () const
 
void setConnection (KDbConnection *conn)
 
- Protected Member Functions inherited from KDbObject

Additional Inherited Members

- Static Public Member Functions inherited from KDbFieldList
static KDbEscapedString sqlFieldsList (const KDbField::List &list, KDbConnection *conn, const QString &separator=QLatin1String(","), const QString &tableOrAlias=QString(), KDb::IdentifierEscapingType escapingType=KDb::DriverEscaping)
 
- Public Attributes inherited from KDbObject
QString caption
 
QString description
 
int id
 
QString name
 
int type
 

Detailed Description

Provides information about native database table that can be stored using KDb database engine.

Definition at line 37 of file KDbTableSchema.h.

Constructor & Destructor Documentation

◆ KDbTableSchema() [1/6]

KDbTableSchema::KDbTableSchema ( const QString & name)
explicit

Definition at line 72 of file KDbTableSchema.cpp.

◆ KDbTableSchema() [2/6]

KDbTableSchema::KDbTableSchema ( const KDbObject & object)
explicit

Definition at line 81 of file KDbTableSchema.cpp.

◆ KDbTableSchema() [3/6]

KDbTableSchema::KDbTableSchema ( )

Definition at line 89 of file KDbTableSchema.cpp.

◆ KDbTableSchema() [4/6]

KDbTableSchema::KDbTableSchema ( const KDbTableSchema & ts,
bool copyId )
explicit

Copy constructor. If copyId is true, it's copied as well, otherwise the table id becomes -1, what is usable when we want to store the copy as an independent table.

Definition at line 97 of file KDbTableSchema.cpp.

◆ KDbTableSchema() [5/6]

KDbTableSchema::KDbTableSchema ( const KDbTableSchema & ts,
int id )

Copy constructor like KDbTableSchema(const KDbTableSchema&, bool). id is set as the table identifier. This is rarely usable, e.g. in project and data migration routines when we need to need deal with unique identifiers;

See also
KexiMigrate::performImport().

Definition at line 105 of file KDbTableSchema.cpp.

◆ ~KDbTableSchema()

KDbTableSchema::~KDbTableSchema ( )
override

Definition at line 124 of file KDbTableSchema.cpp.

◆ KDbTableSchema() [6/6]

KDbTableSchema::KDbTableSchema ( KDbConnection * conn,
const QString & name = QString() )
explicitprotected

Automatically retrieves table schema via connection.

Definition at line 115 of file KDbTableSchema.cpp.

Member Function Documentation

◆ addIndex()

bool KDbTableSchema::addIndex ( KDbIndexSchema * index)

Adds index index to this table schema Ownership of the index is transferred to the table schema.

Returns
true on success
Since
3.1

Definition at line 186 of file KDbTableSchema.cpp.

◆ anyNonPKField()

KDbField * KDbTableSchema::anyNonPKField ( )
Returns
any field not being a part of primary key of this table. If there is no such field, returns nullptr.

Definition at line 359 of file KDbTableSchema.cpp.

◆ clear()

void KDbTableSchema::clear ( )
overridevirtual

Removes all fields from the list, clears name and all other properties.

See also
KDbFieldList::clear()

Reimplemented from KDbFieldList.

Definition at line 305 of file KDbTableSchema.cpp.

◆ connection()

KDbConnection * KDbTableSchema::connection ( ) const
protected
Returns
connection object if table was created/retrieved using a connection, otherwise nullptr.

Definition at line 341 of file KDbTableSchema.cpp.

◆ copyIndexFrom()

KDbIndexSchema * KDbTableSchema::copyIndexFrom ( const KDbIndexSchema & index)

Creates a copy of index index with references moved to fields of this table. The new index is added to this table schema. Table fields are taken by name from this table. This way it's possible to copy index owned by other table and add it to another table, e.g. a copied one.

To copy an index from another table, call:

KDbIndexSchema *originalIndex = anotherTable->indices()->at(...);
KDbIndexSchema *newIndex = table->copyIndex(*originalIndex);
// newIndex is now created and is added to the table 'table'
Provides information about database index that can be created for a database table.

To copy an index within the same table, call:

KDbIndexSchema *originalIndex = table->indices()->at(...);
KDbIndexSchema *newIndex = table->copyIndex(*originalIndex);
// newIndex is now created and is added to the table
Since
3.1
Todo
All relationships should be also copied

Definition at line 204 of file KDbTableSchema.cpp.

◆ debugFields()

QDebug KDbTableSchema::debugFields ( QDebug dbg) const

Sends information about fields of this table schema to debug output dbg.

Definition at line 314 of file KDbTableSchema.cpp.

◆ indices()

const QList< KDbIndexSchema * > * KDbTableSchema::indices ( ) const

Definition at line 181 of file KDbTableSchema.cpp.

◆ indicesIterator()

const QList< KDbIndexSchema * >::ConstIterator KDbTableSchema::indicesIterator ( ) const

Definition at line 176 of file KDbTableSchema.cpp.

◆ insertField()

bool KDbTableSchema::insertField ( int index,
KDbField * field )
overridevirtual

Inserts field into a specified position (index). 'order' property of field is set automatically. false is returned if field is nullptr or index is invalid.

Reimplemented from KDbFieldList.

Definition at line 243 of file KDbTableSchema.cpp.

◆ isInternal()

bool KDbTableSchema::isInternal ( ) const
Returns
true if this is internal KDb's table. Internal tables are hidden in applications (if desired) but are available for schema export/import functionality.

Any internal KDb system table's schema (kexi__*) has cleared its KDbObject part, e.g. id=-1 for such table, and no description, caption and so on. This is because it represents a native database table rather that extended Kexi table.

KDbTableSchema object has this property set to false, KDbInternalTableSchema has it set to true.

Definition at line 211 of file KDbTableSchema.cpp.

◆ lookupFields()

QVector< KDbLookupFieldSchema * > KDbTableSchema::lookupFields ( ) const
Returns
list of lookup field schemas for this table. The order is the same as the order of fields within the table.

Definition at line 406 of file KDbTableSchema.cpp.

◆ lookupFieldSchema() [1/3]

KDbLookupFieldSchema * KDbTableSchema::lookupFieldSchema ( const KDbField & field)
Returns
lookup field schema for field. 0 is returned if there is no such field in the table or this field has no lookup schema. Note that even id non-zero is returned here, you may want to check whether lookup field's recordSource().name() is empty (if so, the field should behave as there was no lookup field defined at all).

Definition at line 388 of file KDbTableSchema.cpp.

◆ lookupFieldSchema() [2/3]

const KDbLookupFieldSchema * KDbTableSchema::lookupFieldSchema ( const KDbField & field) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 393 of file KDbTableSchema.cpp.

◆ lookupFieldSchema() [3/3]

KDbLookupFieldSchema * KDbTableSchema::lookupFieldSchema ( const QString & fieldName)

Definition at line 398 of file KDbTableSchema.cpp.

◆ primaryKey() [1/2]

KDbIndexSchema * KDbTableSchema::primaryKey ( )
Returns
list of fields that are primary key of this table. This method never returns nullptr value, if there is no primary key, empty KDbIndexSchema object is returned. KDbIndexSchema object is owned by the table schema.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 166 of file KDbTableSchema.cpp.

◆ primaryKey() [2/2]

const KDbIndexSchema * KDbTableSchema::primaryKey ( ) const

Definition at line 171 of file KDbTableSchema.cpp.

◆ query()

KDbQuerySchema * KDbTableSchema::query ( )
Returns
query schema object that is defined by "select * from <this_table_name>" This query schema object is owned by the table schema object. It is convenient way to get such a query when it is not available otherwise. Always returns non-0.

Definition at line 351 of file KDbTableSchema.cpp.

◆ removeField()

bool KDbTableSchema::removeField ( KDbField * field)
overridevirtual

Reimplemented for internal reasons.

Reimplemented from KDbFieldList.

Definition at line 293 of file KDbTableSchema.cpp.

◆ removeIndex()

bool KDbTableSchema::removeIndex ( KDbIndexSchema * index)

Removes index index from this table schema Ownership of the index is transferred to the table schema.

Returns
true on success
Since
3.1

Definition at line 195 of file KDbTableSchema.cpp.

◆ setConnection()

void KDbTableSchema::setConnection ( KDbConnection * conn)
protected

For KDbConnection.

Definition at line 346 of file KDbTableSchema.cpp.

◆ setLookupFieldSchema()

bool KDbTableSchema::setLookupFieldSchema ( const QString & fieldName,
KDbLookupFieldSchema * lookupFieldSchema )

Sets lookup field schema lookupFieldSchema for fieldName. Passing nullptr lookupFieldSchema will remove the previously set lookup field.

Returns
true if lookupFieldSchema has been added, or false if there is no such field fieldName.

Definition at line 373 of file KDbTableSchema.cpp.

◆ setPrimaryKey()

void KDbTableSchema::setPrimaryKey ( KDbIndexSchema * pkey)

Sets table's primary key index to pkey. Pass pkey as nullptr to unassign existing primary key. In this case "primary" property of previous primary key KDbIndexSchema object that will be cleared, making it an ordinary index.

If this table already has primary key assigned, it is unassigned using setPrimaryKey(nullptr).

Before assigning as primary key, you should add the index to indices list with addIndex() (this is not done automatically!).

<

Todo

Definition at line 216 of file KDbTableSchema.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 11:54:31 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.