KexiDB::Field Class Reference
#include <field.h>
Inheritance diagram for KexiDB::Field:

Detailed Description
Meta-data for a field.KexiDB::Field provides information about single database field.
Field class has defined following members:
- name
- type
- database constraints
- additional options
- length (make sense mostly for string types)
- precision (for floating-point type)
- defaultValue
- caption (user readable name that can be e.g. translated)
- description (user readable name additional text, can be useful for developers)
- width (a hint for displaying in tabular mode or as text box)
Field can also have assigned expression (see KexiDB::BaseExpr class, and expression() method). If an expression is defined, then field's name is
Note that aliases for fields are defined within query, not in Field object, because the same field can be used in different queries with different alias.
Notes for advanced use: Field obeject is designed to be owned by a parent object. Such a parent object can be KexiDB::TableSchema, if the field defines single table column, or KexiDB::QuerySchema, if the field defines an expression (KexiDB::BaseExpr class).
Using expression class for fields allos to define expressions within queries like "SELECT AVG(price) FROM products"
You can choose whether your field is owned by query or table, using appropriate constructor, or using parameterless constructor and calling setTable() or setQuery() later.
Definition at line 72 of file field.h.
Public Types | |
| typedef QPtrList< Field > | List |
| list of fields | |
| typedef QPtrVector< Field > | Vector |
| vector of fields | |
| typedef QPtrListIterator< Field > | ListIterator |
| iterator for list of fields | |
| typedef QPair< Field *, Field * > | Pair |
| fields pair | |
| typedef QPtrList< Pair > | PairList |
| list of fields pair | |
| typedef QMap< QCString, QVariant > | CustomPropertiesMap |
| A data type used for handling custom properties of a field. | |
| enum | Type { InvalidType = 0, Byte = 1, ShortInteger = 2, Integer = 3, BigInteger = 4, Boolean = 5, Date = 6, DateTime = 7, Time = 8, Float = 9, Double = 10, Text = 11, LongText = 12, BLOB = 13, LastType = 13, Null = 64, Asterisk = 128, Enum = 129, Map = 130 } |
| enum | TypeGroup { InvalidGroup = 0, TextGroup = 1, IntegerGroup = 2, FloatGroup = 3, BooleanGroup = 4, DateTimeGroup = 5, BLOBGroup = 6, LastTypeGroup = 6 } |
| enum | Constraints { NoConstraints = 0, AutoInc = 1, Unique = 2, PrimaryKey = 4, ForeignKey = 8, NotNull = 16, NotEmpty = 32, Indexed = 64 } |
| enum | Options { NoOptions = 0, Unsigned = 1 } |
Public Member Functions | |
| Field (TableSchema *tableSchema) | |
| Field () | |
| Field (const QString &name, Type ctype, uint cconst=NoConstraints, uint options=NoOptions, uint length=0, uint precision=0, QVariant defaultValue=QVariant(), const QString &caption=QString::null, const QString &description=QString::null, uint width=0) | |
| Field (const Field &f) | |
| virtual | ~Field () |
| QString | name () const |
| virtual TableSchema * | table () const |
| virtual void | setTable (TableSchema *table) |
| QuerySchema * | query () const |
| void | setQuery (QuerySchema *query) |
| bool | isAutoIncrement () const |
| bool | isPrimaryKey () const |
| bool | isUniqueKey () const |
| bool | isForeignKey () const |
| bool | isNotNull () const |
| bool | isNotEmpty () const |
| bool | isIndexed () const |
| bool | isNumericType () const |
| bool | isIntegerType () const |
| bool | isFPNumericType () const |
| bool | isDateTimeType () const |
| bool | isTextType () const |
| uint | options () const |
| void | setOptions (uint options) |
| QVariant::Type | variantType () const |
| Converts field's type to QVariant equivalent as accurate as possible. | |
| Type | type () const |
| QString | typeName () const |
| TypeGroup | typeGroup () const |
| QString | typeGroupName () const |
| QString | typeString () const |
| QString | typeGroupString () const |
| QString | subType () const |
| void | setSubType (const QString &subType) |
| QVariant | defaultValue () const |
| uint | length () const |
| uint | precision () const |
| uint | scale () const |
| int | visibleDecimalPlaces () const |
| uint | constraints () const |
| int | order () const |
| QString | caption () const |
| QString | captionOrName () const |
| QString | description () const |
| uint | width () const |
| bool | isUnsigned () const |
| if the type has the unsigned attribute | |
| bool | hasEmptyProperty () const |
| bool | isAutoIncrementAllowed () const |
| void | setType (Type t) |
| void | setName (const QString &name) |
| void | setConstraints (uint c) |
| void | setLength (uint l) |
| void | setScale (uint s) |
| void | setVisibleDecimalPlaces (int p) |
| void | setPrecision (uint p) |
| void | setUnsigned (bool u) |
| void | setDefaultValue (const QVariant &def) |
| bool | setDefaultValue (const QCString &def) |
| void | setAutoIncrement (bool a) |
| void | setPrimaryKey (bool p) |
| void | setUniqueKey (bool u) |
| void | setForeignKey (bool f) |
| void | setNotNull (bool n) |
| void | setNotEmpty (bool n) |
| void | setIndexed (bool s) |
| void | setCaption (const QString &caption) |
| void | setDescription (const QString &description) |
| void | setWidth (uint w) |
| bool | isQueryAsterisk () const |
| virtual QString | debugString () const |
| void | debug () |
| KexiDB::BaseExpr * | expression () |
| void | setExpression (KexiDB::BaseExpr *expr) |
| bool | isExpression () const |
| QValueVector< QString > | enumHints () const |
| QString | enumHint (uint num) |
| void | setEnumHints (const QValueVector< QString > &l) |
| QVariant | customProperty (const QCString &propertyName, const QVariant &defaultValue=QVariant()) const |
| void | setCustomProperty (const QCString &propertyName, const QVariant &value) |
| Sets value value for custom property propertyName. | |
| const CustomPropertiesMap | customProperties () const |
Static Public Member Functions | |
| static uint | defaultTextLength () |
| static QVariant::Type | variantType (uint type) |
| Converts type type to QVariant equivalent as accurate as possible. | |
| static QString | typeName (uint type) |
| static QString | typeString (uint type) |
| static Type | typeForString (const QString &typeString) |
| static TypeGroup | typeGroupForString (const QString &typeGroupString) |
| static TypeGroup | typeGroup (uint type) |
| static QString | typeGroupName (uint typeGroup) |
| static QString | typeGroupString (uint typeGroup) |
| static bool | isNumericType (uint type) |
| static bool | isIntegerType (uint type) |
| static bool | isFPNumericType (uint type) |
| static bool | isDateTimeType (uint type) |
| static bool | isTextType (uint type) |
| static bool | hasEmptyProperty (uint type) |
| static bool | isAutoIncrementAllowed (uint type) |
Protected Member Functions | |
| Field (QuerySchema *querySchema, BaseExpr *expr=0) | |
| void | init () |
Protected Attributes | |
| FieldList * | m_parent |
| In most cases this points to a TableSchema object that field is assigned. | |
| QString | m_name |
| QString | m_subType |
| uint | m_constraints |
| uint | m_length |
| also used for storing scale for floating point types | |
| uint | m_precision |
| int | m_visibleDecimalPlaces |
| used in visibleDecimalPlaces() | |
| uint | m_options |
| QVariant | m_defaultValue |
| int | m_order |
| QString | m_caption |
| QString | m_desc |
| uint | m_width |
| QValueVector< QString > | m_hints |
| KexiDB::BaseExpr * | m_expr |
| CustomPropertiesMap * | m_customProperties |
Static Protected Attributes | |
| static FieldTypeNames | m_typeNames |
| real i18n'd type names (and not-i18n'd type name strings) | |
| static FieldTypeGroupNames | m_typeGroupNames |
| real i18n'd type group names (and not-i18n'd group name strings) | |
Friends | |
| class | Connection |
| class | FieldList |
| class | TableSchema |
| class | QuerySchema |
Classes | |
| class | FieldTypeGroupNames |
| class | FieldTypeNames |
Member Typedef Documentation
|
|
A data type used for handling custom properties of a field.
|
|
|
list of fields
|
|
|
iterator for list of fields
|
|
|
fields pair
|
|
|
list of fields pair
|
|
|
vector of fields
|
Member Enumeration Documentation
|
|
Possible constraints defined for a field. |
|
|
Possible options defined for a field. |
|
|
Unified (most common used) types of fields.
|
|
|
Type groups for fields. |
Constructor & Destructor Documentation
|
|
Creates a database field as a child of tableSchema table No other properties are set (even the name), so these should be set later. Definition at line 48 of file field.cpp. References KexiDB::FieldList::fieldCount(), init(), m_order, m_parent, NoConstraints, and setConstraints(). |
|
|
Creates a database field without any properties set. These should be set later. Definition at line 41 of file field.cpp. References init(), NoConstraints, and setConstraints(). |
|
||||||||||||||||||||||||||||||||||||||||||||
|
Creates a database field with specified properties. Definition at line 66 of file field.cpp. References defaultTextLength(), m_length, setConstraints(), and Text. |
|
|
Copy constructor. Definition at line 93 of file field.cpp. References customProperties(), m_customProperties, and m_expr. |
|
|
Definition at line 107 of file field.cpp. References m_customProperties, and m_expr. |
|
||||||||||||
|
Creates a database field as a child of querySchema table Assigns expr expression to this field, if present. Used internally by query schemas, e.g. to declare asterisks or to add expression columns. No other properties are set, so these should be set later. Definition at line 56 of file field.cpp. References KexiDB::FieldList::fieldCount(), init(), m_order, m_parent, NoConstraints, setConstraints(), and setExpression(). |
Member Function Documentation
|
|
Definition at line 371 of file field.h. Referenced by buildValuesForKexi__Fields(), KexiDB::QueryColumnInfo::captionOrAliasOrName(), and KexiTableDesignerView::createPropertySet(). |
|
|
Definition at line 374 of file field.h. Referenced by KexiTableDesignerView::initData(), KexiTableViewColumn::KexiTableViewColumn(), KexiTableViewData::saveRow(), and KexiDB::QuerySchema::setColumnAlias(). |
|
|
Definition at line 364 of file field.h. Referenced by buildValuesForKexi__Fields(). |
|
|
Definition at line 559 of file field.h. Referenced by Field(), and KexiDB::Connection::storeExtendedTableSchemaData(). |
|
||||||||||||
|
Definition at line 644 of file field.cpp. References m_customProperties. Referenced by KexiTableDesignerView::createPropertySet(). |
|
|
Shows debug information about this field. Definition at line 628 of file field.cpp. References debugString(), and KexiDBDbg. |
|
|
Definition at line 583 of file field.cpp. References AutoInc, KexiDB::BaseExpr::debugString(), KexiDB::Driver::defaultSQLTypeName(), KexiDB::Connection::driver(), foreach, ForeignKey, isFPNumericType(), m_constraints, m_customProperties, m_defaultValue, m_expr, m_length, m_name, m_options, m_precision, NotEmpty, NotNull, PrimaryKey, scale(), table(), Text, type(), Unique, Unsigned, and KexiDB::variantToString(). Referenced by debug(), KexiDB::OrderByColumn::debugString(), KexiDB::FieldList::debugString(), KexiDB::AlterTableHandler::InsertFieldAction::debugString(), and KexiTableDesignerView::slotRowUpdated(). |
|
|
Definition at line 112 of file field.h. Referenced by Field(), KexiDB::ConstExpr::type(), and KexiTableDesignerViewPrivate::updatePropertiesVisibility(). |
|
|
Definition at line 326 of file field.h. Referenced by buildValuesForKexi__Fields(), KexiTableDesignerView::createPropertySet(), KexiDB::Connection::createTableStatement(), KexiDB::AlterTableHandler::execute(), and KexiDB::Connection::insertRow(). |
|
|
Definition at line 377 of file field.h. Referenced by buildValuesForKexi__Fields(), KexiTableDesignerView::createPropertySet(), KexiTableDesignerView::initData(), and KexiDataAwareObjectInterface::setData(). |
|
|
|
|
|
Definition at line 541 of file field.h. Referenced by KexiComboBoxPopup::setData(). |
|
|
Definition at line 521 of file field.h. Referenced by KexiQueryDesignerGuiEditor::showFieldsOrRelationsForQueryInternal(). |
|
|
static version of hasEmptyProperty() method
Definition at line 271 of file field.cpp. References BLOB, and isTextType(). |
|
|
Definition at line 388 of file field.h. Referenced by KexiDB::isEmptyValue(), and KexiTableDesignerViewPrivate::updatePropertiesVisibility(). |
|
|
Definition at line 113 of file field.cpp. References InvalidType, m_customProperties, m_defaultValue, m_expr, m_length, m_name, m_options, m_order, m_parent, m_precision, m_visibleDecimalPlaces, m_width, and NoOptions. Referenced by Field(). |
|
|
Definition at line 231 of file field.h. Referenced by KexiDB::QuerySchema::autoIncrementFields(), KexiDB::FieldList::autoIncrementFields(), KexiTableDesignerView::createPropertySet(), KexiDB::Connection::createTableStatement(), KexiTableViewData::saveRow(), setAutoIncrement(), and setConstraints(). |
|
|
static version of isAutoIncrementAllowed() method
Definition at line 276 of file field.cpp. References isIntegerType(). |
|
|
Definition at line 396 of file field.h. Referenced by KexiDB::setFieldProperties(), KexiDB::setFieldProperty(), setAutoIncrement(), setConstraints(), and KexiTableDesignerViewPrivate::updatePropertiesVisibility(). |
|
|
static version of isDateTimeType() method !
|
|
|
Definition at line 273 of file field.h. Referenced by typeGroup(). |
|
|
Definition at line 537 of file field.h. Referenced by KexiQueryDesignerGuiEditor::buildSchema(), KexiDB::QuerySchema::insertField(), and KexiQueryDesignerGuiEditor::showFieldsOrRelationsForQueryInternal(). |
|
|
Definition at line 240 of file field.h. Referenced by setForeignKey(). |
|
|
static version of isFPNumericType() method !
|
|
|
Definition at line 266 of file field.h. Referenced by KexiTableViewColumn::acceptsFirstChar(), KexiDB::QuerySchema::addToWhereExpression(), buildValuesForKexi__Fields(), KexiDB::Connection::createTableStatement(), KexiDB::cstringToVariant(), debugString(), KexiDB::FieldValidator::FieldValidator(), setPrecision(), setScale(), KexiTableViewData::setSorting(), KexiTableEdit::setupContents(), KexiDB::SQLiteCursor::storeCurrentRow(), KexiDB::BinaryExpr::type(), typeGroup(), KexiTableDesignerViewPrivate::updatePropertiesVisibility(), and KexiDB::SQLiteCursor::value(). |
|
|
Definition at line 249 of file field.h. Referenced by KexiTableDesignerView::createPropertySet(), KexiDB::TableSchema::insertField(), setConstraints(), and setIndexed(). |
|
|
static version of isIntegerType() method !
Definition at line 210 of file field.cpp. References BigInteger, Byte, Integer, and ShortInteger. |
|
|
Definition at line 259 of file field.h. Referenced by KexiDB::QuerySchema::addToWhereExpression(), KexiDB::cstringToVariant(), KexiDB::FieldValidator::FieldValidator(), isAutoIncrementAllowed(), KexiDB::Relationship::setIndices(), KexiTableEdit::setupContents(), KexiDB::BinaryExpr::type(), typeGroup(), and KexiDB::SQLiteCursor::value(). |
|
|
Definition at line 246 of file field.h. Referenced by KexiTableDesignerView::createPropertySet(), KexiDB::AlterTableHandler::execute(), KexiTableViewData::saveRow(), and setNotEmpty(). |
|
|
Definition at line 243 of file field.h. Referenced by KexiTableDesignerView::createPropertySet(), KexiDB::Connection::createTableStatement(), KexiDB::AlterTableHandler::execute(), KexiTableViewData::saveRow(), and setNotNull(). |
|
|
static version of isNumericType() method !
Definition at line 223 of file field.cpp. References BigInteger, Byte, Double, Float, Integer, and ShortInteger. |
|
|
Definition at line 252 of file field.h. Referenced by KexiTableViewColumn::acceptsFirstChar(), KexiTableViewData::setSorting(), and KexiTableDesignerViewPrivate::updatePropertiesVisibility(). |
|
|
Definition at line 234 of file field.h. Referenced by KexiDB::TableSchema::anyNonPKField(), KexiDB::Relationship::createIndices(), KexiTableDesignerView::createPropertySet(), KexiDB::Connection::createTableStatement(), KexiTableDesignerView::initData(), KexiDB::TableSchema::insertField(), setConstraints(), setPrimaryKey(), and KexiQueryDesignerGuiEditor::showFieldsOrRelationsForQueryInternal(). |
|
|
There can be added asterisks (QueryAsterisk objects) to query schemas' field list. QueryAsterisk subclasses Field class, and to check if the given object (pointed by Field*) is asterisk or just ordinary field definition, you can call this method. This is just effective version of QObject::isA(). Every QueryAsterisk object returns true here, and every Field object returns false. Definition at line 266 of file field.cpp. Referenced by KexiQueryDesignerGuiEditor::buildSchema(), KexiDB::QuerySchema::computeFieldsExpanded(), KexiDB::Relationship::createIndices(), KexiDB::QuerySchema::insertField(), KexiDB::QuerySchema::removeField(), and KexiQueryDesignerGuiEditor::showFieldsOrRelationsForQueryInternal(). |
|
|
static version of isTextType() method !
|
|
|
Definition at line 280 of file field.h. Referenced by KexiDB::cstringToVariant(), KexiDB::SQLitePreparedStatement::execute(), KexiDB::MySqlPreparedStatement::execute(), hasEmptyProperty(), KexiDB::Relationship::setIndices(), KexiTableViewData::setSorting(), KexiDB::SQLiteCursor::storeCurrentRow(), typeGroup(), and KexiDB::SQLiteCursor::value(). |
|
|
Definition at line 237 of file field.h. Referenced by KexiRelationView::addConnection(), KexiTableDesignerView::createPropertySet(), KexiDB::Connection::createTableStatement(), KexiDB::TableSchema::insertField(), KexiDB::isDefaultValueAllowed(), and setUniqueKey(). |
|
|
if the type has the unsigned attribute
Definition at line 384 of file field.h. Referenced by KexiTableViewColumn::acceptsFirstChar(), KexiTableDesignerView::createPropertySet(), KexiDB::Connection::createTableStatement(), KexiDB::FieldValidator::FieldValidator(), KexiDB::Relationship::setIndices(), and KexiTableViewData::setSorting(). |
|
|
Definition at line 330 of file field.h. Referenced by buildValuesForKexi__Fields(), KexiTableDesignerView::createPropertySet(), and KexiDB::Connection::createTableStatement(). |
|
|
|
Definition at line 286 of file field.h. Referenced by buildValuesForKexi__Fields(). |
|
|
|
