From 4d495175043c399fdca6e1bb4c74ef176fc76fb4 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 6 Aug 2025 11:29:57 +0900 Subject: Replace TRUE/FALSE with boolean values true/false - part 4 Signed-off-by: Michele Calgaro --- doc/html/sql.html | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'doc/html/sql.html') diff --git a/doc/html/sql.html b/doc/html/sql.html index 9a9aa90d1..4949a7be9 100644 --- a/doc/html/sql.html +++ b/doc/html/sql.html @@ -238,7 +238,7 @@ connection. int main( int argc, char *argv[] ) { - TQApplication app( argc, argv, FALSE ); + TQApplication app( argc, argv, false ); TQSqlDatabase *defaultDB = TQSqlDatabase::addDatabase( DB_SALES_DRIVER ); defaultDB->setDatabaseName( DB_SALES_DBNAME ); @@ -271,7 +271,7 @@ the TQOCI8 (Oracle 8 and 9) driver the TNS Service Name must be passed to setDatbaseName(). When connecting to ODBC data sources the Data Source Name (DSN) should be used in the setDatabaseName() call.

Third we call open() to open the database and give us access to the -data. If this call fails it will return FALSE; error information can +data. If this call fails it will return false; error information can be obtained from TQSqlDatabase::lastError().

Connecting to Multiple Databases @@ -314,7 +314,7 @@ function in connection.h. defaultDB->setHostName( DB_SALES_HOST ); if ( ! defaultDB->open() ) { tqWarning( "Failed to open sales database: " + defaultDB->lastError().text() ); - return FALSE; + return false; } TQSqlDatabase *oracle = TQSqlDatabase::addDatabase( DB_ORDERS_DRIVER, "ORACLE" ); @@ -324,7 +324,7 @@ function in connection.h. oracle->setHostName( DB_ORDERS_HOST ); if ( ! oracle->open() ) { tqWarning( "Failed to open orders database: " + oracle->lastError().text() ); - return FALSE; + return false; } TQSqlQuery q(TQString::null, defaultDB); @@ -341,7 +341,7 @@ function in connection.h. TQSqlQuery q2(TQString::null, oracle); q2.exec("create table people (id integer primary key, name char(40))"); - return TRUE; + return true; }

From sql/overview/connection.cpp

@@ -355,7 +355,7 @@ function in connection.h. int main( int argc, char *argv[] ) { - TQApplication app( argc, argv, FALSE ); + TQApplication app( argc, argv, false ); if ( createConnections() ) { // Databases successfully opened; get pointers to them: @@ -401,7 +401,7 @@ section and use the TQSqlCursor class covered in

Transactions

If the underlying database engine supports transactions -TQSqlDriver::hasFeature( TQSqlDriver::Transactions ) will return TRUE. +TQSqlDriver::hasFeature( TQSqlDriver::Transactions ) will return true. You can use TQSqlDatabase::transaction() to initiate a transaction, followed by the SQL commands you want to execute within the context of the transaction, and then either TQSqlDatabase::commit() or @@ -418,7 +418,7 @@ the transaction, and then either TQSqlDataba int main( int argc, char *argv[] ) { - TQApplication app( argc, argv, FALSE ); + TQApplication app( argc, argv, false ); if ( createConnections() ) { TQSqlDatabase *oracledb = TQSqlDatabase::database( "ORACLE" ); @@ -469,7 +469,7 @@ section.

From sql/overview/basicbrowsing2/main.cpp

The above code introduces a count of how many records are successfully -inserted. Note that isActive() returns FALSE if the query, e.g. the +inserted. Note that isActive() returns false if the query, e.g. the insertion, fails. numRowsAffected() returns -1 if the number of rows cannot be determined, e.g. if the query fails.

@@ -495,7 +495,7 @@ cannot be determined, e.g. if the query fails. int main( int argc, char *argv[] ) { - TQApplication app( argc, argv, FALSE ); + TQApplication app( argc, argv, false ); int rows = 0; @@ -961,7 +961,7 @@ examples provides additional information. if ( createConnections() ) { TQSqlCursor staffCursor( "staff" ); - TQDataTable *staffTable = new TQDataTable( &staffCursor, TRUE ); + TQDataTable *staffTable = new TQDataTable( &staffCursor, true ); app.setMainWidget( staffTable ); staffTable->refresh(); staffTable->show(); @@ -976,7 +976,7 @@ examples provides additional information.

Data-Aware tables require the tqdatatable.h and tqsqlcursor.h header files. We create our application object, call createConnections() and create the cursor. We create the TQDataTable passing it a pointer to -the cursor, and set the autoPopulate flag to TRUE. Next we make our TQDataTable the main widget and call refresh() to populate it with data +the cursor, and set the autoPopulate flag to true. Next we make our TQDataTable the main widget and call refresh() to populate it with data and call show() to make it visible.

The autoPopulate flag tells the TQDataTable whether or nor it should create columns based on the cursor. autoPopulate does not affect the @@ -1134,8 +1134,8 @@ confirm their update. We also hold pointers to the TQ TQSqlForm since they will need to be accessed outside the constructor.

-

        staffCursor.setTrimmed( "forename", TRUE );
-        staffCursor.setTrimmed( "surname",  TRUE );
+
        staffCursor.setTrimmed( "forename", true );
+        staffCursor.setTrimmed( "surname",  true );
 

We call setTrimmed() on the text fields so that any spaces used to right pad the fields are removed when the fields are retrieved. @@ -1378,7 +1378,7 @@ to subclass TQDataTable and reimplement the paintField() function. TQ_OBJECT public: CustomTable( - TQSqlCursor *cursor, bool autoPopulate = FALSE, + TQSqlCursor *cursor, bool autoPopulate = false, TQWidget * parent = 0, const char * name = 0 ) : TQDataTable( cursor, autoPopulate, parent, name ) {} void paintField( @@ -1504,7 +1504,7 @@ of the calculateField() function since we will be reimplementing it. { TQSqlFieldInfo productName( "productname", TQVariant::String ); append( productName ); - setCalculated( productName.name(), TRUE ); + setCalculated( productName.name(), true ); } TQVariant InvoiceItemCursor::calculateField( const TQString & name ) @@ -1524,7 +1524,7 @@ of the calculateField() function since we will be reimplementing it. TQSqlField called productname and append this to the InvoiceItemCursor's set of fields. We call setCalculated() on productname to identify it as a calculated field. The first argument -to setCalculated() is the field name, the second a bool which if TRUE +to setCalculated() is the field name, the second a bool which if true signifies that calculateField() must be called to get the field's value.

            invoiceItemTable->addColumn( "productname", "Product" );
@@ -1548,15 +1548,15 @@ function require some simple expansion. We'll look at each in turn.
     {
         TQSqlFieldInfo productName( "productname", TQVariant::String );
         append( productName );
-        setCalculated( productName.name(), TRUE );
+        setCalculated( productName.name(), true );
 
         TQSqlFieldInfo productPrice( "price", TQVariant::Double );
         append( productPrice );
-        setCalculated( productPrice.name(), TRUE );
+        setCalculated( productPrice.name(), true );
 
         TQSqlFieldInfo productCost( "cost", TQVariant::Double );
         append( productCost );
-        setCalculated( productCost.name(), TRUE );
+        setCalculated( productCost.name(), true );
     }
 

From sql/overview/subclass4/main.cpp

-- cgit v1.2.3