Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The TQDataBrowser class provides data manipulation and navigation for data entry forms. More...
#include <ntqdatabrowser.h>
Inherits TQWidget.
A high-level API is provided for navigating through data records in a cursor, for inserting, updating and deleting records, and for refreshing data in the display.
If you want a read-only form to present database data use TQDataView; if you want a table-based presentation of your data use TQDataTable.
A TQDataBrowser is used to associate a dataset with a form in much the same way as a TQDataTable associates a dataset with a table. Once the data browser has been constructed it can be associated with a dataset with setSqlCursor(), and with a form with setForm(). Boundary checking, sorting and filtering can be set with setBoundaryChecking(), setSort() and setFilter(), respectively.
The insertCurrent() function reads the fields from the default form into the default cursor and performs the insert. The updateCurrent() and deleteCurrent() functions perform similarly to update and delete the current record respectively.
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 form when the user edits a record and then navigates.
The record set is navigated using first(), next(), prev(), last() and seek(). The form's display is updated with refresh(). When navigation takes place the firstRecordAvailable(), lastRecordAvailable(), nextRecordAvailable() and prevRecordAvailable() signals are emitted. When the cursor record is changed due to navigation the cursorChanged() signal is emitted.
If you want finer control of the insert, update and delete processes then you can use the lower level functions to perform these operations as described below.
The form is populated with data from the database with readFields(). If the user is allowed to edit, (see setReadOnly()), write the form's data back to the cursor's edit buffer with writeFields(). You can clear the values in the form with clearValues(). Editing is performed as follows:
See also Database Classes.
This enum describes where the data browser is positioned.
Returns TRUE if the browser automatically applies edits; otherwise returns FALSE. See the "autoEdit" property for details.
This signal is emitted just before the cursor's edit buffer is deleted from the database. The buf parameter points to the edit buffer being deleted. You might connect to this signal to capture some auditing information about the deletion.
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. You might connect to this signal to populate a generated primary key for example.
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. You might connect to this signal to capture some auditing information about the update.
This is achieved by moving the default cursor and checking the position, however the current default form values will not be altered. After checking for the boundary, the cursor is moved back to its former position. See TQDataBrowser::Boundary.
See also Boundary.
Returns TRUE if boundary checking is active; otherwise returns FALSE. See the "boundaryChecking" property for details.
All the edit buffer field values are set to their 'zero state', e.g. 0 for numeric fields and "" for string fields. Then the widgets are updated using the property map. For example, a combobox that is property-mapped to integers would scroll to the first item. See the TQSqlPropertyMap constructor for the default mappings of widgets to properties.
Returns TRUE if the browser confirms cancel operations; otherwise returns FALSE. See the "confirmCancels" property for details.
Returns TRUE if the browser confirms deletions; otherwise returns FALSE. See the "confirmDelete" property for details.
Returns TRUE if the browser confirms edits; otherwise returns FALSE. See the "confirmEdits" property for details.
Returns TRUE if the data browser confirms insertions; otherwise returns FALSE. See the "confirmInsert" property for details.
Returns TRUE if the browser confirms updates; otherwise returns FALSE. See the "confirmUpdate" property for details.
This signal is emitted whenever the current cursor position changes. The record parameter points to the contents of the current cursor's record.
This signal is emitted whenever the cursor record was changed due to navigation. The mode parameter is the edit that just took place, e.g. Insert, Update or Delete. See TQSqlCursor::Mode.
Otherwise, the following happens:
The current form's record is deleted from the database, providing that the data browser is not in insert mode. If the data browser is actively inserting a record (see insert()), the insert action is canceled, and the browser navigates to the last valid record that was current. If there is an error, handleError() is called.
See also cursor, form(), and handleError().
Returns the data browser's filter. See the "filter" property for details.
If the browser is already positioned on the first record nothing happens.
This signal is emitted whenever the position of the cursor changes. The available parameter indicates whether or not the first record in the default cursor is available.
If auto-editing is on (see setAutoEdit()), the following happens:
If there is an error handling any of the above auto-edit actions, handleError() is called and no insert or update is performed.
If no error occurred, or auto-editing is not enabled, the data browser begins actively inserting a record into the database by performing the following actions:
See also cursorChanged(), sqlCursor(), form(), and handleError().
Returns TRUE if the browser is read-only; otherwise returns FALSE. See the "readOnly" property for details.
If the browser is already positioned on the last record nothing happens.
This signal is emitted whenever the position of the cursor changes. The available parameter indicates whether or not the last record in the default cursor is available.
If the browser is positioned on the last record nothing happens.
This signal is emitted whenever the position of the cursor changes. The available parameter indicates whether or not the next record in the default cursor is available.
If the browser is positioned on the first record nothing happens.
This signal is emitted whenever the position of the cursor changes. The available parameter indicates whether or not the previous record in the default cursor is available.
This signal is emitted when the data browser enters deletion mode. The buf parameter points to the record buffer being deleted. (Note that TQSqlCursor::primeDelete() is not called on the default cursor, as this would corrupt values in the form.) Connect to this signal in order to, for example, save a copy of the deleted record for auditing purposes.
See also del().
This signal is emitted when the data browser enters insertion mode. The buf parameter points to the record buffer that is to be inserted. Connect to this signal to, for example, prime the record buffer with default data values, auto-numbered fields etc. (Note that TQSqlCursor::primeInsert() is not called on the default cursor, as this would corrupt values in the form.)
See also insert().
This signal is emitted when the data browser enters update mode. Note that during navigation (first(), last(), next(), prev()), each record that is shown in the default form is primed for update. The buf parameter points to the record buffer being updated. (Note that TQSqlCursor::primeUpdate() is not called on the default cursor, as this would corrupt values in the form.) Connect to this signal in order to, for example, keep track of which records have been updated, perhaps for auditing purposes.
See also update().
If the browser is already positioned on the desired record nothing happens.
Sets whether the browser automatically applies edits to autoEdit. See the "autoEdit" property for details.
Sets whether boundary checking is active to active. See the "boundaryChecking" property for details.
Sets whether the browser confirms cancel operations to confirm. See the "confirmCancels" property for details.
Sets whether the browser confirms deletions to confirm. See the "confirmDelete" property for details.
Sets whether the browser confirms edits to confirm. See the "confirmEdits" property for details.
Sets whether the data browser confirms insertions to confirm. See the "confirmInsert" property for details.
Sets whether the browser confirms updates to confirm. See the "confirmUpdate" property for details.
Sets the data browser's filter to filter. See the "filter" property for details.
Sets whether the browser is read-only to active. See the "readOnly" property for details.
Sets the data browser's sort to sort. See the "sort" property for details.
Sets the data browser's sort to the TQSqlIndex sort. To apply the new sort, use refresh().
See also sqlCursor(), form(), and setForm().
Returns the data browser's sort. See the "sort" property for details.
See also setSqlCursor().
If there is no default cursor or no default form, nothing happens. Otherwise, the following happens:
If the data browser is actively inserting a record (see insert()), that record is inserted into the database using insertCurrent(). Otherwise, the database is updated with the current form's data using updateCurrent(). If there is an error handling either action, handleError() is called.
See also cursor, form(), and handleError().
This property holds whether the browser automatically applies edits.
The default value for this property is TRUE. When the user begins an insertion or an update on a form there are two possible outcomes when they navigate to another record:
Set this property's value with setAutoEdit() and get this property's value with autoEdit().
This property holds whether boundary checking is active.
When boundary checking is active (the default), signals are emitted indicating the current position of the default cursor.
See also boundary().
Set this property's value with setBoundaryChecking() and get this property's value with boundaryChecking().
This property holds whether the browser confirms cancel operations.
If this 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.
See also confirmEdits and confirmCancel().
Set this property's value with setConfirmCancels() and get this property's value with confirmCancels().
This property holds whether the browser confirms deletions.
If this property is TRUE, the browser confirms deletions, otherwise deletions happen immediately.
See also confirmCancels, confirmEdits, confirmUpdate, confirmInsert, and confirmEdit().
Set this property's value with setConfirmDelete() and get this property's value with confirmDelete().
This property holds whether the browser confirms edits.
If this property is TRUE, the browser confirms all edit operations (insertions, updates and deletions), otherwise all edit operations happen immediately. Confirmation is achieved by presenting the user with a message box -- this behavior can be changed by reimplementing the confirmEdit() function,
See also confirmEdit(), confirmCancels, confirmInsert, confirmUpdate, and confirmDelete.
Set this property's value with setConfirmEdits() and get this property's value with confirmEdits().
This property holds whether the data browser confirms insertions.
If this property is TRUE, the browser confirms insertions, otherwise insertions happen immediately.
See also confirmCancels, confirmEdits, confirmUpdate, confirmDelete, and confirmEdit().
Set this property's value with setConfirmInsert() and get this property's value with confirmInsert().
This property holds whether the browser confirms updates.
If this property is TRUE, the browser confirms updates, otherwise updates happen immediately.
See also confirmCancels, confirmEdits, confirmInsert, confirmDelete, and confirmEdit().
Set this property's value with setConfirmUpdate() and get this property's value with confirmUpdate().
This property holds the data browser's filter.
The filter applies to the data shown in the browser. Call refresh() to apply the new filter. A filter is a string containing a SQL WHERE clause without the WHERE keyword, e.g. "id>1000", "name LIKE 'A%'", etc.
There is no default filter.
See also sort.
Set this property's value with setFilter() and get this property's value with filter().
This property holds whether the browser is read-only.
The default is FALSE, i.e. data can be edited. If the data browser is read-only, no database edits will be allowed.
Set this property's value with setReadOnly() and get this property's value with isReadOnly().
This property holds the data browser's sort.
The data browser's sort affects the order in which records are viewed in the browser. Call refresh() to apply the new sort.
When retrieving the sort property, a string list is returned in the form 'fieldname order', e.g. 'id ASC', 'surname DESC'.
There is no default sort.
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
TQStringList list = myDataBrowser.sort(); TQStringList::Iterator it = list.begin(); while( it != list.end() ) { myProcessing( *it ); ++it; }
Set this property's value with setSort() and get this property's value with sort().
This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.
Copyright © 2007 Trolltech | Trademarks | TQt 3.3.8
|