summaryrefslogtreecommitdiffstats
path: root/examples3/SQL/runsqlex.py
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-29 01:11:08 -0600
committerTimothy Pearson <[email protected]>2011-11-29 01:11:08 -0600
commit8a055d66f43592c257cece2eb8cc021808062917 (patch)
treed0922f201bd5d24b62a33160d1d9baf9e89f9a70 /examples3/SQL/runsqlex.py
parentb388516ca2691303a076a0764fd40bf7116fe43d (diff)
downloadpytqt-8a055d66f43592c257cece2eb8cc021808062917.tar.gz
pytqt-8a055d66f43592c257cece2eb8cc021808062917.zip
Initial TQt conversion
Diffstat (limited to 'examples3/SQL/runsqlex.py')
-rwxr-xr-xexamples3/SQL/runsqlex.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/examples3/SQL/runsqlex.py b/examples3/SQL/runsqlex.py
index 7f2afa7..09f567d 100755
--- a/examples3/SQL/runsqlex.py
+++ b/examples3/SQL/runsqlex.py
@@ -13,30 +13,30 @@ TRUE = 1
FALSE = 0
def showError(err, parent):
- errStr = QString("The database reported an error:\n\n")
+ errStr = TQString("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)
+ TQMessageBox.warning(parent, "Error", errStr)
-class CustomSqlCursor(QSqlCursor):
+class CustomSqlCursor(TQSqlCursor):
def __init__(self, query = None, autopopulate = TRUE, db = None):
- QSqlCursor.__init__(self, None, autopopulate, db)
+ TQSqlCursor.__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)
+ self.setMode(TQSqlCursor.ReadOnly)
- def select(self, filter, sort = QSqlIndex()):
+ def select(self, filter, sort = TQSqlIndex()):
return self.execQuery(self.lastQuery())
def primaryIndex(self, prime = TRUE):
- return QSqlIndex()
+ return TQSqlIndex()
def insert(self, invalidate = TRUE):
return FALSE
@@ -68,21 +68,21 @@ class MainWindow(SqlEx):
if str(self.conDiag.comboDriver.text(i)) == DB_DRIVER:
self.conDiag.comboDriver.setCurrentItem(i)
break
- if self.conDiag.exec_loop() != QDialog.Accepted:
+ if self.conDiag.exec_loop() != TQDialog.Accepted:
return
if self.dt.sqlCursor():
self.dt.setSqlCursor()
# close old connection (if any)
- if QSqlDatabase.contains("SqlEx"):
- oldDb = QSqlDatabase.database("SqlEx")
+ if TQSqlDatabase.contains("SqlEx"):
+ oldDb = TQSqlDatabase.database("SqlEx")
oldDb.close()
- QSqlDatabase.removeDatabase("SqlEx")
+ TQSqlDatabase.removeDatabase("SqlEx")
# open the new connection
- db = QSqlDatabase.addDatabase(self.conDiag.comboDriver.currentText(), "SqlEx")
+ db = TQSqlDatabase.addDatabase(self.conDiag.comboDriver.currentText(), "SqlEx")
if not db:
- QMessageBox.warning(self, "Error", "Could not open database")
+ TQMessageBox.warning(self, "Error", "Could not open database")
return
db.setHostName(self.conDiag.editHostname.text())
@@ -98,15 +98,15 @@ class MainWindow(SqlEx):
tables = db.tables()
for t in tables:
- lvi = QListViewItem(self.lv, t)
+ lvi = TQListViewItem(self.lv, t)
fields = db.recordInfo(t)
for f in fields:
req = "?"
- if f.isRequired() > 0:
+ if f.isRetquired() > 0:
req = "Yes"
- elif f.isRequired() == 0:
+ elif f.isRetquired() == 0:
req = "No"
- fi = QListViewItem(lvi, f.name(), QVariant.typeToName(f.type()), req)
+ fi = TQListViewItem(lvi, f.name(), TQVariant.typeToName(f.type()), req)
lvi.insertItem(fi)
self.lv.insertItem(lvi)
@@ -114,11 +114,11 @@ class MainWindow(SqlEx):
def execQuery(self):
cursor = CustomSqlCursor(self.te.text(), TRUE,
- QSqlDatabase.database("SqlEx", TRUE))
+ TQSqlDatabase.database("SqlEx", TRUE))
if cursor.isSelect():
self.dt.setSqlCursor(cursor, TRUE, TRUE)
self.dt.refresh()
- txt = QString("Query OK")
+ txt = TQString("Query OK")
if cursor.size() >= 0:
txt.append(", returned rows: %s" % cursor.size())
self.lbl.setText(txt)
@@ -134,16 +134,16 @@ class MainWindow(SqlEx):
i = item.parent()
if not i:
i = item
- cursor = QSqlCursor(i.text(0), TRUE, QSqlDatabase.database("SqlEx", TRUE))
+ cursor = TQSqlCursor(i.text(0), TRUE, TQSqlDatabase.database("SqlEx", TRUE))
self.dt.setSqlCursor(cursor, TRUE, TRUE)
self.dt.setSort(cursor.primaryIndex())
- self.dt.refresh(QDataTable.RefreshAll)
+ self.dt.refresh(TQDataTable.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()"))
+ a = TQApplication(sys.argv)
+ TQObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
w = MainWindow()
a.setMainWidget(w)
w.show()