diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-29 01:11:08 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-29 01:11:08 -0600 |
commit | 8a055d66f43592c257cece2eb8cc021808062917 (patch) | |
tree | d0922f201bd5d24b62a33160d1d9baf9e89f9a70 /examples3/SQL/sqlsubclass5.py | |
parent | b388516ca2691303a076a0764fd40bf7116fe43d (diff) | |
download | pytqt-8a055d66f43592c257cece2eb8cc021808062917.tar.gz pytqt-8a055d66f43592c257cece2eb8cc021808062917.zip |
Initial TQt conversion
Diffstat (limited to 'examples3/SQL/sqlsubclass5.py')
-rwxr-xr-x | examples3/SQL/sqlsubclass5.py | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/examples3/SQL/sqlsubclass5.py b/examples3/SQL/sqlsubclass5.py index 137ff93..07cc90a 100755 --- a/examples3/SQL/sqlsubclass5.py +++ b/examples3/SQL/sqlsubclass5.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,16 +19,16 @@ 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: return fn = str(field.name()) if fn == "pricesid": - query = QSqlQuery("SELECT name FROM prices WHERE id=%s" % + query = TQSqlQuery("SELECT name FROM prices WHERE id=%s" % field.value().toString()) value = "" if query.next(): @@ -37,78 +37,78 @@ class CustomTable(QDataTable): self.fieldAlignment(field), value) elif fn == "quantity": p.drawText(2, 2, cr.width()-6, cr.height()-4, - Qt.AlignRight|Qt.AlignVCenter, field.value().toString()) + TQt.AlignRight|TQt.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.setPen(TQColor("red")) + value = TQString(u"%.2f \u20ac" % v) p.drawText(2, 2, cr.width()-6, cr.height()-4, - Qt.AlignRight|Qt.AlignVCenter, value) + TQt.AlignRight|TQt.AlignVCenter, value) elif fn == "paiddate": if field.value().toDate().isNull(): - v = QString("not yet") - p.setPen(QColor("red")) + v = TQString("not yet") + p.setPen(TQColor("red")) else: - v = field.value().toDate().toString(Qt.LocalDate) + v = field.value().toDate().toString(TQt.LocalDate) p.drawText(2, 2, cr.width()-4, cr.height()-4, - Qt.AlignHCenter|Qt.AlignVCenter, v) + TQt.AlignHCenter|TQt.AlignVCenter, v) else: - QDataTable.paintField(self, p, field, cr, b) + TQDataTable.paintField(self, p, field, cr, b) -class InvoiceItemCursor(QSqlCursor): +class InvoiceItemCursor(TQSqlCursor): def __init__(self): - QSqlCursor.__init__(self, "invoiceitem") + TQSqlCursor.__init__(self, "invoiceitem") - productPrice = QSqlFieldInfo("price", QVariant.Double) + productPrice = TQSqlFieldInfo("price", TQVariant.Double) self.append(productPrice) self.setCalculated(productPrice.name(), TRUE) - productCost = QSqlFieldInfo("cost", QVariant.Double) + productCost = TQSqlFieldInfo("cost", TQVariant.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;" % + query = TQSqlQuery("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;" % + query = TQSqlQuery("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;" % + query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" % (self.field("pricesid").value().toInt())) if query.next(): - return QVariant(query.value(0).toDouble() * + return TQVariant(query.value(0).toDouble() * self.value("quantity").toDouble()) - return QVariant(QString.null) + return TQVariant(TQString.null) def primeInsert(self): buffer = self.editBuffer() - buffer.setValue("id", QVariant(0)) - buffer.setValue("paiddate", QVariant(QDate.currentDate())) - buffer.setValue("quantity", QVariant(1)) + buffer.setValue("id", TQVariant(0)) + buffer.setValue("paiddate", TQVariant(TQDate.currentDate())) + buffer.setValue("quantity", TQVariant(1)) return buffer -class ProductPicker(QComboBox): +class ProductPicker(TQComboBox): def __init__(self, parent = None, name = None): - QComboBox.__init__(self, parent, name) - cur = QSqlCursor("prices") + TQComboBox.__init__(self, parent, name) + cur = TQSqlCursor("prices") 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: @@ -116,13 +116,13 @@ class CustomSqlEditorFactory(QSqlEditorFactory): return ProductPicker(parent) except AttributeError: pass - return QSqlEditorFactory.createEditor(self, parent, field) + return TQSqlEditorFactory.createEditor(self, parent, field) class Table(CustomTable): def __init__(self): self.invoiceItemCursor = InvoiceItemCursor() - QDataTable.__init__(self, self.invoiceItemCursor) - self.propMap = QSqlPropertyMap() + TQDataTable.__init__(self, self.invoiceItemCursor) + self.propMap = TQSqlPropertyMap() self.editorFactory = CustomSqlEditorFactory() self.propMap.insert("ProductPicker", "pricesid") self.installPropertyMap(self.propMap) @@ -141,7 +141,7 @@ class Table(CustomTable): if __name__=='__main__': - app = QApplication(sys.argv) + app = TQApplication(sys.argv) if createConnection(): t = Table() app.setMainWidget(t) |