Kexi API Documentation (2.0 alpha)

KexiDB::TableSchema Class Reference

#include <tableschema.h>

Inheritance diagram for KexiDB::TableSchema:

KexiDB::FieldList KexiDB::SchemaData KexiDB::InternalTableSchema List of all members.

Detailed Description

KexiDB::TableSchema provides information about native database table that can be stored using KexiDB database engine.

Definition at line 42 of file tableschema.h.

Public Types

typedef QPtrList< TableSchemaList
 Type of tables list.
typedef QPtrListIterator<
TableSchema
ListIterator
 Iterator for tables list.

Public Member Functions

 TableSchema (const QString &name)
 TableSchema (const SchemaData &sdata)
 TableSchema ()
 TableSchema (const TableSchema &ts, bool copyId=true)
 TableSchema (const TableSchema &ts, int setId)
virtual ~TableSchema ()
virtual FieldListinsertField (uint index, Field *field)
virtual void removeField (KexiDB::Field *field)
IndexSchemaprimaryKey () const
void setPrimaryKey (IndexSchema *pkey)
const IndexSchema::ListIterator indicesIterator () const
const IndexSchema::Listindices ()
virtual void clear ()
QString debugString (bool includeTableName)
virtual QString debugString ()
Connectionconnection () const
bool isKexiDBSystem () const
void setKexiDBSystem (bool set)
virtual bool isNative () const
virtual void setNative (bool set)
QuerySchemaquery ()
FieldanyNonPKField ()
bool setLookupFieldSchema (const QString &fieldName, LookupFieldSchema *lookupFieldSchema)
LookupFieldSchemalookupFieldSchema (const Field &field) const
LookupFieldSchemalookupFieldSchema (const QString &fieldName)
const QPtrVector< LookupFieldSchema > & lookupFieldsList ()

Protected Member Functions

 TableSchema (Connection *conn, const QString &name=QString::null)

Protected Attributes

IndexSchema::List m_indices
QGuardedPtr< Connectionm_conn
IndexSchemam_pkey
QuerySchemam_query
 cached query schema that is defined by "select * from <this_table_name>"
Private * d

Friends

class Connection


Member Typedef Documentation

typedef QPtrList<TableSchema> KexiDB::TableSchema::List
 

Type of tables list.

Definition at line 45 of file tableschema.h.

typedef QPtrListIterator<TableSchema> KexiDB::TableSchema::ListIterator
 

Iterator for tables list.

Definition at line 46 of file tableschema.h.


Constructor & Destructor Documentation

TableSchema::TableSchema const QString name  ) 
 

Definition at line 64 of file tableschema.cpp.

References KexiDB::SchemaData::m_name.

TableSchema::TableSchema const SchemaData sdata  ) 
 

Definition at line 74 of file tableschema.cpp.

TableSchema::TableSchema  ) 
 

Definition at line 83 of file tableschema.cpp.

TableSchema::TableSchema const TableSchema ts,
bool  copyId = true
 

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 92 of file tableschema.cpp.

TableSchema::TableSchema const TableSchema ts,
int  setId
 

Copy constructor like TableSchema(const TableSchema&, bool). setId 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 99 of file tableschema.cpp.

References KexiDB::SchemaData::m_id.

TableSchema::~TableSchema  )  [virtual]
 

Definition at line 123 of file tableschema.cpp.

References d, m_conn, and m_query.

TableSchema::TableSchema Connection conn,
const QString name = QString::null
[protected]
 

Automatically retrieves table schema via connection.

Definition at line 108 of file tableschema.cpp.

References d, m_indices, KexiDB::SchemaData::m_name, and m_pkey.


Member Function Documentation

Field * TableSchema::anyNonPKField  ) 
 

Returns:
any field not being a part of primary key of this table. If there is no such field, returns 0.

Definition at line 372 of file tableschema.cpp.

References d, KexiDB::FieldList::hasField(), KexiDB::Field::isPrimaryKey(), KexiDB::FieldList::m_fields, and m_pkey.

Referenced by KexiDB::Connection::insertRow().

