kexi
KexiTableViewData Class Reference
#include <kexitableviewdata.h>
Detailed Description
Reimplements QPtrList to allow configurable sorting and more. Original author: Till Busch. Reimplemented by Jaroslaw Staniek.
Definition at line 194 of file kexitableviewdata.h.
Public Types | |
typedef QPtrListIterator< KexiTableItem > | Iterator |
Signals | |
void | destroying () |
void | aboutToChangeCell (KexiTableItem *item, int colnum, QVariant &newValue, KexiDB::ResultInfo *result) |
void | aboutToInsertRow (KexiTableItem *item, KexiDB::ResultInfo *result, bool repaint) |
void | aboutToUpdateRow (KexiTableItem *item, KexiDB::RowEditBuffer *buffer, KexiDB::ResultInfo *result) |
void | rowUpdated (KexiTableItem *) |
void | rowInserted (KexiTableItem *, bool repaint) |
void | rowInserted (KexiTableItem *, uint index, bool repaint) |
void | aboutToDeleteRow (KexiTableItem &item, KexiDB::ResultInfo *result, bool repaint) |
void | rowDeleted () |
void | rowsDeleted (const QValueList< int > &rowsToDelete) |
void | reloadRequested () |
void | rowRepaintRequested (KexiTableItem &) |
Public Member Functions | |
KexiTableViewData () | |
KexiTableViewData (KexiDB::Cursor *c) | |
KexiTableViewData (const QValueList< QVariant > &keys, const QValueList< QVariant > &values, KexiDB::Field::Type keyType=KexiDB::Field::Text, KexiDB::Field::Type valueType=KexiDB::Field::Text) | |
KexiTableViewData (KexiDB::Field::Type keyType, KexiDB::Field::Type valueType) | |
virtual | ~KexiTableViewData () |
void | preloadAllRows () |
void | setSorting (int column, bool ascending=true) |
int | sortedColumn () const |
int | sortingOrder () const |
void | addColumn (KexiTableViewColumn *col) |
int | globalColumnID (int visibleID) |
int | visibleColumnID (int globalID) |
bool | isDBAware () |
QString | dbTableName () const |
KexiDB::Cursor * | cursor () const |
uint | columnsCount () const |
KexiTableViewColumn * | column (uint c) |
virtual bool | isReadOnly () const |
virtual void | setReadOnly (bool set) |
virtual bool | isInsertingEnabled () const |
virtual void | setInsertingEnabled (bool set) |
void | clearRowEditBuffer () |
bool | updateRowEditBufferRef (KexiTableItem *item, int colnum, KexiTableViewColumn *col, QVariant &newval, bool allowSignals=true) |
bool | updateRowEditBuffer (KexiTableItem *item, int colnum, KexiTableViewColumn *col, QVariant newval, bool allowSignals=true) |
bool | updateRowEditBuffer (KexiTableItem *item, int colnum, QVariant newval, bool allowSignals=true) |
KexiDB::RowEditBuffer * | rowEditBuffer () const |
KexiDB::ResultInfo * | result () |
bool | saveRowChanges (KexiTableItem &item, bool repaint=false) |
bool | saveNewRow (KexiTableItem &item, bool repaint=false) |
bool | deleteRow (KexiTableItem &item, bool repaint=false) |
void | deleteRows (const QValueList< int > &rowsToDelete, bool repaint=false) |
virtual bool | deleteAllRows (bool repaint=false) |
virtual void | clearInternal () |
void | insertRow (KexiTableItem &item, uint index, bool repaint=false) |
int | autoIncrementedColumn () |
void | reload () |
KexiTableItem * | at (uint index) |
virtual uint | count () const |
bool | isEmpty () const |
KexiTableItem * | first () |
KexiTableItem * | last () |
int | findRef (const KexiTableItem *item) |
void | sort () |
bool | removeFirst () |
bool | removeLast () |
void | append (const KexiTableItem *item) |
void | prepend (const KexiTableItem *item) |
Iterator | iterator () |
Iterator * | createIterator () |
bool | containsROWIDInfo () const |
KexiTableItem * | createItem () const |
Public Attributes | |
KexiTableViewColumn::List | columns |
Protected Member Functions | |
void | init () |
void | init (const QValueList< QVariant > &keys, const QValueList< QVariant > &values, KexiDB::Field::Type keyType, KexiDB::Field::Type valueType) |
virtual int | compareItems (Item item1, Item item2) |
int | cmpStr (Item item1, Item item2) |
int | cmpInt (Item item1, Item item2) |
int | cmpUInt (Item item1, Item item2) |
int | cmpLongLong (Item item1, Item item2) |
int | cmpULongLong (Item item1, Item item2) |
int | cmpDouble (Item item1, Item item2) |
int | cmpDate (Item item1, Item item2) |
int | cmpDateTime (Item item1, Item item2) |
int | cmpTime (Item item1, Item item2) |
bool | saveRow (KexiTableItem &item, bool insert, bool repaint) |
Protected Attributes | |
int | m_key |
short | m_order |
short | m_type |
KexiDB::RowEditBuffer * | m_pRowEditBuffer |
QGuardedPtr< KexiDB::Cursor > | m_cursor |
KexiDB::ResultInfo | m_result |
uint | m_visibleColumnsCount |
QValueVector< int > | m_visibleColumnsIDs |
QValueVector< int > | m_globalColumnsIDs |
bool | m_readOnly: 1 |
bool | m_insertingEnabled: 1 |
bool | m_inside_acceptEditor: 1 |
bool | m_containsROWIDInfo: 1 |
int | m_autoIncrementedColumn |
int(KexiTableViewData::* | cmpFunc )(void *, void *) |
QVariant | m_leftTmp |
QVariant | m_rightTmp |
Static Protected Attributes | |
static unsigned short | charTable [] |
Constructor & Destructor Documentation
KexiTableViewData::KexiTableViewData | ( | ) |
KexiTableViewData::KexiTableViewData | ( | KexiDB::Cursor * | c | ) |
KexiTableViewData::KexiTableViewData | ( | const QValueList< QVariant > & | keys, | |
const QValueList< QVariant > & | values, | |||
KexiDB::Field::Type | keyType = KexiDB::Field::Text , |
|||
KexiDB::Field::Type | valueType = KexiDB::Field::Text | |||
) |
Defines two-column table usually used with comboboxes. First column is invisible and contains key values. Second column and contains user-visible value.
- Parameters:
-
keys a list of keys values a list of text values (must be of the same length as keys list) keyType a type for keys valueType a type for values
Definition at line 245 of file kexitableviewdata.cpp.
KexiTableViewData::KexiTableViewData | ( | KexiDB::Field::Type | keyType, | |
KexiDB::Field::Type | valueType | |||
) |
Like above constructor, but keys and values are not provided. You can do this later by calling append(KexiTableItem*) method. (KexiTableItem object must have exactly two columns)
Definition at line 254 of file kexitableviewdata.cpp.
Member Function Documentation
void KexiTableViewData::aboutToChangeCell | ( | KexiTableItem * | item, | |
int | colnum, | |||
QVariant & | newValue, | |||
KexiDB::ResultInfo * | result | |||
) | [signal] |
Emitted before change of the single, currently edited cell. Connect this signal to your slot and set result->success to false to disallow this change. You can also change newValue to other value, or change other columns in item row.
void KexiTableViewData::aboutToDeleteRow | ( | KexiTableItem & | item, | |
KexiDB::ResultInfo * | result, | |||
bool | repaint | |||
) | [signal] |
Emited before deleting of a current row. Connect this signal to your slot and set result->success to false to disallow this deleting.
void KexiTableViewData::aboutToInsertRow | ( | KexiTableItem * | item, | |
KexiDB::ResultInfo * | result, | |||
bool | repaint | |||
) | [signal] |
Emited before inserting of a new, current row. Connect this signal to your slot and set result->success to false to disallow this inserting. You can also change columns in item row.
void KexiTableViewData::aboutToUpdateRow | ( | KexiTableItem * | item, | |
KexiDB::RowEditBuffer * | buffer, | |||
KexiDB::ResultInfo * | result | |||
) | [signal] |
Emited before changing of an edited, current row. Connect this signal to your slot and set result->success to false to disallow this change. You can also change columns in item row.
void KexiTableViewData::addColumn | ( | KexiTableViewColumn * | col | ) |
Adds column col. Warning: col will be owned by this object, and deleted on its destruction.
Definition at line 329 of file kexitableviewdata.cpp.
int KexiTableViewData::autoIncrementedColumn | ( | ) |
- Todo:
- what about multiple autoinc columns?
what about changing column order?
Definition at line 793 of file kexitableviewdata.cpp.
void KexiTableViewData::clearRowEditBuffer | ( | ) |
Clears and initializes internal row edit buffer for incoming editing. Creates buffer using KexiDB::RowEditBuffer(false) (false means not db-aware type) if our data is not db-aware, or db-aware buffer if data is db-aware (isDBAware()==true).
- See also:
- KexiDB::RowEditBuffer
Definition at line 526 of file kexitableviewdata.cpp.
bool KexiTableViewData::containsROWIDInfo | ( | ) | const [inline] |
- Returns:
- true if ROWID information is stored within every row. Only reasonable for db-aware version. ROWID information is available if DriverBehaviour::ROW_ID_FIELD_RETURNS_LAST_AUTOINCREMENTED_VALUE == false for a KexiDB database driver and a table has no primary key defined. Phisically, ROWID information is stored after last KexiTableItem's element, so every KexiTableItem's length is expanded by one.
Definition at line 394 of file kexitableviewdata.h.
QString KexiTableViewData::dbTableName | ( | ) | const |
For db-aware data set only: table name is returned; equivalent to cursor()->query()->parentTable()->name().
Definition at line 360 of file kexitableviewdata.cpp.
bool KexiTableViewData::deleteAllRows | ( | bool | repaint = false |
) | [virtual] |
Deletes all rows. Works either for db-aware and non db-aware tables. Column's definition is not changed. For db-aware version, all rows are removed from a database. Row-edit buffer is cleared.
If repaint is true, reloadRequested() signal is emitted after deleting (if at least one row was deleted), so presenters can repaint their contents.
- Returns:
- true on success.
Definition at line 778 of file kexitableviewdata.cpp.
void KexiTableViewData::deleteRows | ( | const QValueList< int > & | rowsToDelete, | |
bool | repaint = false | |||
) |
Deletes rows (by number) passed with rowsToDelete. Currently, this method is only for non data-aware tables.
Definition at line 734 of file kexitableviewdata.cpp.
void KexiTableViewData::insertRow | ( | KexiTableItem & | item, | |
uint | index, | |||
bool | repaint = false | |||
) |
Inserts new item at index index. item will be owned by this data object. Note: Reasonable only for not not-db-aware version.
Definition at line 754 of file kexitableviewdata.cpp.
bool KexiTableViewData::isDBAware | ( | ) | [inline] |
virtual bool KexiTableViewData::isInsertingEnabled | ( | ) | const [inline, virtual] |
- Returns:
- true if data inserting is enabled (the default).
Definition at line 282 of file kexitableviewdata.h.
bool KexiTableViewData::isReadOnly | ( | ) | const [virtual] |
- Returns:
- true if data is not editable. Can be set using setReadOnly() but it's still true if database cursor returned by cursor() is not 0 and has read-only connection.
Definition at line 828 of file kexitableviewdata.cpp.
void KexiTableViewData::preloadAllRows | ( | ) |
Preloads all rows provided by cursor (only for db-aware version).
- Todo:
- change to bool and return false on error!
Definition at line 809 of file kexitableviewdata.cpp.
void KexiTableViewData::reload | ( | ) | [inline] |
Emits reloadRequested() signal to reload presenters.
Definition at line 372 of file kexitableviewdata.h.
void KexiTableViewData::reloadRequested | ( | ) | [signal] |
Displayed data needs to be reloaded in all presenters.
KexiDB::ResultInfo* KexiTableViewData::result | ( | ) | [inline] |
- Returns:
- last operation's result information (always not null).
Definition at line 328 of file kexitableviewdata.h.
void KexiTableViewData::rowDeleted | ( | ) | [signal] |
Current row has been deleted.
void KexiTableViewData::rowInserted | ( | KexiTableItem * | , | |
uint | index, | |||
bool | repaint | |||
) | [signal] |
A row has been inserted at index position (not db-aware data only).
void KexiTableViewData::rowInserted | ( | KexiTableItem * | , | |
bool | repaint | |||
) | [signal] |
A row has been inserted.
void KexiTableViewData::rowsDeleted | ( | const QValueList< int > & | rowsToDelete | ) | [signal] |
Rows have been deleted.
void KexiTableViewData::rowUpdated | ( | KexiTableItem * | ) | [signal] |
Current row has been updated.
bool KexiTableViewData::saveRow | ( | KexiTableItem & | item, | |
bool | insert, | |||
bool | repaint | |||
) | [protected] |
internal: for saveRowChanges() and saveNewRow()
- Todo:
- set m_result.column if possible
Definition at line 585 of file kexitableviewdata.cpp.
void KexiTableViewData::setInsertingEnabled | ( | bool | set | ) | [virtual] |
Sets insertingEnabled flag. If true, empty row is available If set is true, read-only flag will be cleared automatically.
- See also:
- setReadOnly()
Definition at line 517 of file kexitableviewdata.cpp.
void KexiTableViewData::setReadOnly | ( | bool | set | ) | [virtual] |
Sets readOnly flag for this data. If set is true, insertingEnabled flag will be cleared automatically.
- See also:
- isInsertingEnabled()
Definition at line 508 of file kexitableviewdata.cpp.
void KexiTableViewData::setSorting | ( | int | column, | |
bool | ascending = true | |||
) |
Sets sorting for column. If column is -1, sorting is disabled.
Definition at line 367 of file kexitableviewdata.cpp.
int KexiTableViewData::sortedColumn | ( | ) | const [inline] |
- Returns:
- the column number by which the data is sorted, or -1 if sorting is disabled. In this case sortingOrder() will return 0. Initial sorted column number for data after instantiating object is -1.
Definition at line 240 of file kexitableviewdata.h.
int KexiTableViewData::sortingOrder | ( | ) | const [inline] |
- Returns:
- 1 if ascending sort order is set, -1 id descending sort order is set, or 0 if no sorting is set. This is independant of whether data is sorted now. Initial sorting for data after instantiating object is 0.
Definition at line 245 of file kexitableviewdata.h.
bool KexiTableViewData::updateRowEditBuffer | ( | KexiTableItem * | item, | |
int | colnum, | |||
QVariant | newval, | |||
bool | allowSignals = true | |||
) | [inline] |
Added for convenience. Like above but it's assumed that item item's columns are ordered like in table view, not like in form view. Don't use this with form views.
Definition at line 318 of file kexitableviewdata.h.
bool KexiTableViewData::updateRowEditBuffer | ( | KexiTableItem * | item, | |
int | colnum, | |||
KexiTableViewColumn * | col, | |||
QVariant | newval, | |||
bool | allowSignals = true | |||
) | [inline] |
Added for convenience. Like above but newval is passed by value.
Definition at line 309 of file kexitableviewdata.h.
bool KexiTableViewData::updateRowEditBufferRef | ( | KexiTableItem * | item, | |
int | colnum, | |||
KexiTableViewColumn * | col, | |||
QVariant & | newval, | |||
bool | allowSignals = true | |||
) |
Updates internal row edit buffer: currently edited column col (number colnum) has now assigned new value of newval. Uses column's caption to address the column in buffer if the buffer is of simple type, or db-aware buffer if (isDBAware()==true). (then fields are addressed with KexiDB::Field, instead of caption strings). If allowSignals is true (the default), aboutToChangeCell() signal is emitted. Note that newval may be changed in aboutToChangeCell() signal handler.
- See also:
- KexiDB::RowEditBuffer
Definition at line 535 of file kexitableviewdata.cpp.
Member Data Documentation
unsigned short KexiTableViewData::charTable [static, protected] |
Columns information
Definition at line 269 of file kexitableviewdata.h.
bool KexiTableViewData::m_containsROWIDInfo [protected] |
bool KexiTableViewData::m_inside_acceptEditor [protected] |
Used in acceptEditor() to avoid infinite recursion, eg. when we're calling acceptRowEdit() during cell accepting phase.
Definition at line 483 of file kexitableviewdata.h.
QVariant KexiTableViewData::m_leftTmp [protected] |
Temporary, used in compare functions like cmpInt(), cmpString() to avoid memory allocations.
Definition at line 494 of file kexitableviewdata.h.
KexiDB::ResultInfo KexiTableViewData::m_result [protected] |
used to faster lookup columns of simple type (not dbaware)
Definition at line 473 of file kexitableviewdata.h.
The documentation for this class was generated from the following files: