Home · All Classes · All Functions · Overviews

Q3DataTable Class Reference
[Qt3Support module]

The Q3DataTable class provides a flexible SQL table widget that supports browsing and editing. More...

 #include <Q3DataTable>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

This class is not part of the Qt GUI Framework Edition.

Inherits Q3Table.


Public Types

enum Refresh { RefreshData, RefreshColumns, RefreshAll }

Properties


Public Functions

Q3DataTable ( QWidget * parent = 0, const char * name = 0 )
Q3DataTable ( Q3SqlCursor * cursor, bool autoPopulate = false, QWidget * parent = 0, const char * name = 0 )
~Q3DataTable ()
virtual void addColumn ( const QString & fieldName, const QString & label = QString(), int width = -1, const QIconSet & iconset = QIconSet() )
bool autoDelete () const
bool autoEdit () const
bool confirmCancels () const
bool confirmDelete () const
bool confirmEdits () const
bool confirmInsert () const
bool confirmUpdate () const
QSqlRecord * currentRecord () const
Qt::DateFormat dateFormat () const
QString falseText () const
QString filter () const
int indexOf ( uint i ) const
void installEditorFactory ( Q3SqlEditorFactory * f )
void installPropertyMap ( Q3SqlPropertyMap * m )
QString nullText () const
void refresh ( Refresh mode )
virtual void setAutoDelete ( bool enable )
virtual void setAutoEdit ( bool autoEdit )
virtual void setColumn ( uint col, const QString & fieldName, const QString & label = QString(), int width = -1, const QIconSet & iconset = QIconSet() )
virtual void setConfirmCancels ( bool confirm )
virtual void setConfirmDelete ( bool confirm )
virtual void setConfirmEdits ( bool confirm )
virtual void setConfirmInsert ( bool confirm )
virtual void setConfirmUpdate ( bool confirm )
virtual void setDateFormat ( const Qt::DateFormat f )
virtual void setFalseText ( const QString & falseText )
virtual void setFilter ( const QString & filter )
virtual void setNullText ( const QString & nullText )
virtual void setSort ( const QStringList & sort )
virtual void setSort ( const QSqlIndex & sort )
virtual void setSqlCursor ( Q3SqlCursor * cursor = 0, bool autoPopulate = false, bool autoDelete = false )
virtual void setTrueText ( const QString & trueText )
QStringList sort () const
Q3SqlCursor * sqlCursor () const
QString trueText () const
QVariant value ( int row, int col ) const

Reimplemented Public Functions

virtual void hideColumn ( int col )
virtual int numCols () const
virtual int numRows () const
virtual void removeColumn ( int col )
virtual void selectRow ( int row )
virtual void setNumCols ( int r )
virtual void setNumRows ( int r )
virtual void showColumn ( int col )
virtual void sortColumn ( int col, bool ascending = true, bool wholeRows = false )
virtual QString text ( int row, int col ) const

Public Slots

virtual void adjustColumn ( int col )
virtual void find ( const QString & str, bool caseSensitive, bool backwards )
virtual void refresh ()
virtual void setColumnStretchable ( int col, bool s )
virtual void setColumnWidth ( int col, int w )
virtual void sortAscending ( int col )
virtual void sortDescending ( int col )
virtual void swapColumns ( int col1, int col2, bool swapHeaders = false )

Signals

void beforeDelete ( QSqlRecord * buf )
void beforeInsert ( QSqlRecord * buf )
void beforeUpdate ( QSqlRecord * buf )
void currentChanged ( QSqlRecord * record )
void cursorChanged ( QSql::Op mode )
void primeDelete ( QSqlRecord * buf )
void primeInsert ( QSqlRecord * buf )
void primeUpdate ( QSqlRecord * buf )

Protected Functions

virtual bool beginInsert ()
virtual QWidget * beginUpdate ( int row, int col, bool replace )
virtual QSql::Confirm confirmCancel ( QSql::Op m )
virtual QSql::Confirm confirmEdit ( QSql::Op m )
virtual bool deleteCurrent ()
virtual int fieldAlignment ( const QSqlField * field )
virtual void handleError ( const QSqlError & e )
virtual bool insertCurrent ()
virtual void paintField ( QPainter * p, const QSqlField * field, const QRect & cr, bool selected )
void repaintCell ( int row, int col )
void reset ()
void setSize ( Q3SqlCursor * sql )
virtual bool updateCurrent ()

Reimplemented Protected Functions

