kexi

#include <indexschema.h>

Inheritance diagram for KexiDB::IndexSchema:
KexiDB::FieldList KexiDB::SchemaData

Public Types

typedef TQPtrList< IndexSchema > List
typedef TQPtrListIterator< IndexSchema > ListIterator

Public Member Functions

 IndexSchema (TableSchema *tableSchema)
 IndexSchema (const IndexSchema &idx, TableSchema &parentTable)
virtual ~IndexSchema ()
virtual FieldList & addField (Field *field)
TableSchema * table () const
Relationship::List * masterRelationships ()
Relationship::List * detailsRelationships ()
void attachRelationship (Relationship *rel)
void detachRelationship (Relationship *rel)
bool isAutoGenerated () const
bool isPrimaryKey () const
void setPrimaryKey (bool set)
bool isUnique () const
void setUnique (bool set)
virtual TQString debugString ()
Public Member Functions inherited from KexiDB::FieldList
 FieldList (bool owner=false)
 FieldList (const FieldList &fl, bool deepCopyFields=true)
virtual ~FieldList ()
uint fieldCount () const
FieldList & addField (Field *field)
virtual FieldList & insertField (uint index, Field *field)
virtual void removeField (KexiDB::Field *field)
Field * field (uint id)
virtual Field * field (const TQString &name)
bool hasField (const Field *field)
int indexOf (const Field *field)
TQStringList names () const
Field::ListIterator fieldsIterator () const
Field::List * fields ()
Field::List * autoIncrementFields ()
bool isOwner () const
virtual void clear ()
void debug ()
FieldList * subList (const TQString &n1, const TQString &n2=TQString(), const TQString &n3=TQString(), const TQString &n4=TQString(), const TQString &n5=TQString(), const TQString &n6=TQString(), const TQString &n7=TQString(), const TQString &n8=TQString(), const TQString &n9=TQString(), const TQString &n10=TQString(), const TQString &n11=TQString(), const TQString &n12=TQString(), const TQString &n13=TQString(), const TQString &n14=TQString(), const TQString &n15=TQString(), const TQString &n16=TQString(), const TQString &n17=TQString(), const TQString &n18=TQString())
FieldList * subList (const TQStringList &list)
FieldList * subList (const TQValueList< uint > &list)
TQString sqlFieldsList (Driver *driver, const TQString &separator=TQString::fromLatin1(","), const TQString &tableAlias=TQString(), int drvEscaping=Driver::EscapeDriver|Driver::EscapeAsNecessary)
void renameField (const TQString &oldName, const TQString &newName)
void renameField (KexiDB::Field *field, const TQString &newName)
Public Member Functions inherited from KexiDB::SchemaData
 SchemaData (int obj_type=KexiDB::UnknownObjectType)
int type () const
int id () const
TQString name () const
TQString objectName () const
void setName (const TQString &n)
TQString caption () const
void setCaption (const TQString &c)
TQString description () const
void setDescription (const TQString &desc)
virtual TQString schemaDataDebugString () const
virtual bool isNative () const
virtual void setNative (bool set)

Protected Member Functions

void setAutoGenerated (bool set)
void setForeignKey (bool set)
void attachRelationship (Relationship *rel, bool ownedByMaster)
Protected Member Functions inherited from KexiDB::SchemaData
void clear ()

Protected Attributes

TableSchema * m_tableSchema
Relationship::List m_master_owned_rels
Relationship::List m_master_rels
Relationship::List m_details_rels
bool m_primary: 1
bool m_unique: 1
bool m_isAutoGenerated: 1
bool m_isForeignKey: 1
Protected Attributes inherited from KexiDB::FieldList
Field::List m_fields
TQDict< Field > m_fields_by_name
Field::List * m_autoinc_fields
Protected Attributes inherited from KexiDB::SchemaData
int m_type
int m_id
TQString m_name
TQString m_caption
TQString m_desc
bool m_native: 1

Friends

class Connection
class TableSchema
class QuerySchema
class Relationship

Additional Inherited Members

Static Public Member Functions inherited from KexiDB::FieldList
static TQString sqlFieldsList (Field::List *list, Driver *driver, const TQString &separator=TQString::fromLatin1(","), const TQString &tableAlias=TQString(), int drvEscaping=Driver::EscapeDriver|Driver::EscapeAsNecessary)

