diff options
Diffstat (limited to 'kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginQtSQL.py')
-rw-r--r-- | kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginQtSQL.py | 164 |
1 files changed, 82 insertions, 82 deletions
diff --git a/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginQtSQL.py b/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginQtSQL.py index 76e544a6..8f983eb5 100644 --- a/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginQtSQL.py +++ b/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginQtSQL.py @@ -47,7 +47,7 @@ class CopyCenterPlugin: def __init__(self,copycenterplugin): self._init_(copycenterplugin) self.options = { - 'driver': 'QMYSQL3', #'QMYSQL3','QPSQL7','QODBC3',... + 'driver': 'TQMYSQL3', #'TQMYSQL3','TQPSQL7','TQODBC3',... 'hostname': '127.0.0.1', 'port': 3306, 'username': 'root', #'MyUsername', @@ -61,9 +61,9 @@ class CopyCenterPlugin: self._init(copierer) tablename = str(self.widget.tableedit.text()) wherestatement = str(self.widget.whereedit.text()) - from TQt import qt - from TQt import qtsql - self.cursor = qtsql.TQSqlCursor(tablename,True,self.database) + from TQt import tqt + from TQt import tqtsql + self.cursor = tqtsql.TQSqlCursor(tablename,True,self.database) self.cursor.setFilter(wherestatement) if not self.cursor.select(): raise Exception("Select on cursor failed.<br>%s<br>%s" % ( str(self.cursor.lastError().driverText()),str(self.cursor.lastError().databaseText()) )) @@ -93,7 +93,7 @@ class CopyCenterPlugin: def __init__(self,copycenterplugin): self._init_(copycenterplugin) self.options = { - 'driver': 'QMYSQL3', #'QMYSQL3','QPSQL7','QODBC3',... + 'driver': 'TQMYSQL3', #'TQMYSQL3','TQPSQL7','TQODBC3',... 'hostname': '127.0.0.1', 'port': 3306, 'username': 'root', #'MyUsername', @@ -106,8 +106,8 @@ class CopyCenterPlugin: } def init(self,copierer): self._init(copierer) - from TQt import qt - from TQt import qtsql + from TQt import tqt + from TQt import tqtsql self.fieldlist = [] for fieldname in str(self.widget.fieldedit.text()).split(","): @@ -115,7 +115,7 @@ class CopyCenterPlugin: if fn != "": self.fieldlist.append(fn) tablename = str(self.widget.tableedit.text()) - self.cursor = qtsql.TQSqlCursor(tablename,True,self.database) + self.cursor = tqtsql.TQSqlCursor(tablename,True,self.database) { 0: self.initInsert, 1: self.initUpdate @@ -132,16 +132,16 @@ class CopyCenterPlugin: def writeInsert(self, record): print("insert record: %s" % record) - from TQt import qt + from TQt import tqt cursorrecord = self.cursor.primeInsert() count = len(record) for i in range(len(self.fieldlist)): if i == count: break r = record[i] if r == None: - v = qt.TQVariant() + v = tqt.TQVariant() else: - v = qt.TQVariant(r) + v = tqt.TQVariant(r) cursorrecord.setValue(self.fieldlist[i], v) rowcount = self.cursor.insert() if rowcount < 1: @@ -162,11 +162,11 @@ class CopyCenterPlugin: pkindex = self.cursor.index(self.indexfieldname) if not pkindex: raise Exception("Invalid index-field defined.") self.cursor.setPrimaryIndex(pkindex) - #self.cursor.setMode( qtsql.TQSqlCursor.Insert | qtsql.TQSqlCursor.Update ) + #self.cursor.setMode( tqtsql.TQSqlCursor.Insert | tqtsql.TQSqlCursor.Update ) self.copierer.appendProgressMessage("Update SQL: %s" % str(self.cursor.executedQuery())) def writeUpdate(self, record): - from TQt import qt + from TQt import tqt # determinate the primary-index try: idx = self.fieldlist.index(self.indexfieldname) @@ -192,9 +192,9 @@ class CopyCenterPlugin: if self.indexfieldname != fieldname: # don't update the indexfield! r = record[i] if r == None: - v = qt.TQVariant() + v = tqt.TQVariant() else: - v = qt.TQVariant(r) + v = tqt.TQVariant(r) cursorrecord.setValue(fieldname, v) # Write updated record. rowcount = self.cursor.update() @@ -210,11 +210,11 @@ class CopyCenterPlugin: pass def widget(self,dialog,plugin,parent): - """ Each plugin may provide a qt.TQWidget back to the + """ Each plugin may provide a tqt.TQWidget back to the CopyCenter.py. The widget will be used to configure our plugin settings. """ - from TQt import qt + from TQt import tqt import os self.dialog = dialog @@ -228,14 +228,14 @@ class CopyCenterPlugin: item = None for table in self.mainwidget.plugin.database.tables(): if item == None: - item = qt.TQListViewItem(self.listview,table) + item = tqt.TQListViewItem(self.listview,table) else: - item = qt.TQListViewItem(self.listview,item,table) + item = tqt.TQListViewItem(self.listview,item,table) if table == text: self.listview.setSelected(item,True) self.listview.ensureItemVisible(item) - qt.TQObject.connect(self.listview, qt.SIGNAL("doubleClicked(QListViewItem*, const QPoint&, int)"), self.okClicked) - qt.TQObject.connect(self.okbtn, qt.SIGNAL("clicked()"), self.okClicked) + tqt.TQObject.connect(self.listview, tqt.SIGNAL("doubleClicked(TQListViewItem*, const TQPoint&, int)"), self.okClicked) + tqt.TQObject.connect(self.okbtn, tqt.SIGNAL("clicked()"), self.okClicked) def okClicked(self): item = self.listview.selectedItem() if item == None: @@ -248,7 +248,7 @@ class CopyCenterPlugin: def __init__(self, mainwidget): ListViewDialog.__init__(self,parent,"Fields") self.mainwidget = mainwidget - self.listview.setSelectionMode(qt.TQListView.Multi) + self.listview.setSelectionMode(tqt.TQListView.Multi) self.listview.setSorting(-1) self.listview.header().setClickEnabled(False) self.listview.addColumn("Name") @@ -264,10 +264,10 @@ class CopyCenterPlugin: opts = "" for s in ('Required','Calculated'): #,'Generated'): if getattr(fieldinfo,"is%s" % s)(): opts += "%s " % s - item = self.addItem((fieldinfo.name(), qt.TQVariant.typeToName(fieldinfo.type()), opts),item) + item = self.addItem((fieldinfo.name(), tqt.TQVariant.typeToName(fieldinfo.type()), opts),item) if allfields or fieldinfo.name() in fieldslist: self.listview.setSelected(item,True) - qt.TQObject.connect(self.okbtn, qt.SIGNAL("clicked()"), self.okClicked) + tqt.TQObject.connect(self.okbtn, tqt.SIGNAL("clicked()"), self.okClicked) def okClicked(self): selitems = [] item = self.listview.firstChild() @@ -279,101 +279,101 @@ class CopyCenterPlugin: self.close() - class MainWidget(qt.TQHBox): + class MainWidget(tqt.TQHBox): def __init__(self,plugin,dialog,parent): - from TQt import qt - from TQt import qtsql - qt.TQHBox.__init__(self,parent) + from TQt import tqt + from TQt import tqtsql + tqt.TQHBox.__init__(self,parent) self.dialog = dialog self.plugin = plugin - self.connectionbox = qt.TQVBox(parent) + self.connectionbox = tqt.TQVBox(parent) self.connectionbox.setSpacing(2) - driverbox = qt.TQHBox(self.connectionbox) - driverlabel = qt.TQLabel("Driver:",driverbox) - self.driveredit = qt.TQComboBox(driverbox) - for driver in qtsql.TQSqlDatabase.drivers(): + driverbox = tqt.TQHBox(self.connectionbox) + driverlabel = tqt.TQLabel("Driver:",driverbox) + self.driveredit = tqt.TQComboBox(driverbox) + for driver in tqtsql.TQSqlDatabase.drivers(): self.driveredit.insertItem(driver) if self.plugin.options['driver'] == driver: self.driveredit.setCurrentItem(self.driveredit.count() - 1) driverlabel.setBuddy(self.driveredit) driverbox.setStretchFactor(self.driveredit,1) - hostbox = qt.TQHBox(self.connectionbox) - hostlabel = qt.TQLabel("Hostname:",hostbox) - self.hostedit = qt.TQLineEdit(self.plugin.options['hostname'],hostbox) + hostbox = tqt.TQHBox(self.connectionbox) + hostlabel = tqt.TQLabel("Hostname:",hostbox) + self.hostedit = tqt.TQLineEdit(self.plugin.options['hostname'],hostbox) hostlabel.setBuddy(self.hostedit) hostbox.setStretchFactor(self.hostedit,1) - portbox = qt.TQHBox(self.connectionbox) - portlabel = qt.TQLabel("Port:",portbox) - self.portedit = qt.TQLineEdit(str(self.plugin.options['port']),portbox) + portbox = tqt.TQHBox(self.connectionbox) + portlabel = tqt.TQLabel("Port:",portbox) + self.portedit = tqt.TQLineEdit(str(self.plugin.options['port']),portbox) portlabel.setBuddy(self.portedit) portbox.setStretchFactor(self.portedit,1) - userbox = qt.TQHBox(self.connectionbox) - userlabel = qt.TQLabel("Username:",userbox) - self.useredit = qt.TQLineEdit(self.plugin.options['username'],userbox) + userbox = tqt.TQHBox(self.connectionbox) + userlabel = tqt.TQLabel("Username:",userbox) + self.useredit = tqt.TQLineEdit(self.plugin.options['username'],userbox) userlabel.setBuddy(self.useredit) userbox.setStretchFactor(self.useredit,1) - passbox = qt.TQHBox(self.connectionbox) - passlabel = qt.TQLabel("Password:",passbox) - self.passedit = qt.TQLineEdit(self.plugin.options['password'],passbox) - self.passedit.setEchoMode(qt.TQLineEdit.Password) + passbox = tqt.TQHBox(self.connectionbox) + passlabel = tqt.TQLabel("Password:",passbox) + self.passedit = tqt.TQLineEdit(self.plugin.options['password'],passbox) + self.passedit.setEchoMode(tqt.TQLineEdit.Password) passlabel.setBuddy(self.passedit) passbox.setStretchFactor(self.passedit,1) - dbbox = qt.TQHBox(self.connectionbox) - dblabel = qt.TQLabel("Database:",dbbox) - self.dbedit = qt.TQLineEdit(self.plugin.options['database'],dbbox) + dbbox = tqt.TQHBox(self.connectionbox) + dblabel = tqt.TQLabel("Database:",dbbox) + self.dbedit = tqt.TQLineEdit(self.plugin.options['database'],dbbox) dblabel.setBuddy(self.dbedit) dbbox.setStretchFactor(self.dbedit,1) - statusbar = qt.TQHBox(parent) + statusbar = tqt.TQHBox(parent) statusbar.setSpacing(2) - statusbar.setStretchFactor(qt.TQWidget(statusbar),1) - self.connectbtn = qt.TQPushButton("Connect",statusbar) - qt.TQObject.connect(self.connectbtn, qt.SIGNAL("clicked()"),self.connectClicked) - self.disconnectbtn = qt.TQPushButton("Disconnect",statusbar) + statusbar.setStretchFactor(tqt.TQWidget(statusbar),1) + self.connectbtn = tqt.TQPushButton("Connect",statusbar) + tqt.TQObject.connect(self.connectbtn, tqt.SIGNAL("clicked()"),self.connectClicked) + self.disconnectbtn = tqt.TQPushButton("Disconnect",statusbar) self.disconnectbtn.setEnabled(False) - qt.TQObject.connect(self.disconnectbtn, qt.SIGNAL("clicked()"),self.disconnectClicked) + tqt.TQObject.connect(self.disconnectbtn, tqt.SIGNAL("clicked()"),self.disconnectClicked) - tablebox = qt.TQHBox(parent) - tablelabel = qt.TQLabel("Table:",tablebox) - self.tableedit = qt.TQLineEdit(self.plugin.options['table'],tablebox) - qt.TQObject.connect(self.tableedit, qt.SIGNAL("textChanged(const QString&)"), self.tableEditChanged) - self.tablebtn = qt.TQPushButton("...",tablebox) + tablebox = tqt.TQHBox(parent) + tablelabel = tqt.TQLabel("Table:",tablebox) + self.tableedit = tqt.TQLineEdit(self.plugin.options['table'],tablebox) + tqt.TQObject.connect(self.tableedit, tqt.SIGNAL("textChanged(const TQString&)"), self.tableEditChanged) + self.tablebtn = tqt.TQPushButton("...",tablebox) self.tablebtn.setEnabled(False) - qt.TQObject.connect(self.tablebtn, qt.SIGNAL("clicked()"), self.tableBtnClicked) + tqt.TQObject.connect(self.tablebtn, tqt.SIGNAL("clicked()"), self.tableBtnClicked) tablelabel.setBuddy(self.tableedit) tablebox.setStretchFactor(self.tableedit,1) - fieldbox = qt.TQHBox(parent) - fieldlabel = qt.TQLabel("Fields:",fieldbox) - self.fieldedit = qt.TQLineEdit(self.plugin.options['fields'],fieldbox) - self.fieldbtn = qt.TQPushButton("...",fieldbox) + fieldbox = tqt.TQHBox(parent) + fieldlabel = tqt.TQLabel("Fields:",fieldbox) + self.fieldedit = tqt.TQLineEdit(self.plugin.options['fields'],fieldbox) + self.fieldbtn = tqt.TQPushButton("...",fieldbox) self.fieldbtn.setEnabled(False) - qt.TQObject.connect(self.fieldbtn, qt.SIGNAL("clicked()"), self.fieldBtnClicked) + tqt.TQObject.connect(self.fieldbtn, tqt.SIGNAL("clicked()"), self.fieldBtnClicked) fieldlabel.setBuddy(self.fieldedit) fieldbox.setStretchFactor(self.fieldedit,1) if self.plugin.plugintype == "Source": - box = qt.TQHBox(parent) - wherelabel = qt.TQLabel("Where:",box) - self.whereedit = qt.TQLineEdit(self.plugin.options['where'],box) + box = tqt.TQHBox(parent) + wherelabel = tqt.TQLabel("Where:",box) + self.whereedit = tqt.TQLineEdit(self.plugin.options['where'],box) wherelabel.setBuddy(self.whereedit) box.setStretchFactor(self.whereedit,1) elif self.plugin.plugintype == "Destination": - class OperationBox(qt.TQVBox): + class OperationBox(tqt.TQVBox): def __init__(self, mainwidget, parent): self.mainwidget = mainwidget - qt.TQVBox.__init__(self, parent) - opbox = qt.TQHBox(self) - operationlabel = qt.TQLabel("Operation:",opbox) - self.mainwidget.operationedit = qt.TQComboBox(opbox) + tqt.TQVBox.__init__(self, parent) + opbox = tqt.TQHBox(self) + operationlabel = tqt.TQLabel("Operation:",opbox) + self.mainwidget.operationedit = tqt.TQComboBox(opbox) for op in ('Insert','Update'): self.mainwidget.operationedit.insertItem(op) if self.mainwidget.plugin.options['operation'] == op: @@ -381,7 +381,7 @@ class CopyCenterPlugin: operationlabel.setBuddy(self.mainwidget.operationedit) opbox.setStretchFactor(self.mainwidget.operationedit,1) self.box = None - qt.TQObject.connect(self.mainwidget.operationedit, qt.SIGNAL("activated(int)"), self.operationActivated) + tqt.TQObject.connect(self.mainwidget.operationedit, tqt.SIGNAL("activated(int)"), self.operationActivated) self.operationActivated() def operationActivated(self, **args): if self.box: @@ -391,9 +391,9 @@ class CopyCenterPlugin: def showInsert(self): pass def showUpdate(self): - self.box = qt.TQHBox(self) - indexlabel = qt.TQLabel("Indexfield:", self.box) - self.mainwidget.indexedit = qt.TQLineEdit(self.mainwidget.plugin.options['indexfield'], self.box) + self.box = tqt.TQHBox(self) + indexlabel = tqt.TQLabel("Indexfield:", self.box) + self.mainwidget.indexedit = tqt.TQLineEdit(self.mainwidget.plugin.options['indexfield'], self.box) indexlabel.setBuddy(self.mainwidget.indexedit) self.box.setStretchFactor(self.mainwidget.indexedit,1) { @@ -451,14 +451,14 @@ class CopyCenterPlugin: return True print("trying to connect...") - from TQt import qtsql + from TQt import tqtsql drivername = str(self.driveredit.currentText()) print("drivername: %s" % drivername) connectionname = "CopyCenter%s" % self.plugin.plugintype print("connectionname: %s" % connectionname) - self.plugin.database = qtsql.TQSqlDatabase.addDatabase(drivername,connectionname) + self.plugin.database = tqtsql.TQSqlDatabase.addDatabase(drivername,connectionname) if not self.plugin.database: - qt.TQMessageBox.critical(self,"Failed to connect","<qt>Failed to create database for driver \"%s\"</qt>" % drivername) + tqt.TQMessageBox.critical(self,"Failed to connect","<qt>Failed to create database for driver \"%s\"</qt>" % drivername) return False hostname = str(self.hostedit.text()) @@ -477,7 +477,7 @@ class CopyCenterPlugin: self.plugin.database.setDatabaseName(databasename) if not self.plugin.database.open(): - qt.TQMessageBox.critical(self,"Failed to connect","<qt>%s<br><br>%s</qt>" % (self.plugin.database.lastError().driverText(),self.plugin.database.lastError().databaseText())) + tqt.TQMessageBox.critical(self,"Failed to connect","<qt>%s<br><br>%s</qt>" % (self.plugin.database.lastError().driverText(),self.plugin.database.lastError().databaseText())) return False print("database is opened now!") self.updateConnectState() |