virtual void activateNextCell ()
virtual void clearCell ( int row, int col )
virtual void columnClicked ( int col )
virtual void contentsContextMenuEvent ( QContextMenuEvent * e )
virtual void contentsMousePressEvent ( QMouseEvent * e )
virtual QWidget * createEditor ( int row, int col, bool initFromCell ) const
virtual void drawContents ( QPainter * p, int cx, int cy, int cw, int ch )
virtual void endEdit ( int row, int col, bool accept, bool replace )
virtual bool eventFilter ( QObject * o, QEvent * e )
virtual Q3TableItem * item ( int row, int col ) const
virtual void keyPressEvent ( QKeyEvent * e )
virtual void paintCell ( QPainter * p, int row, int col, const QRect & cr, bool selected, const QColorGroup & cg )
virtual void resizeData ( int len )
virtual void resizeEvent ( QResizeEvent * e )
virtual void setItem ( int row, int col, Q3TableItem * item )
virtual void setPixmap ( int row, int col, const QPixmap & pix )
virtual void takeItem ( Q3TableItem * i )

Additional Inherited Members


Detailed Description

The Q3DataTable class provides a flexible SQL table widget that supports browsing and editing.

Q3DataTable supports various functions for presenting and editing SQL data from a Q3SqlCursor in a table.

If you want a to present your data in a form use QDataBrowser, or for read-only forms, use QDataView instead.

When displaying data, Q3DataTable only retrieves data for visible rows. If the driver supports the 'query size' property the Q3DataTable will have the correct number of rows and the vertical scroll bar 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 scroll bar 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.

Q3DataTable inherits Q3Table'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 Q3SqlCursor). Q3DataTable 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 behavior of the table when the user edits a record and then navigates. (Note that setAutoDelete() is unrelated; it is used to set whether the Q3SqlCursor 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.

Q3DataTable creates editors using the default Q3SqlEditorFactory. 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 programmatically. 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.


Member Type Documentation

enum Q3DataTable::Refresh

This enum describes the refresh options.

ConstantValueDescription
Q3DataTable::RefreshData1refresh the data, i.e. read it from the database
Q3DataTable::RefreshColumns2refresh the list of fields, e.g. the column headings
Q3DataTable::RefreshAll3refresh both the data and the list of fields


Property Documentation

autoEdit : bool

This property holds 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
  2. the insert or update is abandoned -- this occurs if autoEdit is false

Access functions:

bool autoEdit () const
virtual void setAutoEdit ( bool autoEdit )

confirmCancels : bool

This property holds 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.

Access functions:

bool confirmCancels () const
virtual void setConfirmCancels ( bool confirm )

See also confirmEdits() and confirmCancel().

confirmDelete : bool

This property holds 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 behavior can be changed by overriding the confirmEdit() function), otherwise all delete operations occur immediately.

Access functions:

bool confirmDelete () const
virtual void setConfirmDelete ( bool confirm )

See also confirmCancels(), confirmEdits(), confirmUpdate(), and confirmInsert().

confirmEdits : bool

This property holds 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.

Access functions:

bool confirmEdits () const
virtual void setConfirmEdits ( bool confirm )

See also confirmCancels(), confirmInsert(), confirmUpdate(), and confirmDelete().

confirmInsert : bool

This property holds 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 behavior can be changed by overriding the confirmEdit() function), otherwise all insert operations occur immediately.

Access functions:

bool confirmInsert () const
virtual void setConfirmInsert ( bool confirm )

See also confirmCancels(), confirmEdits(), confirmUpdate(), and confirmDelete().

confirmUpdate : bool

This property holds 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 behavior can be changed by overriding the confirmEdit() function), otherwise all update operations occur immediately.

Access functions:

bool confirmUpdate () const
virtual void setConfirmUpdate ( bool confirm )

See also confirmCancels(), confirmEdits(), confirmInsert(), and confirmDelete().

dateFormat : Qt::DateFormat

This property holds 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.

Access functions:

Qt::DateFormat dateFormat () const
virtual void setDateFormat ( const Qt::DateFormat f )

falseText : QString

This property holds 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".

Access functions:

QString falseText () const
virtual void setFalseText ( const QString & falseText )

filter : QString

This property holds the data filter for the data table.

The filter applies to the data shown in the table. To view data with a new filter, use refresh(). A filter string is an SQL WHERE clause without the WHERE keyword.

There is no default filter.

Access functions:

QString filter () const
virtual void setFilter ( const QString & filter )

See also sort().

nullText : QString

This property holds 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.

Access functions:

QString nullText () const
virtual void setNullText ( const QString & nullText )

numCols : int

This property holds the number of columns in the table.

Access functions:

virtual int numCols () const
virtual void setNumCols ( int r )

numRows : int

