summaryrefslogtreecommitdiffstats
path: root/examples3/SQL/sqltable4.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples3/SQL/sqltable4.py')
-rwxr-xr-xexamples3/SQL/sqltable4.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/examples3/SQL/sqltable4.py b/examples3/SQL/sqltable4.py
index 8f488d3..001e897 100755
--- a/examples3/SQL/sqltable4.py
+++ b/examples3/SQL/sqltable4.py
@@ -5,7 +5,7 @@
#**
#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
#**
-#** This file is part of an example program for PyQt. This example
+#** This file is part of an example program for PyTQt. This example
#** program may be used, distributed and modified without limitation.
#**
#*****************************************************************************/
@@ -19,9 +19,9 @@ from dbconnect import createConnection
TRUE = 1
FALSE = 0
-class CustomTable(QDataTable):
+class CustomTable(TQDataTable):
def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None):
- QDataTable.__init__(self, cursor, autoPopulate, parent, name)
+ TQDataTable.__init__(self, cursor, autoPopulate, parent, name)
def paintField(self, p, field, cr, b):
if not field:
@@ -30,13 +30,13 @@ class CustomTable(QDataTable):
if fn in ("salary", "monsalary"):
v = field.value().toDouble()
if v < 0:
- p.setPen(QColor("red"))
- value = QString(u"%.2f \u20ac" % v)
+ p.setPen(TQColor("red"))
+ value = TQString(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)
+ TQt.AlignRight|TQt.AlignVCenter, value)
elif fn == "statusid":
- query = QSqlQuery("SELECT name FROM status WHERE id=%s" %
+ query = TQSqlQuery("SELECT name FROM status WHERE id=%s" %
field.value().toString())
value = ""
if query.next():
@@ -44,21 +44,21 @@ class CustomTable(QDataTable):
p.drawText(2, 2, cr.width()-4, cr.height()-4,
self.fieldAlignment(field), value)
else:
- QDataTable.paintField(self, p, field, cr, b)
+ TQDataTable.paintField(self, p, field, cr, b)
-class StatusPicker(QComboBox):
+class StatusPicker(TQComboBox):
def __init__(self, parent = None, name = None):
- QComboBox.__init__(self, parent, name)
- cur = QSqlCursor("status")
+ TQComboBox.__init__(self, parent, name)
+ cur = TQSqlCursor("status")
cur.select(cur.index("id"))
while cur.next():
self.insertItem(cur.value("name").toString(), cur.value("id").toInt())
-class CustomSqlEditorFactory(QSqlEditorFactory):
+class CustomSqlEditorFactory(TQSqlEditorFactory):
def __init__(self):
- QSqlEditorFactory.__init__(self)
+ TQSqlEditorFactory.__init__(self)
def createEditor(self, parent, field):
try:
@@ -66,28 +66,28 @@ class CustomSqlEditorFactory(QSqlEditorFactory):
return StatusPicker(parent)
except AttributeError:
pass
- return QSqlEditorFactory.createEditor(self, parent, field)
+ return TQSqlEditorFactory.createEditor(self, parent, field)
-class StaffCursor(QSqlCursor):
+class StaffCursor(TQSqlCursor):
def __init__(self):
- QSqlCursor.__init__(self, "staff")
- monSalary = QSqlFieldInfo("monsalary", QVariant.Double)
+ TQSqlCursor.__init__(self, "staff")
+ monSalary = TQSqlFieldInfo("monsalary", TQVariant.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)
+ return TQVariant(self.value("salary").toDouble() / 12)
+ return TQVariant(TQString.null)
class Table(CustomTable):
def __init__(self):
- #self.staffCursor = QSqlCursor("staff")
+ #self.staffCursor = TQSqlCursor("staff")
self.staffCursor = StaffCursor()
- QDataTable.__init__(self, self.staffCursor)
- self.propMap = QSqlPropertyMap()
+ TQDataTable.__init__(self, self.staffCursor)
+ self.propMap = TQSqlPropertyMap()
self.editorFactory = CustomSqlEditorFactory()
self.propMap.insert("StatusPicker", "statusid")
self.installPropertyMap(self.propMap)
@@ -98,15 +98,15 @@ class Table(CustomTable):
("monsalary","Monthly Salary"),
("statusid", "Status")):
self.addColumn(cn, ch)
- self.order = QStringList("surname")
+ self.order = TQStringList("surname")
self.order.append("forename")
self.setSort(self.order)
self.refresh()
if __name__=='__main__':
- app = QApplication(sys.argv)
- #app.setFont(QFont("Verdana", 11))
+ app = TQApplication(sys.argv)
+ #app.setFont(TQFont("Verdana", 11))
if createConnection():
t = Table()