summaryrefslogtreecommitdiffstats
path: root/examples/sql/overview
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sql/overview')
-rw-r--r--examples/sql/overview/basicbrowsing/README1
-rw-r--r--examples/sql/overview/basicbrowsing/basicbrowsing.pro9
-rw-r--r--examples/sql/overview/basicbrowsing/main.cpp35
-rw-r--r--examples/sql/overview/basicbrowsing2/README1
-rw-r--r--examples/sql/overview/basicbrowsing2/basicbrowsing2.pro9
-rw-r--r--examples/sql/overview/basicbrowsing2/main.cpp43
-rw-r--r--examples/sql/overview/basicdatamanip/README1
-rw-r--r--examples/sql/overview/basicdatamanip/basicdatamanip.pro9
-rw-r--r--examples/sql/overview/basicdatamanip/main.cpp40
-rw-r--r--examples/sql/overview/connect1/README1
-rw-r--r--examples/sql/overview/connect1/connect1.pro9
-rw-r--r--examples/sql/overview/connect1/main.cpp31
-rw-r--r--examples/sql/overview/connection.cpp50
-rw-r--r--examples/sql/overview/connection.h24
-rw-r--r--examples/sql/overview/create_connections/README1
-rw-r--r--examples/sql/overview/create_connections/create_connections.pro9
-rw-r--r--examples/sql/overview/create_connections/main.cpp26
-rw-r--r--examples/sql/overview/custom1/custom1.pro8
-rw-r--r--examples/sql/overview/custom1/main.cpp109
-rw-r--r--examples/sql/overview/custom1/main.h52
-rw-r--r--examples/sql/overview/delete/README1
-rw-r--r--examples/sql/overview/delete/delete.pro9
-rw-r--r--examples/sql/overview/delete/main.cpp29
-rw-r--r--examples/sql/overview/extract/README1
-rw-r--r--examples/sql/overview/extract/extract.pro9
-rw-r--r--examples/sql/overview/extract/main.cpp41
-rw-r--r--examples/sql/overview/form1/form1.pro8
-rw-r--r--examples/sql/overview/form1/main.cpp69
-rw-r--r--examples/sql/overview/form2/form2.pro8
-rw-r--r--examples/sql/overview/form2/main.cpp77
-rw-r--r--examples/sql/overview/form2/main.h33
-rw-r--r--examples/sql/overview/insert/README1
-rw-r--r--examples/sql/overview/insert/insert.pro9
-rw-r--r--examples/sql/overview/insert/main.cpp37
-rw-r--r--examples/sql/overview/insert2/insert2.pro9
-rw-r--r--examples/sql/overview/insert2/main.cpp29
-rw-r--r--examples/sql/overview/navigating/README1
-rw-r--r--examples/sql/overview/navigating/main.cpp33
-rw-r--r--examples/sql/overview/navigating/navigating.pro9
-rw-r--r--examples/sql/overview/order1/README1
-rw-r--r--examples/sql/overview/order1/main.cpp32
-rw-r--r--examples/sql/overview/order1/order1.pro9
-rw-r--r--examples/sql/overview/order2/README1
-rw-r--r--examples/sql/overview/order2/main.cpp34
-rw-r--r--examples/sql/overview/order2/order2.pro9
-rw-r--r--examples/sql/overview/overview.pro33
-rw-r--r--examples/sql/overview/retrieve1/README1
-rw-r--r--examples/sql/overview/retrieve1/main.cpp30
-rw-r--r--examples/sql/overview/retrieve1/retrieve1.pro9
-rw-r--r--examples/sql/overview/retrieve2/README1
-rw-r--r--examples/sql/overview/retrieve2/main.cpp30
-rw-r--r--examples/sql/overview/retrieve2/retrieve2.pro9
-rw-r--r--examples/sql/overview/subclass1/main.cpp38
-rw-r--r--examples/sql/overview/subclass1/subclass1.pro8
-rw-r--r--examples/sql/overview/subclass2/main.cpp42
-rw-r--r--examples/sql/overview/subclass2/main.h23
-rw-r--r--examples/sql/overview/subclass2/subclass2.pro8
-rw-r--r--examples/sql/overview/subclass3/main.cpp57
-rw-r--r--examples/sql/overview/subclass3/main.h25
-rw-r--r--examples/sql/overview/subclass3/subclass3.pro8
-rw-r--r--examples/sql/overview/subclass4/main.cpp81
-rw-r--r--examples/sql/overview/subclass4/main.h25
-rw-r--r--examples/sql/overview/subclass4/subclass4.pro8
-rw-r--r--examples/sql/overview/subclass5/main.cpp94
-rw-r--r--examples/sql/overview/subclass5/main.h25
-rw-r--r--examples/sql/overview/subclass5/subclass5.pro8
-rw-r--r--examples/sql/overview/table1/main.cpp31
-rw-r--r--examples/sql/overview/table1/table1.pro8
-rw-r--r--examples/sql/overview/table2/main.cpp41
-rw-r--r--examples/sql/overview/table2/table2.pro8
-rw-r--r--examples/sql/overview/table3/main.cpp90
-rw-r--r--examples/sql/overview/table3/main.h40
-rw-r--r--examples/sql/overview/table3/table3.pro8
-rw-r--r--examples/sql/overview/table4/main.cpp109
-rw-r--r--examples/sql/overview/table4/main.h53
-rw-r--r--examples/sql/overview/table4/table4.pro8
-rw-r--r--examples/sql/overview/update/README1
-rw-r--r--examples/sql/overview/update/main.cpp32
-rw-r--r--examples/sql/overview/update/update.pro9
79 files changed, 1968 insertions, 0 deletions
diff --git a/examples/sql/overview/basicbrowsing/README b/examples/sql/overview/basicbrowsing/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/basicbrowsing/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/basicbrowsing/basicbrowsing.pro b/examples/sql/overview/basicbrowsing/basicbrowsing.pro
new file mode 100644
index 000000000..b7245c992
--- /dev/null
+++ b/examples/sql/overview/basicbrowsing/basicbrowsing.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
+
diff --git a/examples/sql/overview/basicbrowsing/main.cpp b/examples/sql/overview/basicbrowsing/main.cpp
new file mode 100644
index 000000000..a63182444
--- /dev/null
+++ b/examples/sql/overview/basicbrowsing/main.cpp
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlquery.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlDatabase *oracledb = TQSqlDatabase::database( "ORACLE" );
+ // Copy data from the oracle database to the ODBC (default)
+ // database
+ TQSqlQuery target;
+ TQSqlQuery query( "SELECT id, name FROM people", oracledb );
+ if ( query.isActive() ) {
+ while ( query.next() ) {
+ target.exec( "INSERT INTO people ( id, name ) VALUES ( " +
+ query.value(0).toString() +
+ ", '" + query.value(1).toString() + "' )" );
+ }
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/basicbrowsing2/README b/examples/sql/overview/basicbrowsing2/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/basicbrowsing2/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/basicbrowsing2/basicbrowsing2.pro b/examples/sql/overview/basicbrowsing2/basicbrowsing2.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/basicbrowsing2/basicbrowsing2.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/basicbrowsing2/main.cpp b/examples/sql/overview/basicbrowsing2/main.cpp
new file mode 100644
index 000000000..5f7cbcb9f
--- /dev/null
+++ b/examples/sql/overview/basicbrowsing2/main.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlquery.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlDatabase *oracledb = TQSqlDatabase::database( "ORACLE" );
+ // Copy data from the oracle database to the ODBC (default)
+ // database
+ TQSqlQuery target;
+ TQSqlQuery query( "SELECT id, name FROM people", oracledb );
+ int count = 0;
+ if ( query.isActive() ) {
+ while ( query.next() ) {
+ target.exec( "INSERT INTO people ( id, name ) VALUES ( " +
+ query.value(0).toString() +
+ ", '" + query.value(1).toString() + "' )" );
+ if ( target.isActive() )
+ count += target.numRowsAffected();
+ }
+ }
+ }
+
+ return 0;
+}
+
+
+
+
+
diff --git a/examples/sql/overview/basicdatamanip/README b/examples/sql/overview/basicdatamanip/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/basicdatamanip/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/basicdatamanip/basicdatamanip.pro b/examples/sql/overview/basicdatamanip/basicdatamanip.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/basicdatamanip/basicdatamanip.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/basicdatamanip/main.cpp b/examples/sql/overview/basicdatamanip/main.cpp
new file mode 100644
index 000000000..7777f9813
--- /dev/null
+++ b/examples/sql/overview/basicdatamanip/main.cpp
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlquery.h>
+#include "../connection.h"
+
+bool createConnections();
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ int rows = 0;
+
+ if ( createConnections() ) {
+ TQSqlQuery query( "INSERT INTO staff ( id, forename, surname, salary ) "
+ "VALUES ( 1155, 'Ginger', 'Davis', 50000 )" );
+ if ( query.isActive() ) rows += query.numRowsAffected() ;
+
+ query.exec( "UPDATE staff SET salary=60000 WHERE id=1155" );
+ if ( query.isActive() ) rows += query.numRowsAffected() ;
+
+ query.exec( "DELETE FROM staff WHERE id=1155" );
+ if ( query.isActive() ) rows += query.numRowsAffected() ;
+ }
+
+ return ( rows == 3 ) ? 0 : 1;
+}
+
+
+
diff --git a/examples/sql/overview/connect1/README b/examples/sql/overview/connect1/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/connect1/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/connect1/connect1.pro b/examples/sql/overview/connect1/connect1.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/connect1/connect1.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/connect1/main.cpp b/examples/sql/overview/connect1/main.cpp
new file mode 100644
index 000000000..16f3eeab2
--- /dev/null
+++ b/examples/sql/overview/connect1/main.cpp
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include "../connection.h"
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ TQSqlDatabase *defaultDB = TQSqlDatabase::addDatabase( DB_SALES_DRIVER );
+ defaultDB->setDatabaseName( DB_SALES_DBNAME );
+ defaultDB->setUserName( DB_SALES_USER );
+ defaultDB->setPassword( DB_SALES_PASSWD );
+ defaultDB->setHostName( DB_SALES_HOST );
+
+ if ( defaultDB->open() ) {
+ // Database successfully opened; we can now issue SQL commands.
+ }
+
+ return 0;
+}
+
diff --git a/examples/sql/overview/connection.cpp b/examples/sql/overview/connection.cpp
new file mode 100644
index 000000000..0bbc7116c
--- /dev/null
+++ b/examples/sql/overview/connection.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+#include <qsqldatabase.h>
+#include "connection.h"
+
+bool createConnections()
+{
+
+ TQSqlDatabase *defaultDB = TQSqlDatabase::addDatabase( DB_SALES_DRIVER );
+ defaultDB->setDatabaseName( DB_SALES_DBNAME );
+ defaultDB->setUserName( DB_SALES_USER );
+ defaultDB->setPassword( DB_SALES_PASSWD );
+ defaultDB->setHostName( DB_SALES_HOST );
+ if ( ! defaultDB->open() ) {
+ qWarning( "Failed to open sales database: " + defaultDB->lastError().text() );
+ return FALSE;
+ }
+
+ TQSqlDatabase *oracle = TQSqlDatabase::addDatabase( DB_ORDERS_DRIVER, "ORACLE" );
+ oracle->setDatabaseName( DB_ORDERS_DBNAME );
+ oracle->setUserName( DB_ORDERS_USER );
+ oracle->setPassword( DB_ORDERS_PASSWD );
+ oracle->setHostName( DB_ORDERS_HOST );
+ if ( ! oracle->open() ) {
+ qWarning( "Failed to open orders database: " + oracle->lastError().text() );
+ return FALSE;
+ }
+
+ TQSqlQuery q(TQString::null, defaultDB);
+ q.exec("create table people (id integer primary key, name char(40))");
+ q.exec("create table staff (id integer primary key, forename char(40), "
+ "surname char(40), salary float, statusid integer)");
+ q.exec("create table status (id integer primary key, name char(30))");
+ q.exec("create table creditors (id integer primary key, forename char(40), "
+ "surname char(40), city char(30))");
+ q.exec("create table prices (id integer primary key, name char(40), price float)");
+ q.exec("create table invoiceitem (id integer primary key, "
+ "pricesid integer, quantity integer, paiddate date)");
+
+ TQSqlQuery q2(TQString::null, oracle);
+ q2.exec("create table people (id integer primary key, name char(40))");
+
+ return TRUE;
+}
diff --git a/examples/sql/overview/connection.h b/examples/sql/overview/connection.h
new file mode 100644
index 000000000..c2c5195b6
--- /dev/null
+++ b/examples/sql/overview/connection.h
@@ -0,0 +1,24 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+// Enter your connection info here
+
+#define DB_SALES_DRIVER "TQSQLITE"
+#define DB_SALES_DBNAME ":memory:"
+#define DB_SALES_USER ""
+#define DB_SALES_PASSWD ""
+#define DB_SALES_HOST ""
+
+#define DB_ORDERS_DRIVER "TQSQLITE"
+#define DB_ORDERS_DBNAME ":memory:"
+#define DB_ORDERS_USER ""
+#define DB_ORDERS_PASSWD ""
+#define DB_ORDERS_HOST ""
+
+bool createConnections();
diff --git a/examples/sql/overview/create_connections/README b/examples/sql/overview/create_connections/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/create_connections/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/create_connections/create_connections.pro b/examples/sql/overview/create_connections/create_connections.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/create_connections/create_connections.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/create_connections/main.cpp b/examples/sql/overview/create_connections/main.cpp
new file mode 100644
index 000000000..c4b3a9b71
--- /dev/null
+++ b/examples/sql/overview/create_connections/main.cpp
@@ -0,0 +1,26 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ // Databases successfully opened; get pointers to them:
+ TQSqlDatabase *oracledb = TQSqlDatabase::database( "ORACLE" );
+ // Now we can now issue SQL commands to the oracle connection
+ // or to the default connection
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/custom1/custom1.pro b/examples/sql/overview/custom1/custom1.pro
new file mode 100644
index 000000000..c490bedd0
--- /dev/null
+++ b/examples/sql/overview/custom1/custom1.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS = main.h
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/custom1/main.cpp b/examples/sql/overview/custom1/main.cpp
new file mode 100644
index 000000000..808444c7c
--- /dev/null
+++ b/examples/sql/overview/custom1/main.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "main.h"
+
+
+CustomEdit::CustomEdit( TQWidget *parent, const char *name ) :
+ TQLineEdit( parent, name )
+{
+ connect( this, SIGNAL(textChanged(const TQString &)),
+ this, SLOT(changed(const TQString &)) );
+}
+
+
+void CustomEdit::changed( const TQString &line )
+{
+ setUpperLine( line );
+}
+
+
+void CustomEdit::setUpperLine( const TQString &line )
+{
+ upperLineText = line.upper();
+ setText( upperLineText );
+}
+
+
+TQString CustomEdit::upperLine() const
+{
+ return upperLineText;
+}
+
+
+FormDialog::FormDialog()
+{
+ TQLabel *forenameLabel = new TQLabel( "Forename:", this );
+ CustomEdit *forenameEdit = new CustomEdit( this );
+ TQLabel *surnameLabel = new TQLabel( "Surname:", this );
+ CustomEdit *surnameEdit = new CustomEdit( this );
+ TQLabel *salaryLabel = new TQLabel( "Salary:", this );
+ TQLineEdit *salaryEdit = new TQLineEdit( this );
+ salaryEdit->setAlignment( TQt::AlignRight );
+ TQPushButton *saveButton = new TQPushButton( "&Save", this );
+ connect( saveButton, SIGNAL(clicked()), this, SLOT(save()) );
+
+ TQGridLayout *grid = new TQGridLayout( this );
+ grid->addWidget( forenameLabel, 0, 0 );
+ grid->addWidget( forenameEdit, 0, 1 );
+ grid->addWidget( surnameLabel, 1, 0 );
+ grid->addWidget( surnameEdit, 1, 1 );
+ grid->addWidget( salaryLabel, 2, 0 );
+ grid->addWidget( salaryEdit, 2, 1 );
+ grid->addWidget( saveButton, 3, 0 );
+ grid->activate();
+
+ staffCursor = new TQSqlCursor( "staff" );
+ staffCursor->setTrimmed( "forename", TRUE );
+ staffCursor->setTrimmed( "surname", TRUE );
+ idIndex = staffCursor->index( "id" );
+ staffCursor->select( idIndex );
+ staffCursor->first();
+
+ propMap = new TQSqlPropertyMap;
+ propMap->insert( forenameEdit->className(), "upperLine" );
+
+ sqlForm = new TQSqlForm( this );
+ sqlForm->setRecord( staffCursor->primeUpdate() );
+ sqlForm->installPropertyMap( propMap );
+ sqlForm->insert( forenameEdit, "forename" );
+ sqlForm->insert( surnameEdit, "surname" );
+ sqlForm->insert( salaryEdit, "salary" );
+ sqlForm->readFields();
+}
+
+
+FormDialog::~FormDialog()
+{
+ delete staffCursor;
+}
+
+
+void FormDialog::save()
+{
+ sqlForm->writeFields();
+ staffCursor->update();
+ staffCursor->select( idIndex );
+ staffCursor->first();
+}
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( ! createConnections() )
+ return 1;
+
+ FormDialog *formDialog = new FormDialog();
+ formDialog->show();
+ app.setMainWidget( formDialog );
+
+ return app.exec();
+}
diff --git a/examples/sql/overview/custom1/main.h b/examples/sql/overview/custom1/main.h
new file mode 100644
index 000000000..191672245
--- /dev/null
+++ b/examples/sql/overview/custom1/main.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qdialog.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include <qsqlform.h>
+#include <qsqlpropertymap.h>
+#include "../connection.h"
+
+class CustomEdit : public TQLineEdit
+{
+ Q_OBJECT
+ Q_PROPERTY( TQString upperLine READ upperLine WRITE setUpperLine )
+ public:
+ CustomEdit( TQWidget *parent=0, const char *name=0 );
+ TQString upperLine() const;
+ void setUpperLine( const TQString &line );
+ public slots:
+ void changed( const TQString &line );
+ private:
+ TQString upperLineText;
+};
+
+
+class FormDialog : public TQDialog
+{
+ Q_OBJECT
+ public:
+ FormDialog();
+ ~FormDialog();
+ public slots:
+ void save();
+ private:
+ TQSqlCursor *staffCursor;
+ TQSqlForm *sqlForm;
+ TQSqlPropertyMap *propMap;
+ TQSqlIndex idIndex;
+};
+
+
diff --git a/examples/sql/overview/delete/README b/examples/sql/overview/delete/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/delete/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/delete/delete.pro b/examples/sql/overview/delete/delete.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/delete/delete.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/delete/main.cpp b/examples/sql/overview/delete/main.cpp
new file mode 100644
index 000000000..ebe2108fa
--- /dev/null
+++ b/examples/sql/overview/delete/main.cpp
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlCursor cur( "prices" );
+ cur.select( "id=999" );
+ if ( cur.next() ) {
+ cur.primeDelete();
+ cur.del();
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/extract/README b/examples/sql/overview/extract/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/extract/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/extract/extract.pro b/examples/sql/overview/extract/extract.pro
new file mode 100644
index 000000000..c517268f4
--- /dev/null
+++ b/examples/sql/overview/extract/extract.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH =../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/extract/main.cpp b/examples/sql/overview/extract/main.cpp
new file mode 100644
index 000000000..191601c82
--- /dev/null
+++ b/examples/sql/overview/extract/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlCursor cur( "creditors" );
+
+ TQStringList orderFields = TQStringList() << "surname" << "forename";
+ TQSqlIndex order = cur.index( orderFields );
+
+ TQStringList filterFields = TQStringList() << "surname" << "city";
+ TQSqlIndex filter = cur.index( filterFields );
+ cur.setValue( "surname", "Chirac" );
+ cur.setValue( "city", "Paris" );
+
+ cur.select( filter, order );
+
+ while ( cur.next() ) {
+ int id = cur.value( "id" ).toInt();
+ TQString name = cur.value( "forename" ).toString() + " " +
+ cur.value( "surname" ).toString();
+ qDebug( TQString::number( id ) + ": " + name );
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/form1/form1.pro b/examples/sql/overview/form1/form1.pro
new file mode 100644
index 000000000..a6cd8cb47
--- /dev/null
+++ b/examples/sql/overview/form1/form1.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/form1/main.cpp b/examples/sql/overview/form1/main.cpp
new file mode 100644
index 000000000..8f1c05b0e
--- /dev/null
+++ b/examples/sql/overview/form1/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qdialog.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include <qsqlform.h>
+#include "../connection.h"
+
+class FormDialog : public TQDialog
+{
+ public:
+ FormDialog();
+};
+
+
+FormDialog::FormDialog()
+{
+ TQLabel *forenameLabel = new TQLabel( "Forename:", this );
+ TQLabel *forenameDisplay = new TQLabel( this );
+ TQLabel *surnameLabel = new TQLabel( "Surname:", this );
+ TQLabel *surnameDisplay = new TQLabel( this );
+ TQLabel *salaryLabel = new TQLabel( "Salary:", this );
+ TQLineEdit *salaryEdit = new TQLineEdit( this );
+
+ TQGridLayout *grid = new TQGridLayout( this );
+ grid->addWidget( forenameLabel, 0, 0 );
+ grid->addWidget( forenameDisplay, 0, 1 );
+ grid->addWidget( surnameLabel, 1, 0 );
+ grid->addWidget( surnameDisplay, 1, 1 );
+ grid->addWidget( salaryLabel, 2, 0 );
+ grid->addWidget( salaryEdit, 2, 1 );
+ grid->activate();
+
+ TQSqlCursor staffCursor( "staff" );
+ staffCursor.select();
+ staffCursor.next();
+
+ TQSqlForm sqlForm( this );
+ sqlForm.setRecord( staffCursor.primeUpdate() );
+ sqlForm.insert( forenameDisplay, "forename" );
+ sqlForm.insert( surnameDisplay, "surname" );
+ sqlForm.insert( salaryEdit, "salary" );
+ sqlForm.readFields();
+}
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( ! createConnections() ) return 1;
+
+ FormDialog *formDialog = new FormDialog();
+ formDialog->show();
+ app.setMainWidget( formDialog );
+
+ return app.exec();
+}
diff --git a/examples/sql/overview/form2/form2.pro b/examples/sql/overview/form2/form2.pro
new file mode 100644
index 000000000..c490bedd0
--- /dev/null
+++ b/examples/sql/overview/form2/form2.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS = main.h
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/form2/main.cpp b/examples/sql/overview/form2/main.cpp
new file mode 100644
index 000000000..2d5420bdc
--- /dev/null
+++ b/examples/sql/overview/form2/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "main.h"
+
+FormDialog::FormDialog()
+ : staffCursor( "staff" )
+{
+ staffCursor.setTrimmed( "forename", TRUE );
+ staffCursor.setTrimmed( "surname", TRUE );
+
+ TQLabel *forenameLabel = new TQLabel( "Forename:", this );
+ TQLineEdit *forenameEdit = new TQLineEdit( this );
+ TQLabel *surnameLabel = new TQLabel( "Surname:", this );
+ TQLineEdit *surnameEdit = new TQLineEdit( this );
+ TQLabel *salaryLabel = new TQLabel( "Salary:", this );
+ TQLineEdit *salaryEdit = new TQLineEdit( this );
+ TQPushButton *saveButton = new TQPushButton( "&Save", this );
+ connect( saveButton, SIGNAL(clicked()), this, SLOT(save()) );
+
+ TQGridLayout *grid = new TQGridLayout( this );
+ grid->addWidget( forenameLabel, 0, 0 );
+ grid->addWidget( forenameEdit, 0, 1 );
+ grid->addWidget( surnameLabel, 1, 0 );
+ grid->addWidget( surnameEdit, 1, 1 );
+ grid->addWidget( salaryLabel, 2, 0 );
+ grid->addWidget( salaryEdit, 2, 1 );
+ grid->addWidget( saveButton, 3, 0 );
+ grid->activate();
+
+ idIndex = staffCursor.index( "id" );
+ staffCursor.select( idIndex );
+ staffCursor.first();
+
+ sqlForm = new TQSqlForm( this );
+ sqlForm->setRecord( staffCursor.primeUpdate() );
+ sqlForm->insert( forenameEdit, "forename" );
+ sqlForm->insert( surnameEdit, "surname" );
+ sqlForm->insert( salaryEdit, "salary" );
+ sqlForm->readFields();
+}
+
+
+FormDialog::~FormDialog()
+{
+
+}
+
+
+void FormDialog::save()
+{
+ sqlForm->writeFields();
+ staffCursor.update();
+ staffCursor.select( idIndex );
+ staffCursor.first();
+}
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( ! createConnections() )
+ return 1;
+
+ FormDialog *formDialog = new FormDialog();
+ formDialog->show();
+ app.setMainWidget( formDialog );
+
+ return app.exec();
+}
diff --git a/examples/sql/overview/form2/main.h b/examples/sql/overview/form2/main.h
new file mode 100644
index 000000000..31a0f66cd
--- /dev/null
+++ b/examples/sql/overview/form2/main.h
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qdialog.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include <qsqlform.h>
+#include "../connection.h"
+
+class FormDialog : public TQDialog
+{
+ Q_OBJECT
+ public:
+ FormDialog();
+ ~FormDialog();
+ public slots:
+ void save();
+ private:
+ TQSqlCursor staffCursor;
+ TQSqlForm *sqlForm;
+ TQSqlIndex idIndex;
+};
diff --git a/examples/sql/overview/insert/README b/examples/sql/overview/insert/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/insert/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/insert/insert.pro b/examples/sql/overview/insert/insert.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/insert/insert.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/insert/main.cpp b/examples/sql/overview/insert/main.cpp
new file mode 100644
index 000000000..47276819f
--- /dev/null
+++ b/examples/sql/overview/insert/main.cpp
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ int count = 0;
+ TQSqlCursor cur( "prices" );
+ TQStringList names = TQStringList() <<
+ "Screwdriver" << "Hammer" << "Wrench" << "Saw";
+ int id = 20;
+ for ( TQStringList::Iterator name = names.begin();
+ name != names.end(); ++name ) {
+ TQSqlRecord *buffer = cur.primeInsert();
+ buffer->setValue( "id", id );
+ buffer->setValue( "name", *name );
+ buffer->setValue( "price", 100.0 + (double)id );
+ count += cur.insert();
+ id++;
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/insert2/insert2.pro b/examples/sql/overview/insert2/insert2.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/insert2/insert2.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/insert2/main.cpp b/examples/sql/overview/insert2/main.cpp
new file mode 100644
index 000000000..800a94464
--- /dev/null
+++ b/examples/sql/overview/insert2/main.cpp
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlCursor cur( "prices" );
+ TQSqlRecord *buffer = cur.primeInsert();
+ buffer->setValue( "id", 53981 );
+ buffer->setValue( "name", "Thingy" );
+ buffer->setValue( "price", 105.75 );
+ cur.insert();
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/navigating/README b/examples/sql/overview/navigating/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/navigating/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/navigating/main.cpp b/examples/sql/overview/navigating/main.cpp
new file mode 100644
index 000000000..519aa2698
--- /dev/null
+++ b/examples/sql/overview/navigating/main.cpp
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlquery.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlQuery query( "SELECT id, name FROM people ORDER BY name" );
+ if ( ! query.isActive() ) return 1; // Query failed
+ int i;
+ i = query.size(); // In this example we have 9 records; i == 9.
+ query.first(); // Moves to the first record.
+ i = query.at(); // i == 0
+ query.last(); // Moves to the last record.
+ i = query.at(); // i == 8
+ query.seek( query.size() / 2 ); // Moves to the middle record.
+ i = query.at(); // i == 4
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/navigating/navigating.pro b/examples/sql/overview/navigating/navigating.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/navigating/navigating.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/order1/README b/examples/sql/overview/order1/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/order1/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/order1/main.cpp b/examples/sql/overview/order1/main.cpp
new file mode 100644
index 000000000..7b185d459
--- /dev/null
+++ b/examples/sql/overview/order1/main.cpp
@@ -0,0 +1,32 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlCursor cur( "staff" );
+ TQStringList fields = TQStringList() << "surname" << "forename";
+ TQSqlIndex order = cur.index( fields );
+ cur.select( order );
+ while ( cur.next() ) {
+ qDebug( cur.value( "id" ).toString() + ": " +
+ cur.value( "surname" ).toString() + " " +
+ cur.value( "forename" ).toString() );
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/order1/order1.pro b/examples/sql/overview/order1/order1.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/order1/order1.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/order2/README b/examples/sql/overview/order2/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/order2/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/order2/main.cpp b/examples/sql/overview/order2/main.cpp
new file mode 100644
index 000000000..9165d2a9f
--- /dev/null
+++ b/examples/sql/overview/order2/main.cpp
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlCursor cur( "staff" );
+ TQStringList fields = TQStringList() << "id" << "forename";
+ TQSqlIndex order = cur.index( fields );
+ TQSqlIndex filter = cur.index( "surname" );
+ cur.setValue( "surname", "Bloggs" );
+ cur.select( filter, order );
+ while ( cur.next() ) {
+ qDebug( cur.value( "id" ).toString() + ": " +
+ cur.value( "surname" ).toString() + " " +
+ cur.value( "forename" ).toString() );
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/order2/order2.pro b/examples/sql/overview/order2/order2.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/order2/order2.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/overview.pro b/examples/sql/overview/overview.pro
new file mode 100644
index 000000000..59be65100
--- /dev/null
+++ b/examples/sql/overview/overview.pro
@@ -0,0 +1,33 @@
+TEMPLATE = subdirs
+
+CONFIG += ordered
+
+REQUIRES = full-config
+
+SUBDIRS = basicbrowsing \
+ basicbrowsing2 \
+ basicdatamanip \
+ connect1 \
+ create_connections \
+ custom1 \
+ delete \
+ extract \
+ form1 \
+ form2 \
+ insert \
+ insert2 \
+ navigating \
+ order1 \
+ order2 \
+ retrieve1 \
+ retrieve2 \
+ subclass1 \
+ subclass2 \
+ subclass3 \
+ subclass4 \
+ subclass5 \
+ table1 \
+ table2 \
+ table3 \
+ table4 \
+ update
diff --git a/examples/sql/overview/retrieve1/README b/examples/sql/overview/retrieve1/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/retrieve1/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/retrieve1/main.cpp b/examples/sql/overview/retrieve1/main.cpp
new file mode 100644
index 000000000..956f8a17f
--- /dev/null
+++ b/examples/sql/overview/retrieve1/main.cpp
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlquery.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlQuery query( "SELECT id, surname FROM staff" );
+ if ( query.isActive() ) {
+ while ( query.next() ) {
+ qDebug( query.value(0).toString() + ": " +
+ query.value(1).toString() );
+ }
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/retrieve1/retrieve1.pro b/examples/sql/overview/retrieve1/retrieve1.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/retrieve1/retrieve1.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/retrieve2/README b/examples/sql/overview/retrieve2/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/retrieve2/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/retrieve2/main.cpp b/examples/sql/overview/retrieve2/main.cpp
new file mode 100644
index 000000000..4cb0150be
--- /dev/null
+++ b/examples/sql/overview/retrieve2/main.cpp
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ TQSqlCursor cur( "staff" ); // Specify the table/view name
+ cur.select(); // We'll retrieve every record
+ while ( cur.next() ) {
+ qDebug( cur.value( "id" ).toString() + ": " +
+ cur.value( "surname" ).toString() + " " +
+ cur.value( "salary" ).toString() );
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/retrieve2/retrieve2.pro b/examples/sql/overview/retrieve2/retrieve2.pro
new file mode 100644
index 000000000..c58585ea2
--- /dev/null
+++ b/examples/sql/overview/retrieve2/retrieve2.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/subclass1/main.cpp b/examples/sql/overview/subclass1/main.cpp
new file mode 100644
index 000000000..476ebd898
--- /dev/null
+++ b/examples/sql/overview/subclass1/main.cpp
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include <qdatatable.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ TQSqlCursor invoiceItemCursor( "invoiceitem" );
+
+ TQDataTable *invoiceItemTable = new TQDataTable( &invoiceItemCursor );
+
+ app.setMainWidget( invoiceItemTable );
+
+ invoiceItemTable->addColumn( "pricesid", "PriceID" );
+ invoiceItemTable->addColumn( "quantity", "Quantity" );
+ invoiceItemTable->addColumn( "paiddate", "Paid" );
+
+ invoiceItemTable->refresh();
+ invoiceItemTable->show();
+
+ return app.exec();
+ }
+
+ return 1;
+}
diff --git a/examples/sql/overview/subclass1/subclass1.pro b/examples/sql/overview/subclass1/subclass1.pro
new file mode 100644
index 000000000..a6cd8cb47
--- /dev/null
+++ b/examples/sql/overview/subclass1/subclass1.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/subclass2/main.cpp b/examples/sql/overview/subclass2/main.cpp
new file mode 100644
index 000000000..f7f9bd91f
--- /dev/null
+++ b/examples/sql/overview/subclass2/main.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "main.h"
+#include <qdatatable.h>
+
+InvoiceItemCursor::InvoiceItemCursor() :
+ TQSqlCursor( "invoiceitem" )
+{
+ // NOOP
+}
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ InvoiceItemCursor invoiceItemCursor;
+
+ TQDataTable *invoiceItemTable = new TQDataTable( &invoiceItemCursor );
+
+ app.setMainWidget( invoiceItemTable );
+
+ invoiceItemTable->addColumn( "pricesid", "PriceID" );
+ invoiceItemTable->addColumn( "quantity", "Quantity" );
+ invoiceItemTable->addColumn( "paiddate", "Paid" );
+
+ invoiceItemTable->refresh();
+ invoiceItemTable->show();
+
+ return app.exec();
+ }
+
+ return 1;
+}
diff --git a/examples/sql/overview/subclass2/main.h b/examples/sql/overview/subclass2/main.h
new file mode 100644
index 000000000..020ecbff7
--- /dev/null
+++ b/examples/sql/overview/subclass2/main.h
@@ -0,0 +1,23 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+class TQSqlRecord;
+
+class InvoiceItemCursor : public TQSqlCursor
+{
+ public:
+ InvoiceItemCursor();
+};
+
+
diff --git a/examples/sql/overview/subclass2/subclass2.pro b/examples/sql/overview/subclass2/subclass2.pro
new file mode 100644
index 000000000..a6cd8cb47
--- /dev/null
+++ b/examples/sql/overview/subclass2/subclass2.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/subclass3/main.cpp b/examples/sql/overview/subclass3/main.cpp
new file mode 100644
index 000000000..db77b855e
--- /dev/null
+++ b/examples/sql/overview/subclass3/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "main.h"
+#include <qdatatable.h>
+
+InvoiceItemCursor::InvoiceItemCursor() :
+ TQSqlCursor( "invoiceitem" )
+{
+ TQSqlFieldInfo productName( "productname", TQVariant::String );
+ append( productName );
+ setCalculated( productName.name(), TRUE );
+}
+
+
+TQVariant InvoiceItemCursor::calculateField( const TQString & name )
+{
+ if ( name == "productname" ) {
+ TQSqlQuery query( "SELECT name FROM prices WHERE id=" +
+ field( "pricesid" )->value().toString() );
+ if ( query.next() )
+ return query.value( 0 );
+ }
+
+ return TQVariant( TQString::null );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ InvoiceItemCursor invoiceItemCursor;
+
+ TQDataTable *invoiceItemTable = new TQDataTable( &invoiceItemCursor );
+
+ app.setMainWidget( invoiceItemTable );
+
+ invoiceItemTable->addColumn( "productname", "Product" );
+ invoiceItemTable->addColumn( "quantity", "Quantity" );
+ invoiceItemTable->addColumn( "paiddate", "Paid" );
+
+ invoiceItemTable->refresh();
+ invoiceItemTable->show();
+
+ return app.exec();
+ }
+
+ return 1;
+}
diff --git a/examples/sql/overview/subclass3/main.h b/examples/sql/overview/subclass3/main.h
new file mode 100644
index 000000000..06b0a1734
--- /dev/null
+++ b/examples/sql/overview/subclass3/main.h
@@ -0,0 +1,25 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+class TQSqlRecord;
+
+class InvoiceItemCursor : public TQSqlCursor
+{
+ public:
+ InvoiceItemCursor();
+ protected:
+ TQVariant calculateField( const TQString & name );
+};
+
+
diff --git a/examples/sql/overview/subclass3/subclass3.pro b/examples/sql/overview/subclass3/subclass3.pro
new file mode 100644
index 000000000..a6cd8cb47
--- /dev/null
+++ b/examples/sql/overview/subclass3/subclass3.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/subclass4/main.cpp b/examples/sql/overview/subclass4/main.cpp
new file mode 100644
index 000000000..a96870e4d
--- /dev/null
+++ b/examples/sql/overview/subclass4/main.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "main.h"
+#include <qdatatable.h>
+
+InvoiceItemCursor::InvoiceItemCursor() :
+ TQSqlCursor( "invoiceitem" )
+{
+ TQSqlFieldInfo productName( "productname", TQVariant::String );
+ append( productName );
+ setCalculated( productName.name(), TRUE );
+
+ TQSqlFieldInfo productPrice( "price", TQVariant::Double );
+ append( productPrice );
+ setCalculated( productPrice.name(), TRUE );
+
+ TQSqlFieldInfo productCost( "cost", TQVariant::Double );
+ append( productCost );
+ setCalculated( productCost.name(), TRUE );
+}
+
+
+TQVariant InvoiceItemCursor::calculateField( const TQString & name )
+{
+
+ if ( name == "productname" ) {
+ TQSqlQuery query( "SELECT name FROM prices WHERE id=" +
+ field( "pricesid" )->value().toString() );
+ if ( query.next() )
+ return query.value( 0 );
+ }
+ else if ( name == "price" ) {
+ TQSqlQuery query( "SELECT price FROM prices WHERE id=" +
+ field( "pricesid" )->value().toString() );
+ if ( query.next() )
+ return query.value( 0 );
+ }
+ else if ( name == "cost" ) {
+ TQSqlQuery query( "SELECT price FROM prices WHERE id=" +
+ field( "pricesid" )->value().toString() );
+ if ( query.next() )
+ return TQVariant( query.value( 0 ).toDouble() *
+ value( "quantity").toDouble() );
+ }
+
+ return TQVariant( TQString::null );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ InvoiceItemCursor invoiceItemCursor;
+
+ TQDataTable *invoiceItemTable = new TQDataTable( &invoiceItemCursor );
+
+ app.setMainWidget( invoiceItemTable );
+
+ invoiceItemTable->addColumn( "productname", "Product" );
+ invoiceItemTable->addColumn( "price", "Price" );
+ invoiceItemTable->addColumn( "quantity", "Quantity" );
+ invoiceItemTable->addColumn( "cost", "Cost" );
+ invoiceItemTable->addColumn( "paiddate", "Paid" );
+
+ invoiceItemTable->refresh();
+ invoiceItemTable->show();
+
+ return app.exec();
+ }
+
+ return 1;
+}
diff --git a/examples/sql/overview/subclass4/main.h b/examples/sql/overview/subclass4/main.h
new file mode 100644
index 000000000..06b0a1734
--- /dev/null
+++ b/examples/sql/overview/subclass4/main.h
@@ -0,0 +1,25 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+class TQSqlRecord;
+
+class InvoiceItemCursor : public TQSqlCursor
+{
+ public:
+ InvoiceItemCursor();
+ protected:
+ TQVariant calculateField( const TQString & name );
+};
+
+
diff --git a/examples/sql/overview/subclass4/subclass4.pro b/examples/sql/overview/subclass4/subclass4.pro
new file mode 100644
index 000000000..a6cd8cb47
--- /dev/null
+++ b/examples/sql/overview/subclass4/subclass4.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/subclass5/main.cpp b/examples/sql/overview/subclass5/main.cpp
new file mode 100644
index 000000000..260ddaf2a
--- /dev/null
+++ b/examples/sql/overview/subclass5/main.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "main.h"
+#include <qdatatable.h>
+
+InvoiceItemCursor::InvoiceItemCursor() :
+ TQSqlCursor( "invoiceitem" )
+{
+ TQSqlFieldInfo productName( "productname", TQVariant::String );
+ append( productName );
+ setCalculated( productName.name(), TRUE );
+
+ TQSqlFieldInfo productPrice( "price", TQVariant::Double );
+ append( productPrice );
+ setCalculated( productPrice.name(), TRUE );
+
+ TQSqlFieldInfo productCost( "cost", TQVariant::Double );
+ append( productCost );
+ setCalculated( productCost.name(), TRUE );
+}
+
+
+TQVariant InvoiceItemCursor::calculateField( const TQString & name )
+{
+
+ if ( name == "productname" ) {
+ TQSqlQuery query( "SELECT name FROM prices WHERE id=" +
+ field( "pricesid" )->value().toString() );
+ if ( query.next() )
+ return query.value( 0 );
+ }
+ else if ( name == "price" ) {
+ TQSqlQuery query( "SELECT price FROM prices WHERE id=" +
+ field( "pricesid" )->value().toString() );
+ if ( query.next() )
+ return query.value( 0 );
+ }
+ else if ( name == "cost" ) {
+ TQSqlQuery query( "SELECT price FROM prices WHERE id=" +
+ field( "pricesid" )->value().toString() );
+ if ( query.next() )
+ return TQVariant( query.value( 0 ).toDouble() *
+ value( "quantity").toDouble() );
+ }
+
+ return TQVariant( TQString::null );
+}
+
+
+TQSqlRecord *InvoiceItemCursor::primeInsert()
+{
+ TQSqlRecord *buffer = editBuffer();
+ TQSqlQuery query( "SELECT NEXTVAL( 'invoiceitem_seq' )" );
+ if ( query.next() )
+ buffer->setValue( "id", query.value( 0 ) );
+ buffer->setValue( "paiddate", TQDate::currentDate() );
+ buffer->setValue( "quantity", 1 );
+
+ return buffer;
+}
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ InvoiceItemCursor invoiceItemCursor;
+
+ TQDataTable *invoiceItemTable = new TQDataTable( &invoiceItemCursor );
+
+ app.setMainWidget( invoiceItemTable );
+
+ invoiceItemTable->addColumn( "productname", "Product" );
+ invoiceItemTable->addColumn( "price", "Price" );
+ invoiceItemTable->addColumn( "quantity", "Quantity" );
+ invoiceItemTable->addColumn( "cost", "Cost" );
+ invoiceItemTable->addColumn( "paiddate", "Paid" );
+
+ invoiceItemTable->refresh();
+ invoiceItemTable->show();
+
+ return app.exec();
+ }
+
+ return 1;
+}
diff --git a/examples/sql/overview/subclass5/main.h b/examples/sql/overview/subclass5/main.h
new file mode 100644
index 000000000..6f3a0edca
--- /dev/null
+++ b/examples/sql/overview/subclass5/main.h
@@ -0,0 +1,25 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qdatetime.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+class TQSqlRecord;
+
+class InvoiceItemCursor : public TQSqlCursor
+{
+ public:
+ InvoiceItemCursor();
+ TQSqlRecord *primeInsert();
+ protected:
+ TQVariant calculateField( const TQString & name );
+};
diff --git a/examples/sql/overview/subclass5/subclass5.pro b/examples/sql/overview/subclass5/subclass5.pro
new file mode 100644
index 000000000..a6cd8cb47
--- /dev/null
+++ b/examples/sql/overview/subclass5/subclass5.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/table1/main.cpp b/examples/sql/overview/table1/main.cpp
new file mode 100644
index 000000000..c0041a9a2
--- /dev/null
+++ b/examples/sql/overview/table1/main.cpp
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include <qdatatable.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ TQSqlCursor staffCursor( "staff" );
+ TQDataTable *staffTable = new TQDataTable( &staffCursor, TRUE );
+ app.setMainWidget( staffTable );
+ staffTable->refresh();
+ staffTable->show();
+
+ return app.exec();
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/table1/table1.pro b/examples/sql/overview/table1/table1.pro
new file mode 100644
index 000000000..a6cd8cb47
--- /dev/null
+++ b/examples/sql/overview/table1/table1.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/table2/main.cpp b/examples/sql/overview/table2/main.cpp
new file mode 100644
index 000000000..79c9993f9
--- /dev/null
+++ b/examples/sql/overview/table2/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include <qdatatable.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ TQSqlCursor staffCursor( "staff" );
+
+ TQDataTable *staffTable = new TQDataTable( &staffCursor );
+
+ app.setMainWidget( staffTable );
+
+ staffTable->addColumn( "forename", "Forename" );
+ staffTable->addColumn( "surname", "Surname" );
+ staffTable->addColumn( "salary", "Annual Salary" );
+
+ TQStringList order = TQStringList() << "surname" << "forename";
+ staffTable->setSort( order );
+
+ staffTable->refresh();
+ staffTable->show();
+
+ return app.exec();
+ }
+
+ return 1;
+}
diff --git a/examples/sql/overview/table2/table2.pro b/examples/sql/overview/table2/table2.pro
new file mode 100644
index 000000000..a6cd8cb47
--- /dev/null
+++ b/examples/sql/overview/table2/table2.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/table3/main.cpp b/examples/sql/overview/table3/main.cpp
new file mode 100644
index 000000000..4b9f2050e
--- /dev/null
+++ b/examples/sql/overview/table3/main.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "main.h"
+#include <qdatatable.h>
+
+StatusPicker::StatusPicker( TQWidget *parent, const char *name )
+ : TQComboBox( parent, name )
+{
+ TQSqlCursor cur( "status" );
+ cur.select( cur.index( "name" ) );
+
+ int i = 0;
+ while ( cur.next() ) {
+ insertItem( cur.value( "name" ).toString(), i );
+ index2id[i] = cur.value( "id" ).toInt();
+ i++;
+ }
+}
+
+
+int StatusPicker::statusId() const
+{
+ return index2id[ currentItem() ];
+}
+
+
+void StatusPicker::setStatusId( int statusid )
+{
+ TQMap<int,int>::Iterator it;
+ for ( it = index2id.begin(); it != index2id.end(); ++it ) {
+ if ( it.data() == statusid ) {
+ setCurrentItem( it.key() );
+ break;
+ }
+ }
+}
+
+
+
+TQWidget *CustomSqlEditorFactory::createEditor(
+ TQWidget *parent, const TQSqlField *field )
+{
+ if ( field->name() == "statusid" ) {
+ TQWidget *editor = new StatusPicker( parent );
+ return editor;
+ }
+
+ return TQSqlEditorFactory::createEditor( parent, field );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ TQSqlCursor staffCursor( "staff" );
+
+ TQDataTable *staffTable = new TQDataTable( &staffCursor );
+ TQSqlPropertyMap *propMap = new TQSqlPropertyMap();
+ CustomSqlEditorFactory *editorFactory = new CustomSqlEditorFactory();
+ propMap->insert( "StatusPicker", "statusid" );
+ staffTable->installPropertyMap( propMap );
+ staffTable->installEditorFactory( editorFactory );
+
+ app.setMainWidget( staffTable );
+
+ staffTable->addColumn( "forename", "Forename" );
+ staffTable->addColumn( "surname", "Surname" );
+ staffTable->addColumn( "salary", "Annual Salary" );
+ staffTable->addColumn( "statusid", "Status" );
+
+ TQStringList order = TQStringList() << "surname" << "forename";
+ staffTable->setSort( order );
+
+ staffTable->refresh();
+ staffTable->show();
+
+ return app.exec();
+ }
+
+ return 1;
+}
diff --git a/examples/sql/overview/table3/main.h b/examples/sql/overview/table3/main.h
new file mode 100644
index 000000000..dd0d8d095
--- /dev/null
+++ b/examples/sql/overview/table3/main.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qcombobox.h>
+#include <qmap.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include <qsqleditorfactory.h>
+#include <qsqlpropertymap.h>
+#include "../connection.h"
+
+class StatusPicker : public TQComboBox
+{
+ Q_OBJECT
+ Q_PROPERTY( int statusid READ statusId WRITE setStatusId )
+ public:
+ StatusPicker( TQWidget *parent=0, const char *name=0 );
+ int statusId() const;
+ void setStatusId( int id );
+ private:
+ TQMap< int, int > index2id;
+};
+
+
+class CustomSqlEditorFactory : public TQSqlEditorFactory
+{
+ Q_OBJECT
+ public:
+ TQWidget *createEditor( TQWidget *parent, const TQSqlField *field );
+};
+
+
+
diff --git a/examples/sql/overview/table3/table3.pro b/examples/sql/overview/table3/table3.pro
new file mode 100644
index 000000000..c490bedd0
--- /dev/null
+++ b/examples/sql/overview/table3/table3.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS = main.h
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/table4/main.cpp b/examples/sql/overview/table4/main.cpp
new file mode 100644
index 000000000..b557b3f1e
--- /dev/null
+++ b/examples/sql/overview/table4/main.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "main.h"
+
+
+StatusPicker::StatusPicker( TQWidget *parent, const char *name )
+ : TQComboBox( parent, name )
+{
+ TQSqlCursor cur( "status" );
+ cur.select( cur.index( "name" ) );
+
+ int i = 0;
+ while ( cur.next() ) {
+ insertItem( cur.value( "name" ).toString(), i );
+ index2id[i] = cur.value( "id" ).toInt();
+ i++;
+ }
+}
+
+
+int StatusPicker::statusId() const
+{
+ return index2id[ currentItem() ];
+}
+
+
+void StatusPicker::setStatusId( int statusid )
+{
+ TQMap<int,int>::Iterator it;
+ for ( it = index2id.begin(); it != index2id.end(); ++it ) {
+ if ( it.data() == statusid ) {
+ setCurrentItem( it.key() );
+ break;
+ }
+ }
+}
+
+
+void CustomTable::paintField( TQPainter * p, const TQSqlField* field,
+ const TQRect & cr, bool b)
+{
+ if ( !field )
+ return;
+ if ( field->name() == "statusid" ) {
+ TQSqlQuery query( "SELECT name FROM status WHERE id=" +
+ field->value().toString() );
+ TQString text;
+ if ( query.next() ) {
+ text = query.value( 0 ).toString();
+ }
+ p->drawText( 2,2, cr.width()-4, cr.height()-4, fieldAlignment( field ), text );
+ }
+ else {
+ TQDataTable::paintField( p, field, cr, b) ;
+ }
+}
+
+
+TQWidget *CustomSqlEditorFactory::createEditor(
+ TQWidget *parent, const TQSqlField *field )
+{
+ if ( field->name() == "statusid" ) {
+ TQWidget *editor = new StatusPicker( parent );
+ return editor;
+ }
+
+ return TQSqlEditorFactory::createEditor( parent, field );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv );
+
+ if ( createConnections() ) {
+ TQSqlCursor staffCursor( "staff" );
+
+ CustomTable *staffTable = new CustomTable( &staffCursor );
+ TQSqlPropertyMap *propMap = new TQSqlPropertyMap();
+ CustomSqlEditorFactory *editorFactory = new CustomSqlEditorFactory();
+ propMap->insert( "StatusPicker", "statusid" );
+ staffTable->installPropertyMap( propMap );
+ staffTable->installEditorFactory( editorFactory );
+
+ app.setMainWidget( staffTable );
+
+ staffTable->addColumn( "forename", "Forename" );
+ staffTable->addColumn( "surname", "Surname" );
+ staffTable->addColumn( "salary", "Annual Salary" );
+ staffTable->addColumn( "statusid", "Status" );
+
+ TQStringList order = TQStringList() << "surname" << "forename";
+ staffTable->setSort( order );
+
+ staffTable->refresh();
+ staffTable->show();
+
+ return app.exec();
+ }
+
+ return 1;
+}
diff --git a/examples/sql/overview/table4/main.h b/examples/sql/overview/table4/main.h
new file mode 100644
index 000000000..59edfc9d5
--- /dev/null
+++ b/examples/sql/overview/table4/main.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qcombobox.h>
+#include <qmap.h>
+#include <qpainter.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include <qsqleditorfactory.h>
+#include <qsqlpropertymap.h>
+#include <qdatatable.h>
+#include "../connection.h"
+
+class StatusPicker : public TQComboBox
+{
+ Q_OBJECT
+ Q_PROPERTY( int statusid READ statusId WRITE setStatusId )
+public:
+ StatusPicker( TQWidget *parent=0, const char *name=0 );
+ int statusId() const;
+ void setStatusId( int id );
+private:
+ TQMap< int, int > index2id;
+};
+
+
+class CustomTable : public TQDataTable
+{
+ Q_OBJECT
+public:
+ CustomTable(
+ TQSqlCursor *cursor, bool autoPopulate = FALSE,
+ TQWidget * parent = 0, const char * name = 0 ) :
+ TQDataTable( cursor, autoPopulate, parent, name ) {}
+ void paintField(
+ TQPainter * p, const TQSqlField* field, const TQRect & cr, bool );
+
+};
+
+
+class CustomSqlEditorFactory : public TQSqlEditorFactory
+{
+ Q_OBJECT
+public:
+ TQWidget *createEditor( TQWidget *parent, const TQSqlField *field );
+};
diff --git a/examples/sql/overview/table4/table4.pro b/examples/sql/overview/table4/table4.pro
new file mode 100644
index 000000000..c490bedd0
--- /dev/null
+++ b/examples/sql/overview/table4/table4.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+
+REQUIRES = full-config
+
+HEADERS = main.h
+SOURCES = main.cpp ../connection.cpp
diff --git a/examples/sql/overview/update/README b/examples/sql/overview/update/README
new file mode 100644
index 000000000..eae3cd7f9
--- /dev/null
+++ b/examples/sql/overview/update/README
@@ -0,0 +1 @@
+This example is part of the overview in sql.html
diff --git a/examples/sql/overview/update/main.cpp b/examples/sql/overview/update/main.cpp
new file mode 100644
index 000000000..207702c06
--- /dev/null
+++ b/examples/sql/overview/update/main.cpp
@@ -0,0 +1,32 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include <qsqlcursor.h>
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ TQApplication app( argc, argv, FALSE );
+
+ if ( createConnections() ) {
+ TQSqlCursor cur( "prices" );
+ cur.select( "id=202" );
+ if ( cur.next() ) {
+ TQSqlRecord *buffer = cur.primeUpdate();
+ double price = buffer->value( "price" ).toDouble();
+ double newprice = price * 1.05;
+ buffer->setValue( "price", newprice );
+ cur.update();
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/sql/overview/update/update.pro b/examples/sql/overview/update/update.pro
new file mode 100644
index 000000000..9e6df96c9
--- /dev/null
+++ b/examples/sql/overview/update/update.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../../include
+
+REQUIRES = full-config
+
+HEADERS =
+SOURCES = main.cpp ../connection.cpp