summaryrefslogtreecommitdiffstats
path: root/tools/designer/examples/book/book7
diff options
context:
space:
mode:
Diffstat (limited to 'tools/designer/examples/book/book7')
-rw-r--r--tools/designer/examples/book/book7/book.ui189
-rw-r--r--tools/designer/examples/book/book7/book.ui.h33
-rw-r--r--tools/designer/examples/book/book7/book7.pro7
-rw-r--r--tools/designer/examples/book/book7/editbook.ui384
-rw-r--r--tools/designer/examples/book/book7/editbook.ui.h42
-rw-r--r--tools/designer/examples/book/book7/main.cpp27
6 files changed, 682 insertions, 0 deletions
diff --git a/tools/designer/examples/book/book7/book.ui b/tools/designer/examples/book/book7/book.ui
new file mode 100644
index 0000000..b3c2869
--- /dev/null
+++ b/tools/designer/examples/book/book7/book.ui
@@ -0,0 +1,189 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>BookForm</class>
+<include location="global" impldecl="in declaration">qsqlrecord.h</include>
+<include location="local" impldecl="in declaration">editbook.h</include>
+<include location="global" impldecl="in declaration">qdatabrowser.h</include>
+<include location="local" implDecl="in declaration">book.ui.h</include>
+<layoutdefaults spacing="6" margin="11"/>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>BookForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>490</width>
+ <height>504</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Book</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QSplitter">
+ <property name="name">
+ <cstring>Splitter1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>MShape</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>MShadow</enum>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <widget class="QDataTable">
+ <column>
+ <property name="text">
+ <string>Surname</string>
+ </property>
+ <property name="field">
+ <string>surname</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Forename</string>
+ </property>
+ <property name="field">
+ <string>forename</string>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>AuthorDataTable</cstring>
+ </property>
+ <property name="confirmDelete">
+ <bool>true</bool>
+ </property>
+ <property name="sort">
+ <stringlist>
+ <string>surname ASC</string>
+ <string>forename ASC</string>
+ </stringlist>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>author</string>
+ </stringlist>
+ </property>
+ </widget>
+ <widget class="QDataTable">
+ <column>
+ <property name="text">
+ <string>Title</string>
+ </property>
+ <property name="field">
+ <string>title</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Price</string>
+ </property>
+ <property name="field">
+ <string>price</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Notes</string>
+ </property>
+ <property name="field">
+ <string>notes</string>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>BookDataTable</cstring>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="sort">
+ <stringlist>
+ <string>title ASC</string>
+ </stringlist>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>book</string>
+ </stringlist>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>EditPushButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Edit Books</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>QuitPushButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Quit</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection language="C++">
+ <sender>QuitPushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>BookForm</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>EditPushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>BookForm</receiver>
+ <slot>editClicked()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>AuthorDataTable</sender>
+ <signal>primeInsert(QSqlRecord*)</signal>
+ <receiver>BookForm</receiver>
+ <slot>primeInsertAuthor(QSqlRecord*)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>AuthorDataTable</sender>
+ <signal>currentChanged(QSqlRecord*)</signal>
+ <receiver>BookForm</receiver>
+ <slot>newCurrentAuthor(QSqlRecord*)</slot>
+ </connection>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">editClicked()</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">newCurrentAuthor( QSqlRecord * author )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">primeInsertAuthor( QSqlRecord * buffer )</slot>
+</connections>
+</UI>
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 0000000..de754b1
--- /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 );
+ QSqlCursor cur( "book" );
+ dialog->BookDataBrowser->setSqlCursor( &cur );
+ dialog->BookDataBrowser->setFilter( BookDataTable->filter() );
+ dialog->BookDataBrowser->setSort(QSqlIndex::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( QSqlRecord *author )
+{
+ BookDataTable->setFilter( "authorid=" + author->value( "id" ).toString() );
+ BookDataTable->refresh();
+}
+
+void BookForm::primeInsertAuthor( QSqlRecord *buffer )
+{
+ QSqlQuery 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 0000000..22c7e9b
--- /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 0000000..85df2ba
--- /dev/null
+++ b/tools/designer/examples/book/book7/editbook.ui
@@ -0,0 +1,384 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>EditBookForm</class>
+<include location="global" impldecl="in declaration">qsqlrecord.h</include>
+<include location="local" implDecl="in declaration">editbook.ui.h</include>
+<forward>class QSqlRecord;</forward>
+<layoutdefaults spacing="6" margin="11"/>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>EditBookForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>528</width>
+ <height>305</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Edit Books</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QDataBrowser">
+ <property name="name">
+ <cstring>BookDataBrowser</cstring>
+ </property>
+ <property name="sort">
+ <stringlist>
+ <string>title ASC</string>
+ </stringlist>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>book</string>
+ </stringlist>
+ </property>
+ <property name="frameworkCode" stdset="0">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>Layout2</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>labelPrice</cstring>
+ </property>
+ <property name="text">
+ <string>Price</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>labelTitle</cstring>
+ </property>
+ <property name="text">
+ <string>Title</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>QLineEditTitle</cstring>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>book</string>
+ <string>title</string>
+ </stringlist>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>QLineEditPrice</cstring>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>book</string>
+ <string>price</string>
+ </stringlist>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="0">
+ <property name="name">
+ <cstring>Layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>PushButtonInsert</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Insert</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>PushButtonUpdate</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Update</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>PushButtonDelete</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>PushButtonClose</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Close</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>Layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>PushButtonFirst</cstring>
+ </property>
+ <property name="text">
+ <string>|&lt; &amp;First</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>PushButtonPrev</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;&lt; &amp;Prev</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>PushButtonNext</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Next &gt;&gt;</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>PushButtonLast</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Last &gt;|</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>Layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Author</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>ComboBoxAuthor</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>author_view</string>
+ <string>name</string>
+ </stringlist>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection language="C++">
+ <sender>PushButtonFirst</sender>
+ <signal>clicked()</signal>
+ <receiver>BookDataBrowser</receiver>
+ <slot>first()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>BookDataBrowser</sender>
+ <signal>firstRecordAvailable( bool )</signal>
+ <receiver>PushButtonFirst</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>PushButtonPrev</sender>
+ <signal>clicked()</signal>
+ <receiver>BookDataBrowser</receiver>
+ <slot>prev()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>BookDataBrowser</sender>
+ <signal>prevRecordAvailable( bool )</signal>
+ <receiver>PushButtonPrev</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>PushButtonNext</sender>
+ <signal>clicked()</signal>
+ <receiver>BookDataBrowser</receiver>
+ <slot>next()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>BookDataBrowser</sender>
+ <signal>nextRecordAvailable( bool )</signal>
+ <receiver>PushButtonNext</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>PushButtonLast</sender>
+ <signal>clicked()</signal>
+ <receiver>BookDataBrowser</receiver>
+ <slot>last()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>BookDataBrowser</sender>
+ <signal>lastRecordAvailable( bool )</signal>
+ <receiver>PushButtonLast</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>PushButtonInsert</sender>
+ <signal>clicked()</signal>
+ <receiver>BookDataBrowser</receiver>
+ <slot>insert()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>PushButtonUpdate</sender>
+ <signal>clicked()</signal>
+ <receiver>BookDataBrowser</receiver>
+ <slot>update()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>PushButtonDelete</sender>
+ <signal>clicked()</signal>
+ <receiver>BookDataBrowser</receiver>
+ <slot>del()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>PushButtonClose</sender>
+ <signal>clicked()</signal>
+ <receiver>EditBookForm</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection language="C++">
+ <sender>BookDataBrowser</sender>
+ <signal>primeUpdate(QSqlRecord*)</signal>
+ <receiver>EditBookForm</receiver>
+ <slot>primeUpdateBook(QSqlRecord*)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>BookDataBrowser</sender>
+ <signal>beforeUpdate(QSqlRecord*)</signal>
+ <receiver>EditBookForm</receiver>
+ <slot>beforeUpdateBook(QSqlRecord*)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>BookDataBrowser</sender>
+ <signal>beforeInsert(QSqlRecord*)</signal>
+ <receiver>EditBookForm</receiver>
+ <slot>beforeUpdateBook(QSqlRecord*)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>BookDataBrowser</sender>
+ <signal>primeInsert(QSqlRecord*)</signal>
+ <receiver>EditBookForm</receiver>
+ <slot>primeInsertBook(QSqlRecord*)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>BookDataBrowser</sender>
+ <signal>primeInsert(QSqlRecord*)</signal>
+ <receiver>EditBookForm</receiver>
+ <slot>primeInsertBook(QSqlRecord*)</slot>
+ </connection>
+ <slot access="protected" specifier="virtual" language="C++" returnType="void">init()</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">beforeUpdateBook( QSqlRecord * buffer )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">primeInsertBook( QSqlRecord * buffer )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">primeUpdateBook( QSqlRecord * buffer )</slot>
+</connections>
+<tabstops>
+ <tabstop>QLineEditTitle</tabstop>
+ <tabstop>QLineEditPrice</tabstop>
+ <tabstop>ComboBoxAuthor</tabstop>
+ <tabstop>PushButtonFirst</tabstop>
+ <tabstop>PushButtonPrev</tabstop>
+ <tabstop>PushButtonNext</tabstop>
+ <tabstop>PushButtonLast</tabstop>
+ <tabstop>PushButtonInsert</tabstop>
+ <tabstop>PushButtonUpdate</tabstop>
+ <tabstop>PushButtonDelete</tabstop>
+ <tabstop>PushButtonClose</tabstop>
+</tabstops>
+</UI>
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 0000000..f955312
--- /dev/null
+++ b/tools/designer/examples/book/book7/editbook.ui.h
@@ -0,0 +1,42 @@
+void EditBookForm::init()
+{
+ QSqlQuery query( "SELECT surname FROM author ORDER BY surname;" );
+ while ( query.next() )
+ ComboBoxAuthor->insertItem( query.value( 0 ).toString());
+}
+
+void EditBookForm::beforeUpdateBook( QSqlRecord * buffer )
+{
+ QSqlQuery query( "SELECT id FROM author WHERE surname ='" +
+ ComboBoxAuthor->currentText() + "';" );
+ if ( query.next() )
+ buffer->setValue( "authorid", query.value( 0 ) );
+}
+
+void EditBookForm::primeInsertBook( QSqlRecord * buffer )
+{
+ QSqlQuery 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( QSqlRecord * buffer )
+{
+ // Who is this book's author?
+ QSqlQuery query( "SELECT surname FROM author WHERE id='" +
+ buffer->value( "authorid" ).toString() + "';" );
+ QString 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 0000000..464ed42
--- /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 Qt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qsqldatabase.h>
+#include "book.h"
+#include "../connection.h"
+
+int main( int argc, char *argv[] )
+{
+ QApplication app( argc, argv );
+
+ if ( ! createConnections() )
+ return 1;
+
+ BookForm bookForm;
+ app.setMainWidget( &bookForm );
+ bookForm.show();
+
+ return app.exec();
+}