Detailed Description

Provides information about database index that can be created for a database table.

IndexSchema object stores information about table fields that defines this index and additional properties like: whether index is unique or primary key (requires unique). Single-field index can be also auto generated.

Definition at line 43 of file indexschema.h.

Member Typedef Documentation

◆ List

typedef TQPtrList<IndexSchema> KexiDB::IndexSchema::List

Definition at line 46 of file indexschema.h.

◆ ListIterator

typedef TQPtrListIterator<IndexSchema> KexiDB::IndexSchema::ListIterator

Definition at line 47 of file indexschema.h.

Constructor & Destructor Documentation

◆ IndexSchema() [1/2]

IndexSchema::IndexSchema ( TableSchema * tableSchema)

Constructs empty index schema object that is assigned to table, and will be owned by this table. Any fields added with addField() won't be owned by index, but by its table. Do not forget to add these fields to table, because adding these to IndexSchema is not enough.

Definition at line 32 of file indexschema.cpp.

◆ IndexSchema() [2/2]

IndexSchema::IndexSchema ( const IndexSchema & idx,
TableSchema & parentTable )

Copy constructor. Copies all attributes from index idx, and fields assigned with it but the fields are taken (by name) from parentTable, not from idx itself, so it's possible to copy of index for a copy of table.

To copy an index within the same table it's enough to call:

new IndexSchema(idx, *idx.table());
IndexSchema(TableSchema *tableSchema)
Todo
All relationships should be also copied

Definition at line 44 of file indexschema.cpp.

◆ ~IndexSchema()

IndexSchema::~IndexSchema ( )
virtual

Destroys the index. Field objects are not deleted. All Relationship objects listed in masterRelationships() list are destroyed (these are also detached from detail-side indices before destruction). Relationship objects listed in detailsRelationships() are not touched.

Definition at line 75 of file indexschema.cpp.

Member Function Documentation

◆ addField()

FieldList & IndexSchema::addField ( Field * field)
virtual

Adds field at the end of field list. Field will not be owned by index. Field must belong to a table the index is bulit on, otherwise field couldn't be added.

Definition at line 91 of file indexschema.cpp.

◆ attachRelationship() [1/2]

void IndexSchema::attachRelationship ( Relationship * rel)

Attaches relationship definition rel to this IndexSchema object. If rel relationship has this IndexSchema defined at the master-side, rel is added to the list of master relationships (available with masterRelationships()). If rel relationship has this IndexSchema defined at the details-side, rel is added to the list of details relationships (available with detailsRelationships()). For the former case, attached rel object is now owned by this IndexSchema object.

Note: call detachRelationship() for IndexSchema object that rel was previously attached to, if any.

Definition at line 164 of file indexschema.cpp.

◆ attachRelationship() [2/2]

void IndexSchema::attachRelationship ( Relationship * rel,
bool ownedByMaster )
protected

Internal version of attachRelationship(). If ownedByMaster is true, attached rel object will be owned by this index.

Definition at line 169 of file indexschema.cpp.

◆ debugString()

TQString IndexSchema::debugString ( )
virtual
Returns
String for debugging purposes.

Reimplemented from KexiDB::FieldList.

Definition at line 154 of file indexschema.cpp.

◆ detachRelationship()

void IndexSchema::detachRelationship ( Relationship * rel)

Detaches relationship definition rel for this IndexSchema object from the list of master relationships (available with masterRelationships()), or from details relationships list, depending for which side of the relationship is this IndexSchem object assigned.

Note: If rel was detached from masterRelationships() list, this object now has no parent, so you need to attach it to somewhere or destruct it.

Definition at line 192 of file indexschema.cpp.

◆ detailsRelationships()

Relationship::List * KexiDB::IndexSchema::detailsRelationships ( )
inline
Returns
list of relationships to the table (of this index), i.e. any such relationship in which this table is at 'details' side. See Relationship class documentation for more information.

Definition at line 94 of file indexschema.h.

◆ isAutoGenerated()

bool IndexSchema::isAutoGenerated ( ) const
Returns
true if index is auto-generated. Auto-generated index is one-field index that was automatically generated for CREATE TABLE statement when the field has UNIQUE or PRIMARY KEY constraint enabled.

Any newly created IndexSchema object has this flag set to false.

