From dda8474928bd7276e1fad8fb7a601e7c83ff2bc2 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 10 Jul 2011 15:17:53 -0500 Subject: Added TQt4 HEAD --- .../qt4/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 +++++++++++++++++++++ .../designer/examples/book/book8/editbook.ui.h | 47 +++ .../tools/designer/examples/book/book8/main.cpp | 27 ++ 6 files changed, 689 insertions(+) create mode 100644 tqtinterface/qt4/tools/designer/examples/book/book8/book.ui create mode 100644 tqtinterface/qt4/tools/designer/examples/book/book8/book.ui.h create mode 100644 tqtinterface/qt4/tools/designer/examples/book/book8/book8.pro create mode 100644 tqtinterface/qt4/tools/designer/examples/book/book8/editbook.ui create mode 100644 tqtinterface/qt4/tools/designer/examples/book/book8/editbook.ui.h create mode 100644 tqtinterface/qt4/tools/designer/examples/book/book8/main.cpp (limited to 'tqtinterface/qt4/tools/designer/examples/book/book8') diff --git a/tqtinterface/qt4/tools/designer/examples/book/book8/book.ui b/tqtinterface/qt4/tools/designer/examples/book/book8/book.ui new file mode 100644 index 0000000..cc6f1d8 --- /dev/null +++ b/tqtinterface/qt4/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(QSqlRecord*) + BookForm + primeInsertAuthor(QSqlRecord*) + + + AuthorDataTable + currentChanged(QSqlRecord*) + BookForm + newCurrentAuthor(QSqlRecord*) + + editClicked() + newCurrentAuthor( QSqlRecord * author ) + primeInsertAuthor( QSqlRecord * buffer ) + + diff --git a/tqtinterface/qt4/tools/designer/examples/book/book8/book.ui.h b/tqtinterface/qt4/tools/designer/examples/book/book8/book.ui.h new file mode 100644 index 0000000..24bb69c --- /dev/null +++ b/tqtinterface/qt4/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/tqtinterface/qt4/tools/designer/examples/book/book8/book8.pro b/tqtinterface/qt4/tools/designer/examples/book/book8/book8.pro new file mode 100644 index 0000000..e4bdf75 --- /dev/null +++ b/tqtinterface/qt4/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/tqtinterface/qt4/tools/designer/examples/book/book8/editbook.ui b/tqtinterface/qt4/tools/designer/examples/book/book8/editbook.ui new file mode 100644 index 0000000..f4c2cba --- /dev/null +++ b/tqtinterface/qt4/tools/designer/examples/book/book8/editbook.ui @@ -0,0 +1,386 @@ + +EditBookForm +qsqlrecord.h +editbook.ui.h +class QSqlRecord; +QMap<QString,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 + + + + + QLineEditTitle + + + + (default) + book + title + + + + + + QLineEditPrice + + + + (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(QSqlRecord*) + EditBookForm + primeUpdateBook(QSqlRecord*) + + + BookDataBrowser + beforeUpdate(QSqlRecord*) + EditBookForm + beforeUpdateBook(QSqlRecord*) + + + BookDataBrowser + beforeInsert(QSqlRecord*) + EditBookForm + beforeUpdateBook(QSqlRecord*) + + + BookDataBrowser + primeInsert(QSqlRecord*) + EditBookForm + primeInsertBook(QSqlRecord*) + + + BookDataBrowser + primeInsert(QSqlRecord*) + EditBookForm + primeInsertBook(QSqlRecord*) + + init() + beforeUpdateBook( QSqlRecord * buffer ) + mapAuthor( const QString & name, int & id, bool populate ) + primeInsertBook( QSqlRecord * buffer ) + primeUpdateBook( QSqlRecord * buffer ) + + + QLineEditTitle + QLineEditPrice + ComboBoxAuthor + PushButtonFirst + PushButtonPrev + PushButtonNext + PushButtonLast + PushButtonInsert + PushButtonUpdate + PushButtonDelete + PushButtonClose + + diff --git a/tqtinterface/qt4/tools/designer/examples/book/book8/editbook.ui.h b/tqtinterface/qt4/tools/designer/examples/book/book8/editbook.ui.h new file mode 100644 index 0000000..12e6eb6 --- /dev/null +++ b/tqtinterface/qt4/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.tqcontains( author ) && authorMap[author] == id ) { + ComboBoxAuthor->setCurrentItem( i ) ; + break; + } + } +} + diff --git a/tqtinterface/qt4/tools/designer/examples/book/book8/main.cpp b/tqtinterface/qt4/tools/designer/examples/book/book8/main.cpp new file mode 100644 index 0000000..d244790 --- /dev/null +++ b/tqtinterface/qt4/tools/designer/examples/book/book8/main.cpp @@ -0,0 +1,27 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. +** +** 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(); +} -- cgit v1.2.1