This property holds the number of rows in the table.

Access functions:

virtual int numRows () const
virtual void setNumRows ( int r )

sort : QStringList

This property holds 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;
 }

Access functions:

QStringList sort () const
virtual void setSort ( const QStringList & sort )
virtual void setSort ( const QSqlIndex & sort )

See also filter() and refresh().

trueText : QString

This property holds 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".

Access functions:

QString trueText () const
virtual void setTrueText ( const QString & trueText )

Member Function Documentation

Q3DataTable::Q3DataTable ( QWidget * parent = 0, const char * name = 0 )

Constructs a data table which is a child of parent, called name name.

Q3DataTable::Q3DataTable ( Q3SqlCursor * 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.

Q3DataTable::~Q3DataTable ()

Destroys the object and frees any allocated resources.

void Q3DataTable::activateNextCell ()   [virtual protected]

Reimplemented from Q3Table::activateNextCell().

void Q3DataTable::addColumn ( const QString & fieldName, const QString & label = QString(), 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.

See also setSqlCursor() and refresh().

void Q3DataTable::adjustColumn ( int col )   [virtual slot]

Reimplemented from Q3Table::adjustColumn().

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 Q3SqlCursor 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.

bool Q3DataTable::autoDelete () const

Returns true if the table will automatically delete the cursor specified by setSqlCursor(); otherwise returns false.

See also setAutoDelete().

void Q3DataTable::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 Q3DataTable::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 Q3DataTable::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 Q3DataTable::beginInsert ()   [virtual protected]

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 and false is returned. Otherwise returns true.

Editing takes place using the cursor's edit buffer(see Q3SqlCursor::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.

QWidget * Q3DataTable::beginUpdate ( int row, int col, bool replace )   [virtual protected]

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 Q3SqlCursor::editBuffer()).

row and col refer to the row and column in the Q3DataTable.

(replace is provided for reimplementors and reflects the API of Q3Table::beginEdit().)

void Q3DataTable::clearCell ( int row, int col )   [virtual protected]

Reimplemented from Q3Table::clearCell().

void Q3DataTable::columnClicked ( int col )   [virtual protected]

Reimplemented from Q3Table::columnClicked().

QSql::Confirm Q3DataTable::confirmCancel ( QSql::Op m )   [virtual protected]

Protected virtual function which returns a confirmation for canceling 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.

QSql::Confirm Q3DataTable::confirmEdit ( QSql::Op m )   [virtual protected]

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.

void Q3DataTable::contentsContextMenuEvent ( QContextMenuEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsContextMenuEvent().

void Q3DataTable::contentsMousePressEvent ( QMouseEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsMousePressEvent().

QWidget * Q3DataTable::createEditor ( int row, int col, bool initFromCell ) const   [virtual protected]

Reimplemented from Q3Table::createEditor().

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 Q3DataTable cell.

void Q3DataTable::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 * Q3DataTable::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 Q3DataTable::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.

bool Q3DataTable::deleteCurrent ()   [virtual protected]

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.

void Q3DataTable::drawContents ( QPainter * p, int cx, int cy, int cw, int ch )   [virtual protected]

Reimplemented from Q3ScrollView::drawContents().

void Q3DataTable::endEdit ( int row, int col, bool accept, bool replace )   [virtual protected]

Reimplemented from Q3Table::endEdit().

bool Q3DataTable::eventFilter ( QObject * o, QEvent * e )   [virtual protected]

Reimplemented from QObject::eventFilter().

int Q3DataTable::fieldAlignment ( const QSqlField * field )   [virtual protected]

Returns the alignment for field.

void Q3DataTable::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.

void Q3DataTable::handleError ( const QSqlError & e )   [virtual protected]

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.

void Q3DataTable::hideColumn ( int col )   [virtual]

Reimplemented from Q3Table::hideColumn().

int Q3DataTable::indexOf ( uint i ) const

Returns the index of the field within the current SQL query that is displayed in column i.

bool Q3DataTable::insertCurrent ()   [virtual protected]

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 Q3DataTable::installEditorFactory ( Q3SqlEditorFactory * 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 Q3DataTable takes ownership of this pointer, and will delete it when it is no longer needed or when installEditorFactory() is called again.

See also Q3SqlEditorFactory.

void Q3DataTable::installPropertyMap ( Q3SqlPropertyMap * 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 Q3DataTable takes ownership of this pointer, and will delete it when it is no longer needed or when installPropertMap() is called again.

See also Q3SqlPropertyMap.

Q3TableItem * Q3DataTable::item ( int row, int col ) const   [virtual protected]

Reimplemented from Q3Table::item().

See also setItem().

void Q3DataTable::keyPressEvent ( QKeyEvent * e )   [virtual protected]

Reimplemented from QWidget::keyPressEvent().

void Q3DataTable::paintCell ( QPainter * p, int row, int col, const QRect & cr, bool selected, const QColorGroup & cg )   [virtual protected]

Reimplemented from Q3Table::paintCell().

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.

void Q3DataTable::paintField ( QPainter * p, const QSqlField * field, const QRect & cr, bool selected )   [virtual protected]

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.

void Q3DataTable::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 Q3DataTable::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 Q3DataTable::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'.

void Q3DataTable::refresh ( Refresh mode )

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.

See also Refresh, setSqlCursor(), and addColumn().

void Q3DataTable::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( Q3DataTable::RefreshData ).

void Q3DataTable::removeColumn ( int col )   [virtual]

Reimplemented from Q3Table::removeColumn().

Removes column col from the list of columns to be displayed. If col does not exist, nothing happens.

See also QSqlField.

void Q3DataTable::repaintCell ( int row, int col )   [protected]

Repaints the cell at row, col.

void Q3DataTable::reset ()   [protected]

Resets the table so that it displays no data.

See also setSqlCursor().

void Q3DataTable::resizeData ( int len )   [virtual protected]

Reimplemented from Q3Table::resizeData().

void Q3DataTable::resizeEvent ( QResizeEvent * e )   [virtual protected]

Reimplemented from QWidget::resizeEvent().

void Q3DataTable::selectRow ( int row )   [virtual]

Reimplemented from Q3Table::selectRow().

void Q3DataTable::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.

See also autoDelete().

void Q3DataTable::setColumn ( uint col, const QString & fieldName, const QString & label = QString(), 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.

See also setSqlCursor() and refresh().

void Q3DataTable::setColumnStretchable ( int col, bool s )   [virtual slot]

Reimplemented from Q3Table::setColumnStretchable().

void Q3DataTable::setColumnWidth ( int col, int w )   [virtual slot]

Reimplemented from Q3Table::setColumnWidth().

Sets the column col to the width w. Note that unlike Q3Table the Q3DataTable is not immediately redrawn, you must call refresh(Q3DataTable::RefreshColumns) yourself.

See also refresh().

void Q3DataTable::setItem ( int row, int col, Q3TableItem * item )   [virtual protected]

Reimplemented from Q3Table::setItem().

See also item().

void Q3DataTable::setNumCols ( int r )   [virtual]

Reimplemented from Q3Table::setNumCols().

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.

See also numCols().

void Q3DataTable::setNumRows ( int r )   [virtual]

Reimplemented from Q3Table::setNumRows().

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.

See also numRows().

void Q3DataTable::setPixmap ( int row, int col, const QPixmap & pix )   [virtual protected]

Reimplemented from Q3Table::setPixmap().

void Q3DataTable::setSize ( Q3SqlCursor * 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 Q3DataTable::setSqlCursor ( Q3SqlCursor * 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.

See also sqlCursor(), refresh(), setReadOnly(), setAutoDelete(), and QSqlDriver::nullText().

void Q3DataTable::showColumn ( int col )   [virtual]

Reimplemented from Q3Table::showColumn().

void Q3DataTable::sortAscending ( int col )   [virtual slot]

Sorts column col in ascending order.

See also setSorting().

void Q3DataTable::sortColumn ( int col, bool ascending = true, bool wholeRows = false )   [virtual]

Reimplemented from Q3Table::sortColumn().

Sorts column col in ascending order if ascending is true (the default); otherwise sorts in descending order.

The wholeRows parameter is ignored; Q3DataTable always sorts whole rows by the specified column.

void Q3DataTable::sortDescending ( int col )   [virtual slot]

Sorts column col in descending order.

See also setSorting().

Q3SqlCursor * Q3DataTable::sqlCursor () const

Returns the cursor used by the data table.

See also setSqlCursor().

void Q3DataTable::swapColumns ( int col1, int col2, bool swapHeaders = false )   [virtual slot]

Reimplemented from Q3Table::swapColumns().

void Q3DataTable::takeItem ( Q3TableItem * i )   [virtual protected]

Reimplemented from Q3Table::takeItem().

QString Q3DataTable::text ( int row, int col ) const   [virtual]

Reimplemented from Q3Table::text().

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 an empty string is returned.

bool Q3DataTable::updateCurrent ()   [virtual protected]

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.

QVariant Q3DataTable::value ( int row, int col ) const

Returns the value in cell row, col, or an invalid value if the cell does not exist or has no value.


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt 4.6.3