From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- tools/designer/examples/book/book.sql | 42 +++ tools/designer/examples/book/book1/book.ui | 71 +++++ tools/designer/examples/book/book1/book.ui.h | 5 + tools/designer/examples/book/book1/book1.pro | 8 + tools/designer/examples/book/book1/main.cpp | 27 ++ tools/designer/examples/book/book2/book.ui | 77 +++++ tools/designer/examples/book/book2/book.ui.h | 10 + tools/designer/examples/book/book2/book2.pro | 8 + tools/designer/examples/book/book2/main.cpp | 27 ++ tools/designer/examples/book/book3/book.ui | 141 +++++++++ tools/designer/examples/book/book3/book.ui.h | 16 + tools/designer/examples/book/book3/book3.pro | 8 + tools/designer/examples/book/book3/main.cpp | 27 ++ tools/designer/examples/book/book4/book.ui | 179 +++++++++++ tools/designer/examples/book/book4/book.ui.h | 16 + tools/designer/examples/book/book4/book4.pro | 8 + tools/designer/examples/book/book4/main.cpp | 29 ++ tools/designer/examples/book/book5/book.ui | 188 +++++++++++ tools/designer/examples/book/book5/book.ui.h | 23 ++ tools/designer/examples/book/book5/book5.pro | 8 + tools/designer/examples/book/book5/editbook.ui | 291 +++++++++++++++++ tools/designer/examples/book/book5/editbook.ui.h | 10 + tools/designer/examples/book/book5/main.cpp | 27 ++ tools/designer/examples/book/book6/book.ui | 189 +++++++++++ tools/designer/examples/book/book6/book.ui.h | 33 ++ tools/designer/examples/book/book6/book6.pro | 8 + tools/designer/examples/book/book6/editbook.ui | 300 ++++++++++++++++++ tools/designer/examples/book/book6/editbook.ui.h | 10 + tools/designer/examples/book/book6/main.cpp | 27 ++ tools/designer/examples/book/book7/book.ui | 189 +++++++++++ tools/designer/examples/book/book7/book.ui.h | 33 ++ tools/designer/examples/book/book7/book7.pro | 7 + tools/designer/examples/book/book7/editbook.ui | 384 ++++++++++++++++++++++ tools/designer/examples/book/book7/editbook.ui.h | 42 +++ tools/designer/examples/book/book7/main.cpp | 27 ++ tools/designer/examples/book/book8/book.ui | 189 +++++++++++ tools/designer/examples/book/book8/book.ui.h | 33 ++ tools/designer/examples/book/book8/book8.pro | 7 + tools/designer/examples/book/book8/editbook.ui | 386 +++++++++++++++++++++++ tools/designer/examples/book/book8/editbook.ui.h | 47 +++ tools/designer/examples/book/book8/main.cpp | 27 ++ tools/designer/examples/book/connection.cpp | 52 +++ tools/designer/examples/book/connection.h | 18 ++ 43 files changed, 3254 insertions(+) create mode 100644 tools/designer/examples/book/book.sql create mode 100644 tools/designer/examples/book/book1/book.ui create mode 100644 tools/designer/examples/book/book1/book.ui.h create mode 100644 tools/designer/examples/book/book1/book1.pro create mode 100644 tools/designer/examples/book/book1/main.cpp create mode 100644 tools/designer/examples/book/book2/book.ui create mode 100644 tools/designer/examples/book/book2/book.ui.h create mode 100644 tools/designer/examples/book/book2/book2.pro create mode 100644 tools/designer/examples/book/book2/main.cpp create mode 100644 tools/designer/examples/book/book3/book.ui create mode 100644 tools/designer/examples/book/book3/book.ui.h create mode 100644 tools/designer/examples/book/book3/book3.pro create mode 100644 tools/designer/examples/book/book3/main.cpp create mode 100644 tools/designer/examples/book/book4/book.ui create mode 100644 tools/designer/examples/book/book4/book.ui.h create mode 100644 tools/designer/examples/book/book4/book4.pro create mode 100644 tools/designer/examples/book/book4/main.cpp create mode 100644 tools/designer/examples/book/book5/book.ui create mode 100644 tools/designer/examples/book/book5/book.ui.h create mode 100644 tools/designer/examples/book/book5/book5.pro create mode 100644 tools/designer/examples/book/book5/editbook.ui create mode 100644 tools/designer/examples/book/book5/editbook.ui.h create mode 100644 tools/designer/examples/book/book5/main.cpp create mode 100644 tools/designer/examples/book/book6/book.ui create mode 100644 tools/designer/examples/book/book6/book.ui.h create mode 100644 tools/designer/examples/book/book6/book6.pro create mode 100644 tools/designer/examples/book/book6/editbook.ui create mode 100644 tools/designer/examples/book/book6/editbook.ui.h create mode 100644 tools/designer/examples/book/book6/main.cpp create mode 100644 tools/designer/examples/book/book7/book.ui create mode 100644 tools/designer/examples/book/book7/book.ui.h create mode 100644 tools/designer/examples/book/book7/book7.pro create mode 100644 tools/designer/examples/book/book7/editbook.ui create mode 100644 tools/designer/examples/book/book7/editbook.ui.h create mode 100644 tools/designer/examples/book/book7/main.cpp create mode 100644 tools/designer/examples/book/book8/book.ui create mode 100644 tools/designer/examples/book/book8/book.ui.h create mode 100644 tools/designer/examples/book/book8/book8.pro create mode 100644 tools/designer/examples/book/book8/editbook.ui create mode 100644 tools/designer/examples/book/book8/editbook.ui.h create mode 100644 tools/designer/examples/book/book8/main.cpp create mode 100644 tools/designer/examples/book/connection.cpp create mode 100644 tools/designer/examples/book/connection.h (limited to 'tools/designer/examples/book') diff --git a/tools/designer/examples/book/book.sql b/tools/designer/examples/book/book.sql new file mode 100644 index 000000000..417ef4347 --- /dev/null +++ b/tools/designer/examples/book/book.sql @@ -0,0 +1,42 @@ +-- The following SQL generates the database +-- used by the 'book' example programs +-- Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +-- +-- This file is part of an example program for Qt. This example +-- program may be used, distributed and modified without limitation. + +DROP TABLE author; +DROP TABLE book; +DROP TABLE sequence; + +CREATE TABLE author +( id integer primary key, +forename varchar(40), +surname varchar(40) ); + +CREATE TABLE book +( id integer primary key, +title varchar(40), +price numeric(10,2), +authorid integer, +notes varchar(255) ); + +create index book_authorid_idx on book( authorid ); + +CREATE TABLE sequence +( tablename varchar(10), +sequence numeric); + +INSERT INTO author VALUES ( 0, 'Philip K', 'Dick' ); +INSERT INTO author VALUES ( 1, 'Robert', 'Heinlein' ); +INSERT INTO author VALUES ( 2, 'Sarah', 'Paretsky' ); + +INSERT INTO book VALUES ( 0, 'The Man Who Japed', 6.99, 0, 'A good book' ); +INSERT INTO book VALUES ( 1, 'The Man in the High Castle', 9.99, 0, 'Worth reading' ); +INSERT INTO book VALUES ( 2, 'The Number of the Beast', 8.99, 1, 'Get this!' ); +INSERT INTO book VALUES ( 3, 'Indemnity Only', 9.99, 2, 'Cool' ); +INSERT INTO book VALUES ( 4, 'Burn Marks', 9.99, 2, 'Need to make notes' ); +INSERT INTO book VALUES ( 5, 'Deadlock', 9.99, 2, 'Hmmm..' ); + +INSERT INTO sequence VALUES ( 'author', 2 ); +INSERT INTO sequence VALUES ( 'book', 5 ); diff --git a/tools/designer/examples/book/book1/book.ui b/tools/designer/examples/book/book1/book.ui new file mode 100644 index 000000000..61aaa27c0 --- /dev/null +++ b/tools/designer/examples/book/book1/book.ui @@ -0,0 +1,71 @@ + +BookForm +book.ui.h + + + + BookForm + + + + 0 + 0 + 584 + 472 + + + + Book + + + + unnamed + + + 11 + + + 6 + + + + + Surname + + + surname + + + + + Forename + + + forename + + + + AuthorcDataTable + + + true + + + + surname ASC + forename ASC + + + + + (default) + author + + + + + + + primeInsertAuthor( TQSqlRecord * ) + + diff --git a/tools/designer/examples/book/book1/book.ui.h b/tools/designer/examples/book/book1/book.ui.h new file mode 100644 index 000000000..d72786093 --- /dev/null +++ b/tools/designer/examples/book/book1/book.ui.h @@ -0,0 +1,5 @@ +void BookForm::primeInsertAuthor( TQSqlRecord * ) +{ + +} + diff --git a/tools/designer/examples/book/book1/book1.pro b/tools/designer/examples/book/book1/book1.pro new file mode 100644 index 000000000..a7e1f7bd2 --- /dev/null +++ b/tools/designer/examples/book/book1/book1.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +LANGUAGE = C++ + +CONFIG += qt warn_on release + +SOURCES += main.cpp ../connection.cpp +FORMS = book.ui +DBFILE = book.db diff --git a/tools/designer/examples/book/book1/main.cpp b/tools/designer/examples/book/book1/main.cpp new file mode 100644 index 000000000..cf3e80fd1 --- /dev/null +++ b/tools/designer/examples/book/book1/main.cpp @@ -0,0 +1,27 @@ +/**************************************************************************** +** +** 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 +#include +#include "book.h" +#include "../connection.h" + +int main( int argc, char *argv[] ) +{ + TQApplication app( argc, argv ); + + if ( ! createConnections() ) + return 1; + + BookForm bookForm; + app.setMainWidget( &bookForm ); + bookForm.show(); + + return app.exec(); +} diff --git a/tools/designer/examples/book/book2/book.ui b/tools/designer/examples/book/book2/book.ui new file mode 100644 index 000000000..3efd719c6 --- /dev/null +++ b/tools/designer/examples/book/book2/book.ui @@ -0,0 +1,77 @@ + +BookForm +book.ui.h + + + + BookForm + + + + 0 + 0 + 576 + 468 + + + + Book + + + + unnamed + + + 11 + + + 6 + + + + + Surname + + + surname + + + + + Forename + + + forename + + + + AuthorcDataTable + + + true + + + + surname ASC + forename ASC + + + + + (default) + author + + + + + + + + AuthorcDataTable + primeInsert(TQSqlRecord*) + BookForm + primeInsertAuthor(TQSqlRecord*) + + primeInsertAuthor( TQSqlRecord * buffer ) + + diff --git a/tools/designer/examples/book/book2/book.ui.h b/tools/designer/examples/book/book2/book.ui.h new file mode 100644 index 000000000..3295581d7 --- /dev/null +++ b/tools/designer/examples/book/book2/book.ui.h @@ -0,0 +1,10 @@ +void BookForm::primeInsertAuthor( TQSqlRecord * buffer ) +{ + TQSqlQuery query; + query.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='author';" ); + query.exec( "SELECT sequence FROM sequence WHERE tablename='author';" ); + if ( query.next() ) { + buffer->setValue( "id", query.value( 0 ) ); + } +} + diff --git a/tools/designer/examples/book/book2/book2.pro b/tools/designer/examples/book/book2/book2.pro new file mode 100644 index 000000000..a7e1f7bd2 --- /dev/null +++ b/tools/designer/examples/book/book2/book2.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +LANGUAGE = C++ + +CONFIG += qt warn_on release + +SOURCES += main.cpp ../connection.cpp +FORMS = book.ui +DBFILE = book.db diff --git a/tools/designer/examples/book/book2/main.cpp b/tools/designer/examples/book/book2/main.cpp new file mode 100644 index 000000000..cf3e80fd1 --- /dev/null +++ b/tools/designer/examples/book/book2/main.cpp @@ -0,0 +1,27 @@ +/**************************************************************************** +** +** 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 +#include +#include "book.h" +#include "../connection.h" + +int main( int argc, char *argv[] ) +{ + TQApplication app( argc, argv ); + + if ( ! createConnections() ) + return 1; + + BookForm bookForm; + app.setMainWidget( &bookForm ); + bookForm.show(); + + return app.exec(); +} diff --git a/tools/designer/examples/book/book3/book.ui b/tools/designer/examples/book/book3/book.ui new file mode 100644 index 000000000..9059929c5 --- /dev/null +++ b/tools/designer/examples/book/book3/book.ui @@ -0,0 +1,141 @@ + +BookForm +book.ui.h + + + + BookForm + + + + 0 + 0 + 566 + 464 + + + + Book + + + + unnamed + + + 11 + + + 6 + + + + Splitter1 + + + MShape + + + MShadow + + + Vertical + + + + + Surname + + + surname + + + + + Forename + + + forename + + + + AuthorDataTable + + + true + + + + surname ASC + forename ASC + + + + + (default) + author + + + + + + + Title + + + title + + + + + Price + + + price + + + + + Notes + + + notes + + + + BookDataTable + + + true + + + + title ASC + + + + + (default) + book + + + + + + + + + AuthorDataTable + currentChanged(TQSqlRecord*) + BookForm + newCurrentAuthor(TQSqlRecord*) + + + AuthorDataTable + primeInsert(TQSqlRecord*) + BookForm + primeInsertAuthor(TQSqlRecord*) + + newCurrentAuthor( TQSqlRecord * author ) + primeInsertAuthor( TQSqlRecord * buffer ) + + diff --git a/tools/designer/examples/book/book3/book.ui.h b/tools/designer/examples/book/book3/book.ui.h new file mode 100644 index 000000000..707ee907e --- /dev/null +++ b/tools/designer/examples/book/book3/book.ui.h @@ -0,0 +1,16 @@ +void BookForm::newCurrentAuthor( TQSqlRecord *author ) +{ + BookDataTable->setFilter( "authorid=" + author->value( "id" ).toString() ); + BookDataTable->refresh(); +} + +void BookForm::primeInsertAuthor( TQSqlRecord *buffer ) +{ + TQSqlQuery query; + query.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='author';" ); + query.exec( "SELECT sequence FROM sequence WHERE tablename='author';" ); + if ( query.next() ) { + buffer->setValue( "id", query.value( 0 ) ); + } +} + diff --git a/tools/designer/examples/book/book3/book3.pro b/tools/designer/examples/book/book3/book3.pro new file mode 100644 index 000000000..a7e1f7bd2 --- /dev/null +++ b/tools/designer/examples/book/book3/book3.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +LANGUAGE = C++ + +CONFIG += qt warn_on release + +SOURCES += main.cpp ../connection.cpp +FORMS = book.ui +DBFILE = book.db diff --git a/tools/designer/examples/book/book3/main.cpp b/tools/designer/examples/book/book3/main.cpp new file mode 100644 index 000000000..70b8cc892 --- /dev/null +++ b/tools/designer/examples/book/book3/main.cpp @@ -0,0 +1,27 @@ +/**************************************************************************** +** +** 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 +#include +#include "book.h" +#include "../connection.h" + +int main( int argc, char *argv[] ) +{ + TQApplication app( argc, argv ); + + if ( ! createConnections() ) + return 1; + + BookForm bookForm; + app.setMainWidget( &bookForm ); + bookForm.show(); + + return app.exec(); +} diff --git a/tools/designer/examples/book/book4/book.ui b/tools/designer/examples/book/book4/book.ui new file mode 100644 index 000000000..0bb5e7ca1 --- /dev/null +++ b/tools/designer/examples/book/book4/book.ui @@ -0,0 +1,179 @@ + +BookForm +book.ui.h + + + + BookForm + + + + 0 + 0 + 546 + 532 + + + + Book + + + + unnamed + + + 11 + + + 6 + + + + Splitter1 + + + MShape + + + MShadow + + + Vertical + + + + + Surname + + + surname + + + + + Forename + + + forename + + + + AuthorDataTable + + + true + + + + surname ASC + forename ASC + + + + + (default) + author + + + + + + + Title + + + title + + + + + Price + + + price + + + + + Notes + + + notes + + + + BookDataTable + + + true + + + + title ASC + + + + + (default) + book + + + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + EditPushButton + + + &Edit Books + + + + + QuitPushButton + + + &Quit + + + + + + + + + AuthorDataTable + currentChanged(TQSqlRecord*) + BookForm + newCurrentAuthor(TQSqlRecord*) + + + AuthorDataTable + primeInsert(TQSqlRecord*) + BookForm + primeInsertAuthor(TQSqlRecord*) + + + QuitPushButton + clicked() + BookForm + accept() + + newCurrentAuthor( TQSqlRecord * author ) + primeInsertAuthor( TQSqlRecord * buffer ) + + diff --git a/tools/designer/examples/book/book4/book.ui.h b/tools/designer/examples/book/book4/book.ui.h new file mode 100644 index 000000000..730cafe1f --- /dev/null +++ b/tools/designer/examples/book/book4/book.ui.h @@ -0,0 +1,16 @@ +void BookForm::newCurrentAuthor( TQSqlRecord * author ) +{ + BookDataTable->setFilter( "authorid=" + author->value( "id" ).toString() ); + BookDataTable->refresh(); +} + +void BookForm::primeInsertAuthor( TQSqlRecord * buffer ) +{ + TQSqlQuery query; + query.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='author';" ); + query.exec( "SELECT sequence FROM sequence WHERE tablename='author';" ); + if ( query.next() ) { + buffer->setValue( "id", query.value( 0 ) ); + } +} + diff --git a/tools/designer/examples/book/book4/book4.pro b/tools/designer/examples/book/book4/book4.pro new file mode 100644 index 000000000..a7e1f7bd2 --- /dev/null +++ b/tools/designer/examples/book/book4/book4.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +LANGUAGE = C++ + +CONFIG += qt warn_on release + +SOURCES += main.cpp ../connection.cpp +FORMS = book.ui +DBFILE = book.db diff --git a/tools/designer/examples/book/book4/main.cpp b/tools/designer/examples/book/book4/main.cpp new file mode 100644 index 000000000..cdcdd5091 --- /dev/null +++ b/tools/designer/examples/book/book4/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 +#include +#include "book.h" +#include "../connection.h" + +int main( int argc, char *argv[] ) +{ + TQApplication app( argc, argv ); + + if ( ! createConnections() ) + return 1; + + BookForm bookForm; + app.setMainWidget( &bookForm ); + bookForm.show(); + + return app.exec(); +} + + diff --git a/tools/designer/examples/book/book5/book.ui b/tools/designer/examples/book/book5/book.ui new file mode 100644 index 000000000..4c3e4de4e --- /dev/null +++ b/tools/designer/examples/book/book5/book.ui @@ -0,0 +1,188 @@ + +BookForm +qdatabrowser.h +editbook.h +book.ui.h + + + + BookForm + + + + 0 + 0 + 530 + 524 + + + + Book + + + + unnamed + + + 11 + + + 6 + + + + Splitter1 + + + MShape + + + MShadow + + + Vertical + + + + + Surname + + + surname + + + + + Forename + + + forename + + + + AuthorDataTable + + + true + + + + surname ASC + forename ASC + + + + + (default) + author + + + + + + + Title + + + title + + + + + Price + + + price + + + + + Notes + + + notes + + + + BookDataTable + + + true + + + + title ASC + + + + + (default) + book + + + + + + + Layout5 + + + + unnamed + + + 0 + + + 6 + + + + EditPushButton + + + &Edit Books + + + + + QuitPushButton + + + &Quit + + + + + + + + + QuitPushButton + clicked() + BookForm + accept() + + + EditPushButton + clicked() + BookForm + editClicked() + + + AuthorDataTable + primeInsert(TQSqlRecord*) + BookForm + primeInsertAuthor(TQSqlRecord*) + + + AuthorDataTable + currentChanged(TQSqlRecord*) + BookForm + newCurrentAuthor(TQSqlRecord*) + + editClicked() + newCurrentAuthor( TQSqlRecord * author ) + primeInsertAuthor( TQSqlRecord * buffer ) + + diff --git a/tools/designer/examples/book/book5/book.ui.h b/tools/designer/examples/book/book5/book.ui.h new file mode 100644 index 000000000..c41fa174f --- /dev/null +++ b/tools/designer/examples/book/book5/book.ui.h @@ -0,0 +1,23 @@ +void BookForm::editClicked() +{ + EditBookForm *dialog = new EditBookForm( this, "Edit Book Form", TRUE ); + dialog->exec(); + delete dialog; +} + +void BookForm::newCurrentAuthor( TQSqlRecord *author ) +{ + BookDataTable->setFilter( "authorid=" + author->value( "id" ).toString() ); + BookDataTable->refresh(); +} + +void BookForm::primeInsertAuthor( TQSqlRecord *buffer ) +{ + TQSqlQuery query; + query.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='author';" ); + query.exec( "SELECT sequence FROM sequence WHERE tablename='author';" ); + if ( query.next() ) { + buffer->setValue( "id", query.value( 0 ) ); + } +} + diff --git a/tools/designer/examples/book/book5/book5.pro b/tools/designer/examples/book/book5/book5.pro new file mode 100644 index 000000000..030db5f22 --- /dev/null +++ b/tools/designer/examples/book/book5/book5.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +LANGUAGE = C++ + +CONFIG += qt warn_on release + +SOURCES += main.cpp ../connection.cpp +FORMS = book.ui editbook.ui +DBFILE = book.db diff --git a/tools/designer/examples/book/book5/editbook.ui b/tools/designer/examples/book/book5/editbook.ui new file mode 100644 index 000000000..92031a366 --- /dev/null +++ b/tools/designer/examples/book/book5/editbook.ui @@ -0,0 +1,291 @@ + +EditBookForm + + + EditBookForm + + + + 0 + 0 + 568 + 301 + + + + Edit Books + + + + unnamed + + + 11 + + + 6 + + + + BookDataBrowser + + + + title ASC + + + + + (default) + book + + + + false + + + + unnamed + + + 11 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + labelPrice + + + Price + + + + + labelTitle + + + Title + + + + + TQLineEditTitle + + + + + + + (default) + book + title + + + + + + TQLineEditPrice + + + + (default) + book + price + + + + + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonFirst + + + |< &First + + + + + PushButtonPrev + + + << &Prev + + + + + PushButtonNext + + + &Next >> + + + + + PushButtonLast + + + &Last >| + + + + + + + Layout6 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonInsert + + + &Insert + + + + + PushButtonUpdate + + + &Update + + + + + PushButtonDelete + + + &Delete + + + + + PushButtonClose + + + &Close + + + + + + + + + + + PushButtonFirst + clicked() + BookDataBrowser + first() + + + BookDataBrowser + firstRecordAvailable( bool ) + PushButtonFirst + setEnabled(bool) + + + PushButtonPrev + clicked() + BookDataBrowser + prev() + + + BookDataBrowser + prevRecordAvailable( bool ) + PushButtonPrev + setEnabled(bool) + + + PushButtonNext + clicked() + BookDataBrowser + next() + + + BookDataBrowser + nextRecordAvailable( bool ) + PushButtonNext + setEnabled(bool) + + + PushButtonLast + clicked() + BookDataBrowser + last() + + + BookDataBrowser + lastRecordAvailable( bool ) + PushButtonLast + setEnabled(bool) + + + PushButtonInsert + clicked() + BookDataBrowser + insert() + + + PushButtonUpdate + clicked() + BookDataBrowser + update() + + + PushButtonDelete + clicked() + BookDataBrowser + del() + + + + editbook.ui.h + + + init() + destroy() + + + diff --git a/tools/designer/examples/book/book5/editbook.ui.h b/tools/designer/examples/book/book5/editbook.ui.h new file mode 100644 index 000000000..4a8a6363f --- /dev/null +++ b/tools/designer/examples/book/book5/editbook.ui.h @@ -0,0 +1,10 @@ +void EditBookForm::init() +{ + +} + +void EditBookForm::destroy() +{ + +} + diff --git a/tools/designer/examples/book/book5/main.cpp b/tools/designer/examples/book/book5/main.cpp new file mode 100644 index 000000000..cf3e80fd1 --- /dev/null +++ b/tools/designer/examples/book/book5/main.cpp @@ -0,0 +1,27 @@ +/**************************************************************************** +** +** 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 +#include +#include "book.h" +#include "../connection.h" + +int main( int argc, char *argv[] ) +{ + TQApplication app( argc, argv ); + + if ( ! createConnections() ) + return 1; + + BookForm bookForm; + app.setMainWidget( &bookForm ); + bookForm.show(); + + return app.exec(); +} diff --git a/tools/designer/examples/book/book6/book.ui b/tools/designer/examples/book/book6/book.ui new file mode 100644 index 000000000..8fe77d4cd --- /dev/null +++ b/tools/designer/examples/book/book6/book.ui @@ -0,0 +1,189 @@ + +BookForm +qsqlrecord.h +editbook.h +qdatabrowser.h +book.ui.h + + + + BookForm + + + + 0 + 0 + 494 + 506 + + + + Book + + + + unnamed + + + 11 + + + 6 + + + + Splitter1 + + + MShape + + + MShadow + + + Vertical + + + + + Surname + + + surname + + + + + Forename + + + forename + + + + AuthorDataTable + + + true + + + + surname ASC + forename ASC + + + + + (default) + author + + + + + + + Title + + + title + + + + + Price + + + price + + + + + Notes + + + notes + + + + BookDataTable + + + true + + + + title ASC + + + + + (default) + book + + + + + + + Layout5 + + + + unnamed + + + 0 + + + 6 + + + + EditPushButton + + + &Edit Books + + + + + QuitPushButton + + + &Quit + + + + + + + + + QuitPushButton + clicked() + BookForm + accept() + + + EditPushButton + clicked() + BookForm + editClicked() + + + AuthorDataTable + primeInsert(TQSqlRecord*) + BookForm + primeInsertAuthor(TQSqlRecord*) + + + AuthorDataTable + currentChanged(TQSqlRecord*) + BookForm + newCurrentAuthor(TQSqlRecord*) + + editClicked() + newCurrentAuthor( TQSqlRecord * author ) + primeInsertAuthor( TQSqlRecord * buffer ) + + diff --git a/tools/designer/examples/book/book6/book.ui.h b/tools/designer/examples/book/book6/book.ui.h new file mode 100644 index 000000000..fe0b39d9d --- /dev/null +++ b/tools/designer/examples/book/book6/book.ui.h @@ -0,0 +1,33 @@ +void BookForm::editClicked() +{ + EditBookForm *dialog = new EditBookForm( this, "Edit Book Form", TRUE ); + TQSqlCursor cur( "book" ); + dialog->BookDataBrowser->setSqlCursor( &cur ); + dialog->BookDataBrowser->setFilter( BookDataTable->filter() ); + dialog->BookDataBrowser->setSort(TQSqlIndex::fromStringList( + BookDataTable->sort(), &cur ) ); + dialog->BookDataBrowser->refresh(); + int i = BookDataTable->currentRow(); + if ( i == -1 ) i = 0; // Always use the first row + dialog->BookDataBrowser->seek( i ); + dialog->exec(); + delete dialog; + BookDataTable->refresh(); +} + +void BookForm::newCurrentAuthor( TQSqlRecord * author ) +{ + BookDataTable->setFilter( "authorid=" + author->value( "id" ).toString() ); + BookDataTable->refresh(); +} + +void BookForm::primeInsertAuthor( TQSqlRecord * buffer ) +{ + TQSqlQuery query; + query.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='author';" ); + query.exec( "SELECT sequence FROM sequence WHERE tablename='author';" ); + if ( query.next() ) { + buffer->setValue( "id", query.value( 0 ) ); + } +} + diff --git a/tools/designer/examples/book/book6/book6.pro b/tools/designer/examples/book/book6/book6.pro new file mode 100644 index 000000000..030db5f22 --- /dev/null +++ b/tools/designer/examples/book/book6/book6.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +LANGUAGE = C++ + +CONFIG += qt warn_on release + +SOURCES += main.cpp ../connection.cpp +FORMS = book.ui editbook.ui +DBFILE = book.db diff --git a/tools/designer/examples/book/book6/editbook.ui b/tools/designer/examples/book/book6/editbook.ui new file mode 100644 index 000000000..5b3bc10c4 --- /dev/null +++ b/tools/designer/examples/book/book6/editbook.ui @@ -0,0 +1,300 @@ + +EditBookForm +qsqlrecord.h +editbook.ui.h +class TQSqlRecord; + + + + EditBookForm + + + + 0 + 0 + 536 + 285 + + + + Edit Books + + + + unnamed + + + 11 + + + 6 + + + + BookDataBrowser + + + + title ASC + + + + + (default) + book + + + + false + + + + unnamed + + + 11 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + labelPrice + + + Price + + + + + labelTitle + + + Title + + + + + TQLineEditTitle + + + + (default) + book + title + + + + + + TQLineEditPrice + + + + (default) + book + price + + + + + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonFirst + + + |< &First + + + + + PushButtonPrev + + + << &Prev + + + + + PushButtonNext + + + &Next >> + + + + + PushButtonLast + + + &Last >| + + + + + + + Layout6 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonInsert + + + &Insert + + + + + PushButtonUpdate + + + &Update + + + true + + + + + PushButtonDelete + + + &Delete + + + + + PushButtonClose + + + &Close + + + + + + + + + + + PushButtonFirst + clicked() + BookDataBrowser + first() + + + BookDataBrowser + firstRecordAvailable( bool ) + PushButtonFirst + setEnabled(bool) + + + PushButtonPrev + clicked() + BookDataBrowser + prev() + + + BookDataBrowser + prevRecordAvailable( bool ) + PushButtonPrev + setEnabled(bool) + + + PushButtonNext + clicked() + BookDataBrowser + next() + + + BookDataBrowser + nextRecordAvailable( bool ) + PushButtonNext + setEnabled(bool) + + + PushButtonLast + clicked() + BookDataBrowser + last() + + + BookDataBrowser + lastRecordAvailable( bool ) + PushButtonLast + setEnabled(bool) + + + PushButtonInsert + clicked() + BookDataBrowser + insert() + + + PushButtonUpdate + clicked() + BookDataBrowser + update() + + + PushButtonDelete + clicked() + BookDataBrowser + del() + + + BookDataBrowser + primeInsert(TQSqlRecord*) + EditBookForm + primeInsertBook(TQSqlRecord*) + + + PushButtonClose + clicked() + EditBookForm + accept() + + primeInsertBook( TQSqlRecord * buffer ) + + diff --git a/tools/designer/examples/book/book6/editbook.ui.h b/tools/designer/examples/book/book6/editbook.ui.h new file mode 100644 index 000000000..28d5035f8 --- /dev/null +++ b/tools/designer/examples/book/book6/editbook.ui.h @@ -0,0 +1,10 @@ +void EditBookForm::primeInsertBook( TQSqlRecord * buffer ) +{ + TQSqlQuery query; + query.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='book';" ); + query.exec( "SELECT sequence FROM sequence WHERE tablename='book';" ); + if ( query.next() ) { + buffer->setValue( "id", query.value( 0 ) ); + } +} + diff --git a/tools/designer/examples/book/book6/main.cpp b/tools/designer/examples/book/book6/main.cpp new file mode 100644 index 000000000..cf3e80fd1 --- /dev/null +++ b/tools/designer/examples/book/book6/main.cpp @@ -0,0 +1,27 @@ +/**************************************************************************** +** +** 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 +#include +#include "book.h" +#include "../connection.h" + +int main( int argc, char *argv[] ) +{ + TQApplication app( argc, argv ); + + if ( ! createConnections() ) + return 1; + + BookForm bookForm; + app.setMainWidget( &bookForm ); + bookForm.show(); + + return app.exec(); +} diff --git a/tools/designer/examples/book/book7/book.ui b/tools/designer/examples/book/book7/book.ui new file mode 100644 index 000000000..faea95188 --- /dev/null +++ b/tools/designer/examples/book/book7/book.ui @@ -0,0 +1,189 @@ + +BookForm +qsqlrecord.h +editbook.h +qdatabrowser.h +book.ui.h + + + + BookForm + + + + 0 + 0 + 490 + 504 + + + + Book + + + + unnamed + + + 11 + + + 6 + + + + Splitter1 + + + MShape + + + MShadow + + + Vertical + + + + + Surname + + + surname + + + + + Forename + + + forename + + + + AuthorDataTable + + + true + + + + surname ASC + forename ASC + + + + + (default) + author + + + + + + + Title + + + title + + + + + Price + + + price + + + + + Notes + + + notes + + + + BookDataTable + + + true + + + + title ASC + + + + + (default) + book + + + + + + + Layout5 + + + + unnamed + + + 0 + + + 6 + + + + EditPushButton + + + &Edit Books + + + + + QuitPushButton + + + &Quit + + + + + + + + + QuitPushButton + clicked() + BookForm + accept() + + + EditPushButton + clicked() + BookForm + editClicked() + + + AuthorDataTable + primeInsert(TQSqlRecord*) + BookForm + primeInsertAuthor(TQSqlRecord*) + + + AuthorDataTable + currentChanged(TQSqlRecord*) + BookForm + newCurrentAuthor(TQSqlRecord*) + + editClicked() + newCurrentAuthor( TQSqlRecord * author ) + primeInsertAuthor( TQSqlRecord * buffer ) + + diff --git a/tools/designer/examples/book/book7/book.ui.h b/tools/designer/examples/book/book7/book.ui.h new file mode 100644 index 000000000..1cb2f0b9c --- /dev/null +++ b/tools/designer/examples/book/book7/book.ui.h @@ -0,0 +1,33 @@ +void BookForm::editClicked() +{ + EditBookForm *dialog = new EditBookForm( this, "Edit Book Form", TRUE ); + TQSqlCursor cur( "book" ); + dialog->BookDataBrowser->setSqlCursor( &cur ); + dialog->BookDataBrowser->setFilter( BookDataTable->filter() ); + dialog->BookDataBrowser->setSort(TQSqlIndex::fromStringList( + BookDataTable->sort(), &cur ) ); + dialog->BookDataBrowser->refresh(); + int i = BookDataTable->currentRow(); + if ( i == -1 ) i = 0; // Always use the first row + dialog->BookDataBrowser->seek( i ); + dialog->exec(); + delete dialog; + BookDataTable->refresh(); +} + +void BookForm::newCurrentAuthor( TQSqlRecord *author ) +{ + BookDataTable->setFilter( "authorid=" + author->value( "id" ).toString() ); + BookDataTable->refresh(); +} + +void BookForm::primeInsertAuthor( TQSqlRecord *buffer ) +{ + TQSqlQuery query; + query.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='author';" ); + query.exec( "SELECT sequence FROM sequence WHERE tablename='author';" ); + if ( query.next() ) { + buffer->setValue( "id", query.value( 0 ) ); + } +} + diff --git a/tools/designer/examples/book/book7/book7.pro b/tools/designer/examples/book/book7/book7.pro new file mode 100644 index 000000000..22c7e9b39 --- /dev/null +++ b/tools/designer/examples/book/book7/book7.pro @@ -0,0 +1,7 @@ +TEMPLATE = app +LANGUAGE = C++ + +CONFIG += qt warn_on release +SOURCES += main.cpp ../connection.cpp +FORMS = book.ui editbook.ui +DBFILE = book.db diff --git a/tools/designer/examples/book/book7/editbook.ui b/tools/designer/examples/book/book7/editbook.ui new file mode 100644 index 000000000..d0f876db5 --- /dev/null +++ b/tools/designer/examples/book/book7/editbook.ui @@ -0,0 +1,384 @@ + +EditBookForm +qsqlrecord.h +editbook.ui.h +class TQSqlRecord; + + + + EditBookForm + + + + 0 + 0 + 528 + 305 + + + + Edit Books + + + + unnamed + + + 11 + + + 6 + + + + BookDataBrowser + + + + title ASC + + + + + (default) + book + + + + true + + + + unnamed + + + 11 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + labelPrice + + + Price + + + + + labelTitle + + + Title + + + + + TQLineEditTitle + + + + (default) + book + title + + + + + + TQLineEditPrice + + + + (default) + book + price + + + + + + + + Layout6 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonInsert + + + &Insert + + + + + PushButtonUpdate + + + &Update + + + true + + + + + PushButtonDelete + + + &Delete + + + + + PushButtonClose + + + &Close + + + + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonFirst + + + |< &First + + + + + PushButtonPrev + + + << &Prev + + + + + PushButtonNext + + + &Next >> + + + + + PushButtonLast + + + &Last >| + + + + + + + Layout6 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel1 + + + Author + + + + + ComboBoxAuthor + + + + 7 + 0 + 0 + 0 + + + + + (default) + author_view + name + + + + + + + + + + + + PushButtonFirst + clicked() + BookDataBrowser + first() + + + BookDataBrowser + firstRecordAvailable( bool ) + PushButtonFirst + setEnabled(bool) + + + PushButtonPrev + clicked() + BookDataBrowser + prev() + + + BookDataBrowser + prevRecordAvailable( bool ) + PushButtonPrev + setEnabled(bool) + + + PushButtonNext + clicked() + BookDataBrowser + next() + + + BookDataBrowser + nextRecordAvailable( bool ) + PushButtonNext + setEnabled(bool) + + + PushButtonLast + clicked() + BookDataBrowser + last() + + + BookDataBrowser + lastRecordAvailable( bool ) + PushButtonLast + setEnabled(bool) + + + PushButtonInsert + clicked() + BookDataBrowser + insert() + + + PushButtonUpdate + clicked() + BookDataBrowser + update() + + + PushButtonDelete + clicked() + BookDataBrowser + del() + + + PushButtonClose + clicked() + EditBookForm + accept() + + + BookDataBrowser + primeUpdate(TQSqlRecord*) + EditBookForm + primeUpdateBook(TQSqlRecord*) + + + BookDataBrowser + beforeUpdate(TQSqlRecord*) + EditBookForm + beforeUpdateBook(TQSqlRecord*) + + + BookDataBrowser + beforeInsert(TQSqlRecord*) + EditBookForm + beforeUpdateBook(TQSqlRecord*) + + + BookDataBrowser + primeInsert(TQSqlRecord*) + EditBookForm + primeInsertBook(TQSqlRecord*) + + + BookDataBrowser + primeInsert(TQSqlRecord*) + EditBookForm + primeInsertBook(TQSqlRecord*) + + init() + beforeUpdateBook( TQSqlRecord * buffer ) + primeInsertBook( TQSqlRecord * buffer ) + primeUpdateBook( TQSqlRecord * buffer ) + + + TQLineEditTitle + TQLineEditPrice + ComboBoxAuthor + PushButtonFirst + PushButtonPrev + PushButtonNext + PushButtonLast + PushButtonInsert + PushButtonUpdate + PushButtonDelete + PushButtonClose + + diff --git a/tools/designer/examples/book/book7/editbook.ui.h b/tools/designer/examples/book/book7/editbook.ui.h new file mode 100644 index 000000000..0bedf8bb2 --- /dev/null +++ b/tools/designer/examples/book/book7/editbook.ui.h @@ -0,0 +1,42 @@ +void EditBookForm::init() +{ + TQSqlQuery query( "SELECT surname FROM author ORDER BY surname;" ); + while ( query.next() ) + ComboBoxAuthor->insertItem( query.value( 0 ).toString()); +} + +void EditBookForm::beforeUpdateBook( TQSqlRecord * buffer ) +{ + TQSqlQuery query( "SELECT id FROM author WHERE surname ='" + + ComboBoxAuthor->currentText() + "';" ); + if ( query.next() ) + buffer->setValue( "authorid", query.value( 0 ) ); +} + +void EditBookForm::primeInsertBook( TQSqlRecord * buffer ) +{ + TQSqlQuery query; + query.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='book';" ); + query.exec( "SELECT sequence FROM sequence WHERE tablename='book';" ); + if ( query.next() ) { + buffer->setValue( "id", query.value( 0 ) ); + } +} + +void EditBookForm::primeUpdateBook( TQSqlRecord * buffer ) +{ + // Who is this book's author? + TQSqlQuery query( "SELECT surname FROM author WHERE id='" + + buffer->value( "authorid" ).toString() + "';" ); + TQString author = ""; + if ( query.next() ) + author = query.value( 0 ).toString(); + // Set the ComboBox to the right author + for ( int i = 0; i < ComboBoxAuthor->count(); i++ ) { + if ( ComboBoxAuthor->text( i ) == author ) { + ComboBoxAuthor->setCurrentItem( i ) ; + break; + } + } +} + diff --git a/tools/designer/examples/book/book7/main.cpp b/tools/designer/examples/book/book7/main.cpp new file mode 100644 index 000000000..cf3e80fd1 --- /dev/null +++ b/tools/designer/examples/book/book7/main.cpp @@ -0,0 +1,27 @@ +/**************************************************************************** +** +** 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 +#include +#include "book.h" +#include "../connection.h" + +int main( int argc, char *argv[] ) +{ + TQApplication app( argc, argv ); + + if ( ! createConnections() ) + return 1; + + BookForm bookForm; + app.setMainWidget( &bookForm ); + bookForm.show(); + + return app.exec(); +} diff --git a/tools/designer/examples/book/book8/book.ui b/tools/designer/examples/book/book8/book.ui new file mode 100644 index 000000000..faea95188 --- /dev/null +++ b/tools/designer/examples/book/book8/book.ui @@ -0,0 +1,189 @@ + +BookForm +qsqlrecord.h +editbook.h +qdatabrowser.h +book.ui.h + + + + BookForm + + + + 0 + 0 + 490 + 504 + + + + Book + + + + unnamed + + + 11 + + + 6 + + + + Splitter1 + + + MShape + + + MShadow + + + Vertical + + + + + Surname + + + surname + + + + + Forename + + + forename + + + + AuthorDataTable + + + true + + + + surname ASC + forename ASC + + + + + (default) + author + + + + + + + Title + + + title + + + + + Price + + + price + + + + + Notes + + + notes + + + + BookDataTable + + + true + + + + title ASC + + + + + (default) + book + + + + + + + Layout5 + + + + unnamed + + + 0 + + + 6 + + + + EditPushButton + + + &Edit Books + + + + + QuitPushButton + + + &Quit + + + + + + + + + QuitPushButton + clicked() + BookForm + accept() + + + EditPushButton + clicked() + BookForm + editClicked() + + + AuthorDataTable + primeInsert(TQSqlRecord*) + BookForm + primeInsertAuthor(TQSqlRecord*) + + + AuthorDataTable + currentChanged(TQSqlRecord*) + BookForm + newCurrentAuthor(TQSqlRecord*) + + editClicked() + newCurrentAuthor( TQSqlRecord * author ) + primeInsertAuthor( TQSqlRecord * buffer ) + + diff --git a/tools/designer/examples/book/book8/book.ui.h b/tools/designer/examples/book/book8/book.ui.h new file mode 100644 index 000000000..24bb69c4f --- /dev/null +++ b/tools/designer/examples/book/book8/book.ui.h @@ -0,0 +1,33 @@ +void BookForm::editClicked() +{ + EditBookForm *dialog = new EditBookForm( this, "Edit Book Form", TRUE ); + TQSqlCursor cur( "book" ); + dialog->BookDataBrowser->setSqlCursor( &cur ); + dialog->BookDataBrowser->setFilter( BookDataTable->filter() ); + dialog->BookDataBrowser->setSort(TQSqlIndex::fromStringList( + BookDataTable->sort(), &cur ) ); + dialog->BookDataBrowser->refresh(); + int i = BookDataTable->currentRow(); + if ( i == -1 ) i = 0; // Always use the first row + dialog->BookDataBrowser->seek( i ); + dialog->exec(); + delete dialog; + BookDataTable->refresh(); +} + +void BookForm::newCurrentAuthor( TQSqlRecord *author ) +{ + BookDataTable->setFilter( "authorid=" + author->value( "id" ).toString() ); + BookDataTable->refresh(); +} + +void BookForm::primeInsertAuthor( TQSqlRecord *buffer ) +{ + TQSqlQuery q; + q.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='author';" ); + q.exec( "SELECT sequence FROM sequence WHERE tablename='author';" ); + if ( q.next() ) { + buffer->setValue( "id", q.value( 0 ) ); + } +} + diff --git a/tools/designer/examples/book/book8/book8.pro b/tools/designer/examples/book/book8/book8.pro new file mode 100644 index 000000000..e4bdf75a6 --- /dev/null +++ b/tools/designer/examples/book/book8/book8.pro @@ -0,0 +1,7 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main.cpp ../connection.cpp +FORMS = book.ui editbook.ui +CONFIG += qt warn_on release +DBFILE = book.db diff --git a/tools/designer/examples/book/book8/editbook.ui b/tools/designer/examples/book/book8/editbook.ui new file mode 100644 index 000000000..b16d789d2 --- /dev/null +++ b/tools/designer/examples/book/book8/editbook.ui @@ -0,0 +1,386 @@ + +EditBookForm +qsqlrecord.h +editbook.ui.h +class TQSqlRecord; +TQMap<TQString,int> authorMap; + + + + EditBookForm + + + + 0 + 0 + 520 + 369 + + + + Edit Books + + + + unnamed + + + 11 + + + 6 + + + + BookDataBrowser + + + + title ASC + + + + + (default) + book + + + + true + + + + unnamed + + + 11 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + labelPrice + + + Price + + + + + labelTitle + + + Title + + + + + TQLineEditTitle + + + + (default) + book + title + + + + + + TQLineEditPrice + + + + (default) + book + price + + + + + + + + Layout6 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonInsert + + + &Insert + + + + + PushButtonUpdate + + + &Update + + + true + + + + + PushButtonDelete + + + &Delete + + + + + PushButtonClose + + + &Close + + + + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonFirst + + + |< &First + + + + + PushButtonPrev + + + << &Prev + + + + + PushButtonNext + + + &Next >> + + + + + PushButtonLast + + + &Last >| + + + + + + + Layout6 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel1 + + + Author + + + + + ComboBoxAuthor + + + + 7 + 0 + 0 + 0 + + + + + (default) + author_view + name + + + + + + + + + + + + PushButtonFirst + clicked() + BookDataBrowser + first() + + + BookDataBrowser + firstRecordAvailable( bool ) + PushButtonFirst + setEnabled(bool) + + + PushButtonPrev + clicked() + BookDataBrowser + prev() + + + BookDataBrowser + prevRecordAvailable( bool ) + PushButtonPrev + setEnabled(bool) + + + PushButtonNext + clicked() + BookDataBrowser + next() + + + BookDataBrowser + nextRecordAvailable( bool ) + PushButtonNext + setEnabled(bool) + + + PushButtonLast + clicked() + BookDataBrowser + last() + + + BookDataBrowser + lastRecordAvailable( bool ) + PushButtonLast + setEnabled(bool) + + + PushButtonInsert + clicked() + BookDataBrowser + insert() + + + PushButtonUpdate + clicked() + BookDataBrowser + update() + + + PushButtonDelete + clicked() + BookDataBrowser + del() + + + PushButtonClose + clicked() + EditBookForm + accept() + + + BookDataBrowser + primeUpdate(TQSqlRecord*) + EditBookForm + primeUpdateBook(TQSqlRecord*) + + + BookDataBrowser + beforeUpdate(TQSqlRecord*) + EditBookForm + beforeUpdateBook(TQSqlRecord*) + + + BookDataBrowser + beforeInsert(TQSqlRecord*) + EditBookForm + beforeUpdateBook(TQSqlRecord*) + + + BookDataBrowser + primeInsert(TQSqlRecord*) + EditBookForm + primeInsertBook(TQSqlRecord*) + + + BookDataBrowser + primeInsert(TQSqlRecord*) + EditBookForm + primeInsertBook(TQSqlRecord*) + + init() + beforeUpdateBook( TQSqlRecord * buffer ) + mapAuthor( const TQString & name, int & id, bool populate ) + primeInsertBook( TQSqlRecord * buffer ) + primeUpdateBook( TQSqlRecord * buffer ) + + + TQLineEditTitle + TQLineEditPrice + ComboBoxAuthor + PushButtonFirst + PushButtonPrev + PushButtonNext + PushButtonLast + PushButtonInsert + PushButtonUpdate + PushButtonDelete + PushButtonClose + + diff --git a/tools/designer/examples/book/book8/editbook.ui.h b/tools/designer/examples/book/book8/editbook.ui.h new file mode 100644 index 000000000..45876fe71 --- /dev/null +++ b/tools/designer/examples/book/book8/editbook.ui.h @@ -0,0 +1,47 @@ +void EditBookForm::init() +{ + TQSqlQuery query( "SELECT surname, id FROM author ORDER BY surname;" ); + while ( query.next() ) { + ComboBoxAuthor->insertItem( query.value( 0 ).toString() ); + int id = query.value( 1 ).toInt(); + mapAuthor( query.value( 0 ).toString(), id, TRUE ); + } +} + +void EditBookForm::beforeUpdateBook( TQSqlRecord * buffer ) +{ + int id; + mapAuthor( ComboBoxAuthor->currentText(), id, FALSE ); + buffer->setValue( "authorid", id ); +} + +void EditBookForm::mapAuthor( const TQString & name, int & id, bool populate ) +{ + if ( populate ) + authorMap[ name ] = id; + else + id = authorMap[ name ]; +} + +void EditBookForm::primeInsertBook( TQSqlRecord * buffer ) +{ + TQSqlQuery q; + q.exec( "UPDATE sequence SET sequence = sequence + 1 WHERE tablename='book';" ); + q.exec( "SELECT sequence FROM sequence WHERE tablename='book';" ); + if ( q.next() ) { + buffer->setValue( "id", q.value( 0 ) ); + } +} + +void EditBookForm::primeUpdateBook( TQSqlRecord * buffer ) +{ + int id = buffer->value( "authorid" ).toInt(); + for ( int i = 0; i < ComboBoxAuthor->count(); i++ ) { + TQString author = ComboBoxAuthor->text( i ); + if ( authorMap.contains( author ) && authorMap[author] == id ) { + ComboBoxAuthor->setCurrentItem( i ) ; + break; + } + } +} + diff --git a/tools/designer/examples/book/book8/main.cpp b/tools/designer/examples/book/book8/main.cpp new file mode 100644 index 000000000..cf3e80fd1 --- /dev/null +++ b/tools/designer/examples/book/book8/main.cpp @@ -0,0 +1,27 @@ +/**************************************************************************** +** +** 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 +#include +#include "book.h" +#include "../connection.h" + +int main( int argc, char *argv[] ) +{ + TQApplication app( argc, argv ); + + if ( ! createConnections() ) + return 1; + + BookForm bookForm; + app.setMainWidget( &bookForm ); + bookForm.show(); + + return app.exec(); +} diff --git a/tools/designer/examples/book/connection.cpp b/tools/designer/examples/book/connection.cpp new file mode 100644 index 000000000..efb1156ca --- /dev/null +++ b/tools/designer/examples/book/connection.cpp @@ -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 +#include "connection.h" + +bool createConnections() +{ + // create the default database connection + TQSqlDatabase *defaultDB = TQSqlDatabase::addDatabase( DB_BOOKS_DRIVER ); + defaultDB->setDatabaseName( DB_BOOKS ); + defaultDB->setUserName( DB_BOOKS_USER ); + defaultDB->setPassword( DB_BOOKS_PASSWD ); + defaultDB->setHostName( DB_BOOKS_HOST ); + if ( ! defaultDB->open() ) { + qWarning( "Failed to open books database: " + + defaultDB->lastError().driverText() ); + qWarning( defaultDB->lastError().databaseText() ); + return FALSE; + } + + TQSqlQuery q(TQString::null, defaultDB); + q.exec("CREATE TABLE author ( id integer primary key, " + "forename varchar(40), surname varchar(40) )"); + q.exec("CREATE TABLE book ( id integer primary key, " + "title varchar(40), price numeric(10,2), authorid integer, notes varchar(255) )"); + + q.exec("CREATE TABLE sequence ( tablename varchar(10), sequence numeric)"); + + q.exec("INSERT INTO author VALUES ( 0, 'Philip K', 'Dick' )"); + q.exec("INSERT INTO author VALUES ( 1, 'Robert', 'Heinlein' )"); + q.exec("INSERT INTO author VALUES ( 2, 'Sarah', 'Paretsky' )"); + + q.exec("INSERT INTO book VALUES (0, 'The Man Who Japed', 6.99, 0, 'A good book' )"); + q.exec("INSERT INTO book VALUES (1, 'The Man in the High Castle', 9.99, 0, 'Worth reading' )"); + q.exec("INSERT INTO book VALUES ( 2, 'The Number of the Beast', 8.99, 1, 'Get this!' )"); + q.exec("INSERT INTO book VALUES ( 3, 'Indemnity Only', 9.99, 2, 'Cool' )"); + q.exec("INSERT INTO book VALUES ( 4, 'Burn Marks', 9.99, 2, 'Need to make notes' )"); + q.exec("INSERT INTO book VALUES ( 5, 'Deadlock', 9.99, 2, 'Hmmm..' )"); + + q.exec("INSERT INTO sequence VALUES ( 'author', 2 )"); + q.exec("INSERT INTO sequence VALUES ( 'book', 5 )"); + + return TRUE; +} + + diff --git a/tools/designer/examples/book/connection.h b/tools/designer/examples/book/connection.h new file mode 100644 index 000000000..58d2dbf00 --- /dev/null +++ b/tools/designer/examples/book/connection.h @@ -0,0 +1,18 @@ +/**************************************************************************** +** +** 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. +** +*****************************************************************************/ + +// Add your own connection parameters here +#define DB_BOOKS_DRIVER "TQSQLITE" +#define DB_BOOKS ":memory:" +#define DB_BOOKS_USER "" +#define DB_BOOKS_PASSWD "" +#define DB_BOOKS_HOST "" + +bool createConnections(); + -- cgit v1.2.1