diff options
Diffstat (limited to 'qtjava/javalib/examples/demo/sql/BookForm.java')
-rw-r--r-- | qtjava/javalib/examples/demo/sql/BookForm.java | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/qtjava/javalib/examples/demo/sql/BookForm.java b/qtjava/javalib/examples/demo/sql/BookForm.java index 67670357..0c51bd09 100644 --- a/qtjava/javalib/examples/demo/sql/BookForm.java +++ b/qtjava/javalib/examples/demo/sql/BookForm.java @@ -8,37 +8,37 @@ ****************************************************************************/ import org.kde.qt.*; -public class BookForm extends QWidget { - QDataTable AuthorDataTable; - QDataTable BookDataTable; - QPushButton connectButton; - QPushButton editButton; +public class BookForm extends TQWidget { + TQDataTable AuthorDataTable; + TQDataTable BookDataTable; + TQPushButton connectButton; + TQPushButton editButton; - QGridLayout BookFormLayout; - QSizePolicy policy_1; - QSizePolicy policy_2; - QSpacerItem spacer; - QSpacerItem spacer_2; + TQGridLayout BookFormLayout; + TQSizePolicy policy_1; + TQSizePolicy policy_2; + TQSpacerItem spacer; + TQSpacerItem spacer_2; - QSqlCursor authorCursor; - QSqlCursor bookCursor; + TQSqlCursor authorCursor; + TQSqlCursor bookCursor; /* * Constructs a BookForm which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ -BookForm( QWidget parent, String name, int fl ) +BookForm( TQWidget parent, String name, int fl ) { super( parent, name, fl ); if ( name == null ) setName( "BookForm" ); resize( 478, 498 ); setCaption( trUtf8( "Book" ) ); - BookFormLayout = new QGridLayout( this ); + BookFormLayout = new TQGridLayout( this ); BookFormLayout.setSpacing( 6 ); BookFormLayout.setMargin( 11 ); - AuthorDataTable = new QDataTable( this, "AuthorDataTable" ); + AuthorDataTable = new TQDataTable( this, "AuthorDataTable" ); AuthorDataTable.addColumn( "surname", trUtf8( "Surname", "" ) ); AuthorDataTable.addColumn( "forename", trUtf8( "Forename", "" ) ); AuthorDataTable.setSorting( true ); @@ -46,10 +46,10 @@ BookForm( QWidget parent, String name, int fl ) AuthorDataTable.setSort( new String[] { "surname ASC", "forename ASC" } ); BookFormLayout.addMultiCellWidget( AuthorDataTable, 1, 1, 0, 2 ); - spacer = new QSpacerItem( 20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum ); + spacer = new TQSpacerItem( 20, 20, TQSizePolicy.Expanding, TQSizePolicy.Minimum ); BookFormLayout.addMultiCell( spacer, 0, 0, 1, 2 ); - BookDataTable = new QDataTable( this, "BookDataTable" ); + BookDataTable = new TQDataTable( this, "BookDataTable" ); BookDataTable.addColumn( "title", trUtf8( "Title", "" ) ); BookDataTable.addColumn( "price", trUtf8( "Price", "" ) ); BookDataTable.addColumn( "notes", trUtf8( "Notes", "" ) ); @@ -58,19 +58,19 @@ BookForm( QWidget parent, String name, int fl ) BookDataTable.setSort( new String[] { "title ASC" } ); BookFormLayout.addMultiCellWidget( BookDataTable, 2, 2, 0, 2 ); - spacer_2 = new QSpacerItem( 20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum ); + spacer_2 = new TQSpacerItem( 20, 20, TQSizePolicy.Expanding, TQSizePolicy.Minimum ); BookFormLayout.addMultiCell( spacer_2, 3, 3, 0, 1 ); - connectButton = new QPushButton( this, "connectButton" ); - policy_1 = new QSizePolicy( (int)0, (int)0, connectButton.sizePolicy().hasHeightForWidth() ); + connectButton = new TQPushButton( this, "connectButton" ); + policy_1 = new TQSizePolicy( (int)0, (int)0, connectButton.sizePolicy().hasHeightForWidth() ); connectButton.setSizePolicy( policy_1 ); connectButton.setText( trUtf8( "&Connect..." ) ); BookFormLayout.addWidget( connectButton, 0, 0 ); - editButton = new QPushButton( this, "editButton" ); + editButton = new TQPushButton( this, "editButton" ); editButton.setEnabled( false ); - policy_2 = new QSizePolicy( (int)0, (int)0, editButton.sizePolicy().hasHeightForWidth() ); + policy_2 = new TQSizePolicy( (int)0, (int)0, editButton.sizePolicy().hasHeightForWidth() ); editButton.setSizePolicy( policy_2 ); editButton.setText( trUtf8( "&Edit Books" ) ); @@ -84,8 +84,8 @@ BookForm( QWidget parent, String name, int fl ) // signals and slots connections connect( editButton, SIGNAL( "clicked()" ), this, SLOT( "editClicked()" ) ); - connect( AuthorDataTable, SIGNAL( "primeInsert(QSqlRecord)" ), this, SLOT( "primeInsertAuthor(QSqlRecord)" ) ); - connect( AuthorDataTable, SIGNAL( "currentChanged(QSqlRecord)" ), this, SLOT( "newCurrentAuthor(QSqlRecord)" ) ); + connect( AuthorDataTable, SIGNAL( "primeInsert(TQSqlRecord)" ), this, SLOT( "primeInsertAuthor(TQSqlRecord)" ) ); + connect( AuthorDataTable, SIGNAL( "currentChanged(TQSqlRecord)" ), this, SLOT( "newCurrentAuthor(TQSqlRecord)" ) ); connect( connectButton, SIGNAL( "clicked()" ), this, SLOT( "connectClicked()" ) ); // tab order @@ -93,12 +93,12 @@ BookForm( QWidget parent, String name, int fl ) init(); } -BookForm( QWidget parent, String name ) +BookForm( TQWidget parent, String name ) { this(parent, name, 0); } -BookForm( QWidget parent ) +BookForm( TQWidget parent ) { this(parent, null, 0); } @@ -119,12 +119,12 @@ public void destroy() void editClicked() { EditBookForm dialog = new EditBookForm( this, "Edit Book Form", true, 0 ); - QSqlCursor cur = new QSqlCursor( "book" ); + TQSqlCursor cur = new TQSqlCursor( "book" ); dialog.BookDataBrowser.setSqlCursor( cur ); dialog.BookDataBrowser.setFilter( BookDataTable.filter() ); String[] sort = new String[BookDataTable.sort().size()]; sort = (String[]) BookDataTable.sort().toArray(sort); - dialog.BookDataBrowser.setSort(QSqlIndex.fromStringList( + dialog.BookDataBrowser.setSort(TQSqlIndex.fromStringList( sort, cur ) ); dialog.BookDataBrowser.refresh(); int i = BookDataTable.currentRow(); @@ -139,13 +139,13 @@ void connectClicked() { boolean ok = false; ConnectDialog dialog = new ConnectDialog( this, "Connect", true, 0 ); - String[] drivers = new String[QSqlDatabase.drivers().size()];; - drivers = (String[]) QSqlDatabase.drivers().toArray(drivers); + String[] drivers = new String[TQSqlDatabase.drivers().size()];; + drivers = (String[]) TQSqlDatabase.drivers().toArray(drivers); dialog.comboDriver.insertStringList( drivers ); dialog.editDatabase.setText( "book" ); - if ( dialog.exec() == QDialog.Accepted ) { - // QSqlDatabase.removeDatabase( QSqlDatabase.defaultConnection() ); - QSqlDatabase db = QSqlDatabase.addDatabase( dialog.comboDriver.currentText() ); + if ( dialog.exec() == TQDialog.Accepted ) { + // TQSqlDatabase.removeDatabase( TQSqlDatabase.defaultConnection() ); + TQSqlDatabase db = TQSqlDatabase.addDatabase( dialog.comboDriver.currentText() ); db.setDatabaseName( dialog.editDatabase.text() ); db.setUserName( dialog.editUsername.text() ); db.setPassword( dialog.editPassword.text() ); @@ -158,29 +158,29 @@ void connectClicked() } if ( !ok ) { editButton.setEnabled( false ); - BookDataTable.setSqlCursor( (QSqlCursor) null ); - AuthorDataTable.setSqlCursor( (QSqlCursor) null ); + BookDataTable.setSqlCursor( (TQSqlCursor) null ); + AuthorDataTable.setSqlCursor( (TQSqlCursor) null ); } else { editButton.setEnabled( true ); - authorCursor = new QSqlCursor( "author" ); + authorCursor = new TQSqlCursor( "author" ); AuthorDataTable.setSqlCursor( authorCursor, false, true ); - bookCursor = new QSqlCursor( "book" ); + bookCursor = new TQSqlCursor( "book" ); BookDataTable.setSqlCursor( bookCursor, false, true ); - AuthorDataTable.refresh( QDataTable.RefreshAll ); - BookDataTable.refresh( QDataTable.RefreshAll ); + AuthorDataTable.refresh( TQDataTable.RefreshAll ); + BookDataTable.refresh( TQDataTable.RefreshAll ); } dialog = null; } -void newCurrentAuthor(QSqlRecord author) +void newCurrentAuthor(TQSqlRecord author) { BookDataTable.setFilter( "authorid=" + author.value( "id" ).toString() ); BookDataTable.refresh(); } -void primeInsertAuthor(QSqlRecord buffer) +void primeInsertAuthor(TQSqlRecord buffer) { - QSqlQuery q = new QSqlQuery(); + TQSqlQuery q = new TQSqlQuery(); q.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='author';" ); q.exec( "SELECT sequence FROM sequence WHERE tablename='author';" ); if ( q.next() ) { |