diff options
Diffstat (limited to 'kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py')
-rw-r--r-- | kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py | 202 |
1 files changed, 101 insertions, 101 deletions
diff --git a/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py b/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py index e82414050..0b78bfa19 100644 --- a/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py +++ b/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py @@ -99,7 +99,7 @@ class CopyCenterPlugin: def tableNames(self): return self.kexidbconnection.tableNames() def hasTableName(self,tablename): return tablename in self.kexidbconnection.tableNames() def tableSchema(self,tablename): return self.kexidbconnection.tableSchema(tablename) - + def init(self,copierer): self.copierer = copierer if self.kexidbconnection == None: @@ -197,25 +197,25 @@ class CopyCenterPlugin: self.copycenter = copycenter def createWidget(self, dialog, plugin, parent): - """ Each plugin may provide a qt.QWidget back to the + """ Each plugin may provide a qt.TQWidget back to the CopyCenter.py. The widget will be used to configure our plugin settings. """ - import qt + from TQt import qt import os import re self.dialog = dialog self.mainbox = None - class ProjectBox(qt.QHBox): + class ProjectBox(qt.TQHBox): def __init__(self,main,copycenterplugin,plugin,parent): self.main = main self.copycenterplugin = copycenterplugin self.plugin = plugin - qt.QHBox.__init__(self,parent) - prjlabel = qt.QLabel("Project File:",self) - self.prjcombo = qt.QComboBox(self) + qt.TQHBox.__init__(self,parent) + prjlabel = qt.TQLabel("Project File:",self) + self.prjcombo = qt.TQComboBox(self) self.prjcombo.setEditable(True) self.prjcombo.insertItem("") @@ -224,11 +224,11 @@ class CopyCenterPlugin: file = os.path.join(path,f) if os.path.isfile(file) and re.search(".+\\.(kexi|kexis|kexic)$",f): self.prjcombo.insertItem(os.path.join("~",f)) - + prjlabel.setBuddy(self.prjcombo) - prjsavebtn = qt.QPushButton("...",self) - qt.QObject.connect(prjsavebtn, qt.SIGNAL("clicked()"),self.buttonClicked) - qt.QObject.connect(self.prjcombo, qt.SIGNAL("textChanged(const QString&)"), self.main.projectChanged) + 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) 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.QFileDialog.getOpenFileName(text,"*.kexi *.kexis *.kexic;;*",self.copycenterplugin.dialog) + filename = qt.TQFileDialog.getOpenFileName(text,"*.kexi *.kexis *.kexic;;*",self.copycenterplugin.dialog) else: # "Destination": - filename = qt.QFileDialog.getSaveFileName(text,"*.kexi *.kexis *.kexic;;*",self.copycenterplugin.dialog) + filename = qt.TQFileDialog.getSaveFileName(text,"*.kexi *.kexis *.kexic;;*",self.copycenterplugin.dialog) if str(filename) != "": self.prjcombo.setCurrentText(str(filename)) - class DriverBox(qt.QVBox): + class DriverBox(qt.TQVBox): def __init__(self,main,parent): - qt.QVBox.__init__(self,parent) + qt.TQVBox.__init__(self,parent) self.main = main self.copycenterplugin = main.copycenterplugin self.plugin = main.plugin self.driver = None - driverbox = qt.QHBox(self) - driverlabel = qt.QLabel("Driver:",driverbox) - self.drivercombo = qt.QComboBox(driverbox) + driverbox = qt.TQHBox(self) + driverlabel = qt.TQLabel("Driver:",driverbox) + self.drivercombo = qt.TQComboBox(driverbox) self.drivercombo.insertItem("") for driver in self.copycenterplugin.drivermanager.driverNames(): self.drivercombo.insertItem(driver) - qt.QObject.connect(self.drivercombo, qt.SIGNAL("activated(int)"), self.activated) + qt.TQObject.connect(self.drivercombo, qt.SIGNAL("activated(int)"), self.activated) driverlabel.setBuddy(self.drivercombo) driverbox.setStretchFactor(self.drivercombo,1) - - self.box = qt.QVBox(self) + + self.box = qt.TQVBox(self) self.mainbox = None def activated(self,index): @@ -281,58 +281,58 @@ class CopyCenterPlugin: self.driver = self.copycenterplugin.drivermanager.driver(drivertext) - mainbox = qt.QVBox(self.box) + mainbox = qt.TQVBox(self.box) mainbox.setSpacing(2) if self.driver.isFileDriver(): - filebox = qt.QHBox(mainbox) - filelabel = qt.QLabel("File:",filebox) - self.fileedit = qt.QLineEdit(self.plugin.options['file'],filebox) + filebox = qt.TQHBox(mainbox) + filelabel = qt.TQLabel("File:",filebox) + self.fileedit = qt.TQLineEdit(self.plugin.options['file'],filebox) filelabel.setBuddy(self.fileedit) filebox.setStretchFactor(self.fileedit,1) - filebtn = qt.QPushButton("...",filebox) - qt.QObject.connect(filebtn, qt.SIGNAL("clicked()"), self.fileClicked) + filebtn = qt.TQPushButton("...",filebox) + qt.TQObject.connect(filebtn, qt.SIGNAL("clicked()"), self.fileClicked) else: - hostbox = qt.QHBox(mainbox) - hostlabel = qt.QLabel("Hostname:",hostbox) - self.hostedit = qt.QLineEdit(self.plugin.options['hostname'],hostbox) + hostbox = qt.TQHBox(mainbox) + hostlabel = qt.TQLabel("Hostname:",hostbox) + self.hostedit = qt.TQLineEdit(self.plugin.options['hostname'],hostbox) hostlabel.setBuddy(self.hostedit) hostbox.setStretchFactor(self.hostedit,1) - portbox = qt.QHBox(mainbox) - portlabel = qt.QLabel("Port:",portbox) - self.portedit = qt.QLineEdit(self.plugin.options['port'],portbox) + portbox = qt.TQHBox(mainbox) + portlabel = qt.TQLabel("Port:",portbox) + self.portedit = qt.TQLineEdit(self.plugin.options['port'],portbox) portlabel.setBuddy(self.portedit) portbox.setStretchFactor(self.portedit,1) - sockbox = qt.QHBox(mainbox) - self.sockfilecheckbox = qt.QCheckBox("Socket File:",sockbox) - qt.QObject.connect(self.sockfilecheckbox, qt.SIGNAL("toggled(bool)"), self.sockfilecheckboxClicked) - self.sockfilebox = qt.QHBox(sockbox) - self.sockfileedit = qt.QLineEdit(self.plugin.options['socketfile'],self.sockfilebox) + 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) self.sockfilebox.setEnabled(False) - sockfilebtn = qt.QPushButton("...",self.sockfilebox) + sockfilebtn = qt.TQPushButton("...",self.sockfilebox) self.sockfilecheckbox.setChecked( str(self.plugin.options['usesocketfile']) == str(True) ) - qt.QObject.connect(sockfilebtn, qt.SIGNAL("clicked()"), self.sockfileClicked) + qt.TQObject.connect(sockfilebtn, qt.SIGNAL("clicked()"), self.sockfileClicked) self.sockfilebox.setStretchFactor(self.sockfileedit,1) sockbox.setStretchFactor(self.sockfilebox,1) - userbox = qt.QHBox(mainbox) - userlabel = qt.QLabel("Username:",userbox) - self.useredit = qt.QLineEdit(self.plugin.options['username'],userbox) + userbox = qt.TQHBox(mainbox) + userlabel = qt.TQLabel("Username:",userbox) + self.useredit = qt.TQLineEdit(self.plugin.options['username'],userbox) userlabel.setBuddy(self.useredit) userbox.setStretchFactor(self.useredit,1) - passbox = qt.QHBox(mainbox) - passlabel = qt.QLabel("Password:",passbox) - self.passedit = qt.QLineEdit(self.plugin.options['password'],passbox) - self.passedit.setEchoMode(qt.QLineEdit.Password) + passbox = qt.TQHBox(mainbox) + passlabel = qt.TQLabel("Password:",passbox) + self.passedit = qt.TQLineEdit(self.plugin.options['password'],passbox) + self.passedit.setEchoMode(qt.TQLineEdit.Password) passlabel.setBuddy(self.passedit) passbox.setStretchFactor(self.passedit,1) - dbbox = qt.QHBox(mainbox) - dblabel = qt.QLabel("Database:",dbbox) - self.dbedit = qt.QLineEdit(self.plugin.options['database'],dbbox) + dbbox = qt.TQHBox(mainbox) + dblabel = qt.TQLabel("Database:",dbbox) + self.dbedit = qt.TQLineEdit(self.plugin.options['database'],dbbox) dblabel.setBuddy(self.dbedit) dbbox.setStretchFactor(self.dbedit,1) #self.tablecombo.setText("") @@ -347,32 +347,32 @@ class CopyCenterPlugin: text = str(self.fileedit.text()) if text == "": text = self.copycenterplugin.copycenter.homepath if self.plugin.plugintype == "Source": - filename = qt.QFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) + filename = qt.TQFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) else: # "Destination": - filename = qt.QFileDialog.getSaveFileName(text,"*",self.copycenterplugin.dialog) + filename = qt.TQFileDialog.getSaveFileName(text,"*",self.copycenterplugin.dialog) if str(filename) != "": self.fileedit.setText(str(filename)) def sockfilecheckboxClicked(self,checked): self.sockfilebox.setEnabled(checked) - + def sockfileClicked(self): text = str(self.sockfileedit.text()) if text == "": text = self.copycenterplugin.copycenter.homepath if self.plugin.plugintype == "Source": - filename = qt.QFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) + filename = qt.TQFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) else: # "Destination": - filename = qt.QFileDialog.getSaveFileName(text,"*",self.copycenterplugin.dialog) + filename = qt.TQFileDialog.getSaveFileName(text,"*",self.copycenterplugin.dialog) if str(filename) != "": self.sockfileedit.setText(str(filename)) - class TableBox(qt.QHBox): + class TableBox(qt.TQHBox): def __init__(self,copycenterplugin,plugin,parent): - qt.QHBox.__init__(self,parent) + qt.TQHBox.__init__(self,parent) self.copycenterplugin = copycenterplugin self.plugin = plugin - tablelabel = qt.QLabel("Table:",self) - self.tableedit = qt.QLineEdit(self.plugin.options['table'],self) - self.tablebtn = qt.QPushButton("...",self) + tablelabel = qt.TQLabel("Table:",self) + self.tableedit = qt.TQLineEdit(self.plugin.options['table'],self) + self.tablebtn = qt.TQPushButton("...",self) self.tablebtn.setEnabled(False) - qt.QObject.connect(self.tablebtn, qt.SIGNAL("clicked()"), self.buttonClicked) + qt.TQObject.connect(self.tablebtn, qt.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.QListViewItem(self.listview,table) + item = qt.TQListViewItem(self.listview,table) else: - item = qt.QListViewItem(self.listview,item,table) + item = qt.TQListViewItem(self.listview,item,table) if table == text: self.listview.setSelected(item,True) self.listview.ensureItemVisible(item) - qt.QObject.connect(self.listview, qt.SIGNAL("doubleClicked(QListViewItem*, const QPoint&, int)"), self.okClicked) - qt.QObject.connect(self.okbtn, qt.SIGNAL("clicked()"), self.okClicked) + qt.TQObject.connect(self.listview, qt.SIGNAL("doubleClicked(QListViewItem*, const QPoint&, int)"), self.okClicked) + qt.TQObject.connect(self.okbtn, qt.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.QHBox): + class FieldBox(qt.TQHBox): def __init__(self,copycenterplugin,plugin,parent): - qt.QHBox.__init__(self,parent) + qt.TQHBox.__init__(self,parent) self.copycenterplugin = copycenterplugin self.plugin = plugin self.tablename = "" - fieldslabel = qt.QLabel("Fields:",self) - self.fieldsedit = qt.QLineEdit(self.plugin.options['fields'],self) + fieldslabel = qt.TQLabel("Fields:",self) + self.fieldsedit = qt.TQLineEdit(self.plugin.options['fields'],self) self.setStretchFactor(self.fieldsedit,1) fieldslabel.setBuddy(self.fieldsedit) - self.fieldsbtn = qt.QPushButton("...",self) + self.fieldsbtn = qt.TQPushButton("...",self) self.fieldsbtn.setEnabled(False) - qt.QObject.connect(self.fieldsbtn, qt.SIGNAL("clicked()"), self.fieldsClicked) + qt.TQObject.connect(self.fieldsbtn, qt.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.QListView.Multi) + self.listview.setSelectionMode(qt.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.QObject.connect(self.okbtn, qt.SIGNAL("clicked()"), self.okClicked) + qt.TQObject.connect(self.okbtn, qt.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.QHBox): + class MainBox(qt.TQHBox): def __init__(self,copycenterplugin,plugin,parent): - qt.QHBox.__init__(self,parent) + qt.TQHBox.__init__(self,parent) self.copycenterplugin = copycenterplugin self.plugin = plugin self.prjbox = ProjectBox(self,copycenterplugin,plugin,parent) self.driverbox = DriverBox(self,parent) - statusbar = qt.QHBox(parent) + statusbar = qt.TQHBox(parent) statusbar.setSpacing(2) - #self.statuslabel = qt.QLabel("Disconnected",statusbar) + #self.statuslabel = qt.TQLabel("Disconnected",statusbar) #statusbar.setStretchFactor(self.statuslabel,1) - statusbar.setStretchFactor(qt.QWidget(statusbar),1) - self.connectbtn = qt.QPushButton("Connect",statusbar) + statusbar.setStretchFactor(qt.TQWidget(statusbar),1) + self.connectbtn = qt.TQPushButton("Connect",statusbar) self.connectbtn.setEnabled(False) - qt.QObject.connect(self.connectbtn, qt.SIGNAL("clicked()"),self.connectClicked) - self.disconnectbtn = qt.QPushButton("Disconnect",statusbar) + qt.TQObject.connect(self.connectbtn, qt.SIGNAL("clicked()"),self.connectClicked) + self.disconnectbtn = qt.TQPushButton("Disconnect",statusbar) self.disconnectbtn.setEnabled(False) - qt.QObject.connect(self.disconnectbtn, qt.SIGNAL("clicked()"),self.disconnectClicked) + qt.TQObject.connect(self.disconnectbtn, qt.SIGNAL("clicked()"),self.disconnectClicked) #self.connectionbox = ConnectionBox(copycenterplugin,plugin,parent) self.tablebox = TableBox(copycenterplugin,plugin,parent) self.fieldbox = FieldBox(copycenterplugin,plugin,parent) - qt.QObject.connect(self.tablebox.tableedit, qt.SIGNAL("textChanged(const QString&)"), self.fieldbox.tableChanged) + qt.TQObject.connect(self.tablebox.tableedit, qt.SIGNAL("textChanged(const QString&)"), 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.Qt.ExactMatch).text()) + item = str(self.driverbox.drivercombo.listBox().findItem(self.plugin.options['driver'],qt.TQt.ExactMatch).text()) self.driverbox.drivercombo.setCurrentText(item) self.driverbox.activated(item) except: pass if self.plugin.plugintype == "Destination": - #typebox = qt.QHBox(parent) - #label = qt.QLabel("Operation:",typebox) - #combobox = qt.QComboBox(typebox) + #typebox = qt.TQHBox(parent) + #label = qt.TQLabel("Operation:",typebox) + #combobox = qt.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.QHBox(parent) - wherelabel = qt.QLabel("Where:",wherebox) - self.whereedit = qt.QLineEdit(self.plugin.options['where'],wherebox) + wherebox = qt.TQHBox(parent) + wherelabel = qt.TQLabel("Where:",wherebox) + self.whereedit = qt.TQLineEdit(self.plugin.options['where'],wherebox) - #orderbox = qt.QHBox(parent) - #orderlabel = qt.QLabel("Order By:",orderbox) - #orderedit = qt.QLineEdit("",orderbox) + #orderbox = qt.TQHBox(parent) + #orderlabel = qt.TQLabel("Order By:",orderbox) + #orderedit = qt.TQLineEdit("",orderbox) - #errbox = qt.QHBox(parent) - #errlabel = qt.QLabel("On Error:",errbox) - #errcombo = qt.QComboBox(errbox) + #errbox = qt.TQHBox(parent) + #errlabel = qt.TQLabel("On Error:",errbox) + #errcombo = qt.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.QMessageBox.critical(self,"Failed to connect","There exists no such database file \"%s\"" % file) + qt.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.QMessageBox.critical(self,"Failed to connect",connection.lastError()) + qt.TQMessageBox.critical(self,"Failed to connect",connection.lastError()) return False print "Use database \"%s\"" % connectiondata.databaseName() if not connection.useDatabase( connectiondata.databaseName() ): - qt.QMessageBox.critical(self,"Failed to connect",connection.lastError()) + qt.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.QMessageBox.critical(self,"Failed to disconnect",self.plugin.connection.lastError()) + qt.TQMessageBox.critical(self,"Failed to disconnect",self.plugin.connection.lastError()) return self.updateConnectButtons() @@ -639,7 +639,7 @@ class CopyCenterPlugin: except: pass return "" - + mainbox = MainBox(self,plugin,parent) plugin.widget = mainbox return mainbox |