diff options
Diffstat (limited to 'doc/html/designer-manual-8.html')
-rw-r--r-- | doc/html/designer-manual-8.html | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/doc/html/designer-manual-8.html b/doc/html/designer-manual-8.html index 010d85daa..666b65e8e 100644 --- a/doc/html/designer-manual-8.html +++ b/doc/html/designer-manual-8.html @@ -77,7 +77,7 @@ bool createConnections() TQSqlDatabase *defaultDB = TQSqlDatabase::addDatabase( "TQPSQL7" ); if ( ! defaultDB ) { tqWarning( "Failed to connect to driver" ); - return FALSE; + return false; } defaultDB->setDatabaseName( "book" ); defaultDB->setUserName( "bookuser" ); @@ -87,10 +87,10 @@ bool createConnections() tqWarning( "Failed to open books database: " + defaultDB->lastError().driverText() ); tqWarning( defaultDB->lastError().databaseText() ); - return FALSE; + return false; } - return TRUE; + return true; } </pre> <!-- index addDatabase() --><p>We call <tt>addDatabase()</tt> passing it the name of the driver we wish to use. We then set the connection information by calling the <tt>set</tt>... functions. Finally we attempt to open the connection. If we succeed we return true, otherwise we output some error information and return false. From <tt>qt/tools/designer/examples/book/book1/main.cpp</tt></p> @@ -165,9 +165,9 @@ bool createConnections() <p align="center"><b> <a href="tqdatatable.html">TQDataTable</a> User Interface Interaction</b></p> <!-- index Databases!User Interface Interaction --><!-- index User Interface Interaction, Databases --><p>The default user-interface behavior for <a href="tqdatatable.html">TQDataTable</a>s is as follows:</p> <ul><li><p>Users can move to records by clicking the scrollbar and clicking records with the mouse. They can also use the keyboard's navigation keys, e.g. <b>Left Arrow</b>, <b>Right Arrow</b>, <b>Up Arrow</b>, <b>Down Arrow</b>, <b>Page Up</b>, <b>Page Down</b>, <b>Home</b> and <b>End</b>.</p> -<li><p><tt>INSERT</tt> is initiated by right-clicking the record and clicking Insert or by pressing the <b>Ins</b> (Insert) key. The user moves between fields using <b>Tab</b> and <b>Shift+Tab</b>. The <tt>INSERT</tt> will take place if the user presses <b>Enter</b> or <b>Tab</b>s off the last field. If autoEdit is TRUE the insert will take place if the user navigates to another record. <tt>INSERT</tt> is cancelled by pressing <b>Esc</b> (Escape). If autoEdit is FALSE navigating to another record also cancels the <tt>INSERT</tt>. Setting confirmInsert to TRUE will require the user to confirm each <tt>INSERT</tt>.</p> -<li><p><tt>UPDATE</tt> is initiated by right-clicking the record and clicking Update or by pressing <b>F2</b>. The update will take place if the user presses Enter or Tabs off the last field. If autoEdit is TRUE the update will take place if the user navigates to another record. <tt>UPDATE</tt> is cancelled by pressing <b>Esc</b>. If autoEdit is FALSE navigating to another record also cancels the <tt>UPDATE</tt>. Setting confirmUpdate to TRUE will require the user to confirm each <tt>UPDATE</tt>.</p> -<li><p><tt>DELETE</tt> is achieved by right-clicking the record and clicking Delete or by pressing the <b>Del</b> (Delete) key. Setting confirmDelete to TRUE will require the user to confirm each <tt>DELETE</tt>.</p> +<li><p><tt>INSERT</tt> is initiated by right-clicking the record and clicking Insert or by pressing the <b>Ins</b> (Insert) key. The user moves between fields using <b>Tab</b> and <b>Shift+Tab</b>. The <tt>INSERT</tt> will take place if the user presses <b>Enter</b> or <b>Tab</b>s off the last field. If autoEdit is true the insert will take place if the user navigates to another record. <tt>INSERT</tt> is cancelled by pressing <b>Esc</b> (Escape). If autoEdit is false navigating to another record also cancels the <tt>INSERT</tt>. Setting confirmInsert to true will require the user to confirm each <tt>INSERT</tt>.</p> +<li><p><tt>UPDATE</tt> is initiated by right-clicking the record and clicking Update or by pressing <b>F2</b>. The update will take place if the user presses Enter or Tabs off the last field. If autoEdit is true the update will take place if the user navigates to another record. <tt>UPDATE</tt> is cancelled by pressing <b>Esc</b>. If autoEdit is false navigating to another record also cancels the <tt>UPDATE</tt>. Setting confirmUpdate to true will require the user to confirm each <tt>UPDATE</tt>.</p> +<li><p><tt>DELETE</tt> is achieved by right-clicking the record and clicking Delete or by pressing the <b>Del</b> (Delete) key. Setting confirmDelete to true will require the user to confirm each <tt>DELETE</tt>.</p> </ul><p>You can change this default behavior programmatically if required.</p> </blockquote> <h4><a name="2-3"></a>Relating Two Tables Together (Master-Detail)</h4> @@ -239,7 +239,7 @@ bool createConnections() <li><p>The <a href="tqdatabrowser.html">TQDataBrowser</a> will now appear on the form. Resize the form to make it smaller. Click the <a href="tqdatabrowser.html">TQDataBrowser</a> then click the <b>Break Layout</b> toolbar button. Click the buttons then click the <b>Break Layout</b> toolbar button. Add another button called 'PushButtonClose' with the text '&Close' and place it to the right of the Delete button.</p> <li><p><b>Shift+Click</b> the Insert, Update, Delete and Close buttons, then click the <b>Lay Out Horizontally</b> toolbar button. Click the <a href="tqdatabrowser.html">TQDataBrowser</a>, then click the <b>Lay Out in a Grid</b> toolbar button. Finally click the form and click the <b>Lay Out Vertically</b> toolbar button. Now click the <a href="tqdatabrowser.html">TQDataBrowser</a> and rename it 'BookDataBrowser'.</p> <li><p><em>TQt Designer</em> will generate the necessary code to make the browser operational (including generating the appropriate cursor, sort and filter code).</p> -<p>For finer control over the form, we will be creating our own database cursor. Therefore, set the BookDataBrowser's frameworkCode property to FALSE in the Properties window to prevent <em>TQt Designer</em> from generating redundant code for the cursor.</p> +<p>For finer control over the form, we will be creating our own database cursor. Therefore, set the BookDataBrowser's frameworkCode property to false in the Properties window to prevent <em>TQt Designer</em> from generating redundant code for the cursor.</p> </ol><blockquote> <p align="center"><b> <a href="tqdatabrowser.html">TQDataBrowser</a> User Interface Interaction</b></p> <p>The user-interface behavior for <a href="tqdatabrowser.html">TQDataBrowser</a>s is created by connecting slots and signals. The slots provided are:</p> @@ -249,9 +249,9 @@ bool createConnections() <li><!-- index readFields() --><p><tt>readFields()</tt> to read data from the cursor's edit buffer and<!-- index writeFields() --> <tt>writeFields()</tt> to write the form's data to the cursor's edit buffer;</p> <li><!-- index clearValues() --><p><tt>clearValues()</tt> to clear the form's values.</p> </ul><p>If you use <em>TQt Designer</em>'s <a href="tqdatabrowser.html">TQDataBrowser</a> wizard you will be given the option of creating a default set of buttons for navigation and editing. The behavior of these buttons is set up using the slots described above to provide the following functionality:</p> -<ul><li><p><tt>INSERT</tt> is initiated by pressing the <b>Ins</b> (Insert) key. The user moves between fields using <b>Tab</b> and <b>Shift+Tab</b>. If the user presses the Update button the <tt>INSERT</tt> will take place and the user will be taken to the record they have just inserted. If the user presses the Insert button (i.e. a second time) the <tt>INSERT</tt> will take place and a new insertion will be initiated. If autoEdit is TRUE the <tt>INSERT</tt> will take place if the user navigates to another record. <tt>INSERT</tt> is cancelled by pressing the <b>Esc</b> key or by pressing the <b>Del</b> (Delete) key. If autoEdit is FALSE then navigating to another record also cancels the <tt>INSERT</tt>. Setting confirmInsert to TRUE will require the user to confirm each <tt>INSERT</tt>.</p> -<li><p><tt>UPDATE</tt> is automatically initiated whenever the user navigates to a record. An update will take place if the user presses the Update button. If autoEdit is TRUE the update will take place if the user navigates to another record. <tt>UPDATE</tt> is cancelled by pressing the <b>Esc</b> key or by pressing the <b>Del</b> button. If autoEdit is FALSE then navigating to another record also cancels the <tt>UPDATE</tt>. Setting confirmUpdate to TRUE will require the user to confirm each <tt>UPDATE</tt>.</p> -<li><p><tt>DELETE</tt> is achieved by pressing the <b>Del</b> key. Setting confirmDelete to TRUE will require the user to confirm each <tt>DELETE</tt>.</p> +<ul><li><p><tt>INSERT</tt> is initiated by pressing the <b>Ins</b> (Insert) key. The user moves between fields using <b>Tab</b> and <b>Shift+Tab</b>. If the user presses the Update button the <tt>INSERT</tt> will take place and the user will be taken to the record they have just inserted. If the user presses the Insert button (i.e. a second time) the <tt>INSERT</tt> will take place and a new insertion will be initiated. If autoEdit is true the <tt>INSERT</tt> will take place if the user navigates to another record. <tt>INSERT</tt> is cancelled by pressing the <b>Esc</b> key or by pressing the <b>Del</b> (Delete) key. If autoEdit is false then navigating to another record also cancels the <tt>INSERT</tt>. Setting confirmInsert to true will require the user to confirm each <tt>INSERT</tt>.</p> +<li><p><tt>UPDATE</tt> is automatically initiated whenever the user navigates to a record. An update will take place if the user presses the Update button. If autoEdit is true the update will take place if the user navigates to another record. <tt>UPDATE</tt> is cancelled by pressing the <b>Esc</b> key or by pressing the <b>Del</b> button. If autoEdit is false then navigating to another record also cancels the <tt>UPDATE</tt>. Setting confirmUpdate to true will require the user to confirm each <tt>UPDATE</tt>.</p> +<li><p><tt>DELETE</tt> is achieved by pressing the <b>Del</b> key. Setting confirmDelete to true will require the user to confirm each <tt>DELETE</tt>.</p> </ul></blockquote> <h5><a name="3-1-2"></a>Performing the Drilldown</h5> <!-- index Databases!Drilldown --><!-- index Drilldown --><p>We now have a working form for editing book records. We need to start the form when the user clicks our 'Edit Books' button, and to navigate to the record they have selected in the BookDataTable. We also need to provide a means of editing the foreign keys, e.g. authorid.</p> @@ -259,7 +259,7 @@ bool createConnections() <!-- index Object Hierarchy --><li><p>In the Object Explorer window click Members and then click the <tt>editClicked</tt> function. We need to change it to the following:</p> <pre> void BookForm::editClicked() { - EditBookForm *dialog = new EditBookForm( this, "Edit Book Form", TRUE ); + EditBookForm *dialog = new EditBookForm( this, "Edit Book Form", true ); <a href="tqsqlcursor.html">TQSqlCursor</a> cur( "book" ); dialog->BookDataBrowser->setSqlCursor( &cur ); dialog->BookDataBrowser->setFilter( BookDataTable->filter() ); @@ -352,7 +352,7 @@ bool createConnections() while ( query.<a href="tqsqlquery.html#next">next</a>() ) { ComboBoxAuthor->insertItem( query.<a href="tqsqlquery.html#value">value</a>( 0 ).toString() ); int id = query.<a href="tqsqlquery.html#value">value</a>( 1 ).toInt(); - mapAuthor( query.<a href="tqsqlquery.html#value">value</a>( 0 ).toString(), id, TRUE ); + mapAuthor( query.<a href="tqsqlquery.html#value">value</a>( 0 ).toString(), id, true ); } } </pre> @@ -361,7 +361,7 @@ bool createConnections() <pre> void EditBookForm::beforeUpdateBook( <a href="tqsqlrecord.html">TQSqlRecord</a> * buffer ) { int id; - mapAuthor( ComboBoxAuthor->currentText(), id, FALSE ); + mapAuthor( ComboBoxAuthor->currentText(), id, false ); buffer-><a href="tqsqlrecord.html#setValue">setValue</a>( "authorid", id ); } </pre> @@ -374,7 +374,7 @@ bool createConnections() id = authorMap[ name ]; } </pre> - <p>If the populate flag is TRUE, we store the author's name and id in the <a href="tqmap.html">TQMap</a>, otherwise we look up the given author name and set id appropriately.</p> + <p>If the populate flag is true, we store the author's name and id in the <a href="tqmap.html">TQMap</a>, otherwise we look up the given author name and set id appropriately.</p> <li><p>Before we perform an update we must ensure that the author combobox shows the right author.</p> <pre> void EditBookForm::primeUpdateBook( <a href="tqsqlrecord.html">TQSqlRecord</a> * buffer ) { |