diff options
Diffstat (limited to 'python/pyqt/examples3/SQL')
-rw-r--r-- | python/pyqt/examples3/SQL/README | 76 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/connect.ui | 238 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/connect.ui.h | 21 | ||||
-rwxr-xr-x | python/pyqt/examples3/SQL/dbconnect.py | 82 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/dbpar.py | 22 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/form1.ui | 77 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/form2.ui | 327 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/frmconnect.py | 120 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/frmconnect.ui | 245 | ||||
-rwxr-xr-x | python/pyqt/examples3/SQL/runform1.py | 21 | ||||
-rwxr-xr-x | python/pyqt/examples3/SQL/runform2.py | 21 | ||||
-rwxr-xr-x | python/pyqt/examples3/SQL/runsqlex.py | 151 | ||||
-rwxr-xr-x | python/pyqt/examples3/SQL/sqlcustom1.py | 94 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/sqlex.ui | 303 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/sqlex.ui.h | 35 | ||||
-rwxr-xr-x | python/pyqt/examples3/SQL/sqlsubclass5.py | 151 | ||||
-rwxr-xr-x | python/pyqt/examples3/SQL/sqltable4.py | 118 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/testdb_mysql.sql | 57 | ||||
-rw-r--r-- | python/pyqt/examples3/SQL/testdb_pg.sql | 232 |
19 files changed, 0 insertions, 2391 deletions
diff --git a/python/pyqt/examples3/SQL/README b/python/pyqt/examples3/SQL/README deleted file mode 100644 index 9dfc5d41..00000000 --- a/python/pyqt/examples3/SQL/README +++ /dev/null @@ -1,76 +0,0 @@ -This directory contains some translated sql examples from Qt 3.x. - -runform1.py, form1.ui: - - A simple designer generated QDataTable. Run "pyuic form1.ui -o form1.py". - -runform2.py, form2.ui: - - A simple designer generated QDataBrowser. Run "pyuic form2.ui -o form2.py". - -sqlcustom1.py: - - QSqlForm based form with a simple custom editor forcing all input to - be uppercase - -sqltable4.py: - - Custom QDataTable with reimplemented paintField method, combined with - a QComboBox based custom field editor (StatusPicker), gathering its - items from a different table (status) and a calculated column (monsalary). - Note, that QSqlEditorFactory based field editors are somewhat restricted, - because Qt's Q_PROPERTY feature isn't supported, yet. I've circumvented - this limitation by choosing the status table ids corresponding to the - index in the QComboBox. - -sqlsubclass5.py: - - Similar to the former, and even more deviated from its qt ancestor, - because the sense escaped me. This could be related to the different - database layout needed for MySQL (Trolltech used PostgreSQL sequences, - while we're using the simpler, but less powerful auto_increment here). - If you enter and invalid date (e.g. day: 0) in the Paid column, it is - shown as "not yet", but produces some qt warnings. - -runsqlex.py, sqlex.ui, sqlex.ui.h, connect.ui, connect.ui.h: - - This one is a most advanced example, showing the use of a QSqlCursor - driven by QSqlQuery and iterating through database tables and fields. - Definitely worth a look. - -Unfortunately you will have to make sure that these prerequisites are met -before trying the examples: - - - Install MySQL or PostgreSQL and any development packages - - - Create a database user with sufficient rights - - - Create the testdb database - - For MySQL, run: mysql -u user -p password < testdb_mysql.sql - - For PostgreSQL, run: psql -U user template1 -f testdb_pg.sql - - - Build Qt with the mysql and/or psql modules activated. - -Now you should be ready for the fun part. You can run dbconnect.py from -a command line and try to connect to the database. If all went well, -'ok' should be printed after pressing OK. If you don't want to enter all -your data over and over again, create a file named local_dbpar.py here, -with the following keys (with your own data, of course): - -DB_HOSTNAMES = ["localhost"] -DB_DATABASES = ["testdb"] -DB_USERNAME = "name" -DB_PASSWORD = "pass" - -The dbconnect.py script is generated from dbconnect.ui, which was created -with qt's designer. You can find it also in Boudewijn Rempt's book -"GUI Programming with Python, using the Qt Toolkit". Although you won't find -the SQL widgets discussed there, for the simple reason of the book being -written before they appeared, it is a valuable source for anybody new in -this area. - -Please direct any comments, patches and questions to <pykde@mats.gmd.de>. - -Good luck - -Hans-Peter Jansen <hpj@urpla.net> diff --git a/python/pyqt/examples3/SQL/connect.ui b/python/pyqt/examples3/SQL/connect.ui deleted file mode 100644 index cc419203..00000000 --- a/python/pyqt/examples3/SQL/connect.ui +++ /dev/null @@ -1,238 +0,0 @@ -<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> -<class>ConnectDialog</class> -<widget class="QDialog"> - <property name="name"> - <cstring>ConnectDialog</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>303</width> - <height>251</height> - </rect> - </property> - <property name="caption"> - <string>Connect...</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="QGroupBox"> - <property name="name"> - <cstring>GroupBox3</cstring> - </property> - <property name="title"> - <string>Connection settings</string> - </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="QLineEdit" row="1" column="1"> - <property name="name"> - <cstring>editDatabase</cstring> - </property> - </widget> - <widget class="QLabel" row="1" column="0"> - <property name="name"> - <cstring>TextLabel3</cstring> - </property> - <property name="text"> - <string>Database Name:</string> - </property> - <property name="buddy" stdset="0"> - <cstring>comboDatabase</cstring> - </property> - </widget> - <widget class="QLineEdit" row="3" column="1"> - <property name="name"> - <cstring>editPassword</cstring> - </property> - <property name="echoMode"> - <enum>Password</enum> - </property> - </widget> - <widget class="QLabel" row="2" column="0"> - <property name="name"> - <cstring>TextLabel4</cstring> - </property> - <property name="text"> - <string>&Username:</string> - </property> - <property name="buddy" stdset="0"> - <cstring>editUsername</cstring> - </property> - </widget> - <widget class="QLabel" row="3" column="0"> - <property name="name"> - <cstring>TextLabel4_2</cstring> - </property> - <property name="text"> - <string>&Password:</string> - </property> - <property name="buddy" stdset="0"> - <cstring>editPassword</cstring> - </property> - </widget> - <widget class="QComboBox" row="0" column="1"> - <property name="name"> - <cstring>comboDriver</cstring> - </property> - </widget> - <widget class="QLineEdit" row="2" column="1"> - <property name="name"> - <cstring>editUsername</cstring> - </property> - </widget> - <widget class="QLineEdit" row="4" column="1"> - <property name="name"> - <cstring>editHostname</cstring> - </property> - </widget> - <widget class="QLabel" row="4" column="0"> - <property name="name"> - <cstring>TextLabel5</cstring> - </property> - <property name="text"> - <string>&Hostname:</string> - </property> - <property name="buddy" stdset="0"> - <cstring>editHostname</cstring> - </property> - </widget> - <widget class="QLabel" row="5" column="0"> - <property name="name"> - <cstring>TextLabel5_2</cstring> - </property> - <property name="text"> - <string>P&ort:</string> - </property> - <property name="buddy" stdset="0"> - <cstring>portSpinBox</cstring> - </property> - </widget> - <widget class="QSpinBox" row="5" column="1"> - <property name="name"> - <cstring>portSpinBox</cstring> - </property> - <property name="specialValueText"> - <string>Default</string> - </property> - <property name="maxValue"> - <number>65535</number> - </property> - <property name="minValue"> - <number>-1</number> - </property> - <property name="value"> - <number>-1</number> - </property> - </widget> - <widget class="QLabel" row="0" column="0"> - <property name="name"> - <cstring>TextLabel2</cstring> - </property> - <property name="text"> - <string>D&river</string> - </property> - <property name="buddy" stdset="0"> - <cstring>comboDriver</cstring> - </property> - </widget> - </grid> - </widget> - <widget class="QLayoutWidget"> - <property name="name"> - <cstring>Layout25</cstring> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <property name="margin"> - <number>0</number> - </property> - <property name="spacing"> - <number>6</number> - </property> - <spacer> - <property name="name"> - <cstring>Spacer1</cstring> - </property> - <property name="orientation"> - <enum>Horizontal</enum> - </property> - <property name="sizeType"> - <enum>Expanding</enum> - </property> - </spacer> - <widget class="QPushButton"> - <property name="name"> - <cstring>PushButton1</cstring> - </property> - <property name="text"> - <string>&OK</string> - </property> - <property name="default"> - <bool>true</bool> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>PushButton2</cstring> - </property> - <property name="text"> - <string>&Cancel</string> - </property> - </widget> - </hbox> - </widget> - </vbox> -</widget> -<connections> - <connection> - <sender>PushButton1</sender> - <signal>clicked()</signal> - <receiver>ConnectDialog</receiver> - <slot>accept()</slot> - </connection> - <connection> - <sender>PushButton2</sender> - <signal>clicked()</signal> - <receiver>ConnectDialog</receiver> - <slot>reject()</slot> - </connection> -</connections> -<tabstops> - <tabstop>comboDriver</tabstop> - <tabstop>editDatabase</tabstop> - <tabstop>editUsername</tabstop> - <tabstop>editPassword</tabstop> - <tabstop>editHostname</tabstop> - <tabstop>portSpinBox</tabstop> - <tabstop>PushButton1</tabstop> - <tabstop>PushButton2</tabstop> -</tabstops> -<includes> - <include location="local" impldecl="in implementation">connect.ui.h</include> -</includes> -<slots> - <slot>init()</slot> - <slot>destroy()</slot> -</slots> -<layoutdefaults spacing="6" margin="11"/> -</UI> diff --git a/python/pyqt/examples3/SQL/connect.ui.h b/python/pyqt/examples3/SQL/connect.ui.h deleted file mode 100644 index ee6e5a95..00000000 --- a/python/pyqt/examples3/SQL/connect.ui.h +++ /dev/null @@ -1,21 +0,0 @@ -/**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** If you wish to add, delete or rename slots use Qt Designer which will -** update this file, preserving your code. Create an init() slot in place of -** a constructor, and a destroy() slot in place of a destructor. -*****************************************************************************/ - - -void ConnectDialog::init() -{ -from qtsql import QSqlDatabase -#qDebug("ConnectDialog init") -self.comboDriver.clear() -self.comboDriver.insertStringList(TQSqlDatabase.drivers()) -} - -void ConnectDialog::destroy() -{ - -} diff --git a/python/pyqt/examples3/SQL/dbconnect.py b/python/pyqt/examples3/SQL/dbconnect.py deleted file mode 100755 index fdae7de1..00000000 --- a/python/pyqt/examples3/SQL/dbconnect.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python - -import sys -from qt import * -from qtsql import * - -from frmconnect import frmConnect -from dbpar import * - -TRUE = 1 -FALSE = 0 - -def createConnection(): - driver = DB_DRIVER - # all qt examples use QSqlDatabase::addDatabase, but - # this never returns NULL in my experience - drivers = map(str, QSqlDatabase.drivers()) - if driver in drivers: - dlg = dbConnect(driver) - #TODO: make connection parameters accessible - return dlg.exec_loop() - else: - QMessageBox.warning(None, "Database Error", - "<%s> database driver not found!\n\n" - "Please make sure, that this database adaptor\n" - "is available in your Qt installation.\n" % - (driver), QMessageBox.Abort | QMessageBox.Escape) - return FALSE - -class dbConnect(frmConnect): - def __init__(self, driver, parent = None): - frmConnect.__init__(self, parent) - self.hostnames = DB_HOSTNAMES - self.hostname = DB_HOSTNAMES[0] - self.databases = DB_DATABASES - self.database = DB_DATABASES[0] - self.username = DB_USERNAME - self.password = DB_PASSWORD - self.dbdriver = driver - - self.txtName.setText(self.username) - self.txtPasswd.setText(self.password) - map(self.cmbServer.insertItem, self.hostnames) - map(self.cmbDatabase.insertItem, self.databases) - self.connect(self.buttonHelp, SIGNAL("clicked()"), - self.buttonHelp_clicked) - - def accept(self): - self.hostname = self.cmbServer.currentText() - self.database = self.cmbDatabase.currentText() - self.username = self.txtName.text() - self.password = self.txtPasswd.text() - db = QSqlDatabase.addDatabase(self.dbdriver) - if db: - db.setHostName(self.hostname) - db.setDatabaseName(self.database) - db.setUserName(self.username) - db.setPassword(self.password) - if db.open(): - frmConnect.accept(self) - else: - QMessageBox.warning(self, "Database Error", - "Cannot open %s database on %s!\n\n%s\n%s\n" % - (self.database, self.hostname, - db.lastError().driverText(), - db.lastError().databaseText()), " Ooops ") - - - def buttonHelp_clicked(self): - QMessageBox.information(self, "About Connecting", - "Here you specify userid, password, host and database\n" - "for the PyQt sql examples. If you encounter any problems,\n" - "please read the README file in this folder before posting.\n\n" - "Thanks,\nHans-Peter Jansen <hpj@urpla.net>\n") - - -if __name__ == "__main__": - app = QApplication(sys.argv) - if createConnection(): - print "ok" - else: - print "cancel" diff --git a/python/pyqt/examples3/SQL/dbpar.py b/python/pyqt/examples3/SQL/dbpar.py deleted file mode 100644 index 90e92704..00000000 --- a/python/pyqt/examples3/SQL/dbpar.py +++ /dev/null @@ -1,22 +0,0 @@ -# sql examples default database parameter - -# you can create a local_dbpar.py module with definitons -# of your own parameters to overrule these defaults - -#DB_DRIVER = "QPSQL7" -DB_DRIVER = "QMYSQL3" -# list of servers -DB_HOSTNAMES = ["localhost"] -# list of databases -DB_DATABASES = ["testdb"] -# database user id -DB_USERNAME = "" -# database password -DB_PASSWORD = "" - -# remove this in your local_dbpar.py -try: - from local_dbpar import * -except: - pass - diff --git a/python/pyqt/examples3/SQL/form1.ui b/python/pyqt/examples3/SQL/form1.ui deleted file mode 100644 index 38b3cb27..00000000 --- a/python/pyqt/examples3/SQL/form1.ui +++ /dev/null @@ -1,77 +0,0 @@ -<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> -<class>Form1</class> -<widget class="QDialog"> - <property name="name"> - <cstring>Form1</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>600</width> - <height>370</height> - </rect> - </property> - <property name="caption"> - <string>Form1</string> - </property> - <widget class="QDataTable"> - <column> - <property name="text"> - <string>Forename</string> - </property> - <property name="field"> - <string>forename</string> - </property> - </column> - <column> - <property name="text"> - <string>Surname</string> - </property> - <property name="field"> - <string>surname</string> - </property> - </column> - <column> - <property name="text"> - <string>Salary</string> - </property> - <property name="field"> - <string>salary</string> - </property> - </column> - <column> - <property name="text"> - <string>Statusid</string> - </property> - <property name="field"> - <string>statusid</string> - </property> - </column> - <property name="name"> - <cstring>DataTable2</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>600</width> - <height>370</height> - </rect> - </property> - <property name="sorting"> - <bool>true</bool> - </property> - <property name="confirmDelete"> - <bool>true</bool> - </property> - <property name="database" stdset="0"> - <stringlist> - <string>(default)</string> - <string>staff</string> - </stringlist> - </property> - </widget> -</widget> -<layoutdefaults spacing="6" margin="11"/> -</UI> diff --git a/python/pyqt/examples3/SQL/form2.ui b/python/pyqt/examples3/SQL/form2.ui deleted file mode 100644 index ffe2beb5..00000000 --- a/python/pyqt/examples3/SQL/form2.ui +++ /dev/null @@ -1,327 +0,0 @@ -<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> -<class>Form2</class> -<widget class="QDialog"> - <property name="name"> - <cstring>Form2</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>367</width> - <height>152</height> - </rect> - </property> - <property name="caption"> - <string>Form2</string> - </property> - <widget class="QDataBrowser"> - <property name="name"> - <cstring>DataBrowser1</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>366</width> - <height>150</height> - </rect> - </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>staff</string> - </stringlist> - </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>labelSurname</cstring> - </property> - <property name="text"> - <string>Surname</string> - </property> - </widget> - <widget class="QSpinBox" row="1" column="3"> - <property name="name"> - <cstring>QSpinBoxStatusid</cstring> - </property> - <property name="maxValue"> - <number>2147483647</number> - </property> - <property name="database" stdset="0"> - <stringlist> - <string>(default)</string> - <string>staff</string> - <string>statusid</string> - </stringlist> - </property> - </widget> - <widget class="QLineEdit" row="1" column="1"> - <property name="name"> - <cstring>QLineEditSurname</cstring> - </property> - <property name="database" stdset="0"> - <stringlist> - <string>(default)</string> - <string>staff</string> - <string>surname</string> - </stringlist> - </property> - </widget> - <widget class="QLabel" row="1" column="2"> - <property name="name"> - <cstring>labelStatusid</cstring> - </property> - <property name="text"> - <string>Statusid</string> - </property> - </widget> - <widget class="QLabel" row="0" column="0"> - <property name="name"> - <cstring>labelForename</cstring> - </property> - <property name="text"> - <string>Forename</string> - </property> - </widget> - <widget class="QLineEdit" row="0" column="3"> - <property name="name"> - <cstring>QLineEditSalary</cstring> - </property> - <property name="alignment"> - <set>AlignRight</set> - </property> - <property name="database" stdset="0"> - <stringlist> - <string>(default)</string> - <string>staff</string> - <string>salary</string> - </stringlist> - </property> - </widget> - <widget class="QLabel" row="0" column="2"> - <property name="name"> - <cstring>labelSalary</cstring> - </property> - <property name="text"> - <string>Salary</string> - </property> - </widget> - <widget class="QLineEdit" row="0" column="1"> - <property name="name"> - <cstring>QLineEditForename</cstring> - </property> - <property name="database" stdset="0"> - <stringlist> - <string>(default)</string> - <string>staff</string> - <string>forename</string> - </stringlist> - </property> - </widget> - </grid> - </widget> - <widget class="QLayoutWidget" row="1" 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>|< &First</string> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>PushButtonPrev</cstring> - </property> - <property name="text"> - <string><< &Prev</string> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>PushButtonNext</cstring> - </property> - <property name="text"> - <string>&Next >></string> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>PushButtonLast</cstring> - </property> - <property name="text"> - <string>&Last >|</string> - </property> - </widget> - </hbox> - </widget> - <widget class="QLayoutWidget" row="2" column="0"> - <property name="name"> - <cstring>Layout4</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>&Insert</string> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>PushButtonUpdate</cstring> - </property> - <property name="text"> - <string>&Update</string> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>PushButtonDelete</cstring> - </property> - <property name="text"> - <string>&Delete</string> - </property> - </widget> - </hbox> - </widget> - </grid> - </widget> -</widget> -<connections> - <connection> - <sender>PushButtonFirst</sender> - <signal>clicked()</signal> - <receiver>DataBrowser1</receiver> - <slot>first()</slot> - </connection> - <connection> - <sender>DataBrowser1</sender> - <signal>firstRecordAvailable( bool )</signal> - <receiver>PushButtonFirst</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>PushButtonPrev</sender> - <signal>clicked()</signal> - <receiver>DataBrowser1</receiver> - <slot>prev()</slot> - </connection> - <connection> - <sender>DataBrowser1</sender> - <signal>prevRecordAvailable( bool )</signal> - <receiver>PushButtonPrev</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>PushButtonNext</sender> - <signal>clicked()</signal> - <receiver>DataBrowser1</receiver> - <slot>next()</slot> - </connection> - <connection> - <sender>DataBrowser1</sender> - <signal>nextRecordAvailable( bool )</signal> - <receiver>PushButtonNext</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>PushButtonLast</sender> - <signal>clicked()</signal> - <receiver>DataBrowser1</receiver> - <slot>last()</slot> - </connection> - <connection> - <sender>DataBrowser1</sender> - <signal>lastRecordAvailable( bool )</signal> - <receiver>PushButtonLast</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>PushButtonInsert</sender> - <signal>clicked()</signal> - <receiver>DataBrowser1</receiver> - <slot>insert()</slot> - </connection> - <connection> - <sender>PushButtonUpdate</sender> - <signal>clicked()</signal> - <receiver>DataBrowser1</receiver> - <slot>update()</slot> - </connection> - <connection> - <sender>PushButtonDelete</sender> - <signal>clicked()</signal> - <receiver>DataBrowser1</receiver> - <slot>del()</slot> - </connection> -</connections> -<tabstops> - <tabstop>QLineEditForename</tabstop> - <tabstop>QLineEditSurname</tabstop> - <tabstop>QLineEditSalary</tabstop> - <tabstop>QSpinBoxStatusid</tabstop> - <tabstop>PushButtonFirst</tabstop> - <tabstop>PushButtonPrev</tabstop> - <tabstop>PushButtonNext</tabstop> - <tabstop>PushButtonLast</tabstop> - <tabstop>PushButtonInsert</tabstop> - <tabstop>PushButtonUpdate</tabstop> - <tabstop>PushButtonDelete</tabstop> -</tabstops> -<layoutdefaults spacing="6" margin="11"/> -</UI> diff --git a/python/pyqt/examples3/SQL/frmconnect.py b/python/pyqt/examples3/SQL/frmconnect.py deleted file mode 100644 index 23cd0674..00000000 --- a/python/pyqt/examples3/SQL/frmconnect.py +++ /dev/null @@ -1,120 +0,0 @@ -# Form implementation generated from reading ui file 'frmconnect.ui' -# -# Created: Sam Jul 6 12:47:10 2002 -# by: The PyQt User Interface Compiler (pyuic) -# -# WARNING! All changes made in this file will be lost! - - -from qt import * - - -class frmConnect(QDialog): - def __init__(self,parent = None,name = None,modal = 0,fl = 0): - QDialog.__init__(self,parent,name,modal,fl) - - if name == None: - self.setName("frmConnect") - - self.resize(415,154) - self.setCaption(self.trUtf8("Connecting")) - self.setSizeGripEnabled(1) - - frmConnectLayout = QGridLayout(self,1,1,11,6,"frmConnectLayout") - - Layout7 = QVBoxLayout(None,0,6,"Layout7") - - self.buttonOK = QPushButton(self,"buttonOK") - self.buttonOK.setText(self.trUtf8("&OK")) - self.buttonOK.setAutoDefault(1) - self.buttonOK.setDefault(1) - QToolTip.add(self.buttonOK,self.trUtf8("Connect to Database")) - Layout7.addWidget(self.buttonOK) - - self.buttonCancel = QPushButton(self,"buttonCancel") - self.buttonCancel.setText(self.trUtf8("&Cancel")) - QToolTip.add(self.buttonCancel,self.trUtf8("Cancel Connecting")) - Layout7.addWidget(self.buttonCancel) - - self.buttonHelp = QPushButton(self,"buttonHelp") - self.buttonHelp.setText(self.trUtf8("&Help")) - QToolTip.add(self.buttonHelp,self.trUtf8("About Connecting")) - Layout7.addWidget(self.buttonHelp) - spacer = QSpacerItem(0,0,QSizePolicy.Minimum,QSizePolicy.Expanding) - Layout7.addItem(spacer) - - frmConnectLayout.addLayout(Layout7,0,1) - - self.grpConnection = QGroupBox(self,"grpConnection") - self.grpConnection.setTitle(self.trUtf8("")) - self.grpConnection.setColumnLayout(0,Qt.Vertical) - self.grpConnection.layout().setSpacing(6) - self.grpConnection.layout().setMargin(11) - grpConnectionLayout = QGridLayout(self.grpConnection.layout()) - grpConnectionLayout.setAlignment(Qt.AlignTop) - - self.txtName = QLineEdit(self.grpConnection,"txtName") - self.txtName.setMaxLength(16) - QToolTip.add(self.txtName,self.trUtf8("Database User ID")) - - grpConnectionLayout.addWidget(self.txtName,0,1) - - self.lblDatabase = QLabel(self.grpConnection,"lblDatabase") - self.lblDatabase.setText(self.trUtf8("&Database")) - - grpConnectionLayout.addWidget(self.lblDatabase,3,0) - - self.lblServer = QLabel(self.grpConnection,"lblServer") - self.lblServer.setText(self.trUtf8("&Server")) - - grpConnectionLayout.addWidget(self.lblServer,2,0) - - self.lblName = QLabel(self.grpConnection,"lblName") - self.lblName.setText(self.trUtf8("&Name")) - - grpConnectionLayout.addWidget(self.lblName,0,0) - - self.cmbDatabase = QComboBox(0,self.grpConnection,"cmbDatabase") - self.cmbDatabase.setEditable(1) - self.cmbDatabase.setAutoCompletion(1) - self.cmbDatabase.setDuplicatesEnabled(0) - QToolTip.add(self.cmbDatabase,self.trUtf8("Database Name")) - - grpConnectionLayout.addWidget(self.cmbDatabase,3,1) - - self.txtPasswd = QLineEdit(self.grpConnection,"txtPasswd") - self.txtPasswd.setMaxLength(16) - self.txtPasswd.setEchoMode(QLineEdit.Password) - QToolTip.add(self.txtPasswd,self.trUtf8("Database User Password")) - - grpConnectionLayout.addWidget(self.txtPasswd,1,1) - - self.lblPasswd = QLabel(self.grpConnection,"lblPasswd") - self.lblPasswd.setText(self.trUtf8("&Password")) - - grpConnectionLayout.addWidget(self.lblPasswd,1,0) - - self.cmbServer = QComboBox(0,self.grpConnection,"cmbServer") - self.cmbServer.setEditable(1) - self.cmbServer.setAutoCompletion(1) - self.cmbServer.setDuplicatesEnabled(0) - QToolTip.add(self.cmbServer,self.trUtf8("Database Server Address")) - - grpConnectionLayout.addWidget(self.cmbServer,2,1) - - frmConnectLayout.addWidget(self.grpConnection,0,0) - - self.connect(self.buttonOK,SIGNAL("clicked()"),self,SLOT("accept()")) - self.connect(self.buttonCancel,SIGNAL("clicked()"),self,SLOT("reject()")) - - self.setTabOrder(self.txtName,self.txtPasswd) - self.setTabOrder(self.txtPasswd,self.cmbServer) - self.setTabOrder(self.cmbServer,self.cmbDatabase) - self.setTabOrder(self.cmbDatabase,self.buttonOK) - self.setTabOrder(self.buttonOK,self.buttonCancel) - self.setTabOrder(self.buttonCancel,self.buttonHelp) - - self.lblDatabase.setBuddy(self.cmbDatabase) - self.lblServer.setBuddy(self.cmbServer) - self.lblName.setBuddy(self.txtName) - self.lblPasswd.setBuddy(self.txtPasswd) diff --git a/python/pyqt/examples3/SQL/frmconnect.ui b/python/pyqt/examples3/SQL/frmconnect.ui deleted file mode 100644 index a6fc15cc..00000000 --- a/python/pyqt/examples3/SQL/frmconnect.ui +++ /dev/null @@ -1,245 +0,0 @@ -<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> -<class>frmConnect</class> -<widget class="QDialog"> - <property name="name"> - <cstring>frmConnect</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>415</width> - <height>154</height> - </rect> - </property> - <property name="caption"> - <string>Connecting</string> - </property> - <property name="sizeGripEnabled"> - <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="1"> - <property name="name"> - <cstring>Layout7</cstring> - </property> - <vbox> - <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>buttonOK</cstring> - </property> - <property name="text"> - <string>&OK</string> - </property> - <property name="autoDefault"> - <bool>true</bool> - </property> - <property name="default"> - <bool>true</bool> - </property> - <property name="toolTip" stdset="0"> - <string>Connect to Database</string> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>buttonCancel</cstring> - </property> - <property name="text"> - <string>&Cancel</string> - </property> - <property name="toolTip" stdset="0"> - <string>Cancel Connecting</string> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>buttonHelp</cstring> - </property> - <property name="text"> - <string>&Help</string> - </property> - <property name="toolTip" stdset="0"> - <string>About Connecting</string> - </property> - </widget> - <spacer> - <property name="name"> - <cstring>spacer</cstring> - </property> - <property name="orientation"> - <enum>Vertical</enum> - </property> - <property name="sizeType"> - <enum>Expanding</enum> - </property> - </spacer> - </vbox> - </widget> - <widget class="QGroupBox" row="0" column="0"> - <property name="name"> - <cstring>grpConnection</cstring> - </property> - <property name="title"> - <string></string> - </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="QLineEdit" row="0" column="1"> - <property name="name"> - <cstring>txtName</cstring> - </property> - <property name="maxLength"> - <number>16</number> - </property> - <property name="toolTip" stdset="0"> - <string>Database User ID</string> - </property> - </widget> - <widget class="QLabel" row="3" column="0"> - <property name="name"> - <cstring>lblDatabase</cstring> - </property> - <property name="text"> - <string>&Database</string> - </property> - <property name="buddy" stdset="0"> - <cstring>cmbDatabase</cstring> - </property> - </widget> - <widget class="QLabel" row="2" column="0"> - <property name="name"> - <cstring>lblServer</cstring> - </property> - <property name="text"> - <string>&Server</string> - </property> - <property name="buddy" stdset="0"> - <cstring>cmbServer</cstring> - </property> - </widget> - <widget class="QLabel" row="0" column="0"> - <property name="name"> - <cstring>lblName</cstring> - </property> - <property name="text"> - <string>&Name</string> - </property> - <property name="buddy" stdset="0"> - <cstring>txtName</cstring> - </property> - </widget> - <widget class="QComboBox" row="3" column="1"> - <property name="name"> - <cstring>cmbDatabase</cstring> - </property> - <property name="editable"> - <bool>true</bool> - </property> - <property name="autoCompletion"> - <bool>true</bool> - </property> - <property name="duplicatesEnabled"> - <bool>false</bool> - </property> - <property name="toolTip" stdset="0"> - <string>Database Name</string> - </property> - </widget> - <widget class="QLineEdit" row="1" column="1"> - <property name="name"> - <cstring>txtPasswd</cstring> - </property> - <property name="maxLength"> - <number>16</number> - </property> - <property name="echoMode"> - <enum>Password</enum> - </property> - <property name="toolTip" stdset="0"> - <string>Database User Password</string> - </property> - </widget> - <widget class="QLabel" row="1" column="0"> - <property name="name"> - <cstring>lblPasswd</cstring> - </property> - <property name="text"> - <string>&Password</string> - </property> - <property name="buddy" stdset="0"> - <cstring>txtPasswd</cstring> - </property> - </widget> - <widget class="QComboBox" row="2" column="1"> - <property name="name"> - <cstring>cmbServer</cstring> - </property> - <property name="editable"> - <bool>true</bool> - </property> - <property name="autoCompletion"> - <bool>true</bool> - </property> - <property name="duplicatesEnabled"> - <bool>false</bool> - </property> - <property name="toolTip" stdset="0"> - <string>Database Server Address</string> - </property> - </widget> - </grid> - </widget> - </grid> -</widget> -<connections> - <connection> - <sender>buttonOK</sender> - <signal>clicked()</signal> - <receiver>frmConnect</receiver> - <slot>accept()</slot> - </connection> - <connection> - <sender>buttonCancel</sender> - <signal>clicked()</signal> - <receiver>frmConnect</receiver> - <slot>reject()</slot> - </connection> -</connections> -<tabstops> - <tabstop>txtName</tabstop> - <tabstop>txtPasswd</tabstop> - <tabstop>cmbServer</tabstop> - <tabstop>cmbDatabase</tabstop> - <tabstop>buttonOK</tabstop> - <tabstop>buttonCancel</tabstop> - <tabstop>buttonHelp</tabstop> -</tabstops> -<layoutdefaults spacing="6" margin="11"/> -</UI> diff --git a/python/pyqt/examples3/SQL/runform1.py b/python/pyqt/examples3/SQL/runform1.py deleted file mode 100755 index d5760ce1..00000000 --- a/python/pyqt/examples3/SQL/runform1.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python - -import sys -from qt import * - -from form1 import Form1 -from dbconnect import createConnection - -class mainWindow(Form1): - def __init__(self,parent = None,name = None,fl = 0): - Form1.__init__(self,parent,name,fl) - -if __name__ == "__main__": - a = QApplication(sys.argv) - if createConnection(): - QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()")) - w = mainWindow() - a.setMainWidget(w) - w.show() - a.exec_loop() - diff --git a/python/pyqt/examples3/SQL/runform2.py b/python/pyqt/examples3/SQL/runform2.py deleted file mode 100755 index ba0ca4a5..00000000 --- a/python/pyqt/examples3/SQL/runform2.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python - -import sys -from qt import * - -from form2 import Form2 -from dbconnect import createConnection - -class mainWindow(Form2): - def __init__(self,parent = None,name = None,fl = 0): - Form2.__init__(self,parent,name,fl) - -if __name__ == "__main__": - a = QApplication(sys.argv) - if createConnection(): - QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()")) - w = mainWindow() - a.setMainWidget(w) - w.show() - a.exec_loop() - diff --git a/python/pyqt/examples3/SQL/runsqlex.py b/python/pyqt/examples3/SQL/runsqlex.py deleted file mode 100755 index 7f2afa71..00000000 --- a/python/pyqt/examples3/SQL/runsqlex.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env python - -import sys -from qt import * -from qtsql import * - -from sqlex import SqlEx -from connect import ConnectDialog - -from dbpar import * - -TRUE = 1 -FALSE = 0 - -def showError(err, parent): - errStr = QString("The database reported an error:\n\n") - if not err.databaseText().isEmpty(): - errStr.append(err.databaseText()) - errStr.append("\n") - if not err.driverText().isEmpty(): - errStr.append(err.driverText()) - errStr.append("\n") - QMessageBox.warning(parent, "Error", errStr) - -class CustomSqlCursor(QSqlCursor): - def __init__(self, query = None, autopopulate = TRUE, db = None): - QSqlCursor.__init__(self, None, autopopulate, db) - self.execQuery(query) - if self.isSelect() and autopopulate: - fields = self.driver().recordInfo(self) - for f in fields: - self.append(f) - self.setMode(QSqlCursor.ReadOnly) - - def select(self, filter, sort = QSqlIndex()): - return self.execQuery(self.lastQuery()) - - def primaryIndex(self, prime = TRUE): - return QSqlIndex() - - def insert(self, invalidate = TRUE): - return FALSE - - def update(self, invalidate = TRUE): - return FALSE - - def delRecords(self, invalidate = TRUE): - return FALSE - - def setName(self, name, autopopulate = TRUE): - return - - -class MainWindow(SqlEx): - def __init__(self,parent = None,name = None,fl = 0): - SqlEx.__init__(self,parent,name,fl) - self.conDiag = ConnectDialog(self, "Connection Dialog", TRUE) - self.firstconn = TRUE - - def dbConnect(self): - if self.firstconn: - self.firstconn = FALSE - self.conDiag.editUsername.setText(DB_USERNAME) - self.conDiag.editPassword.setText(DB_PASSWORD) - self.conDiag.editHostname.setText(DB_HOSTNAMES[0]) - self.conDiag.editDatabase.setText(DB_DATABASES[0]) - for i in range(self.conDiag.comboDriver.count()): - if str(self.conDiag.comboDriver.text(i)) == DB_DRIVER: - self.conDiag.comboDriver.setCurrentItem(i) - break - if self.conDiag.exec_loop() != QDialog.Accepted: - return - if self.dt.sqlCursor(): - self.dt.setSqlCursor() - - # close old connection (if any) - if QSqlDatabase.contains("SqlEx"): - oldDb = QSqlDatabase.database("SqlEx") - oldDb.close() - QSqlDatabase.removeDatabase("SqlEx") - - # open the new connection - db = QSqlDatabase.addDatabase(self.conDiag.comboDriver.currentText(), "SqlEx") - if not db: - QMessageBox.warning(self, "Error", "Could not open database") - return - - db.setHostName(self.conDiag.editHostname.text()) - db.setDatabaseName(self.conDiag.editDatabase.text()) - db.setPort(self.conDiag.portSpinBox.value()) - if not db.open(self.conDiag.editUsername.text(), - self.conDiag.editPassword.text()): - showError(db.lastError(), self) - return - - self.lbl.setText("Double-Click on a table-name to view the contents") - self.lv.clear() - - tables = db.tables() - for t in tables: - lvi = QListViewItem(self.lv, t) - fields = db.recordInfo(t) - for f in fields: - req = "?" - if f.isRequired() > 0: - req = "Yes" - elif f.isRequired() == 0: - req = "No" - fi = QListViewItem(lvi, f.name(), QVariant.typeToName(f.type()), req) - lvi.insertItem(fi) - self.lv.insertItem(lvi) - - self.submitBtn.setEnabled(TRUE) - - def execQuery(self): - cursor = CustomSqlCursor(self.te.text(), TRUE, - QSqlDatabase.database("SqlEx", TRUE)) - if cursor.isSelect(): - self.dt.setSqlCursor(cursor, TRUE, TRUE) - self.dt.refresh() - txt = QString("Query OK") - if cursor.size() >= 0: - txt.append(", returned rows: %s" % cursor.size()) - self.lbl.setText(txt) - else: - if not cursor.isActive(): - # an error occured - showError(cursor.lastError(), self) - else: - self.lbl.setText("Query OK, affected rows: %s" % - cursor.numRowsAffected()) - - def showTable(self, item): - i = item.parent() - if not i: - i = item - cursor = QSqlCursor(i.text(0), TRUE, QSqlDatabase.database("SqlEx", TRUE)) - self.dt.setSqlCursor(cursor, TRUE, TRUE) - self.dt.setSort(cursor.primaryIndex()) - self.dt.refresh(QDataTable.RefreshAll) - self.lbl.setText("Displaying table %s" % i.text(0)) - - -if __name__ == "__main__": - a = QApplication(sys.argv) - QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()")) - w = MainWindow() - a.setMainWidget(w) - w.show() - a.exec_loop() - diff --git a/python/pyqt/examples3/SQL/sqlcustom1.py b/python/pyqt/examples3/SQL/sqlcustom1.py deleted file mode 100755 index 46ca5801..00000000 --- a/python/pyqt/examples3/SQL/sqlcustom1.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python - -#**************************************************************************** -#** $Id$ -#** -#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved. -#** -#** This file is part of an example program for PyQt. This example -#** program may be used, distributed and modified without limitation. -#** -#*****************************************************************************/ - -import sys -from qt import * -from qtsql import * - -from dbconnect import createConnection - -TRUE = 1 -FALSE = 0 - -class CustomEdit(QLineEdit): - def __init__(self, parent = None, name = None): - QLineEdit.__init__(self, parent, name) - QObject.connect(self, SIGNAL("textChanged(const QString &)"), - self.changed) - - def changed(self, line): - self.setUpperLine(line) - - def setUpperLine(self, line): - self.upperLineText = line.upper() - self.setText(self.upperLineText) - - -class FormDialog(QDialog): - def __init__(self): - QDialog.__init__(self) - forenameLabel = QLabel("Forename:", self) - forenameEdit = CustomEdit(self) - surnameLabel = QLabel("Surname:", self) - surnameEdit = CustomEdit(self) - salaryLabel = QLabel("Salary:", self) - salaryEdit = QLineEdit(self) - salaryEdit.setAlignment(Qt.AlignRight) - saveButton = QPushButton("&Save", self) - self.connect(saveButton, SIGNAL("clicked()"), self.save) - - grid = QGridLayout(self) - 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() - - self.staffCursor = QSqlCursor("staff") - self.staffCursor.setTrimmed("forename", TRUE) - self.staffCursor.setTrimmed("surname", TRUE) - self.idIndex = self.staffCursor.index("id") - self.staffCursor.select(self.idIndex) - self.staffCursor.first() - - self.propMap = QSqlPropertyMap() - self.propMap.insert(forenameEdit.className(), "upperLine") - - self.sqlForm = QSqlForm() - self.sqlForm.setRecord(self.staffCursor.primeUpdate()) - self.sqlForm.installPropertyMap(self.propMap) - self.sqlForm.insert(forenameEdit, "forename") - self.sqlForm.insert(surnameEdit, "surname") - self.sqlForm.insert(salaryEdit, "salary") - self.sqlForm.readFields() - - def save(self): - self.sqlForm.writeFields() - self.staffCursor.update() - self.staffCursor.select(self.idIndex) - self.staffCursor.first() - - -if __name__=='__main__': - app = QApplication( sys.argv ) - - if createConnection(): - formDialog = FormDialog() - formDialog.show() - - app.setMainWidget(formDialog) - app.exec_loop() - - diff --git a/python/pyqt/examples3/SQL/sqlex.ui b/python/pyqt/examples3/SQL/sqlex.ui deleted file mode 100644 index 022fed93..00000000 --- a/python/pyqt/examples3/SQL/sqlex.ui +++ /dev/null @@ -1,303 +0,0 @@ -<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> -<class>SqlEx</class> -<widget class="QWidget"> - <property name="name"> - <cstring>SqlEx</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>669</width> - <height>438</height> - </rect> - </property> - <property name="caption"> - <string>SQL Browser</string> - </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="1" column="0"> - <property name="name"> - <cstring>Layout23</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>lbl</cstring> - </property> - <property name="text"> - <string>Press "Connect" to open a database</string> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>conBtn</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>80</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>&Connect...</string> - </property> - </widget> - </hbox> - </widget> - <widget class="QSplitter" row="0" column="0"> - <property name="name"> - <cstring>vsplit</cstring> - </property> - <property name="orientation"> - <enum>Vertical</enum> - </property> - <widget class="QSplitter"> - <property name="name"> - <cstring>hsplit</cstring> - </property> - <property name="orientation"> - <enum>Horizontal</enum> - </property> - <widget class="QListView"> - <column> - <property name="text"> - <string>Tables</string> - </property> - <property name="clickable"> - <bool>true</bool> - </property> - <property name="resizeable"> - <bool>true</bool> - </property> - </column> - <column> - <property name="text"> - <string>Type</string> - </property> - <property name="clickable"> - <bool>true</bool> - </property> - <property name="resizeable"> - <bool>true</bool> - </property> - </column> - <column> - <property name="text"> - <string>Required</string> - </property> - <property name="clickable"> - <bool>true</bool> - </property> - <property name="resizeable"> - <bool>true</bool> - </property> - </column> - <property name="name"> - <cstring>lv</cstring> - </property> - <property name="margin"> - <number>0</number> - </property> - <property name="allColumnsShowFocus"> - <bool>true</bool> - </property> - <property name="rootIsDecorated"> - <bool>true</bool> - </property> - <property name="resizeMode"> - <enum>LastColumn</enum> - </property> - </widget> - <widget class="QDataTable"> - <property name="name"> - <cstring>dt</cstring> - </property> - <property name="frameworkCode" stdset="0"> - <bool>false</bool> - </property> - </widget> - </widget> - <widget class="QGroupBox"> - <property name="name"> - <cstring>gb</cstring> - </property> - <property name="title"> - <string>SQL Query</string> - </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>Layout22</cstring> - </property> - <vbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <property name="margin"> - <number>0</number> - </property> - <property name="spacing"> - <number>6</number> - </property> - <widget class="QTextEdit"> - <property name="name"> - <cstring>te</cstring> - </property> - </widget> - <widget class="QLayoutWidget"> - <property name="name"> - <cstring>Layout21</cstring> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <property name="margin"> - <number>0</number> - </property> - <property name="spacing"> - <number>6</number> - </property> - <spacer> - <property name="name"> - <cstring>Spacer3</cstring> - </property> - <property name="orientation"> - <enum>Horizontal</enum> - </property> - <property name="sizeType"> - <enum>Expanding</enum> - </property> - </spacer> - <widget class="QPushButton"> - <property name="name"> - <cstring>submitBtn</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>80</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>&Submit</string> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>clearBtn</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>80</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>C&lear</string> - </property> - </widget> - </hbox> - </widget> - </vbox> - </widget> - </grid> - </widget> - </widget> - </grid> -</widget> -<connections> - <connection> - <sender>clearBtn</sender> - <signal>clicked()</signal> - <receiver>te</receiver> - <slot>clear()</slot> - </connection> - <connection> - <sender>conBtn</sender> - <signal>clicked()</signal> - <receiver>SqlEx</receiver> - <slot>dbConnect()</slot> - </connection> - <connection> - <sender>lv</sender> - <signal>returnPressed(QListViewItem*)</signal> - <receiver>SqlEx</receiver> - <slot>showTable(QListViewItem*)</slot> - </connection> - <connection> - <sender>lv</sender> - <signal>doubleClicked(QListViewItem*)</signal> - <receiver>SqlEx</receiver> - <slot>showTable(QListViewItem*)</slot> - </connection> - <connection> - <sender>submitBtn</sender> - <signal>clicked()</signal> - <receiver>SqlEx</receiver> - <slot>execQuery()</slot> - </connection> -</connections> -<includes> - <include location="local" impldecl="in implementation">sqlex.ui.h</include> -</includes> -<slots> - <slot>init()</slot> - <slot>dbConnect()</slot> - <slot>showTable( QListViewItem * )</slot> - <slot>execQuery()</slot> -</slots> -<layoutdefaults spacing="6" margin="11"/> -</UI> diff --git a/python/pyqt/examples3/SQL/sqlex.ui.h b/python/pyqt/examples3/SQL/sqlex.ui.h deleted file mode 100644 index f1acd9ec..00000000 --- a/python/pyqt/examples3/SQL/sqlex.ui.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** If you wish to add, delete or rename slots use Qt Designer which will -** update this file, preserving your code. Create an init() slot in place of -** a constructor, and a destroy() slot in place of a destructor. -*****************************************************************************/ - - -void SqlEx::init() -{ -self.hsplit.setSizes([250]) -self.hsplit.setResizeMode(self.lv, TQSplitter.KeepSize) -self.vsplit.setResizeMode(self.gb, TQSplitter.KeepSize) -self.submitBtn.setEnabled(0) -} - - -void SqlEx::dbConnect() -{ - -} - - -void SqlEx::showTable( TQListViewItem * ) -{ - -} - - - -void SqlEx::execQuery() -{ - -} diff --git a/python/pyqt/examples3/SQL/sqlsubclass5.py b/python/pyqt/examples3/SQL/sqlsubclass5.py deleted file mode 100755 index a130e78a..00000000 --- a/python/pyqt/examples3/SQL/sqlsubclass5.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env python - -#**************************************************************************** -#** $Id$ -#** -#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved. -#** -#** This file is part of an example program for PyQt. This example -#** program may be used, distributed and modified without limitation. -#** -#*****************************************************************************/ - -import sys -from qt import * -from qtsql import * - -from dbconnect import createConnection - -TRUE = 1 -FALSE = 0 - -class CustomTable(QDataTable): - def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None): - QDataTable.__init__(self, cursor, autoPopulate, parent, name) - - def paintField(self, p, field, cr, b): - if not field: - return - fn = str(field.name()) - if fn == "pricesid": - query = QSqlQuery("SELECT name FROM prices WHERE id=%s" % - field.value().toString()) - value = "" - if query.next(): - value = query.value(0).toString() - p.drawText(2, 2, cr.width()-4, cr.height()-4, - self.fieldAlignment(field), value) - elif fn == "quantity": - p.drawText(2, 2, cr.width()-6, cr.height()-4, - Qt.AlignRight|Qt.AlignVCenter, field.value().toString()) - elif fn in ("price", "cost"): - v = field.value().toDouble() - if v < 0: - p.setPen(QColor("red")) - value = QString(u"%.2f \u20ac" % v) - p.drawText(2, 2, cr.width()-6, cr.height()-4, - Qt.AlignRight|Qt.AlignVCenter, value) - elif fn == "paiddate": - if field.value().toDate().isNull(): - v = QString("not yet") - p.setPen(QColor("red")) - else: - v = field.value().toDate().toString(Qt.LocalDate) - p.drawText(2, 2, cr.width()-4, cr.height()-4, - Qt.AlignHCenter|Qt.AlignVCenter, v) - else: - QDataTable.paintField(self, p, field, cr, b) - - -class InvoiceItemCursor(QSqlCursor): - def __init__(self): - QSqlCursor.__init__(self, "invoiceitem") - - productPrice = QSqlFieldInfo("price", QVariant.Double) - self.append(productPrice) - self.setCalculated(productPrice.name(), TRUE) - - productCost = QSqlFieldInfo("cost", QVariant.Double) - self.append(productCost) - self.setCalculated(productCost.name(), TRUE) - - def calculateField(self, name): - fn = str(name) - if fn == "productname": - query = QSqlQuery("SELECT name FROM prices WHERE id=%d;" % - (self.field("pricesid").value().toInt())) - if query.next(): - return query.value(0) - elif fn == "price": - query = QSqlQuery("SELECT price FROM prices WHERE id=%d;" % - (self.field("pricesid").value().toInt())) - if query.next(): - return query.value(0) - elif fn == "cost": - query = QSqlQuery("SELECT price FROM prices WHERE id=%d;" % - (self.field("pricesid").value().toInt())) - if query.next(): - return QVariant(query.value(0).toDouble() * - self.value("quantity").toDouble()) - return QVariant(QString.null) - - def primeInsert(self): - buffer = self.editBuffer() - buffer.setValue("id", QVariant(0)) - buffer.setValue("paiddate", QVariant(QDate.currentDate())) - buffer.setValue("quantity", QVariant(1)) - return buffer - - -class ProductPicker(QComboBox): - def __init__(self, parent = None, name = None): - QComboBox.__init__(self, parent, name) - cur = QSqlCursor("prices") - cur.select(cur.index("id")) - while cur.next(): - self.insertItem(cur.value("name").toString(), cur.value("id").toInt()) - - -class CustomSqlEditorFactory(QSqlEditorFactory): - def __init__(self): - QSqlEditorFactory.__init__(self) - - def createEditor(self, parent, field): - try: - if str(field.name()) == "pricesid": - return ProductPicker(parent) - except AttributeError: - pass - return QSqlEditorFactory.createEditor(self, parent, field) - -class Table(CustomTable): - def __init__(self): - self.invoiceItemCursor = InvoiceItemCursor() - QDataTable.__init__(self, self.invoiceItemCursor) - self.propMap = QSqlPropertyMap() - self.editorFactory = CustomSqlEditorFactory() - self.propMap.insert("ProductPicker", "pricesid") - self.installPropertyMap(self.propMap) - self.installEditorFactory(self.editorFactory) - - for cn, ch in (("pricesid", "Product"), - ("quantity", "Quantity"), - ("price", "Price" ), - ("cost", "Cost"), - ("paiddate", "Paid")): - self.addColumn(cn, ch) - self.setColumnWidth(0 , 150) - self.setColumnWidth(1, 70) - self.resize(600, 250) - self.refresh() - - -if __name__=='__main__': - app = QApplication(sys.argv) - if createConnection(): - t = Table() - app.setMainWidget(t) - t.show() - app.exec_loop() - - diff --git a/python/pyqt/examples3/SQL/sqltable4.py b/python/pyqt/examples3/SQL/sqltable4.py deleted file mode 100755 index 4fa6ed06..00000000 --- a/python/pyqt/examples3/SQL/sqltable4.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python - -#**************************************************************************** -#** $Id$ -#** -#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved. -#** -#** This file is part of an example program for PyQt. This example -#** program may be used, distributed and modified without limitation. -#** -#*****************************************************************************/ - -import sys -from qt import * -from qtsql import * - -from dbconnect import createConnection - -TRUE = 1 -FALSE = 0 - -class CustomTable(QDataTable): - def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None): - QDataTable.__init__(self, cursor, autoPopulate, parent, name) - - def paintField(self, p, field, cr, b): - if not field: - return - fn = str(field.name()) - if fn in ("salary", "monsalary"): - v = field.value().toDouble() - if v < 0: - p.setPen(QColor("red")) - value = QString(u"%.2f \u20ac" % v) - #print unicode(value).encode("iso-8859-15") - p.drawText(2, 2, cr.width()-6, cr.height()-4, - Qt.AlignRight|Qt.AlignVCenter, value) - elif fn == "statusid": - query = QSqlQuery("SELECT name FROM status WHERE id=%s" % - field.value().toString()) - value = "" - if query.next(): - value = query.value(0).toString() - p.drawText(2, 2, cr.width()-4, cr.height()-4, - self.fieldAlignment(field), value) - else: - QDataTable.paintField(self, p, field, cr, b) - - -class StatusPicker(QComboBox): - def __init__(self, parent = None, name = None): - QComboBox.__init__(self, parent, name) - cur = QSqlCursor("status") - cur.select(cur.index("id")) - while cur.next(): - self.insertItem(cur.value("name").toString(), cur.value("id").toInt()) - - -class CustomSqlEditorFactory(QSqlEditorFactory): - def __init__(self): - QSqlEditorFactory.__init__(self) - - def createEditor(self, parent, field): - try: - if str(field.name()) == "statusid": - return StatusPicker(parent) - except AttributeError: - pass - return QSqlEditorFactory.createEditor(self, parent, field) - - -class StaffCursor(QSqlCursor): - def __init__(self): - QSqlCursor.__init__(self, "staff") - monSalary = QSqlFieldInfo("monsalary", QVariant.Double) - self.append(monSalary) - self.setCalculated(monSalary.name(), TRUE) - - def calculateField(self, name): - if str(name) == "monsalary": - return QVariant(self.value("salary").toDouble() / 12) - return QVariant(QString.null) - - -class Table(CustomTable): - def __init__(self): - #self.staffCursor = QSqlCursor("staff") - self.staffCursor = StaffCursor() - QDataTable.__init__(self, self.staffCursor) - self.propMap = QSqlPropertyMap() - self.editorFactory = CustomSqlEditorFactory() - self.propMap.insert("StatusPicker", "statusid") - self.installPropertyMap(self.propMap) - self.installEditorFactory(self.editorFactory) - for cn, ch in (("forename", "Forename"), - ("surname", "Surname" ), - ("salary", "Annual Salary"), - ("monsalary","Monthly Salary"), - ("statusid", "Status")): - self.addColumn(cn, ch) - self.order = QStringList("surname") - self.order.append("forename") - self.setSort(self.order) - self.refresh() - - -if __name__=='__main__': - app = QApplication(sys.argv) - #app.setFont(QFont("Verdana", 11)) - - if createConnection(): - t = Table() - app.setMainWidget(t) - t.resize(600, 250) - t.show() - app.exec_loop() - - diff --git a/python/pyqt/examples3/SQL/testdb_mysql.sql b/python/pyqt/examples3/SQL/testdb_mysql.sql deleted file mode 100644 index 144d4c90..00000000 --- a/python/pyqt/examples3/SQL/testdb_mysql.sql +++ /dev/null @@ -1,57 +0,0 @@ -drop database testdb; -create database testdb; -use testdb; - -create table people (id integer primary key auto_increment, - name char(40)); - -create table staff (id integer primary key auto_increment, - forename char(40), - surname char(40), - salary float(10,2), - statusid integer); - -create table status (id integer primary key, - name char(30)); - -create table creditors (id integer primary key auto_increment, - forename char(40), - surname char(40), - city char(30)); - -create table prices (id integer primary key, - name char(40), - price float); - -create table invoiceitem (id integer primary key auto_increment, - pricesid integer, - quantity integer, - paiddate date); - -insert into staff (forename, surname, salary, statusid) values - ("Hugo", "Hurtig", 123450.50, 0), - ("Alfred E.", "Neumann", 56780.90, 1), - ("Agate", "Schnell-Fertig", 12340.56, 2), - ("Emil", "Dotterschreck", -5670.23, 3), - ("Eugen", "Nutzlos", -7833.56, 3), - ("Harald", "Schmidt", -150000.0, 3), - ("Urmel", "auf dem Eis", 7778.0, 2); - -insert into status (id, name) values - (0, 'Chief'), - (1, 'Programmer'), - (2, 'Secretary'), - (3, 'Driver'); - -insert into prices (id, name, price) values - (0, "Waschbecken", 150.25), - (1, "Wellensittich", 27.95), - (2, "Roter Papagei", 850.0), - (3, "Spam & Eggs", -7.50), - (4, "Renault Espace", 9000.0), - (5, "Tux, der Pinguin", 65.35), - (6, "Makroskop", 985000.0), - (7, "Regenbaum", 1235.65), - (8, "Bluterguß", 23.95), - (9, "Weltmeisterschaft", 2.95), - (10, "Premiere Dekoder", -185.75); diff --git a/python/pyqt/examples3/SQL/testdb_pg.sql b/python/pyqt/examples3/SQL/testdb_pg.sql deleted file mode 100644 index 73a42703..00000000 --- a/python/pyqt/examples3/SQL/testdb_pg.sql +++ /dev/null @@ -1,232 +0,0 @@ --- --- Selected TOC Entries: --- --- --- TOC Entry ID 1 (OID 0) --- --- Name: testdb Type: DATABASE Owner: postgres --- - -CREATE DATABASE "testdb"; - -\connect testdb postgres --- --- TOC Entry ID 16 (OID 17332) --- --- Name: people Type: TABLE Owner: postgres --- - -CREATE TABLE "people" ( - "id" integer DEFAULT nextval('people_id_seq'::text) NOT NULL, - "name" character(40), - Constraint "people_pkey" Primary Key ("id") -); - --- --- TOC Entry ID 17 (OID 17335) --- --- Name: staff Type: TABLE Owner: postgres --- - -CREATE TABLE "staff" ( - "id" integer DEFAULT nextval('staff_id_seq'::text) NOT NULL, - "forename" character(40), - "surname" character(40), - "salary" money, - "statusid" integer, - Constraint "staff_pkey" Primary Key ("id") -); - --- --- TOC Entry ID 18 (OID 17338) --- --- Name: status Type: TABLE Owner: postgres --- - -CREATE TABLE "status" ( - "id" integer NOT NULL, - "name" character(30), - Constraint "status_pkey" Primary Key ("id") -); - --- --- TOC Entry ID 19 (OID 17341) --- --- Name: creditors Type: TABLE Owner: postgres --- - -CREATE TABLE "creditors" ( - "id" integer DEFAULT nextval('creditors_id_seq'::text) NOT NULL, - "forename" character(40), - "surname" character(40), - "city" character(30), - Constraint "creditors_pkey" Primary Key ("id") -); - --- --- TOC Entry ID 20 (OID 17344) --- --- Name: prices Type: TABLE Owner: postgres --- - -CREATE TABLE "prices" ( - "id" integer NOT NULL, - "name" character(40), - "price" real, - Constraint "prices_pkey" Primary Key ("id") -); - --- --- TOC Entry ID 21 (OID 17347) --- --- Name: invoiceitem Type: TABLE Owner: postgres --- - -CREATE TABLE "invoiceitem" ( - "id" integer DEFAULT nextval('invoice_id_seq'::text) NOT NULL, - "pricesid" integer, - "quantity" integer, - "paiddate" date, - Constraint "invoiceitem_pkey" Primary Key ("id") -); - --- --- TOC Entry ID 2 (OID 17351) --- --- Name: people_id_seq Type: SEQUENCE Owner: postgres --- - -CREATE SEQUENCE "people_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1; - --- --- TOC Entry ID 4 (OID 17353) --- --- Name: staff_id_seq Type: SEQUENCE Owner: postgres --- - -CREATE SEQUENCE "staff_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1; - --- --- TOC Entry ID 6 (OID 17355) --- --- Name: creditors_id_seq Type: SEQUENCE Owner: postgres --- - -CREATE SEQUENCE "creditors_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1; - --- --- TOC Entry ID 8 (OID 17357) --- --- Name: invoice_id_seq Type: SEQUENCE Owner: postgres --- - -CREATE SEQUENCE "invoice_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1; - --- --- Data for TOC Entry ID 28 (OID 17332) --- --- Name: people Type: TABLE DATA Owner: postgres --- - - -COPY "people" FROM stdin; -\. --- --- Data for TOC Entry ID 29 (OID 17335) --- --- Name: staff Type: TABLE DATA Owner: postgres --- - - -COPY "staff" FROM stdin; -1 Hugo Hurtig $123,450.50 0 -2 Alfred E. Neumann $56,780.90 1 -3 Agate Schnell-Fertig $12,340.56 2 -6 Eugen Nutzlos -$7,833.56 3 -7 Harald Schmidt -$150,000.00 3 -4 Urmel auf dem Eis $7,778.00 2 -5 Emil Dotterschreck -$5,670.23 3 -\. --- --- Data for TOC Entry ID 30 (OID 17338) --- --- Name: status Type: TABLE DATA Owner: postgres --- - - -COPY "status" FROM stdin; -0 Chief -1 Programmer -2 Secretary -3 Driver -\. --- --- Data for TOC Entry ID 31 (OID 17341) --- --- Name: creditors Type: TABLE DATA Owner: postgres --- - - -COPY "creditors" FROM stdin; -\. --- --- Data for TOC Entry ID 32 (OID 17344) --- --- Name: prices Type: TABLE DATA Owner: postgres --- - - -COPY "prices" FROM stdin; -0 Waschbecken 150.25 -1 Wellensittich 27.95 -2 Roter Papagei 850 -3 Spam & Eggs -7.5 -4 Renault Espace 9000 -5 Tux, der Pinguin 65.35 -6 Makroskop 985000 -7 Regenbaum 1235.65 -8 Bluterguß 23.95 -9 Weltmeisterschaft 2.95 -10 Premiere Dekoder -185.75 -\. --- --- Data for TOC Entry ID 33 (OID 17347) --- --- Name: invoiceitem Type: TABLE DATA Owner: postgres --- - - -COPY "invoiceitem" FROM stdin; -\. --- --- TOC Entry ID 3 (OID 17351) --- --- Name: people_id_seq Type: SEQUENCE SET Owner: postgres --- - -SELECT setval ('"people_id_seq"', 1, false); - --- --- TOC Entry ID 5 (OID 17353) --- --- Name: staff_id_seq Type: SEQUENCE SET Owner: postgres --- - -SELECT setval ('"staff_id_seq"', 8, true); - --- --- TOC Entry ID 7 (OID 17355) --- --- Name: creditors_id_seq Type: SEQUENCE SET Owner: postgres --- - -SELECT setval ('"creditors_id_seq"', 1, false); - --- --- TOC Entry ID 9 (OID 17357) --- --- Name: invoice_id_seq Type: SEQUENCE SET Owner: postgres --- - -SELECT setval ('"invoice_id_seq"', 1, false); - |