diff options
Diffstat (limited to 'kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py')
-rw-r--r-- | kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py b/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py index 20b812123..ca6a3f6ba 100644 --- a/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py +++ b/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py @@ -197,25 +197,25 @@ class CopyCenterPlugin: self.copycenter = copycenter def createWidget(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 import re self.dialog = dialog self.mainbox = None - class ProjectBox(qt.TQHBox): + class ProjectBox(tqt.TQHBox): def __init__(self,main,copycenterplugin,plugin,parent): self.main = main self.copycenterplugin = copycenterplugin self.plugin = plugin - qt.TQHBox.__init__(self,parent) - prjlabel = qt.TQLabel("Project File:",self) - self.prjcombo = qt.TQComboBox(self) + tqt.TQHBox.__init__(self,parent) + prjlabel = tqt.TQLabel("Project File:",self) + self.prjcombo = tqt.TQComboBox(self) self.prjcombo.setEditable(True) self.prjcombo.insertItem("") @@ -226,9 +226,9 @@ class CopyCenterPlugin: self.prjcombo.insertItem(os.path.join("~",f)) prjlabel.setBuddy(self.prjcombo) - prjsavebtn = qt.TQPushButton("...",self) - qt.TQObject.connect(prjsavebtn, qt.SIGNAL("clicked()"),self.buttonClicked) - qt.TQObject.connect(self.prjcombo, qt.SIGNAL("textChanged(const QString&)"), self.main.projectChanged) + prjsavebtn = tqt.TQPushButton("...",self) + tqt.TQObject.connect(prjsavebtn, tqt.SIGNAL("clicked()"),self.buttonClicked) + tqt.TQObject.connect(self.prjcombo, tqt.SIGNAL("textChanged(const TQString&)"), self.main.projectChanged) self.setStretchFactor(self.prjcombo,1) def buttonClicked(self): text = str(self.prjcombo.currentText()) @@ -238,31 +238,31 @@ class CopyCenterPlugin: import os text = os.path.join(self.copycenterplugin.copycenter.homepath,text[2:]) if self.plugin.plugintype == "Source": - filename = qt.TQFileDialog.getOpenFileName(text,"*.kexi *.kexis *.kexic;;*",self.copycenterplugin.dialog) + filename = tqt.TQFileDialog.getOpenFileName(text,"*.kexi *.kexis *.kexic;;*",self.copycenterplugin.dialog) else: # "Destination": - filename = qt.TQFileDialog.getSaveFileName(text,"*.kexi *.kexis *.kexic;;*",self.copycenterplugin.dialog) + filename = tqt.TQFileDialog.getSaveFileName(text,"*.kexi *.kexis *.kexic;;*",self.copycenterplugin.dialog) if str(filename) != "": self.prjcombo.setCurrentText(str(filename)) - class DriverBox(qt.TQVBox): + class DriverBox(tqt.TQVBox): def __init__(self,main,parent): - qt.TQVBox.__init__(self,parent) + tqt.TQVBox.__init__(self,parent) self.main = main self.copycenterplugin = main.copycenterplugin self.plugin = main.plugin self.driver = None - driverbox = qt.TQHBox(self) - driverlabel = qt.TQLabel("Driver:",driverbox) - self.drivercombo = qt.TQComboBox(driverbox) + driverbox = tqt.TQHBox(self) + driverlabel = tqt.TQLabel("Driver:",driverbox) + self.drivercombo = tqt.TQComboBox(driverbox) self.drivercombo.insertItem("") for driver in self.copycenterplugin.drivermanager.driverNames(): self.drivercombo.insertItem(driver) - qt.TQObject.connect(self.drivercombo, qt.SIGNAL("activated(int)"), self.activated) + tqt.TQObject.connect(self.drivercombo, tqt.SIGNAL("activated(int)"), self.activated) driverlabel.setBuddy(self.drivercombo) driverbox.setStretchFactor(self.drivercombo,1) - self.box = qt.TQVBox(self) + self.box = tqt.TQVBox(self) self.mainbox = None def activated(self,index): @@ -281,58 +281,58 @@ class CopyCenterPlugin: self.driver = self.copycenterplugin.drivermanager.driver(drivertext) - mainbox = qt.TQVBox(self.box) + mainbox = tqt.TQVBox(self.box) mainbox.setSpacing(2) if self.driver.isFileDriver(): - filebox = qt.TQHBox(mainbox) - filelabel = qt.TQLabel("File:",filebox) - self.fileedit = qt.TQLineEdit(self.plugin.options['file'],filebox) + filebox = tqt.TQHBox(mainbox) + filelabel = tqt.TQLabel("File:",filebox) + self.fileedit = tqt.TQLineEdit(self.plugin.options['file'],filebox) filelabel.setBuddy(self.fileedit) filebox.setStretchFactor(self.fileedit,1) - filebtn = qt.TQPushButton("...",filebox) - qt.TQObject.connect(filebtn, qt.SIGNAL("clicked()"), self.fileClicked) + filebtn = tqt.TQPushButton("...",filebox) + tqt.TQObject.connect(filebtn, tqt.SIGNAL("clicked()"), self.fileClicked) else: - hostbox = qt.TQHBox(mainbox) - hostlabel = qt.TQLabel("Hostname:",hostbox) - self.hostedit = qt.TQLineEdit(self.plugin.options['hostname'],hostbox) + hostbox = tqt.TQHBox(mainbox) + 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(mainbox) - portlabel = qt.TQLabel("Port:",portbox) - self.portedit = qt.TQLineEdit(self.plugin.options['port'],portbox) + portbox = tqt.TQHBox(mainbox) + portlabel = tqt.TQLabel("Port:",portbox) + self.portedit = tqt.TQLineEdit(self.plugin.options['port'],portbox) portlabel.setBuddy(self.portedit) portbox.setStretchFactor(self.portedit,1) - sockbox = qt.TQHBox(mainbox) - self.sockfilecheckbox = qt.TQCheckBox("Socket File:",sockbox) - qt.TQObject.connect(self.sockfilecheckbox, qt.SIGNAL("toggled(bool)"), self.sockfilecheckboxClicked) - self.sockfilebox = qt.TQHBox(sockbox) - self.sockfileedit = qt.TQLineEdit(self.plugin.options['socketfile'],self.sockfilebox) + sockbox = tqt.TQHBox(mainbox) + self.sockfilecheckbox = tqt.TQCheckBox("Socket File:",sockbox) + tqt.TQObject.connect(self.sockfilecheckbox, tqt.SIGNAL("toggled(bool)"), self.sockfilecheckboxClicked) + self.sockfilebox = tqt.TQHBox(sockbox) + self.sockfileedit = tqt.TQLineEdit(self.plugin.options['socketfile'],self.sockfilebox) self.sockfilebox.setEnabled(False) - sockfilebtn = qt.TQPushButton("...",self.sockfilebox) + sockfilebtn = tqt.TQPushButton("...",self.sockfilebox) self.sockfilecheckbox.setChecked( str(self.plugin.options['usesocketfile']) == str(True) ) - qt.TQObject.connect(sockfilebtn, qt.SIGNAL("clicked()"), self.sockfileClicked) + tqt.TQObject.connect(sockfilebtn, tqt.SIGNAL("clicked()"), self.sockfileClicked) self.sockfilebox.setStretchFactor(self.sockfileedit,1) sockbox.setStretchFactor(self.sockfilebox,1) - userbox = qt.TQHBox(mainbox) - userlabel = qt.TQLabel("Username:",userbox) - self.useredit = qt.TQLineEdit(self.plugin.options['username'],userbox) + userbox = tqt.TQHBox(mainbox) + 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(mainbox) - passlabel = qt.TQLabel("Password:",passbox) - self.passedit = qt.TQLineEdit(self.plugin.options['password'],passbox) - self.passedit.setEchoMode(qt.TQLineEdit.Password) + passbox = tqt.TQHBox(mainbox) + 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(mainbox) - dblabel = qt.TQLabel("Database:",dbbox) - self.dbedit = qt.TQLineEdit(self.plugin.options['database'],dbbox) + dbbox = tqt.TQHBox(mainbox) + dblabel = tqt.TQLabel("Database:",dbbox) + self.dbedit = tqt.TQLineEdit(self.plugin.options['database'],dbbox) dblabel.setBuddy(self.dbedit) dbbox.setStretchFactor(self.dbedit,1) #self.tablecombo.setText("") @@ -347,9 +347,9 @@ class CopyCenterPlugin: text = str(self.fileedit.text()) if text == "": text = self.copycenterplugin.copycenter.homepath if self.plugin.plugintype == "Source": - filename = qt.TQFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) + filename = tqt.TQFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) else: # "Destination": - filename = qt.TQFileDialog.getSaveFileName(text,"*",self.copycenterplugin.dialog) + filename = tqt.TQFileDialog.getSaveFileName(text,"*",self.copycenterplugin.dialog) if str(filename) != "": self.fileedit.setText(str(filename)) def sockfilecheckboxClicked(self,checked): self.sockfilebox.setEnabled(checked) @@ -358,21 +358,21 @@ class CopyCenterPlugin: text = str(self.sockfileedit.text()) if text == "": text = self.copycenterplugin.copycenter.homepath if self.plugin.plugintype == "Source": - filename = qt.TQFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) + filename = tqt.TQFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) else: # "Destination": - filename = qt.TQFileDialog.getSaveFileName(text,"*",self.copycenterplugin.dialog) + filename = tqt.TQFileDialog.getSaveFileName(text,"*",self.copycenterplugin.dialog) if str(filename) != "": self.sockfileedit.setText(str(filename)) - class TableBox(qt.TQHBox): + class TableBox(tqt.TQHBox): def __init__(self,copycenterplugin,plugin,parent): - qt.TQHBox.__init__(self,parent) + tqt.TQHBox.__init__(self,parent) self.copycenterplugin = copycenterplugin self.plugin = plugin - tablelabel = qt.TQLabel("Table:",self) - self.tableedit = qt.TQLineEdit(self.plugin.options['table'],self) - self.tablebtn = qt.TQPushButton("...",self) + tablelabel = tqt.TQLabel("Table:",self) + self.tableedit = tqt.TQLineEdit(self.plugin.options['table'],self) + self.tablebtn = tqt.TQPushButton("...",self) self.tablebtn.setEnabled(False) - qt.TQObject.connect(self.tablebtn, qt.SIGNAL("clicked()"), self.buttonClicked) + tqt.TQObject.connect(self.tablebtn, tqt.SIGNAL("clicked()"), self.buttonClicked) tablelabel.setBuddy(self.tableedit) self.setStretchFactor(self.tableedit,1) def buttonClicked(self): @@ -386,14 +386,14 @@ class CopyCenterPlugin: item = None for table in self.mainwidget.plugin.connection.tableNames(): 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: @@ -404,26 +404,26 @@ class CopyCenterPlugin: dialog = TableDialog(self) dialog.show() - class FieldBox(qt.TQHBox): + class FieldBox(tqt.TQHBox): def __init__(self,copycenterplugin,plugin,parent): - qt.TQHBox.__init__(self,parent) + tqt.TQHBox.__init__(self,parent) self.copycenterplugin = copycenterplugin self.plugin = plugin self.tablename = "" - fieldslabel = qt.TQLabel("Fields:",self) - self.fieldsedit = qt.TQLineEdit(self.plugin.options['fields'],self) + fieldslabel = tqt.TQLabel("Fields:",self) + self.fieldsedit = tqt.TQLineEdit(self.plugin.options['fields'],self) self.setStretchFactor(self.fieldsedit,1) fieldslabel.setBuddy(self.fieldsedit) - self.fieldsbtn = qt.TQPushButton("...",self) + self.fieldsbtn = tqt.TQPushButton("...",self) self.fieldsbtn.setEnabled(False) - qt.TQObject.connect(self.fieldsbtn, qt.SIGNAL("clicked()"), self.fieldsClicked) + tqt.TQObject.connect(self.fieldsbtn, tqt.SIGNAL("clicked()"), self.fieldsClicked) def fieldsClicked(self): ListViewDialog = self.copycenterplugin.dialog.ListViewDialog class FieldsDialog(ListViewDialog): def __init__(self, fieldbox): ListViewDialog.__init__(self,fieldbox,"Fields") self.fieldbox = fieldbox - 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") @@ -441,7 +441,7 @@ class CopyCenterPlugin: item = self.addItem(( field.name(),field.type(),",".join(opts) ),item) if allfields or field.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() @@ -461,47 +461,47 @@ class CopyCenterPlugin: return self.fieldsbtn.setEnabled(False) - class MainBox(qt.TQHBox): + class MainBox(tqt.TQHBox): def __init__(self,copycenterplugin,plugin,parent): - qt.TQHBox.__init__(self,parent) + tqt.TQHBox.__init__(self,parent) self.copycenterplugin = copycenterplugin self.plugin = plugin self.prjbox = ProjectBox(self,copycenterplugin,plugin,parent) self.driverbox = DriverBox(self,parent) - statusbar = qt.TQHBox(parent) + statusbar = tqt.TQHBox(parent) statusbar.setSpacing(2) - #self.statuslabel = qt.TQLabel("Disconnected",statusbar) + #self.statuslabel = tqt.TQLabel("Disconnected",statusbar) #statusbar.setStretchFactor(self.statuslabel,1) - statusbar.setStretchFactor(qt.TQWidget(statusbar),1) - self.connectbtn = qt.TQPushButton("Connect",statusbar) + statusbar.setStretchFactor(tqt.TQWidget(statusbar),1) + self.connectbtn = tqt.TQPushButton("Connect",statusbar) self.connectbtn.setEnabled(False) - qt.TQObject.connect(self.connectbtn, qt.SIGNAL("clicked()"),self.connectClicked) - self.disconnectbtn = qt.TQPushButton("Disconnect",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) #self.connectionbox = ConnectionBox(copycenterplugin,plugin,parent) self.tablebox = TableBox(copycenterplugin,plugin,parent) self.fieldbox = FieldBox(copycenterplugin,plugin,parent) - qt.TQObject.connect(self.tablebox.tableedit, qt.SIGNAL("textChanged(const QString&)"), self.fieldbox.tableChanged) + tqt.TQObject.connect(self.tablebox.tableedit, tqt.SIGNAL("textChanged(const TQString&)"), self.fieldbox.tableChanged) if self.plugin.options['project'] != '': self.prjbox.prjcombo.setCurrentText(self.plugin.options['project']) if self.plugin.options['driver'] != '': try: - item = str(self.driverbox.drivercombo.listBox().findItem(self.plugin.options['driver'],qt.TQt.ExactMatch).text()) + item = str(self.driverbox.drivercombo.listBox().findItem(self.plugin.options['driver'],tqt.TQt.ExactMatch).text()) self.driverbox.drivercombo.setCurrentText(item) self.driverbox.activated(item) except: pass if self.plugin.plugintype == "Destination": - #typebox = qt.TQHBox(parent) - #label = qt.TQLabel("Operation:",typebox) - #combobox = qt.TQComboBox(typebox) + #typebox = tqt.TQHBox(parent) + #label = tqt.TQLabel("Operation:",typebox) + #combobox = tqt.TQComboBox(typebox) #combobox.insertItem("Append") #combobox.insertItem("Replace") #combobox.insertItem("Update") @@ -511,17 +511,17 @@ class CopyCenterPlugin: #typebox.setStretchFactor(combobox,1) pass elif self.plugin.plugintype == "Source": - wherebox = qt.TQHBox(parent) - wherelabel = qt.TQLabel("Where:",wherebox) - self.whereedit = qt.TQLineEdit(self.plugin.options['where'],wherebox) + wherebox = tqt.TQHBox(parent) + wherelabel = tqt.TQLabel("Where:",wherebox) + self.whereedit = tqt.TQLineEdit(self.plugin.options['where'],wherebox) - #orderbox = qt.TQHBox(parent) - #orderlabel = qt.TQLabel("Order By:",orderbox) - #orderedit = qt.TQLineEdit("",orderbox) + #orderbox = tqt.TQHBox(parent) + #orderlabel = tqt.TQLabel("Order By:",orderbox) + #orderedit = tqt.TQLineEdit("",orderbox) - #errbox = qt.TQHBox(parent) - #errlabel = qt.TQLabel("On Error:",errbox) - #errcombo = qt.TQComboBox(errbox) + #errbox = tqt.TQHBox(parent) + #errlabel = tqt.TQLabel("On Error:",errbox) + #errcombo = tqt.TQComboBox(errbox) #errcombo.insertItem("Ask") #errcombo.insertItem("Skip") #errcombo.insertItem("Abort") @@ -576,7 +576,7 @@ class CopyCenterPlugin: if self.driverbox.driver.isFileDriver(): file = str(self.driverbox.fileedit.text()) if file == "" or not os.path.isfile(file): - qt.TQMessageBox.critical(self,"Failed to connect","There exists no such database file \"%s\"" % file) + tqt.TQMessageBox.critical(self,"Failed to connect","There exists no such database file \"%s\"" % file) return False connectiondata.setFileName(file) connectiondata.setDatabaseName(file) @@ -592,11 +592,11 @@ class CopyCenterPlugin: connection = self.driverbox.driver.createConnection(connectiondata) print("Trying to connect") if not connection.connect(): - qt.TQMessageBox.critical(self,"Failed to connect",connection.lastError()) + tqt.TQMessageBox.critical(self,"Failed to connect",connection.lastError()) return False print("Use database \"%s\"" % connectiondata.databaseName()) if not connection.useDatabase( connectiondata.databaseName() ): - qt.TQMessageBox.critical(self,"Failed to connect",connection.lastError()) + tqt.TQMessageBox.critical(self,"Failed to connect",connection.lastError()) return False print("dbnames = %s" % connection.databaseNames()) print("tablenames = %s" % connection.tableNames()) @@ -608,7 +608,7 @@ class CopyCenterPlugin: def disconnectClicked(self): if not self.plugin.connection.disconnect(): - qt.TQMessageBox.critical(self,"Failed to disconnect",self.plugin.connection.lastError()) + tqt.TQMessageBox.critical(self,"Failed to disconnect",self.plugin.connection.lastError()) return self.updateConnectButtons() |