void TableSchema::clear  )  [virtual]
 

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

See also:
FieldList::clear()

Reimplemented from KexiDB::FieldList.

Definition at line 271 of file tableschema.cpp.

References KexiDB::SchemaData::clear(), KexiDB::FieldList::clear(), d, m_conn, and m_indices.

Connection* KexiDB::TableSchema::connection  )  const [inline]
 

Returns:
connection object if table was created/retrieved using a connection, otherwise 0.

Definition at line 109 of file tableschema.h.

Referenced by KexiDB::TableOrQuerySchema::connection(), and KexiDB::QuerySchema::connection().

QString TableSchema::debugString  )  [virtual]
 

Returns:
String for debugging purposes. Equal to debugString(true).

Reimplemented from KexiDB::FieldList.

Definition at line 326 of file tableschema.cpp.

QString TableSchema::debugString bool  includeTableName  ) 
 

Returns:
String for debugging purposes, if includeTableName is true, table name, caption, etc. is prepended, else only debug string for the fields are returned.

Definition at line 331 of file tableschema.cpp.

References KexiDB::LookupFieldSchema::debugString(), KexiDB::FieldList::debugString(), lookupFieldSchema(), KexiDB::FieldList::m_fields, and KexiDB::SchemaData::schemaDataDebugString().

Referenced by KexiDB::TableOrQuerySchema::debugString(), and KexiTableDesignerView::debugStringForCurrentTableSchema().

const IndexSchema::List* KexiDB::TableSchema::indices  )  [inline]
 

Definition at line 93 of file tableschema.h.

const IndexSchema::ListIterator KexiDB::TableSchema::indicesIterator  )  const [inline]
 

Definition at line 90 of file tableschema.h.

Referenced by KexiCellEditorFactory::createEditor().

FieldList & TableSchema::insertField uint  index,
Field field
[virtual]
 

Inserts field into a specified position (index). 'order' property of field is set automatically.

Definition at line 184 of file tableschema.cpp.

References KexiDB::IndexSchema::addField(), KexiDB::FieldList::insertField(), KexiDB::Field::isIndexed(), KexiDB::Field::isPrimaryKey(), KexiDB::Field::isUniqueKey(), KexiDB::FieldList::m_fields, m_indices, KexiDB::Field::m_order, KexiDB::IndexSchema::setAutoGenerated(), setPrimaryKey(), KexiDB::Field::setTable(), and KexiDB::IndexSchema::setUnique().

bool KexiDB::TableSchema::isKexiDBSystem  )  const [inline]
 

Returns:
true if this is KexiDB storage system's table (used internally by KexiDB). This helps in hiding such tables in applications (if desired) and will also enable lookup of system tables for schema export/import functionality.
Any internal KexiDB system table's schema (kexi__*) has cleared its SchemaData 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.

isKexiDBSystem()==true implies isNative()==true.

By default (after allocation), TableSchema object has this property set to false.

Definition at line 125 of file tableschema.h.

virtual bool KexiDB::TableSchema::isNative  )  const [inline, virtual]
 

Returns:
true if this is schema of native database object, When this is kexiDBSystem table, native flag is forced to be on.

Reimplemented from KexiDB::SchemaData.

Definition at line 134 of file tableschema.h.

LookupFieldSchema * TableSchema::lookupFieldSchema const QString fieldName  ) 
 

Definition at line 410 of file tableschema.cpp.

References field, and lookupFieldSchema().

LookupFieldSchema * TableSchema::lookupFieldSchema const Field field  )  const
 

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.

Definition at line 405 of file tableschema.cpp.

References d.

Referenced by debugString(), and lookupFieldSchema().

const QPtrVector< LookupFieldSchema > & TableSchema::lookupFieldsList  ) 
 

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 418 of file tableschema.cpp.

References d, and KexiDB::FieldList::m_fields.

IndexSchema* KexiDB::TableSchema::primaryKey  )  const [inline]
 

Returns:
list of fields that are primary key of this table. This method never returns 0 value, if there is no primary key, empty IndexSchema object is returned. IndexSchema object is owned by the table schema.

Definition at line 76 of file tableschema.h.

Referenced by KexiDB::Connection::deleteAllRows(), KexiDB::Connection::deleteRow(), KexiFormView::initDataSource(), KexiDB::Connection::insertRow(), KexiDB::QuerySchema::pkeyFieldsOrder(), and KexiDB::Connection::updateRow().

QuerySchema * TableSchema::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 364 of file tableschema.cpp.

References m_query.

Referenced by KexiDB::TableOrQuerySchema::columnInfo(), KexiDB::TableOrQuerySchema::columns(), KexiMigration::PqxxMigrate::drv_copyTable(), KexiMigration::MySQLMigrate::drv_copyTable(), KexiDB::Connection::executeQuery(), KexiDB::Connection::isEmpty(), KexiDB::Connection::prepareQuery(), and KexiDB::Connection::selectStatement().

void TableSchema::removeField KexiDB::Field field  )  [virtual]
 

Reimplemented for internal reasons.

Reimplemented from KexiDB::FieldList.

Definition at line 225 of file tableschema.cpp.

References d, and KexiDB::FieldList::removeField().

void TableSchema::setKexiDBSystem bool  set  ) 
 

Sets KexiDBSystem flag to on or off. When on, native flag is forced to be on. When off, native flag is not affected.

See also:
isKexiDBSystem()

Definition at line 347 of file tableschema.cpp.

References KexiDB::SchemaData::m_native.

bool TableSchema::setLookupFieldSchema const QString fieldName,
LookupFieldSchema lookupFieldSchema
 

Sets lookup field schema lookupFieldSchema for fieldName. Passing null 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 387 of file tableschema.cpp.

References d, KexiDB::FieldList::field(), KexiDBWarn, and KexiDB::SchemaData::name().

Referenced by KexiDB::Connection::loadExtendedTableSchemaData().

void TableSchema::setNative bool  set  )  [virtual]
 

Reimplemented from KexiDB::SchemaData.

Definition at line 354 of file tableschema.cpp.

References KexiDBWarn, and KexiDB::SchemaData::m_native.

void TableSchema::setPrimaryKey IndexSchema pkey  ) 
 

Sets table's primary key index to pkey. Pass pkey==0 if you want to unassign existing primary key ("primary" property of given IndexSchema object will be cleared then so this index becomes ordinary index, still existing on table indeices list).

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

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

Definition at line 163 of file tableschema.cpp.

References d, KexiDB::FieldList::fieldCount(), m_indices, m_pkey, and KexiDB::IndexSchema::setPrimaryKey().

Referenced by insertField().


Friends And Related Function Documentation

friend class Connection [friend]
 

Reimplemented from KexiDB::SchemaData.

Definition at line 190 of file tableschema.h.


Member Data Documentation

Private* KexiDB::TableSchema::d [protected]
 

Definition at line 178 of file tableschema.h.

Referenced by anyNonPKField(), clear(), lookupFieldSchema(), lookupFieldsList(), removeField(), setLookupFieldSchema(), setPrimaryKey(), TableSchema(), and ~TableSchema().

QGuardedPtr<Connection> KexiDB::TableSchema::m_conn [protected]
 

Definition at line 172 of file tableschema.h.

Referenced by clear(), KexiDB::Connection::createTable(), and ~TableSchema().

IndexSchema::List KexiDB::TableSchema::m_indices [protected]
 

Definition at line 170 of file tableschema.h.

Referenced by clear(), insertField(), setPrimaryKey(), and TableSchema().

IndexSchema* KexiDB::TableSchema::m_pkey [protected]
 

Definition at line 174 of file tableschema.h.

Referenced by anyNonPKField(), setPrimaryKey(), and TableSchema().

QuerySchema* KexiDB::TableSchema::m_query [protected]
 

cached query schema that is defined by "select * from <this_table_name>"

Definition at line 176 of file tableschema.h.

Referenced by query(), and ~TableSchema().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:50:48 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003