You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/qdatabrowser.html

716 lines
44 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/qdatabrowser.cpp:56 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQDataBrowser Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQDataBrowser Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>
<p>The TQDataBrowser class provides data manipulation and
navigation for data entry forms.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qdatabrowser-h.html">qdatabrowser.h</a>&gt;</tt>
<p>Inherits <a href="qwidget.html">TQWidget</a>.
<p><a href="qdatabrowser-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQDataBrowser"><b>TQDataBrowser</b></a> ( TQWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;fl = 0 )</li>
<li class=fn><a href="#~TQDataBrowser"><b>~TQDataBrowser</b></a> ()</li>
<li class=fn>enum <a href="#Boundary-enum"><b>Boundary</b></a> { Unknown, None, BeforeBeginning, Beginning, End, AfterEnd }</li>
<li class=fn>Boundary <a href="#boundary"><b>boundary</b></a> ()</li>
<li class=fn>void <a href="#setBoundaryChecking"><b>setBoundaryChecking</b></a> ( bool&nbsp;active )</li>
<li class=fn>bool <a href="#boundaryChecking"><b>boundaryChecking</b></a> () const</li>
<li class=fn>void <a href="#setSort-2"><b>setSort</b></a> ( const&nbsp;TQSqlIndex&nbsp;&amp;&nbsp;sort )</li>
<li class=fn>void <a href="#setSort"><b>setSort</b></a> ( const&nbsp;TQStringList&nbsp;&amp;&nbsp;sort )</li>
<li class=fn>TQStringList <a href="#sort"><b>sort</b></a> () const</li>
<li class=fn>void <a href="#setFilter"><b>setFilter</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;filter )</li>
<li class=fn>TQString <a href="#filter"><b>filter</b></a> () const</li>
<li class=fn>virtual void <a href="#setSqlCursor"><b>setSqlCursor</b></a> ( TQSqlCursor&nbsp;*&nbsp;cursor, bool&nbsp;autoDelete = FALSE )</li>
<li class=fn>TQSqlCursor * <a href="#sqlCursor"><b>sqlCursor</b></a> () const</li>
<li class=fn>virtual void <a href="#setForm"><b>setForm</b></a> ( TQSqlForm&nbsp;*&nbsp;form )</li>
<li class=fn>TQSqlForm * <a href="#form"><b>form</b></a> ()</li>
<li class=fn>virtual void <a href="#setConfirmEdits"><b>setConfirmEdits</b></a> ( bool&nbsp;confirm )</li>
<li class=fn>virtual void <a href="#setConfirmInsert"><b>setConfirmInsert</b></a> ( bool&nbsp;confirm )</li>
<li class=fn>virtual void <a href="#setConfirmUpdate"><b>setConfirmUpdate</b></a> ( bool&nbsp;confirm )</li>
<li class=fn>virtual void <a href="#setConfirmDelete"><b>setConfirmDelete</b></a> ( bool&nbsp;confirm )</li>
<li class=fn>virtual void <a href="#setConfirmCancels"><b>setConfirmCancels</b></a> ( bool&nbsp;confirm )</li>
<li class=fn>bool <a href="#confirmEdits"><b>confirmEdits</b></a> () const</li>
<li class=fn>bool <a href="#confirmInsert"><b>confirmInsert</b></a> () const</li>
<li class=fn>bool <a href="#confirmUpdate"><b>confirmUpdate</b></a> () const</li>
<li class=fn>bool <a href="#confirmDelete"><b>confirmDelete</b></a> () const</li>
<li class=fn>bool <a href="#confirmCancels"><b>confirmCancels</b></a> () const</li>
<li class=fn>virtual void <a href="#setReadOnly"><b>setReadOnly</b></a> ( bool&nbsp;active )</li>
<li class=fn>bool <a href="#isReadOnly"><b>isReadOnly</b></a> () const</li>
<li class=fn>virtual void <a href="#setAutoEdit"><b>setAutoEdit</b></a> ( bool&nbsp;autoEdit )</li>
<li class=fn>bool <a href="#autoEdit"><b>autoEdit</b></a> () const</li>
<li class=fn>virtual bool <a href="#seek"><b>seek</b></a> ( int&nbsp;i, bool&nbsp;relative = FALSE )</li>
</ul>
<h2>Public Slots</h2>
<ul>
<li class=fn>virtual void <a href="#refresh"><b>refresh</b></a> ()</li>
<li class=fn>virtual void <a href="#insert"><b>insert</b></a> ()</li>
<li class=fn>virtual void <a href="#update"><b>update</b></a> ()</li>
<li class=fn>virtual void <a href="#del"><b>del</b></a> ()</li>
<li class=fn>virtual void <a href="#first"><b>first</b></a> ()</li>
<li class=fn>virtual void <a href="#last"><b>last</b></a> ()</li>
<li class=fn>virtual void <a href="#next"><b>next</b></a> ()</li>
<li class=fn>virtual void <a href="#prev"><b>prev</b></a> ()</li>
<li class=fn>virtual void <a href="#readFields"><b>readFields</b></a> ()</li>
<li class=fn>virtual void <a href="#writeFields"><b>writeFields</b></a> ()</li>
<li class=fn>virtual void <a href="#clearValues"><b>clearValues</b></a> ()</li>
<li class=fn>void <a href="#updateBoundary"><b>updateBoundary</b></a> ()</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#firstRecordAvailable"><b>firstRecordAvailable</b></a> ( bool&nbsp;available )</li>
<li class=fn>void <a href="#lastRecordAvailable"><b>lastRecordAvailable</b></a> ( bool&nbsp;available )</li>
<li class=fn>void <a href="#nextRecordAvailable"><b>nextRecordAvailable</b></a> ( bool&nbsp;available )</li>
<li class=fn>void <a href="#prevRecordAvailable"><b>prevRecordAvailable</b></a> ( bool&nbsp;available )</li>
<li class=fn>void <a href="#currentChanged"><b>currentChanged</b></a> ( const&nbsp;TQSqlRecord&nbsp;*&nbsp;record )</li>
<li class=fn>void <a href="#primeInsert"><b>primeInsert</b></a> ( TQSqlRecord&nbsp;*&nbsp;buf )</li>
<li class=fn>void <a href="#primeUpdate"><b>primeUpdate</b></a> ( TQSqlRecord&nbsp;*&nbsp;buf )</li>
<li class=fn>void <a href="#primeDelete"><b>primeDelete</b></a> ( TQSqlRecord&nbsp;*&nbsp;buf )</li>
<li class=fn>void <a href="#beforeInsert"><b>beforeInsert</b></a> ( TQSqlRecord&nbsp;*&nbsp;buf )</li>
<li class=fn>void <a href="#beforeUpdate"><b>beforeUpdate</b></a> ( TQSqlRecord&nbsp;*&nbsp;buf )</li>
<li class=fn>void <a href="#beforeDelete"><b>beforeDelete</b></a> ( TQSqlRecord&nbsp;*&nbsp;buf )</li>
<li class=fn>void <a href="#cursorChanged"><b>cursorChanged</b></a> ( TQSqlCursor::Mode&nbsp;mode )</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>bool <a href="#autoEdit-prop"><b>autoEdit</b></a>&nbsp;- whether the browser automatically applies edits</li>
<li class=fn>bool <a href="#boundaryChecking-prop"><b>boundaryChecking</b></a>&nbsp;- whether boundary checking is active</li>
<li class=fn>bool <a href="#confirmCancels-prop"><b>confirmCancels</b></a>&nbsp;- whether the browser confirms cancel operations</li>
<li class=fn>bool <a href="#confirmDelete-prop"><b>confirmDelete</b></a>&nbsp;- whether the browser confirms deletions</li>
<li class=fn>bool <a href="#confirmEdits-prop"><b>confirmEdits</b></a>&nbsp;- whether the browser confirms edits</li>
<li class=fn>bool <a href="#confirmInsert-prop"><b>confirmInsert</b></a>&nbsp;- whether the data browser confirms insertions</li>
<li class=fn>bool <a href="#confirmUpdate-prop"><b>confirmUpdate</b></a>&nbsp;- whether the browser confirms updates</li>
<li class=fn>TQString <a href="#filter-prop"><b>filter</b></a>&nbsp;- the data browser's filter</li>
<li class=fn>bool <a href="#readOnly-prop"><b>readOnly</b></a>&nbsp;- whether the browser is read-only</li>
<li class=fn>TQStringList <a href="#sort-prop"><b>sort</b></a>&nbsp;- the data browser's sort</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual bool <a href="#insertCurrent"><b>insertCurrent</b></a> ()</li>
<li class=fn>virtual bool <a href="#updateCurrent"><b>updateCurrent</b></a> ()</li>
<li class=fn>virtual bool <a href="#deleteCurrent"><b>deleteCurrent</b></a> ()</li>
<li class=fn>virtual bool <a href="#currentEdited"><b>currentEdited</b></a> ()</li>
<li class=fn>virtual TQSql::Confirm <a href="#confirmEdit"><b>confirmEdit</b></a> ( TQSql::Op&nbsp;m )</li>
<li class=fn>virtual TQSql::Confirm <a href="#confirmCancel"><b>confirmCancel</b></a> ( TQSql::Op&nbsp;m )</li>
<li class=fn>virtual void <a href="#handleError"><b>handleError</b></a> ( const&nbsp;TQSqlError&nbsp;&amp;&nbsp;error )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQDataBrowser class provides data manipulation and
navigation for data entry forms.
<p>
<p> 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.
<p> If you want a read-only form to present database data use
<a href="qdataview.html">TQDataView</a>; if you want a table-based presentation of your data use
<a href="qdatatable.html">TQDataTable</a>.
<p> 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 <a href="#setSqlCursor">setSqlCursor</a>(), and with a form with
<a href="#setForm">setForm</a>(). Boundary checking, sorting and filtering can be set
with <a href="#setBoundaryChecking">setBoundaryChecking</a>(), <a href="#setSort">setSort</a>() and <a href="#setFilter">setFilter</a>(),
respectively.
<p> The <a href="#insertCurrent">insertCurrent</a>() function reads the fields from the default
form into the default cursor and performs the insert. The
<a href="#updateCurrent">updateCurrent</a>() and <a href="#deleteCurrent">deleteCurrent</a>() functions perform similarly to
update and delete the current record respectively.
<p> The user can be asked to confirm all edits with <a href="#setConfirmEdits">setConfirmEdits</a>().
For more precise control use <a href="#setConfirmInsert">setConfirmInsert</a>(),
<a href="#setConfirmUpdate">setConfirmUpdate</a>(), <a href="#setConfirmDelete">setConfirmDelete</a>() and <a href="#setConfirmCancels">setConfirmCancels</a>().
Use <a href="#setAutoEdit">setAutoEdit</a>() to control the behaviour of the form when the
user edits a record and then navigates.
<p> The record set is navigated using <a href="#first">first</a>(), <a href="#next">next</a>(), <a href="#prev">prev</a>(), <a href="#last">last</a>()
and <a href="#seek">seek</a>(). The form's display is updated with <a href="#refresh">refresh</a>(). When
navigation takes place the <a href="#firstRecordAvailable">firstRecordAvailable</a>(),
<a href="#lastRecordAvailable">lastRecordAvailable</a>(), <a href="#nextRecordAvailable">nextRecordAvailable</a>() and
<a href="#prevRecordAvailable">prevRecordAvailable</a>() signals are emitted. When the cursor record
is changed due to navigation the <a href="#cursorChanged">cursorChanged</a>() signal is
emitted.
<p> 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.
<p> The form is populated with data from the database with
<a href="#readFields">readFields</a>(). If the user is allowed to edit, (see <a href="#setReadOnly">setReadOnly</a>()),
write the form's data back to the cursor's edit buffer with
<a href="#writeFields">writeFields</a>(). You can clear the values in the form with
<a href="#clearValues">clearValues</a>(). Editing is performed as follows:
<ul>
<li> <em>insert</em> When the data browser enters insertion mode it emits the
<a href="#primeInsert">primeInsert</a>() signal which you can connect to, for example to
pre-populate fields. Call writeFields() to write the user's edits to
the cursor's edit buffer then call <a href="#insert">insert</a>() to insert the record
into the database. The <a href="#beforeInsert">beforeInsert</a>() signal is emitted just before
the cursor's edit buffer is inserted into the database; connect to
this for example, to populate fields such as an auto-generated
primary key.
<li> <em>update</em> For updates the <a href="#primeUpdate">primeUpdate</a>() signal is emitted when
the data browser enters update mode. After calling writeFields()
call <a href="#update">update</a>() to update the record and connect to the <a href="#beforeUpdate">beforeUpdate</a>()
signal to manipulate the user's data before the update takes place.
<li> <em>delete</em> For deletion the <a href="#primeDelete">primeDelete</a>() signal is emitted when
the data browser enters deletion mode. After calling <a href="#writeFields">writeFields</a>()
call <a href="#del">del</a>() to delete the record and connect to the <a href="#beforeDelete">beforeDelete</a>()
signal, for example to record an audit of the deleted record.
</ul>
<p> <p>See also <a href="database.html">Database Classes</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="Boundary-enum"></a>TQDataBrowser::Boundary</h3>
<p> This enum describes where the data browser is positioned.
<ul>
<li><tt>TQDataBrowser::Unknown</tt> - the boundary cannot be determined (usually because
there is no default cursor, or the default cursor is not active).
<li><tt>TQDataBrowser::None</tt> - the browser is not positioned on a boundary, but it is
positioned on a record somewhere in the middle.
<li><tt>TQDataBrowser::BeforeBeginning</tt> - the browser is positioned before the
first available record.
<li><tt>TQDataBrowser::Beginning</tt> - the browser is positioned at the first record.
<li><tt>TQDataBrowser::End</tt> - the browser is positioned at the last
record.
<li><tt>TQDataBrowser::AfterEnd</tt> - the browser is positioned after the last
available record.
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQDataBrowser"></a>TQDataBrowser::TQDataBrowser ( <a href="qwidget.html">TQWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;fl = 0 )
</h3>
Constructs a data browser which is a child of <em>parent</em>, with the
name <em>name</em> and widget flags set to <em>fl</em>.
<h3 class=fn><a name="~TQDataBrowser"></a>TQDataBrowser::~TQDataBrowser ()
</h3>
Destroys the object and frees any allocated resources.
<h3 class=fn>bool <a name="autoEdit"></a>TQDataBrowser::autoEdit () const
</h3><p>Returns TRUE if the browser automatically applies edits; otherwise returns FALSE.
See the <a href="qdatabrowser.html#autoEdit-prop">"autoEdit"</a> property for details.
<h3 class=fn>void <a name="beforeDelete"></a>TQDataBrowser::beforeDelete ( <a href="qsqlrecord.html">TQSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
</h3>
<p> This signal is emitted just before the cursor's edit buffer is
deleted from the database. The <em>buf</em> parameter points to the edit
buffer being deleted. You might connect to this signal to capture
some auditing information about the deletion.
<h3 class=fn>void <a name="beforeInsert"></a>TQDataBrowser::beforeInsert ( <a href="qsqlrecord.html">TQSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
</h3>
<p> This signal is emitted just before the cursor's edit buffer is
inserted into the database. The <em>buf</em> parameter points to the
edit buffer being inserted. You might connect to this signal to
populate a generated primary key for example.
<h3 class=fn>void <a name="beforeUpdate"></a>TQDataBrowser::beforeUpdate ( <a href="qsqlrecord.html">TQSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
</h3>
<p> This signal is emitted just before the cursor's edit buffer is
updated in the database. The <em>buf</em> parameter points to the edit
buffer being updated. You might connect to this signal to capture
some auditing information about the update.
<h3 class=fn><a href="qdatabrowser.html#Boundary-enum">Boundary</a> <a name="boundary"></a>TQDataBrowser::boundary ()
</h3>
Returns an enum indicating the boundary status of the browser.
<p> 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 <a href="#Boundary-enum">TQDataBrowser::Boundary</a>.
<p> <p>See also <a href="#Boundary-enum">Boundary</a>.
<h3 class=fn>bool <a name="boundaryChecking"></a>TQDataBrowser::boundaryChecking () const
</h3><p>Returns TRUE if boundary checking is active; otherwise returns FALSE.
See the <a href="qdatabrowser.html#boundaryChecking-prop">"boundaryChecking"</a> property for details.
<h3 class=fn>void <a name="clearValues"></a>TQDataBrowser::clearValues ()<tt> [virtual slot]</tt>
</h3>
Clears all the values in the form.
<p> 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 <a href="qsqlpropertymap.html">TQSqlPropertyMap</a> constructor for the default
mappings of widgets to properties.
<h3 class=fn><a href="qsql.html#Confirm-enum">TQSql::Confirm</a> <a name="confirmCancel"></a>TQDataBrowser::confirmCancel ( <a href="qsql.html#Op-enum">TQSql::Op</a>&nbsp;m )<tt> [virtual protected]</tt>
</h3>
Protected virtual function which returns a confirmation for
cancelling an edit mode <em>m</em>. Derived classes can reimplement this
function and provide their own confirmation dialog. The default
implementation uses a message box which prompts the user to
confirm the edit action.
<h3 class=fn>bool <a name="confirmCancels"></a>TQDataBrowser::confirmCancels () const
</h3><p>Returns TRUE if the browser confirms cancel operations; otherwise returns FALSE.
See the <a href="qdatabrowser.html#confirmCancels-prop">"confirmCancels"</a> property for details.
<h3 class=fn>bool <a name="confirmDelete"></a>TQDataBrowser::confirmDelete () const
</h3><p>Returns TRUE if the browser confirms deletions; otherwise returns FALSE.
See the <a href="qdatabrowser.html#confirmDelete-prop">"confirmDelete"</a> property for details.
<h3 class=fn><a href="qsql.html#Confirm-enum">TQSql::Confirm</a> <a name="confirmEdit"></a>TQDataBrowser::confirmEdit ( <a href="qsql.html#Op-enum">TQSql::Op</a>&nbsp;m )<tt> [virtual protected]</tt>
</h3>
Protected virtual function which returns a confirmation for an
edit of mode <em>m</em>. Derived classes can reimplement this function
and provide their own confirmation dialog. The default
implementation uses a message box which prompts the user to
confirm the edit action.
<h3 class=fn>bool <a name="confirmEdits"></a>TQDataBrowser::confirmEdits () const
</h3><p>Returns TRUE if the browser confirms edits; otherwise returns FALSE.
See the <a href="qdatabrowser.html#confirmEdits-prop">"confirmEdits"</a> property for details.
<h3 class=fn>bool <a name="confirmInsert"></a>TQDataBrowser::confirmInsert () const
</h3><p>Returns TRUE if the data browser confirms insertions; otherwise returns FALSE.
See the <a href="qdatabrowser.html#confirmInsert-prop">"confirmInsert"</a> property for details.
<h3 class=fn>bool <a name="confirmUpdate"></a>TQDataBrowser::confirmUpdate () const
</h3><p>Returns TRUE if the browser confirms updates; otherwise returns FALSE.
See the <a href="qdatabrowser.html#confirmUpdate-prop">"confirmUpdate"</a> property for details.
<h3 class=fn>void <a name="currentChanged"></a>TQDataBrowser::currentChanged ( const&nbsp;<a href="qsqlrecord.html">TQSqlRecord</a>&nbsp;*&nbsp;record )<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the current cursor position
changes. The <em>record</em> parameter points to the contents of the
current cursor's record.
<h3 class=fn>bool <a name="currentEdited"></a>TQDataBrowser::currentEdited ()<tt> [virtual protected]</tt>
</h3>
Returns TRUE if the form's edit buffer differs from the current
cursor buffer; otherwise returns FALSE.
<h3 class=fn>void <a name="cursorChanged"></a>TQDataBrowser::cursorChanged ( <a href="qsqlcursor.html#Mode-enum">TQSqlCursor::Mode</a>&nbsp;mode )<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the cursor record was changed due
to navigation. The <em>mode</em> parameter is the edit that just took
place, e.g. Insert, Update or Delete. See <a href="qsqlcursor.html#Mode-enum">TQSqlCursor::Mode</a>.
<h3 class=fn>void <a name="del"></a>TQDataBrowser::del ()<tt> [virtual slot]</tt>
</h3>
Performs a delete operation on the data browser's cursor. If there
is no default cursor or no default form, nothing happens.
<p> Otherwise, the following happens:
<p> 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 <a href="#insert">insert</a>()), the insert action
is canceled, and the browser navigates to the last valid record
that was current. If there is an error, <a href="#handleError">handleError</a>() is called.
<h3 class=fn>bool <a name="deleteCurrent"></a>TQDataBrowser::deleteCurrent ()<tt> [virtual protected]</tt>
</h3>
Performs a delete on the default cursor using the values from the
default form and updates the default form. If there is no default
form or no default cursor, nothing happens. If the deletion was
successful, the cursor is repositioned to the nearest record and
TRUE is returned. The nearest record is the next record if there
is one otherwise the previous record if there is one. If an error
occurred during the deletion from the database, <a href="#handleError">handleError</a>() is
called and FALSE is returned.
<p> <p>See also <a href="qwidget.html#cursor-prop">cursor</a>, <a href="#form">form</a>(), and <a href="#handleError">handleError</a>().
<h3 class=fn><a href="qstring.html">TQString</a> <a name="filter"></a>TQDataBrowser::filter () const
</h3><p>Returns the data browser's filter.
See the <a href="qdatabrowser.html#filter-prop">"filter"</a> property for details.
<h3 class=fn>void <a name="first"></a>TQDataBrowser::first ()<tt> [virtual slot]</tt>
</h3>
Moves the default cursor to the first record and refreshes the
default form to display this record. If there is no default form
or no default cursor, nothing happens. If the data browser
successfully navigated to the first record, the default cursor is
primed for update and the <a href="#primeUpdate">primeUpdate</a>() signal is emitted.
<p> If the browser is already positioned on the first record nothing
happens.
<p>
<h3 class=fn>void <a name="firstRecordAvailable"></a>TQDataBrowser::firstRecordAvailable ( bool&nbsp;available )<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the position of the cursor
changes. The <em>available</em> parameter indicates whether or not the
first record in the default cursor is available.
<h3 class=fn><a href="qsqlform.html">TQSqlForm</a>&nbsp;* <a name="form"></a>TQDataBrowser::form ()
</h3>
Returns the data browser's default form or 0 if no form has been
set.
<h3 class=fn>void <a name="handleError"></a>TQDataBrowser::handleError ( const&nbsp;<a href="qsqlerror.html">TQSqlError</a>&nbsp;&amp;&nbsp;error )<tt> [virtual protected]</tt>
</h3>
Virtual function which handles the error <em>error</em>. The default
implementation warns the user with a message box.
<h3 class=fn>void <a name="insert"></a>TQDataBrowser::insert ()<tt> [virtual slot]</tt>
</h3>
Performs an insert operation on the data browser's cursor. If
there is no default cursor or no default form, nothing happens.
<p> If auto-editing is on (see <a href="#setAutoEdit">setAutoEdit</a>()), the following happens:
<p> <ul>
<li> If the browser is already actively inserting a record,
the current form's data is inserted into the database.
<li> If the browser is not inserting a record, but the current record
was changed by the user, the record is updated in the database with
the current form's data (i.e. with the changes).
</ul>
<p> If there is an error handling any of the above auto-edit actions,
<a href="#handleError">handleError</a>() is called and no insert or update is performed.
<p> 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:
<p> <ul>
<li> The default cursor is primed for insert using <a href="qsqlcursor.html#primeInsert">TQSqlCursor::primeInsert</a>().
<li> The <a href="#primeInsert">primeInsert</a>() signal is emitted.
<li> The form is updated with the values in the default cursor's.
edit buffer so that the user can fill in the values to be inserted.
</ul>
<p>
<h3 class=fn>bool <a name="insertCurrent"></a>TQDataBrowser::insertCurrent ()<tt> [virtual protected]</tt>
</h3>
Reads the fields from the default form into the default cursor and
performs an insert on the default cursor. If there is no default
form or no default cursor, nothing happens. If an error occurred
during the insert into the database, <a href="#handleError">handleError</a>() is called and
FALSE is returned. If the insert was successfull, the cursor is
refreshed and relocated to the newly inserted record, the
<a href="#cursorChanged">cursorChanged</a>() signal is emitted, and TRUE is returned.
<p> <p>See also <a href="#cursorChanged">cursorChanged</a>(), <a href="#sqlCursor">sqlCursor</a>(), <a href="#form">form</a>(), and <a href="#handleError">handleError</a>().
<h3 class=fn>bool <a name="isReadOnly"></a>TQDataBrowser::isReadOnly () const
</h3><p>Returns TRUE if the browser is read-only; otherwise returns FALSE.
See the <a href="qdatabrowser.html#readOnly-prop">"readOnly"</a> property for details.
<h3 class=fn>void <a name="last"></a>TQDataBrowser::last ()<tt> [virtual slot]</tt>
</h3>
Moves the default cursor to the last record and refreshes the
default form to display this record. If there is no default form
or no default cursor, nothing happens. If the data browser
successfully navigated to the last record, the default cursor is
primed for update and the <a href="#primeUpdate">primeUpdate</a>() signal is emitted.
<p> If the browser is already positioned on the last record nothing
happens.
<h3 class=fn>void <a name="lastRecordAvailable"></a>TQDataBrowser::lastRecordAvailable ( bool&nbsp;available )<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the position of the cursor
changes. The <em>available</em> parameter indicates whether or not the
last record in the default cursor is available.
<h3 class=fn>void <a name="next"></a>TQDataBrowser::next ()<tt> [virtual slot]</tt>
</h3>
Moves the default cursor to the next record and refreshes the
default form to display this record. If there is no default form
or no default cursor, nothing happens. If the data browser
successfully navigated to the next record, the default cursor is
primed for update and the <a href="#primeUpdate">primeUpdate</a>() signal is emitted.
<p> If the browser is positioned on the last record nothing happens.
<h3 class=fn>void <a name="nextRecordAvailable"></a>TQDataBrowser::nextRecordAvailable ( bool&nbsp;available )<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the position of the cursor
changes. The <em>available</em> parameter indicates whether or not the
next record in the default cursor is available.
<h3 class=fn>void <a name="prev"></a>TQDataBrowser::prev ()<tt> [virtual slot]</tt>
</h3>
Moves the default cursor to the previous record and refreshes the
default form to display this record. If there is no default form
or no default cursor, nothing happens. If the data browser
successfully navigated to the previous record, the default cursor
is primed for update and the <a href="#primeUpdate">primeUpdate</a>() signal is emitted.
<p> If the browser is positioned on the first record nothing happens.
<h3 class=fn>void <a name="prevRecordAvailable"></a>TQDataBrowser::prevRecordAvailable ( bool&nbsp;available )<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the position of the cursor
changes. The <em>available</em> parameter indicates whether or not the
previous record in the default cursor is available.
<h3 class=fn>void <a name="primeDelete"></a>TQDataBrowser::primeDelete ( <a href="qsqlrecord.html">TQSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
</h3>
<p> This signal is emitted when the data browser enters deletion mode.
The <em>buf</em> parameter points to the record buffer being deleted.
(Note that <a href="qsqlcursor.html#primeDelete">TQSqlCursor::primeDelete</a>() is <em>not</em> 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.
<p> <p>See also <a href="#del">del</a>().
<h3 class=fn>void <a name="primeInsert"></a>TQDataBrowser::primeInsert ( <a href="qsqlrecord.html">TQSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
</h3>
<p> This signal is emitted when the data browser enters insertion
mode. The <em>buf</em> parameter points to the record buffer that is to
be inserted. Connect to this signal to, for example, <a href="primes.html#prime">prime</a> the
record buffer with default data values, auto-numbered fields etc.
(Note that <a href="qsqlcursor.html#primeInsert">TQSqlCursor::primeInsert</a>() is <em>not</em> called on the
default cursor, as this would corrupt values in the form.)
<p> <p>See also <a href="#insert">insert</a>().
<h3 class=fn>void <a name="primeUpdate"></a>TQDataBrowser::primeUpdate ( <a href="qsqlrecord.html">TQSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
</h3>
<p> This signal is emitted when the data browser enters update mode.
Note that during navigation (<a href="#first">first</a>(), <a href="#last">last</a>(), <a href="#next">next</a>(), <a href="#prev">prev</a>()),
each record that is shown in the default form is primed for
update. The <em>buf</em> parameter points to the record buffer being
updated. (Note that <a href="qsqlcursor.html#primeUpdate">TQSqlCursor::primeUpdate</a>() is <em>not</em> 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.
<p> <p>See also <a href="#update">update</a>().
<h3 class=fn>void <a name="readFields"></a>TQDataBrowser::readFields ()<tt> [virtual slot]</tt>
</h3>
Reads the fields from the default cursor's edit buffer and
displays them in the form. If there is no default cursor or no
default form, nothing happens.
<h3 class=fn>void <a name="refresh"></a>TQDataBrowser::refresh ()<tt> [virtual slot]</tt>
</h3>
Refreshes the data browser's data using the default cursor. The
browser's current filter and sort are applied if they have been
set.
<p> <p>See also <a href="#filter-prop">filter</a> and <a href="#sort-prop">sort</a>.
<h3 class=fn>bool <a name="seek"></a>TQDataBrowser::seek ( int&nbsp;i, bool&nbsp;relative = FALSE )<tt> [virtual]</tt>
</h3>
Moves the default cursor to the record specified by the index <em>i</em>
and refreshes the default form to display this record. If there is
no default form or no default cursor, nothing happens. If <em>relative</em> is TRUE (the default is FALSE), the cursor is moved
relative to its current position. If the data browser successfully
navigated to the desired record, the default cursor is primed for
update and the <a href="#primeUpdate">primeUpdate</a>() signal is emitted.
<p> If the browser is already positioned on the desired record nothing
happens.
<h3 class=fn>void <a name="setAutoEdit"></a>TQDataBrowser::setAutoEdit ( bool&nbsp;autoEdit )<tt> [virtual]</tt>
</h3><p>Sets whether the browser automatically applies edits to <em>autoEdit</em>.
See the <a href="qdatabrowser.html#autoEdit-prop">"autoEdit"</a> property for details.
<h3 class=fn>void <a name="setBoundaryChecking"></a>TQDataBrowser::setBoundaryChecking ( bool&nbsp;active )
</h3><p>Sets whether boundary checking is active to <em>active</em>.
See the <a href="qdatabrowser.html#boundaryChecking-prop">"boundaryChecking"</a> property for details.
<h3 class=fn>void <a name="setConfirmCancels"></a>TQDataBrowser::setConfirmCancels ( bool&nbsp;confirm )<tt> [virtual]</tt>
</h3><p>Sets whether the browser confirms cancel operations to <em>confirm</em>.
See the <a href="qdatabrowser.html#confirmCancels-prop">"confirmCancels"</a> property for details.
<h3 class=fn>void <a name="setConfirmDelete"></a>TQDataBrowser::setConfirmDelete ( bool&nbsp;confirm )<tt> [virtual]</tt>
</h3><p>Sets whether the browser confirms deletions to <em>confirm</em>.
See the <a href="qdatabrowser.html#confirmDelete-prop">"confirmDelete"</a> property for details.
<h3 class=fn>void <a name="setConfirmEdits"></a>TQDataBrowser::setConfirmEdits ( bool&nbsp;confirm )<tt> [virtual]</tt>
</h3><p>Sets whether the browser confirms edits to <em>confirm</em>.
See the <a href="qdatabrowser.html#confirmEdits-prop">"confirmEdits"</a> property for details.
<h3 class=fn>void <a name="setConfirmInsert"></a>TQDataBrowser::setConfirmInsert ( bool&nbsp;confirm )<tt> [virtual]</tt>
</h3><p>Sets whether the data browser confirms insertions to <em>confirm</em>.
See the <a href="qdatabrowser.html#confirmInsert-prop">"confirmInsert"</a> property for details.
<h3 class=fn>void <a name="setConfirmUpdate"></a>TQDataBrowser::setConfirmUpdate ( bool&nbsp;confirm )<tt> [virtual]</tt>
</h3><p>Sets whether the browser confirms updates to <em>confirm</em>.
See the <a href="qdatabrowser.html#confirmUpdate-prop">"confirmUpdate"</a> property for details.
<h3 class=fn>void <a name="setFilter"></a>TQDataBrowser::setFilter ( const&nbsp;<a href="qstring.html">TQString</a>&nbsp;&amp;&nbsp;filter )
</h3><p>Sets the data browser's filter to <em>filter</em>.
See the <a href="qdatabrowser.html#filter-prop">"filter"</a> property for details.
<h3 class=fn>void <a name="setForm"></a>TQDataBrowser::setForm ( <a href="qsqlform.html">TQSqlForm</a>&nbsp;*&nbsp;form )<tt> [virtual]</tt>
</h3>
Sets the browser's default form to <em>form</em>. The cursor and all
navigation and data manipulation functions that the browser
provides become available to the <em>form</em>.
<h3 class=fn>void <a name="setReadOnly"></a>TQDataBrowser::setReadOnly ( bool&nbsp;active )<tt> [virtual]</tt>
</h3><p>Sets whether the browser is read-only to <em>active</em>.
See the <a href="qdatabrowser.html#readOnly-prop">"readOnly"</a> property for details.
<h3 class=fn>void <a name="setSort"></a>TQDataBrowser::setSort ( const&nbsp;<a href="qstringlist.html">TQStringList</a>&nbsp;&amp;&nbsp;sort )
</h3><p>Sets the data browser's sort to <em>sort</em>.
See the <a href="qdatabrowser.html#sort-prop">"sort"</a> property for details.
<h3 class=fn>void <a name="setSort-2"></a>TQDataBrowser::setSort ( const&nbsp;<a href="qsqlindex.html">TQSqlIndex</a>&nbsp;&amp;&nbsp;sort )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the data browser's sort to the <a href="qsqlindex.html">TQSqlIndex</a> <em>sort</em>. To apply
the new sort, use <a href="#refresh">refresh</a>().
<p>
<h3 class=fn>void <a name="setSqlCursor"></a>TQDataBrowser::setSqlCursor ( <a href="qsqlcursor.html">TQSqlCursor</a>&nbsp;*&nbsp;cursor, bool&nbsp;autoDelete = FALSE )<tt> [virtual]</tt>
</h3>
Sets the default cursor used by the data browser to <em>cursor</em>. If
<em>autoDelete</em> is TRUE (the default is FALSE), the data browser
takes ownership of the <em>cursor</em> pointer, which will be deleted
when the browser is destroyed, or when <a href="#setSqlCursor">setSqlCursor</a>() is called
again. To activate the <em>cursor</em> use <a href="#refresh">refresh</a>(). The cursor's edit
buffer is used in the default form to browse and edit records.
<p> <p>See also <a href="#sqlCursor">sqlCursor</a>(), <a href="#form">form</a>(), and <a href="#setForm">setForm</a>().
<h3 class=fn><a href="qstringlist.html">TQStringList</a> <a name="sort"></a>TQDataBrowser::sort () const
</h3><p>Returns the data browser's sort.
See the <a href="qdatabrowser.html#sort-prop">"sort"</a> property for details.
<h3 class=fn><a href="qsqlcursor.html">TQSqlCursor</a>&nbsp;* <a name="sqlCursor"></a>TQDataBrowser::sqlCursor () const
</h3>
Returns the default cursor used for navigation, or 0 if there is
no default cursor.
<p> <p>See also <a href="#setSqlCursor">setSqlCursor</a>().
<h3 class=fn>void <a name="update"></a>TQDataBrowser::update ()<tt> [virtual slot]</tt>
</h3>
Performs an update operation on the data browser's cursor.
<p> If there is no default cursor or no default form, nothing happens.
Otherwise, the following happens:
<p> If the data browser is actively inserting a record (see <a href="#insert">insert</a>()),
that record is inserted into the database using <a href="#insertCurrent">insertCurrent</a>().
Otherwise, the database is updated with the current form's data
using <a href="#updateCurrent">updateCurrent</a>(). If there is an error handling either
action, <a href="#handleError">handleError</a>() is called.
<h3 class=fn>void <a name="updateBoundary"></a>TQDataBrowser::updateBoundary ()<tt> [slot]</tt>
</h3>
If <a href="#boundaryChecking">boundaryChecking</a>() is TRUE, checks the boundary of the current
default cursor and emits signals which indicate the position of
the cursor.
<h3 class=fn>bool <a name="updateCurrent"></a>TQDataBrowser::updateCurrent ()<tt> [virtual protected]</tt>
</h3>
Reads the fields from the default form into the default cursor and
performs an update on the default cursor. If there is no default
form or no default cursor, nothing happens. If an error occurred
during the update on the database, <a href="#handleError">handleError</a>() is called and
FALSE is returned. If the update was successfull, the cursor is
refreshed and relocated to the updated record, the <a href="#cursorChanged">cursorChanged</a>()
signal is emitted, and TRUE is returned.
<p> <p>See also <a href="qwidget.html#cursor-prop">cursor</a>, <a href="#form">form</a>(), and <a href="#handleError">handleError</a>().
<h3 class=fn>void <a name="writeFields"></a>TQDataBrowser::writeFields ()<tt> [virtual slot]</tt>
</h3>
Writes the form's data to the default cursor's edit buffer. If
there is no default cursor or no default form, nothing happens.
<hr><h2>Property Documentation</h2>
<h3 class=fn>bool <a name="autoEdit-prop"></a>autoEdit</h3>
<p>This property holds whether the browser automatically applies edits.
<p>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:
<p> <ul>
<li> the insert or update is is performed -- this occurs if autoEdit is TRUE
<li> the insert or update is discarded -- this occurs if autoEdit is FALSE
</ul>
<p>Set this property's value with <a href="#setAutoEdit">setAutoEdit</a>() and get this property's value with <a href="#autoEdit">autoEdit</a>().
<h3 class=fn>bool <a name="boundaryChecking-prop"></a>boundaryChecking</h3>
<p>This property holds whether boundary checking is active.
<p>When boundary checking is active (the default), signals are
emitted indicating the current position of the default cursor.
<p> <p>See also <a href="#boundary">boundary</a>().
<p>Set this property's value with <a href="#setBoundaryChecking">setBoundaryChecking</a>() and get this property's value with <a href="#boundaryChecking">boundaryChecking</a>().
<h3 class=fn>bool <a name="confirmCancels-prop"></a>confirmCancels</h3>
<p>This property holds whether the browser confirms cancel operations.
<p>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 <a href="#confirmCancel">confirmCancel</a>() function), otherwise all cancels
occur immediately. The default is FALSE.
<p> <p>See also <a href="#confirmEdits-prop">confirmEdits</a> and <a href="#confirmCancel">confirmCancel</a>().
<p>Set this property's value with <a href="#setConfirmCancels">setConfirmCancels</a>() and get this property's value with <a href="#confirmCancels">confirmCancels</a>().
<h3 class=fn>bool <a name="confirmDelete-prop"></a>confirmDelete</h3>
<p>This property holds whether the browser confirms deletions.
<p>If this property is TRUE, the browser confirms deletions,
otherwise deletions happen immediately.
<p> <p>See also <a href="#confirmCancels-prop">confirmCancels</a>, <a href="#confirmEdits-prop">confirmEdits</a>, <a href="#confirmUpdate-prop">confirmUpdate</a>, <a href="#confirmInsert-prop">confirmInsert</a>, and <a href="#confirmEdit">confirmEdit</a>().
<p>Set this property's value with <a href="#setConfirmDelete">setConfirmDelete</a>() and get this property's value with <a href="#confirmDelete">confirmDelete</a>().
<h3 class=fn>bool <a name="confirmEdits-prop"></a>confirmEdits</h3>
<p>This property holds whether the browser confirms edits.
<p>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 <a href="#confirmEdit">confirmEdit</a>() function,
<p> <p>See also <a href="#confirmEdit">confirmEdit</a>(), <a href="#confirmCancels-prop">confirmCancels</a>, <a href="#confirmInsert-prop">confirmInsert</a>, <a href="#confirmUpdate-prop">confirmUpdate</a>, and <a href="#confirmDelete-prop">confirmDelete</a>.
<p>Set this property's value with <a href="#setConfirmEdits">setConfirmEdits</a>() and get this property's value with <a href="#confirmEdits">confirmEdits</a>().
<h3 class=fn>bool <a name="confirmInsert-prop"></a>confirmInsert</h3>
<p>This property holds whether the data browser confirms insertions.
<p>If this property is TRUE, the browser confirms insertions,
otherwise insertions happen immediately.
<p> <p>See also <a href="#confirmCancels-prop">confirmCancels</a>, <a href="#confirmEdits-prop">confirmEdits</a>, <a href="#confirmUpdate-prop">confirmUpdate</a>, <a href="#confirmDelete-prop">confirmDelete</a>, and <a href="#confirmEdit">confirmEdit</a>().
<p>Set this property's value with <a href="#setConfirmInsert">setConfirmInsert</a>() and get this property's value with <a href="#confirmInsert">confirmInsert</a>().
<h3 class=fn>bool <a name="confirmUpdate-prop"></a>confirmUpdate</h3>
<p>This property holds whether the browser confirms updates.
<p>If this property is TRUE, the browser confirms updates, otherwise
updates happen immediately.
<p> <p>See also <a href="#confirmCancels-prop">confirmCancels</a>, <a href="#confirmEdits-prop">confirmEdits</a>, <a href="#confirmInsert-prop">confirmInsert</a>, <a href="#confirmDelete-prop">confirmDelete</a>, and <a href="#confirmEdit">confirmEdit</a>().
<p>Set this property's value with <a href="#setConfirmUpdate">setConfirmUpdate</a>() and get this property's value with <a href="#confirmUpdate">confirmUpdate</a>().
<h3 class=fn><a href="qstring.html">TQString</a> <a name="filter-prop"></a>filter</h3>
<p>This property holds the data browser's filter.
<p>The filter applies to the data shown in the browser. Call
<a href="#refresh">refresh</a>() 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.
<p> There is no default filter.
<p> <p>See also <a href="#sort-prop">sort</a>.
<p>Set this property's value with <a href="#setFilter">setFilter</a>() and get this property's value with <a href="#filter">filter</a>().
<h3 class=fn>bool <a name="readOnly-prop"></a>readOnly</h3>
<p>This property holds whether the browser is read-only.
<p>The default is FALSE, i.e. data can be edited. If the data browser
is read-only, no database edits will be allowed.
<p>Set this property's value with <a href="#setReadOnly">setReadOnly</a>() and get this property's value with <a href="#isReadOnly">isReadOnly</a>().
<h3 class=fn><a href="qstringlist.html">TQStringList</a> <a name="sort-prop"></a>sort</h3>
<p>This property holds the data browser's sort.
<p>The data browser's sort affects the order in which records are
viewed in the browser. Call <a href="#refresh">refresh</a>() to apply the new sort.
<p> When retrieving the sort property, a string list is returned in
the form 'fieldname order', e.g. 'id ASC', 'surname DESC'.
<p> There is no default sort.
<p> Note that if you want to iterate over the list, you should iterate
over a copy, e.g.
<pre>
<a href="qstringlist.html">TQStringList</a> list = myDataBrowser.sort();
TQStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
myProcessing( *it );
++it;
}
</pre>
<p>Set this property's value with <a href="#setSort">setSort</a>() and get this property's value with <a href="#sort">sort</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>