This flag is handled internally by TableSchema. It can be usable for GUI application if we do not want display implicity/auto generated indices on the indices list or we if want to show these indices to the user in a special way.

Definition at line 109 of file indexschema.cpp.

◆ isPrimaryKey()

bool IndexSchema::isPrimaryKey ( ) const
Returns
true if this index is primary key of its table. This can be one or multifield.

Definition at line 119 of file indexschema.cpp.

◆ isUnique()

bool IndexSchema::isUnique ( ) const
Returns
true if this is unique index. This can be one or multifield.

Definition at line 131 of file indexschema.cpp.

◆ masterRelationships()

Relationship::List * KexiDB::IndexSchema::masterRelationships ( )
inline
Returns
list of relationships from the table (of this index), i.e. any such relationship in which this table is at 'master' side. See Relationship class documentation for more information. All objects listed here will be automatically destroyed on this IndexSchema object destruction.

Definition at line 89 of file indexschema.h.

◆ setAutoGenerated()

void IndexSchema::setAutoGenerated ( bool set)
protected

Internal constructor for convenience. Constructs a new index schema object that is assigned, and adds one field to it. The field must be assigned to a table. This results in the implicit index that is usually used interanlly to declare foreign keys, used in relationships.

Sets auto-generated flag. This method should be called only from TableSchema code

See also
isAutoGenerated().

Definition at line 114 of file indexschema.cpp.

◆ setForeignKey()

void IndexSchema::setForeignKey ( bool set)
protected

If set is true, declares that the index defines a foreign key, created implicity for Relationship object. Setting this to true, implies clearing 'primary key', 'unique' and 'auto generated' flags. If this index contains just single field, it's 'foreign field' flag will be set to true as well.

Definition at line 143 of file indexschema.cpp.

◆ setPrimaryKey()

void IndexSchema::setPrimaryKey ( bool set)

Sets PRIMARY KEY flag.

See also
isPrimary(). Note: Setting PRIMARY KEY on (true), UNIQUE flag will be also implicity set.

Definition at line 124 of file indexschema.cpp.

◆ setUnique()

void IndexSchema::setUnique ( bool set)

Sets UNIQUE flag.

See also
isUnique(). Note: Setting UNIQUE off (false), PRIMARY KEY flag will be also implicity set off, because this UNIQUE is the requirement for PRIMARY KEYS.

Definition at line 136 of file indexschema.cpp.

◆ table()

KexiDB::TableSchema * IndexSchema::table ( ) const
Returns
table that index is defined for.

Definition at line 104 of file indexschema.cpp.

◆ Connection

friend class Connection
friend

Definition at line 201 of file indexschema.h.

◆ QuerySchema

friend class QuerySchema
friend

Definition at line 203 of file indexschema.h.

◆ Relationship

friend class Relationship
friend

Definition at line 204 of file indexschema.h.

◆ TableSchema

friend class TableSchema
friend

Definition at line 202 of file indexschema.h.

Member Data Documentation

◆ m_details_rels

Relationship::List KexiDB::IndexSchema::m_details_rels
protected

a list of relationships to table (of this index)

Definition at line 194 of file indexschema.h.

◆ m_isAutoGenerated

bool KexiDB::IndexSchema::m_isAutoGenerated
protected

Definition at line 198 of file indexschema.h.

◆ m_isForeignKey

bool KexiDB::IndexSchema::m_isForeignKey
protected

Definition at line 199 of file indexschema.h.

◆ m_master_owned_rels

Relationship::List KexiDB::IndexSchema::m_master_owned_rels
protected

table on that index is built

a list of master relationships for the table (of this index), this index is a master key for these relationships and therefore - owner of these

Definition at line 188 of file indexschema.h.

◆ m_master_rels

Relationship::List KexiDB::IndexSchema::m_master_rels
protected

a list of master relationships that are not owned by this schema

Definition at line 191 of file indexschema.h.

◆ m_primary

bool KexiDB::IndexSchema::m_primary
protected

Definition at line 196 of file indexschema.h.

◆ m_tableSchema

TableSchema* KexiDB::IndexSchema::m_tableSchema
protected

Definition at line 182 of file indexschema.h.

◆ m_unique

bool KexiDB::IndexSchema::m_unique
protected

Definition at line 197 of file indexschema.h.


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