Eneboo - Documentación para desarrolladores
|
The QDataTable class provides a flexible SQL table widget that supports browsing and editing. Más...
#include <qdatatable.h>
Tipos públicos | |
enum | Refresh { RefreshData = 1, RefreshColumns = 2, RefreshAll = 3, RefreshData = 1, RefreshColumns = 2, RefreshAll = 3 } |
enum | Refresh { RefreshData = 1, RefreshColumns = 2, RefreshAll = 3, RefreshData = 1, RefreshColumns = 2, RefreshAll = 3 } |
Slots públicos | |
virtual void | find (const QString &str, bool caseSensitive, bool backwards) |
virtual void | sortAscending (int col) |
virtual void | sortDescending (int col) |
virtual void | refresh () |
void | setColumnWidth (int col, int w) |
void | adjustColumn (int col) |
void | setColumnStretchable (int col, bool stretch) |
void | swapColumns (int col1, int col2, bool swapHeaders=FALSE) |
virtual void | find (const QString &str, bool caseSensitive, bool backwards) |
virtual void | sortAscending (int col) |
virtual void | sortDescending (int col) |
virtual void | refresh () |
void | setColumnWidth (int col, int w) |
void | adjustColumn (int col) |
void | setColumnStretchable (int col, bool stretch) |
void | swapColumns (int col1, int col2, bool swapHeaders=FALSE) |
Señales | |
void | currentChanged (QSqlRecord *record) |
void | primeInsert (QSqlRecord *buf) |
void | primeUpdate (QSqlRecord *buf) |
void | primeDelete (QSqlRecord *buf) |
void | beforeInsert (QSqlRecord *buf) |
void | beforeUpdate (QSqlRecord *buf) |
void | beforeDelete (QSqlRecord *buf) |
void | cursorChanged (QSql::Op mode) |
void | currentChanged (QSqlRecord *record) |
void | primeInsert (QSqlRecord *buf) |
void | primeUpdate (QSqlRecord *buf) |
void | primeDelete (QSqlRecord *buf) |
void | beforeInsert (QSqlRecord *buf) |
void | beforeUpdate (QSqlRecord *buf) |
void | beforeDelete (QSqlRecord *buf) |
void | cursorChanged (QSql::Op mode) |
Métodos públicos | |
QDataTable (QWidget *parent=0, const char *name=0) | |
QDataTable (QSqlCursor *cursor, bool autoPopulate=FALSE, QWidget *parent=0, const char *name=0) | |
~QDataTable () | |
virtual void | addColumn (const QString &fieldName, const QString &label=QString::null, int width=-1, const QIconSet &iconset=QIconSet()) |
virtual void | removeColumn (uint col) |
virtual void | setColumn (uint col, const QString &fieldName, const QString &label=QString::null, int width=-1, const QIconSet &iconset=QIconSet()) |
QString | nullText () const |
QString | trueText () const |
QString | falseText () const |
DateFormat | dateFormat () const |
bool | confirmEdits () const |
bool | confirmInsert () const |
bool | confirmUpdate () const |
bool | confirmDelete () const |
bool | confirmCancels () const |
bool | autoDelete () const |
bool | autoEdit () const |
QString | filter () const |
QStringList | sort () const |
virtual void | setSqlCursor (QSqlCursor *cursor=0, bool autoPopulate=FALSE, bool autoDelete=FALSE) |
QSqlCursor * | sqlCursor () const |
virtual void | setNullText (const QString &nullText) |
virtual void | setTrueText (const QString &trueText) |
virtual void | setFalseText (const QString &falseText) |
virtual void | setDateFormat (const DateFormat f) |
virtual void | setConfirmEdits (bool confirm) |
virtual void | setConfirmInsert (bool confirm) |
virtual void | setConfirmUpdate (bool confirm) |
virtual void | setConfirmDelete (bool confirm) |
virtual void | setConfirmCancels (bool confirm) |
virtual void | setAutoDelete (bool enable) |
virtual void | setAutoEdit (bool autoEdit) |
virtual void | setFilter (const QString &filter) |
virtual void | setSort (const QStringList &sort) |
virtual void | setSort (const QSqlIndex &sort) |
void | refresh (Refresh mode) |
void | sortColumn (int col, bool ascending=TRUE, bool wholeRows=FALSE) |
QString | text (int row, int col) const |
QVariant | value (int row, int col) const |
QSqlRecord * | currentRecord () const |
void | installEditorFactory (QSqlEditorFactory *f) |
void | installPropertyMap (QSqlPropertyMap *m) |
int | numCols () const |
int | numRows () const |
void | setNumCols (int c) |
void | setNumRows (int r) |
bool | findBuffer (const QSqlIndex &idx, int atHint=0) |
void | hideColumn (int col) |
void | showColumn (int col) |
QDataTable (QWidget *parent=0, const char *name=0) | |
QDataTable (QSqlCursor *cursor, bool autoPopulate=FALSE, QWidget *parent=0, const char *name=0) | |
~QDataTable () | |
virtual void | addColumn (const QString &fieldName, const QString &label=QString::null, int width=-1, const QIconSet &iconset=QIconSet()) |
virtual void | removeColumn (uint col) |
virtual void | setColumn (uint col, const QString &fieldName, const QString &label=QString::null, int width=-1, const QIconSet &iconset=QIconSet()) |
QString | nullText () const |
QString | trueText () const |
QString | falseText () const |
DateFormat | dateFormat () const |
bool | confirmEdits () const |
bool | confirmInsert () const |
bool | confirmUpdate () const |
bool | confirmDelete () const |
bool | confirmCancels () const |
bool | autoDelete () const |
bool | autoEdit () const |
QString | filter () const |
QStringList | sort () const |
virtual void | setSqlCursor (QSqlCursor *cursor=0, bool autoPopulate=FALSE, bool autoDelete=FALSE) |
QSqlCursor * | sqlCursor () const |
virtual void | setNullText (const QString &nullText) |
virtual void | setTrueText (const QString &trueText) |
virtual void | setFalseText (const QString &falseText) |
virtual void | setDateFormat (const DateFormat f) |
virtual void | setConfirmEdits (bool confirm) |
virtual void | setConfirmInsert (bool confirm) |
virtual void | setConfirmUpdate (bool confirm) |
virtual void | setConfirmDelete (bool confirm) |
virtual void | setConfirmCancels (bool confirm) |
virtual void | setAutoDelete (bool enable) |
virtual void | setAutoEdit (bool autoEdit) |
virtual void | setFilter (const QString &filter) |
virtual void | setSort (const QStringList &sort) |
virtual void | setSort (const QSqlIndex &sort) |
void | refresh (Refresh mode) |
void | sortColumn (int col, bool ascending=TRUE, bool wholeRows=FALSE) |
QString | text (int row, int col) const |
QVariant | value (int row, int col) const |
QSqlRecord * | currentRecord () const |
void | installEditorFactory (QSqlEditorFactory *f) |
void | installPropertyMap (QSqlPropertyMap *m) |
int | numCols () const |
int | numRows () const |
void | setNumCols (int c) |
void | setNumRows (int r) |
bool | findBuffer (const QSqlIndex &idx, int atHint=0) |
void | hideColumn (int col) |
void | showColumn (int col) |
Métodos protegidos | |
virtual bool | insertCurrent () |
virtual bool | updateCurrent () |
virtual bool | deleteCurrent () |
virtual QSql::Confirm | confirmEdit (QSql::Op m) |
virtual QSql::Confirm | confirmCancel (QSql::Op m) |
virtual void | handleError (const QSqlError &e) |
virtual bool | beginInsert () |
virtual QWidget * | beginUpdate (int row, int col, bool replace) |
bool | eventFilter (QObject *o, QEvent *e) |
void | keyPressEvent (QKeyEvent *) |
void | resizeEvent (QResizeEvent *) |
void | contentsMousePressEvent (QMouseEvent *e) |
void | contentsContextMenuEvent (QContextMenuEvent *e) |
void | endEdit (int row, int col, bool accept, bool replace) |
QWidget * | createEditor (int row, int col, bool initFromCell) const |
void | activateNextCell () |
int | indexOf (uint i) const |
void | reset () |
void | setSize (QSqlCursor *sql) |
void | repaintCell (int row, int col) |
void | paintCell (QPainter *p, int row, int col, const QRect &cr, bool selected, const QColorGroup &cg) |
virtual void | paintField (QPainter *p, const QSqlField *field, const QRect &cr, bool selected) |
void | drawContents (QPainter *p, int cx, int cy, int cw, int ch) |
virtual int | fieldAlignment (const QSqlField *field) |
void | columnClicked (int col) |
void | resizeData (int len) |
QTableItem * | item (int row, int col) const |
void | setItem (int row, int col, QTableItem *item) |
void | clearCell (int row, int col) |
void | setPixmap (int row, int col, const QPixmap &pix) |
void | takeItem (QTableItem *i) |
virtual bool | insertCurrent () |
virtual bool | updateCurrent () |
virtual bool | deleteCurrent () |
virtual QSql::Confirm | confirmEdit (QSql::Op m) |
virtual QSql::Confirm | confirmCancel (QSql::Op m) |
virtual void | handleError (const QSqlError &e) |
virtual bool | beginInsert () |
virtual QWidget * | beginUpdate (int row, int col, bool replace) |
bool | eventFilter (QObject *o, QEvent *e) |
void | keyPressEvent (QKeyEvent *) |
void | resizeEvent (QResizeEvent *) |
void | contentsMousePressEvent (QMouseEvent *e) |
void | contentsContextMenuEvent (QContextMenuEvent *e) |
void | endEdit (int row, int col, bool accept, bool replace) |
QWidget * | createEditor (int row, int col, bool initFromCell) const |
void | activateNextCell () |
int | indexOf (uint i) const |
void | reset () |
void | setSize (QSqlCursor *sql) |
void | repaintCell (int row, int col) |
void | paintCell (QPainter *p, int row, int col, const QRect &cr, bool selected, const QColorGroup &cg) |
virtual void | paintField (QPainter *p, const QSqlField *field, const QRect &cr, bool selected) |
void | drawContents (QPainter *p, int cx, int cy, int cw, int ch) |
virtual int | fieldAlignment (const QSqlField *field) |
void | columnClicked (int col) |
void | resizeData (int len) |
QTableItem * | item (int row, int col) const |
void | setItem (int row, int col, QTableItem *item) |
void | clearCell (int row, int col) |
void | setPixmap (int row, int col, const QPixmap &pix) |
void | takeItem (QTableItem *i) |
Propiedades | |
QString | nullText |
the text used to represent NULL values | |
QString | trueText |
the text used to represent true values | |
QString | falseText |
the text used to represent false values | |
DateFormat | dateFormat |
the format used for displaying date/time values | |
bool | confirmEdits |
whether the data table confirms edit operations | |
bool | confirmInsert |
whether the data table confirms insert operations | |
bool | confirmUpdate |
whether the data table confirms update operations | |
bool | confirmDelete |
whether the data table confirms delete operations | |
bool | confirmCancels |
whether the data table confirms cancel operations | |
bool | autoEdit |
whether the data table automatically applies edits | |
QString | filter |
the data filter for the data table | |
QStringList | sort |
the data table's sort | |
int | numCols |
the number of columns in the table | |
int | numRows |
the number of rows in the table |
The QDataTable class provides a flexible SQL table widget that supports browsing and editing.
sql
QDataTable supports various functions for presenting and editing SQL data from a QSqlCursor in a table.
If you want a to present your data in a form use QDataBrowser, or for read-only forms, QDataView.
When displaying data, QDataTable only retrieves data for visible rows. If the driver supports the 'query size' property the QDataTable will have the correct number of rows and the vertical scrollbar will accurately reflect the number of rows displayed in proportion to the number of rows in the dataset. If the driver does not support the 'query size' property, rows are dynamically fetched from the database on an as-needed basis with the scrollbar becoming more accurate as the user scrolls down through the records. This allows extremely large queries to be displayed as quickly as possible, with minimum memory usage.
QDataTable inherits QTable's API and extends it with functions to sort and filter the data and sort columns. See setSqlCursor(), setFilter(), setSort(), setSorting(), sortColumn() and refresh().
When displaying editable cursors, cell editing will be enabled. (For more information on editable cursors, see QSqlCursor). QDataTable can be used to modify existing data and to add new records. When a user makes changes to a field in the table, the cursor's edit buffer is used. The table will not send changes in the edit buffer to the database until the user moves to a different record in the grid or presses Enter. Cell editing is initiated by pressing F2 (or right clicking and then clicking the appropriate popup menu item) and canceled by pressing Esc. If there is a problem updating or adding data, errors are handled automatically (see handleError() to change this behavior). Note that if autoEdit() is FALSE navigating to another record will cancel the insert or update.
The user can be asked to confirm all edits with setConfirmEdits(). For more precise control use setConfirmInsert(), setConfirmUpdate(), setConfirmDelete() and setConfirmCancels(). Use setAutoEdit() to control the behaviour of the table when the user edits a record and then navigates. (Note that setAutoDelete() is unrelated; it is used to set whether the QSqlCursor is deleted when the table is deleted.)
Since the data table can perform edits, it must be able to uniquely identify every record so that edits are correctly applied. Because of this the underlying cursor must have a valid primary index to ensure that a unique record is inserted, updated or deleted within the database otherwise the database may be changed to an inconsistent state.
QDataTable creates editors using the default QSqlEditorFactory. Different editor factories can be used by calling installEditorFactory(). A property map is used to map between the cell's value and the editor. You can use your own property map with installPropertyMap().
The contents of a cell is available as a QString with text() or as a QVariant with value(). The current record is returned by currentRecord(). Use the find() function to search for a string in the table.
Editing actions can be applied programatically. For example, the insertCurrent() function reads the fields from the current record into the cursor and performs the insert. The updateCurrent() and deleteCurrent() functions perform similarly to update and delete the current record respectively.
Columns in the table can be created automatically based on the cursor (see setSqlCursor()). Columns can be manipulated manually using addColumn(), removeColumn() and setColumn().
The table automatically copies many of the properties of the cursor to format the display of data within cells (alignment, visibility, etc.). The cursor can be changed with setSqlCursor(). The filter (see setFilter()) and sort defined within the table are used instead of the filter and sort set on the cursor. For sorting options see setSort(), sortColumn(), sortAscending() and sortDescending(). Note that sorting operations will not behave as expected if you are using a QSqlSelectCursor because it uses user-defined SQL queries to obtain data.
The text used to represent NULL, TRUE and FALSE values can be changed with setNullText(), setTrueText() and setFalseText() respectively. You can change the appearance of cells by reimplementing paintField().
Whenever a new row is selected in the table the currentChanged() signal is emitted. The primeInsert() signal is emitted when an insert is initiated. The primeUpdate() and primeDelete() signals are emitted when update and deletion are initiated respectively. Just before the database is updated a signal is emitted; beforeInsert(), beforeUpdate() or beforeDelete() as appropriate.
enum QDataTable::Refresh |
This enum describes the refresh options.
RefreshData refresh the data, i.e. read it from the database RefreshColumns refresh the list of fields, e.g. the column headings RefreshAll refresh both the data and the list of fields
enum QDataTable::Refresh |
QDataTable::QDataTable | ( | QWidget * | parent = 0 , |
const char * | name = 0 |
||
) |
Constructs a data table which is a child of parent, called name name.
QDataTable::QDataTable | ( | QSqlCursor * | cursor, |
bool | autoPopulate = FALSE , |
||
QWidget * | parent = 0 , |
||
const char * | name = 0 |
||
) |
Constructs a data table which is a child of parent, called name name using the cursor cursor.
If autoPopulate is TRUE (the default is FALSE), columns are automatically created based upon the fields in the cursor record. Note that autoPopulate only governs the creation of columns; to load the cursor's data into the table use refresh().
If the cursor is read-only, the table also becomes read-only. In addition, the table adopts the cursor's driver's definition for representing NULL values as strings.
QDataTable::~QDataTable | ( | ) |
Destroys the object and frees any allocated resources.
QDataTable::QDataTable | ( | QWidget * | parent = 0 , |
const char * | name = 0 |
||
) |
QDataTable::QDataTable | ( | QSqlCursor * | cursor, |
bool | autoPopulate = FALSE , |
||
QWidget * | parent = 0 , |
||
const char * | name = 0 |
||
) |
QDataTable::~QDataTable | ( | ) |
void QDataTable::activateNextCell | ( | ) | [protected, virtual] |
Reimplementado de QTable.
void QDataTable::activateNextCell | ( | ) | [protected, virtual] |
This function is called to activate the next cell if in-place editing was finished by pressing the Enter key.
The default behaviour is to move from top to bottom, i.e. move to the cell beneath the cell being edited. Reimplement this function if you want different behaviour, e.g. moving from left to right.
Reimplementado de QTable.
void QDataTable::addColumn | ( | const QString & | fieldName, |
const QString & | label = QString::null , |
||
int | width = -1 , |
||
const QIconSet & | iconset = QIconSet() |
||
) | [virtual] |
Adds the next column to be displayed using the field fieldName, column label label, width width and iconset iconset.
If label is specified, it is used as the column's header label, otherwise the field's display label is used when setSqlCursor() is called. The iconset is used to set the icon used by the column header; by default there is no icon.
virtual void QDataTable::addColumn | ( | const QString & | fieldName, |
const QString & | label = QString::null , |
||
int | width = -1 , |
||
const QIconSet & | iconset = QIconSet() |
||
) | [virtual] |
void QDataTable::adjustColumn | ( | int | col | ) | [virtual, slot] |
Resizes column col so that the column width is wide enough to display the widest item the column contains.
Reimplementado de QTable.
void QDataTable::adjustColumn | ( | int | col | ) | [virtual, slot] |
Resizes column col so that the column width is wide enough to display the widest item the column contains (including the column label). If the table's QSqlCursor is not currently active, the cursor will be refreshed before the column width is calculated. Be aware that this function may be slow on tables that contain large result sets.
Reimplementado de QTable.
bool QDataTable::autoDelete | ( | ) | const |
bool QDataTable::autoDelete | ( | ) | const |
Returns TRUE if the table will automatically delete the cursor specified by setSqlCursor(); otherwise returns FALSE.
bool QDataTable::autoEdit | ( | ) | const |
bool QDataTable::autoEdit | ( | ) | const |
void QDataTable::beforeDelete | ( | QSqlRecord * | buf | ) | [signal] |
void QDataTable::beforeDelete | ( | QSqlRecord * | buf | ) | [signal] |
This signal is emitted just before the currently selected record is deleted from the database. The buf parameter points to the edit buffer being deleted. Connect to this signal to, for example, copy some of the fields for later use.
void QDataTable::beforeInsert | ( | QSqlRecord * | buf | ) | [signal] |
void QDataTable::beforeInsert | ( | QSqlRecord * | buf | ) | [signal] |
This signal is emitted just before the cursor's edit buffer is inserted into the database. The buf parameter points to the edit buffer being inserted. Connect to this signal to, for example, populate a key field with a unique sequence number.
void QDataTable::beforeUpdate | ( | QSqlRecord * | buf | ) | [signal] |
void QDataTable::beforeUpdate | ( | QSqlRecord * | buf | ) | [signal] |
This signal is emitted just before the cursor's edit buffer is updated in the database. The buf parameter points to the edit buffer being updated. Connect to this signal when you want to transform the user's data behind-the-scenes.
bool QDataTable::beginInsert | ( | ) | [protected, virtual] |
Protected virtual function called when editing is about to begin on a new record. If the table is read-only, or if there's no cursor or the cursor does not allow inserts, nothing happens.
Editing takes place using the cursor's edit buffer(see QSqlCursor::editBuffer()).
When editing begins, a new row is created in the table marked with an asterisk '*' in the row's vertical header column, i.e. at the left of the row.
virtual bool QDataTable::beginInsert | ( | ) | [protected, virtual] |
Protected virtual function called when editing is about to begin on an existing row. If the table is read-only, or if there's no cursor, nothing happens.
Editing takes place using the cursor's edit buffer (see QSqlCursor::editBuffer()).
row and col refer to the row and column in the QDataTable.
(replace is provided for reimplementors and reflects the API of QTable::beginEdit().)
Removes the QTableItem at row, col.
If you don't use {QTableItem}s you may need to reimplement this function: see the notes on large tables.
Reimplementado de QTable.
void QDataTable::columnClicked | ( | int | col | ) | [protected, virtual] |
QSql::Confirm QDataTable::confirmCancel | ( | QSql::Op | m | ) | [protected, virtual] |
Protected virtual function which returns a confirmation for cancelling an edit mode of m. Derived classes can reimplement this function to provide their own cancel dialog. The default implementation uses a message box which prompts the user to confirm the cancel.
virtual QSql::Confirm QDataTable::confirmCancel | ( | QSql::Op | m | ) | [protected, virtual] |
bool QDataTable::confirmCancels | ( | ) | const |
bool QDataTable::confirmCancels | ( | ) | const |
bool QDataTable::confirmDelete | ( | ) | const |
bool QDataTable::confirmDelete | ( | ) | const |
QSql::Confirm QDataTable::confirmEdit | ( | QSql::Op | m | ) | [protected, virtual] |
Protected virtual function which returns a confirmation for an edit of mode m. Derived classes can reimplement this function to provide their own confirmation dialog. The default implementation uses a message box which prompts the user to confirm the edit action.
virtual QSql::Confirm QDataTable::confirmEdit | ( | QSql::Op | m | ) | [protected, virtual] |
bool QDataTable::confirmEdits | ( | ) | const |
bool QDataTable::confirmEdits | ( | ) | const |
bool QDataTable::confirmInsert | ( | ) | const |
bool QDataTable::confirmInsert | ( | ) | const |
bool QDataTable::confirmUpdate | ( | ) | const |
bool QDataTable::confirmUpdate | ( | ) | const |
void QDataTable::contentsContextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
Reimplementado de QTable.
Reimplementado en FLDataTable.
void QDataTable::contentsContextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
Reimplementado de QTable.
Reimplementado en FLDataTable.
void QDataTable::contentsMousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QTable.
void QDataTable::contentsMousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QTable.
QWidget * QDataTable::createEditor | ( | int | row, |
int | col, | ||
bool | initFromCell | ||
) | const [protected, virtual] |
For an editable table, creates an editor suitable for the field in column col. The editor is created using the default editor factory, unless a different editor factory was installed with installEditorFactory(). The editor is primed with the value of the field in col using a property map. The property map used is the default property map, unless a new property map was installed with installPropertMap(). If initFromCell is TRUE then the editor is primed with the value in the QDataTable cell.
Reimplementado de QTable.
QWidget* QDataTable::createEditor | ( | int | row, |
int | col, | ||
bool | initFromCell | ||
) | const [protected, virtual] |
This function returns the widget which should be used as an editor for the contents of the cell at row, col.
If initFromCell is TRUE, the editor is used to edit the current contents of the cell (so the editor widget should be initialized with this content). If initFromCell is FALSE, the content of the cell is replaced with the new content which the user entered into the widget created by this function.
The default functionality is as follows: if initFromCell is TRUE or the cell has a QTableItem and the table item's QTableItem::isReplaceable() is FALSE then the cell is asked to create an appropriate editor (using QTableItem::createEditor()). Otherwise a QLineEdit is used as the editor.
If you want to create your own editor for certain cells, implement a custom QTableItem subclass and reimplement QTableItem::createEditor().
If you are not using {QTableItem}s and you don't want to use a QLineEdit as the default editor, subclass QTable and reimplement this function with code like this:
QTableItem *i = item( row, col ); if ( initFromCell || ( i && !i->isReplaceable() ) ) // If we had a QTableItem ask the base class to create the editor return QTable::createEditor( row, col, initFromCell ); else return ...(create your own editor)
Ownership of the editor widget is transferred to the caller.
If you reimplement this function return 0 for read-only cells. You will need to reimplement setCellContentFromEditor() to retrieve the data the user entered.
Reimplementado de QTable.
void QDataTable::currentChanged | ( | QSqlRecord * | record | ) | [signal] |
void QDataTable::currentChanged | ( | QSqlRecord * | record | ) | [signal] |
This signal is emitted whenever a new row is selected in the table. The record parameter points to the contents of the newly selected record.
QSqlRecord* QDataTable::currentRecord | ( | ) | const |
QSqlRecord * QDataTable::currentRecord | ( | ) | const |
Returns the currently selected record, or 0 if there is no current selection. The table owns the pointer, so do not delete it or otherwise modify it or the cursor it points to.
void QDataTable::cursorChanged | ( | QSql::Op | mode | ) | [signal] |
void QDataTable::cursorChanged | ( | QSql::Op | mode | ) | [signal] |
This signal is emitted whenever the cursor record was changed due to an edit. The mode parameter is the type of edit that just took place.
DateFormat QDataTable::dateFormat | ( | ) | const |
DateFormat QDataTable::dateFormat | ( | ) | const |
bool QDataTable::deleteCurrent | ( | ) | [protected, virtual] |
For an editable table, issues a delete on the current cursor's primary index using the values of the currently selected row. If there is no current cursor or there is no current selection, nothing happens. If confirmEdits() or confirmDelete() is TRUE, confirmEdit() is called to confirm the delete. Returns TRUE if the delete succeeded; otherwise FALSE.
The underlying cursor must have a valid primary index to ensure that a unique record is deleted within the database otherwise the database may be changed to an inconsistent state.
virtual bool QDataTable::deleteCurrent | ( | ) | [protected, virtual] |
Reimplementado de QTable.
Draws the table contents on the painter p. This function is optimized so that it only draws the cells inside the cw pixels wide and ch pixels high clipping rectangle at position cx, cy.
Additionally, drawContents() highlights the current cell.
Reimplementado de QTable.
Reimplementado de QTable.
This function is called when in-place editing of the cell at row, col is requested to stop.
If the cell is not being edited or accept is FALSE the function returns and the cell's contents are left unchanged.
If accept is TRUE the content of the editor must be transferred to the relevant cell. If replace is TRUE the current content of this cell should be replaced by the content of the editor (this means removing the current QTableItem of the cell and creating a new one for the cell). Otherwise (if possible) the content of the editor should just be set to the existing QTableItem of this cell.
setCellContentFromEditor() is called to replace the contents of the cell with the contents of the cell's editor.
Finally clearCellWidget() is called to remove the editor widget.
Reimplementado de QTable.
Reimplementado de QTable.
Reimplementado en FLDataTable.
Reimplementado de QTable.
Reimplementado en FLDataTable.
QString QDataTable::falseText | ( | ) | const |
QString QDataTable::falseText | ( | ) | const |
Returns the alignment for field.
QString QDataTable::filter | ( | ) | const |
QString QDataTable::filter | ( | ) | const |
virtual void QDataTable::find | ( | const QString & | str, |
bool | caseSensitive, | ||
bool | backwards | ||
) | [virtual, slot] |
Searches the current cursor for a cell containing the string str starting at the current cell and working forwards (or backwards if backwards is TRUE). If the string is found, the cell containing the string is set as the current cell. If caseSensitive is FALSE the case of str will be ignored.
The search will wrap, i.e. if the first (or if backwards is TRUE, last) cell is reached without finding str the search will continue until it reaches the starting cell. If str is not found the search will fail and the current cell will remain unchanged.
Selects the record in the table using the current cursor edit buffer and the fields specified by the index idx. If atHint is specified, it will be used as a hint about where to begin searching.
void QDataTable::handleError | ( | const QSqlError & | e | ) | [protected, virtual] |
Protected virtual function which is called when an error e has occurred on the current cursor(). The default implementation displays a warning message to the user with information about the error.
Reimplementado en FLDataTable.
virtual void QDataTable::handleError | ( | const QSqlError & | e | ) | [protected, virtual] |
Reimplementado en FLDataTable.
void QDataTable::hideColumn | ( | int | col | ) | [virtual] |
Returns the index of the field within the current SQL query that is displayed in column i.
Reimplementado en FLDataTable.
Reimplementado en FLDataTable.
virtual bool QDataTable::insertCurrent | ( | ) | [protected, virtual] |
bool QDataTable::insertCurrent | ( | ) | [protected, virtual] |
For an editable table, issues an insert on the current cursor using the values in the cursor's edit buffer. If there is no current cursor or there is no current "insert" row, nothing happens. If confirmEdits() or confirmInsert() is TRUE, confirmEdit() is called to confirm the insert. Returns TRUE if the insert succeeded; otherwise returns FALSE.
The underlying cursor must have a valid primary index to ensure that a unique record is inserted within the database otherwise the database may be changed to an inconsistent state.
void QDataTable::installEditorFactory | ( | QSqlEditorFactory * | f | ) |
void QDataTable::installEditorFactory | ( | QSqlEditorFactory * | f | ) |
Installs a new SQL editor factory f. This enables the user to create and instantiate their own editors for use in cell editing. Note that QDataTable takes ownership of this pointer, and will delete it when it is no longer needed or when installEditorFactory() is called again.
void QDataTable::installPropertyMap | ( | QSqlPropertyMap * | m | ) |
void QDataTable::installPropertyMap | ( | QSqlPropertyMap * | m | ) |
Installs a new property map m. This enables the user to create and instantiate their own property maps for use in cell editing. Note that QDataTable takes ownership of this pointer, and will delete it when it is no longer needed or when installPropertMap() is called again.
QTableItem* QDataTable::item | ( | int | row, |
int | col | ||
) | const [protected, virtual] |
Returns the QTableItem representing the contents of the cell at row, col.
If row or col are out of range or no content has been set for this cell, item() returns 0.
If you don't use {QTableItem}s you may need to reimplement this function: see the notes on large tables.
Reimplementado de QTable.
QTableItem * QDataTable::item | ( | int | row, |
int | col | ||
) | const [protected, virtual] |
Reimplementado de QTable.
QString QDataTable::nullText | ( | ) | const |
QString QDataTable::nullText | ( | ) | const |
void QDataTable::paintCell | ( | QPainter * | p, |
int | row, | ||
int | col, | ||
const QRect & | cr, | ||
bool | selected, | ||
const QColorGroup & | cg | ||
) | [protected, virtual] |
This function renders the cell at row, col with the value of the corresponding cursor field on the painter p. Depending on the table's current edit mode, paintField() is called for the appropriate cursor field. cr describes the cell coordinates in the content coordinate system. If selected is TRUE the cell has been selected and would normally be rendered differently than an unselected cell.
Reimplementado de QTable.
Reimplementado en FLDataTable.
void QDataTable::paintCell | ( | QPainter * | p, |
int | row, | ||
int | col, | ||
const QRect & | cr, | ||
bool | selected, | ||
const QColorGroup & | cg | ||
) | [protected, virtual] |
Paints the cell at row, col on the painter p. The painter has already been translated to the cell's origin. cr describes the cell coordinates in the content coordinate system.
If selected is TRUE the cell is highlighted.
cg is the colorgroup which should be used to draw the cell content.
If you want to draw custom cell content, for example right-aligned text, you must either reimplement paintCell(), or subclass QTableItem and reimplement QTableItem::paint() to do the custom drawing.
If you're using a QTableItem subclass, for example, to store a data structure, then reimplementing QTableItem::paint() may be the best approach. For data you want to draw immediately, e.g. data retrieved from a database, it is probably best to reimplement paintCell(). Note that if you reimplement paintCell(), i.e. don't use {QTableItem}s, you must reimplement other functions: see the notes on large tables.
Note that the painter is not clipped by default in order to get maximum efficiency. If you want clipping, use code like this:
p->setClipRect( cellRect(row, col), QPainter::CoordPainter ); //... your drawing code p->setClipping( FALSE );
Reimplementado de QTable.
Reimplementado en FLDataTable.
virtual void QDataTable::paintField | ( | QPainter * | p, |
const QSqlField * | field, | ||
const QRect & | cr, | ||
bool | selected | ||
) | [protected, virtual] |
Reimplementado en FLDataTable.
void QDataTable::paintField | ( | QPainter * | p, |
const QSqlField * | field, | ||
const QRect & | cr, | ||
bool | selected | ||
) | [protected, virtual] |
Paints the field on the painter p. The painter has already been translated to the appropriate cell's origin where the field is to be rendered. cr describes the cell coordinates in the content coordinate system. The selected parameter is ignored.
If you want to draw custom field content you must reimplement paintField() to do the custom drawing. The default implementation renders the field value as text. If the field is NULL, nullText() is displayed in the cell. If the field is Boolean, trueText() or falseText() is displayed as appropriate.
Reimplementado en FLDataTable.
void QDataTable::primeDelete | ( | QSqlRecord * | buf | ) | [signal] |
void QDataTable::primeDelete | ( | QSqlRecord * | buf | ) | [signal] |
This signal is emitted after the cursor is primed for delete by the table, when a delete action is beginning on the table. The buf parameter points to the edit buffer being deleted. Connect to this signal in order to, for example, record auditing information on deletions.
void QDataTable::primeInsert | ( | QSqlRecord * | buf | ) | [signal] |
void QDataTable::primeInsert | ( | QSqlRecord * | buf | ) | [signal] |
This signal is emitted after the cursor is primed for insert by the table, when an insert action is beginning on the table. The buf parameter points to the edit buffer being inserted. Connect to this signal in order to, for example, prime the record buffer with default data values.
void QDataTable::primeUpdate | ( | QSqlRecord * | buf | ) | [signal] |
void QDataTable::primeUpdate | ( | QSqlRecord * | buf | ) | [signal] |
This signal is emitted after the cursor is primed for update by the table, when an update action is beginning on the table. The buf parameter points to the edit buffer being updated. Connect to this signal in order to, for example, provide some visual feedback that the user is in 'edit mode'.
virtual void QDataTable::refresh | ( | ) | [virtual, slot] |
Reimplementado en FLDataTable.
void QDataTable::refresh | ( | QDataTable::Refresh | mode | ) |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.
Refreshes the table. If there is no currently defined cursor (see setSqlCursor()), nothing happens. The mode parameter determines which type of refresh will take place.
void QDataTable::refresh | ( | ) | [virtual, slot] |
Refreshes the table. The cursor is refreshed using the current filter, the current sort, and the currently defined columns. Equivalent to calling refresh( QDataTable::RefreshData ).
Reimplementado en FLDataTable.
void QDataTable::refresh | ( | Refresh | mode | ) |
void QDataTable::removeColumn | ( | uint | col | ) | [virtual] |
Removes column col from the list of columns to be displayed. If col does not exist, nothing happens.
virtual void QDataTable::removeColumn | ( | uint | col | ) | [virtual] |
Repaints the cell at row, col.
Reimplementado de QTable.
void QDataTable::reset | ( | ) | [protected] |
void QDataTable::reset | ( | void | ) | [protected] |
Resets the table so that it displays no data.
void QDataTable::resizeData | ( | int | len | ) | [protected, virtual] |
This is called when QTable's internal array needs to be resized to len elements.
If you don't use QTableItems you should reimplement this as an empty method to avoid wasting memory. See the notes on large tables for further details.
Reimplementado de QTable.
void QDataTable::resizeEvent | ( | QResizeEvent * | e | ) | [protected, virtual] |
Reimplementado de QScrollView.
void QDataTable::resizeEvent | ( | QResizeEvent * | event | ) | [protected, virtual] |
Reimplementado de QScrollView.
void QDataTable::setAutoDelete | ( | bool | enable | ) | [virtual] |
Sets the cursor auto-delete flag to enable. If enable is TRUE, the table will automatically delete the cursor specified by setSqlCursor(). If enable is FALSE (the default), the cursor will not be deleted.
virtual void QDataTable::setAutoDelete | ( | bool | enable | ) | [virtual] |
void QDataTable::setAutoEdit | ( | bool | autoEdit | ) | [virtual] |
virtual void QDataTable::setAutoEdit | ( | bool | autoEdit | ) | [virtual] |
virtual void QDataTable::setColumn | ( | uint | col, |
const QString & | fieldName, | ||
const QString & | label = QString::null , |
||
int | width = -1 , |
||
const QIconSet & | iconset = QIconSet() |
||
) | [virtual] |
void QDataTable::setColumn | ( | uint | col, |
const QString & | fieldName, | ||
const QString & | label = QString::null , |
||
int | width = -1 , |
||
const QIconSet & | iconset = QIconSet() |
||
) | [virtual] |
Sets the col column to display using the field fieldName, column label label, width width and iconset iconset.
If label is specified, it is used as the column's header label, otherwise the field's display label is used when setSqlCursor() is called. The iconset is used to set the icon used by the column header; by default there is no icon.
If stretch is TRUE, column col is set to be stretchable; otherwise column col is set to be unstretchable.
If the table widget's width decreases or increases stretchable columns will grow narrower or wider to fit the space available as completely as possible. The user cannot manually resize stretchable columns.
Reimplementado de QTable.
Resizes column col to be w pixels wide.
Reimplementado de QTable.
Sets the column col to the width w. Note that unlike QTable the QDataTable is not immediately redrawn, you must call refresh(QDataTable::RefreshColumns) yourself.
Reimplementado de QTable.
virtual void QDataTable::setConfirmCancels | ( | bool | confirm | ) | [virtual] |
void QDataTable::setConfirmCancels | ( | bool | confirm | ) | [virtual] |
virtual void QDataTable::setConfirmDelete | ( | bool | confirm | ) | [virtual] |
void QDataTable::setConfirmDelete | ( | bool | confirm | ) | [virtual] |
void QDataTable::setConfirmEdits | ( | bool | confirm | ) | [virtual] |
virtual void QDataTable::setConfirmEdits | ( | bool | confirm | ) | [virtual] |
virtual void QDataTable::setConfirmInsert | ( | bool | confirm | ) | [virtual] |
void QDataTable::setConfirmInsert | ( | bool | confirm | ) | [virtual] |
virtual void QDataTable::setConfirmUpdate | ( | bool | confirm | ) | [virtual] |
void QDataTable::setConfirmUpdate | ( | bool | confirm | ) | [virtual] |
void QDataTable::setDateFormat | ( | const DateFormat | f | ) | [virtual] |
virtual void QDataTable::setDateFormat | ( | const DateFormat | f | ) | [virtual] |
virtual void QDataTable::setFalseText | ( | const QString & | falseText | ) | [virtual] |
void QDataTable::setFalseText | ( | const QString & | falseText | ) | [virtual] |
void QDataTable::setFilter | ( | const QString & | filter | ) | [virtual] |
virtual void QDataTable::setFilter | ( | const QString & | filter | ) | [virtual] |
void QDataTable::setItem | ( | int | row, |
int | col, | ||
QTableItem * | item | ||
) | [protected, virtual] |
Inserts the table item item into the table at row row, column col, and repaints the cell. If a table item already exists in this cell it is deleted and replaced with item. The table takes ownership of the table item.
If you don't use {QTableItem}s you may need to reimplement this function: see the notes on large tables.
Reimplementado de QTable.
void QDataTable::setItem | ( | int | row, |
int | col, | ||
QTableItem * | item | ||
) | [protected, virtual] |
Reimplementado de QTable.
void QDataTable::setNullText | ( | const QString & | nullText | ) | [virtual] |
virtual void QDataTable::setNullText | ( | const QString & | nullText | ) | [virtual] |
void QDataTable::setNumCols | ( | int | r | ) | [virtual] |
The number of columns in the table will be determined automatically (see addColumn()), so normally this function should never be called. It is included for completeness.
Reimplementado de QTable.
void QDataTable::setNumRows | ( | int | r | ) | [virtual] |
The number of rows in the table will be determined by the cursor (see setSqlCursor()), so normally this function should never be called. It is included for completeness.
Reimplementado de QTable.
Reimplementado de QTable.
Sets the pixmap in the cell at row, col to pix.
If the cell does not contain a table item a QTableItem is created with an EditType of OnTyping
, otherwise the existing table item's pixmap (if any) is replaced with pix.
Note that {QComboTableItem}s and {QCheckTableItem}s don't show pixmaps.
Reimplementado de QTable.
void QDataTable::setSize | ( | QSqlCursor * | sql | ) | [protected] |
If the cursor's sql driver supports query sizes, the number of rows in the table is set to the size of the query. Otherwise, the table dynamically resizes itself as it is scrolled. If sql is not active, it is made active by issuing a select() on the cursor using the sql cursor's current filter and current sort.
void QDataTable::setSize | ( | QSqlCursor * | sql | ) | [protected] |
void QDataTable::setSort | ( | const QStringList & | sort | ) | [virtual] |
void QDataTable::setSort | ( | const QSqlIndex & | sort | ) | [virtual] |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Sets the sort to be applied to the displayed data to sort. If there is no current cursor, nothing happens. A QSqlIndex contains field names and their ordering (ASC or DESC); these are used to compose the ORDER BY clause.
virtual void QDataTable::setSort | ( | const QSqlIndex & | sort | ) | [virtual] |
virtual void QDataTable::setSort | ( | const QStringList & | sort | ) | [virtual] |
virtual void QDataTable::setSqlCursor | ( | QSqlCursor * | cursor = 0 , |
bool | autoPopulate = FALSE , |
||
bool | autoDelete = FALSE |
||
) | [virtual] |
void QDataTable::setSqlCursor | ( | QSqlCursor * | cursor = 0 , |
bool | autoPopulate = FALSE , |
||
bool | autoDelete = FALSE |
||
) | [virtual] |
Sets cursor as the data source for the table. To force the display of the data from cursor, use refresh(). If autoPopulate is TRUE, columns are automatically created based upon the fields in the cursor record. If autoDelete is TRUE (the default is FALSE), the table will take ownership of the cursor and delete it when appropriate. If the cursor is read-only, the table becomes read-only. The table adopts the cursor's driver's definition for representing NULL values as strings.
virtual void QDataTable::setTrueText | ( | const QString & | trueText | ) | [virtual] |
void QDataTable::setTrueText | ( | const QString & | trueText | ) | [virtual] |
void QDataTable::showColumn | ( | int | col | ) | [virtual] |
QStringList QDataTable::sort | ( | ) | const |
QStringList QDataTable::sort | ( | ) | const |
void QDataTable::sortAscending | ( | int | col | ) | [virtual, slot] |
Sorts column col in ascending order.
virtual void QDataTable::sortAscending | ( | int | col | ) | [virtual, slot] |
Sorts column col. If ascending is TRUE the sort is in ascending order, otherwise the sort is in descending order.
If wholeRows is TRUE, entire rows are sorted using swapRows(); otherwise only cells in the column are sorted using swapCells().
Note that if you are not using QTableItems you will need to reimplement swapRows() and swapCells(). (See the notes on large tables.)
Reimplementado de QTable.
Sorts column col in ascending order if ascending is TRUE (the default); otherwise sorts in descending order.
The wholeRows parameter is ignored; QDataTable always sorts whole rows by the specified column.
Reimplementado de QTable.
virtual void QDataTable::sortDescending | ( | int | col | ) | [virtual, slot] |
void QDataTable::sortDescending | ( | int | col | ) | [virtual, slot] |
Sorts column col in descending order.
QSqlCursor* QDataTable::sqlCursor | ( | ) | const |
QSqlCursor * QDataTable::sqlCursor | ( | ) | const |
Returns the cursor used by the data table.
Swaps the data in col1 with col2.
This function is used to swap the positions of two columns. It is called when the user changes the order of columns (see setColumnMovingEnabled(), and when columns are sorted.
If you don't use {QTableItem}s and want your users to be able to swap columns you will need to reimplement this function. (See the notes on large tables.)
If swapHeader is TRUE, the columns' header contents is also swapped.
Reimplementado de QTable.
Reimplementado de QTable.
void QDataTable::takeItem | ( | QTableItem * | i | ) | [protected, virtual] |
Reimplementado de QTable.
void QDataTable::takeItem | ( | QTableItem * | i | ) | [protected, virtual] |
Takes the table item i out of the table. This function does not delete the table item. You must either delete the table item yourself or put it into a table (using setItem()) which will then take ownership of it.
Use this function if you want to move an item from one cell in a table to another, or to move an item from one table to another, reinserting the item with setItem().
If you want to exchange two cells use swapCells().
Reimplementado de QTable.
Returns the text in cell row, col, or an empty string if the cell is empty. If the cell's value is NULL then nullText() will be returned. If the cell does not exist then QString::null is returned.
Reimplementado de QTable.
Returns the text in the cell at row, col, or QString::null if the relevant item does not exist or has no text.
Reimplementado de QTable.
QString QDataTable::trueText | ( | ) | const |
QString QDataTable::trueText | ( | ) | const |
virtual bool QDataTable::updateCurrent | ( | ) | [protected, virtual] |
bool QDataTable::updateCurrent | ( | ) | [protected, virtual] |
For an editable table, issues an update using the cursor's edit buffer. If there is no current cursor or there is no current selection, nothing happens. If confirmEdits() or confirmUpdate() is TRUE, confirmEdit() is called to confirm the update. Returns TRUE if the update succeeded; otherwise returns FALSE.
The underlying cursor must have a valid primary index to ensure that a unique record is updated within the database otherwise the database may be changed to an inconsistent state.
Returns the value in cell row, col, or an invalid value if the cell does not exist or has no value.
bool QDataTable::autoEdit [read, write] |
whether the data table automatically applies edits
The default value for this property is TRUE. When the user begins an insert or update in the table there are two possible outcomes when they navigate to another record:
1 the insert or update is is performed -- this occurs if autoEdit is TRUE the insert or update is abandoned -- this occurs if autoEdit is FALSE
bool QDataTable::confirmCancels [read, write] |
whether the data table confirms cancel operations
If the confirmCancel property is TRUE, all cancels must be confirmed by the user through a message box (this behavior can be changed by overriding the confirmCancel() function), otherwise all cancels occur immediately. The default is FALSE.
bool QDataTable::confirmDelete [read, write] |
whether the data table confirms delete operations
If the confirmDelete property is TRUE, all deletions must be confirmed by the user through a message box (this behaviour can be changed by overriding the confirmEdit() function), otherwise all delete operations occur immediately.
bool QDataTable::confirmEdits [read, write] |
whether the data table confirms edit operations
If the confirmEdits property is TRUE, the data table confirms all edit operations (inserts, updates and deletes). Finer control of edit confirmation can be achieved using confirmCancels, confirmInsert, confirmUpdate and confirmDelete.
bool QDataTable::confirmInsert [read, write] |
whether the data table confirms insert operations
If the confirmInsert property is TRUE, all insertions must be confirmed by the user through a message box (this behaviour can be changed by overriding the confirmEdit() function), otherwise all insert operations occur immediately.
bool QDataTable::confirmUpdate [read, write] |
whether the data table confirms update operations
If the confirmUpdate property is TRUE, all updates must be confirmed by the user through a message box (this behaviour can be changed by overriding the confirmEdit() function), otherwise all update operations occur immediately.
DateFormat QDataTable::dateFormat [read, write] |
the format used for displaying date/time values
The dateFormat property is used for displaying date/time values in the table. The default value is Qt::LocalDate
.
QString QDataTable::falseText [read, write] |
the text used to represent false values
The falseText property will be used to represent NULL values in the table. The default value is "False".
QString QDataTable::filter [read, write] |
QString QDataTable::nullText [read, write] |
the text used to represent NULL values
The nullText property will be used to represent NULL values in the table. The default value is provided by the cursor's driver.
QStringList QDataTable::sort [read, write] |
the data table's sort
The table's sort affects the order in which data records are displayed in the table. To apply a sort, use refresh().
When examining the sort property, a string list is returned with each item having the form 'fieldname order' (e.g., 'id ASC', 'surname DESC').
There is no default sort.
Note that if you want to iterate over the sort list, you should iterate over a copy, e.g.
QStringList list = myDataTable.sort(); QStringList::Iterator it = list.begin(); while( it != list.end() ) { myProcessing( *it ); ++it; }
QString QDataTable::trueText [read, write] |
the text used to represent true values
The trueText property will be used to represent NULL values in the table. The default value is "True".