Update python scripts for PyTQt.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/29/head
Slávek Banko 3 years ago
parent 596d0f7b9e
commit 135d005014
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -83,38 +83,38 @@ class Copierer:
def writeFailed(self,record): pass def writeFailed(self,record): pass
def runGuiApp(copycenter, name): def runGuiApp(copycenter, name):
import qt from TQt import qt
import sys import sys
#-------------------------------------------------------------------- #--------------------------------------------------------------------
class ListViewDialog(qt.QDialog): class ListViewDialog(qt.TQDialog):
def __init__(self, parent, caption): def __init__(self, parent, caption):
qt.QDialog.__init__(self, parent, "ProgressDialog", 1) qt.TQDialog.__init__(self, parent, "ProgressDialog", 1)
self.parent = parent self.parent = parent
self.setCaption(caption) self.setCaption(caption)
layout = qt.QVBoxLayout(self) layout = qt.TQVBoxLayout(self)
box = qt.QVBox(self) box = qt.TQVBox(self)
box.setMargin(2) box.setMargin(2)
layout.addWidget(box) layout.addWidget(box)
self.listview = qt.QListView(box) self.listview = qt.TQListView(box)
self.listview.setAllColumnsShowFocus(True) self.listview.setAllColumnsShowFocus(True)
self.listview.header().setStretchEnabled(True,0) self.listview.header().setStretchEnabled(True,0)
btnbox = qt.QHBox(box) btnbox = qt.TQHBox(box)
btnbox.setMargin(6) btnbox.setMargin(6)
btnbox.setSpacing(6) btnbox.setSpacing(6)
self.okbtn = qt.QPushButton(btnbox) self.okbtn = qt.TQPushButton(btnbox)
self.okbtn.setText("Ok") self.okbtn.setText("Ok")
#qt.QObject.connect(okbtn, qt.SIGNAL("clicked()"), self.okClicked) #qt.TQObject.connect(okbtn, qt.SIGNAL("clicked()"), self.okClicked)
self.cancelbtn = qt.QPushButton(btnbox) self.cancelbtn = qt.TQPushButton(btnbox)
self.cancelbtn.setText("Cancel") self.cancelbtn.setText("Cancel")
qt.QObject.connect(self.cancelbtn, qt.SIGNAL("clicked()"), self.close) qt.TQObject.connect(self.cancelbtn, qt.SIGNAL("clicked()"), self.close)
box.setMinimumSize(qt.QSize(460,380)) box.setMinimumSize(qt.TQSize(460,380))
def addItem(self,valuelist,afteritem = None): def addItem(self,valuelist,afteritem = None):
if afteritem == None: if afteritem == None:
item = qt.QListViewItem(self.listview) item = qt.TQListViewItem(self.listview)
else: else:
item = qt.QListViewItem(self.listview,afteritem) item = qt.TQListViewItem(self.listview,afteritem)
i = 0 i = 0
for value in valuelist: for value in valuelist:
item.setText(i,value) item.setText(i,value)
@ -123,20 +123,20 @@ def runGuiApp(copycenter, name):
#-------------------------------------------------------------------- #--------------------------------------------------------------------
class CopyJobWidget(qt.QVBox): class CopyJobWidget(qt.TQVBox):
def __init__(self,dialog,parent): def __init__(self,dialog,parent):
self.dialog = dialog self.dialog = dialog
qt.QVBox.__init__(self,parent) qt.TQVBox.__init__(self,parent)
self.setSpacing(6) self.setSpacing(6)
typebox = qt.QHBox(self) typebox = qt.TQHBox(self)
typebox.setSpacing(6) typebox.setSpacing(6)
label = qt.QLabel("Job File:",typebox) label = qt.TQLabel("Job File:",typebox)
self.jobfilecombobox = qt.QComboBox(typebox) self.jobfilecombobox = qt.TQComboBox(typebox)
typebox.setStretchFactor(self.jobfilecombobox,1) typebox.setStretchFactor(self.jobfilecombobox,1)
self.jobfilecombobox.setEditable(True) self.jobfilecombobox.setEditable(True)
self.jobfilecombobox.insertItem("") self.jobfilecombobox.insertItem("")
label.setBuddy(self.jobfilecombobox) label.setBuddy(self.jobfilecombobox)
qt.QObject.connect(self.jobfilecombobox, qt.SIGNAL("textChanged(const QString&)"), self.jobfilecomboboxChanged) qt.TQObject.connect(self.jobfilecombobox, qt.SIGNAL("textChanged(const QString&)"), self.jobfilecomboboxChanged)
import os import os
import re import re
@ -145,22 +145,22 @@ def runGuiApp(copycenter, name):
if os.path.isfile(file) and re.search(".+\\.copycenterjob.xml$",f): if os.path.isfile(file) and re.search(".+\\.copycenterjob.xml$",f):
self.jobfilecombobox.insertItem(file) self.jobfilecombobox.insertItem(file)
loadbtn = qt.QPushButton(typebox) loadbtn = qt.TQPushButton(typebox)
loadbtn.setText("Open...") loadbtn.setText("Open...")
qt.QObject.connect(loadbtn, qt.SIGNAL("clicked()"), self.openClicked) qt.TQObject.connect(loadbtn, qt.SIGNAL("clicked()"), self.openClicked)
savebtn = qt.QPushButton(typebox) savebtn = qt.TQPushButton(typebox)
savebtn.setText("Save...") savebtn.setText("Save...")
qt.QObject.connect(savebtn, qt.SIGNAL("clicked()"), self.saveClicked) qt.TQObject.connect(savebtn, qt.SIGNAL("clicked()"), self.saveClicked)
self.listview = qt.QListView(self) self.listview = qt.TQListView(self)
self.listview.setAllColumnsShowFocus(True) self.listview.setAllColumnsShowFocus(True)
self.listview.setSorting(-1) self.listview.setSorting(-1)
self.listview.setDefaultRenameAction(qt.QListView.Reject) self.listview.setDefaultRenameAction(qt.TQListView.Reject)
self.listview.header().setClickEnabled(False) self.listview.header().setClickEnabled(False)
self.listview.addColumn("Name") self.listview.addColumn("Name")
self.listview.addColumn("Value") self.listview.addColumn("Value")
qt.QObject.connect(self.listview, qt.SIGNAL("doubleClicked(QListViewItem*, const QPoint&, int)"), self.doubleClicked) qt.TQObject.connect(self.listview, qt.SIGNAL("doubleClicked(QListViewItem*, const QPoint&, int)"), self.doubleClicked)
#qt.QObject.connect(self.listview, qt.SIGNAL("itemRenamed(QListViewItem*, int, const QString&)"), self.itemRenamed) #qt.TQObject.connect(self.listview, qt.SIGNAL("itemRenamed(QListViewItem*, int, const QString&)"), self.itemRenamed)
def doubleClicked(self, **args): def doubleClicked(self, **args):
print "CopyJobWidget.doubleClicked" print "CopyJobWidget.doubleClicked"
@ -190,12 +190,12 @@ def runGuiApp(copycenter, name):
raise "The XML-file \"%s\" does not contain a valid copy-job." % filename raise "The XML-file \"%s\" does not contain a valid copy-job." % filename
sourcepluginname = str(sourcenode.getAttribute('plugin')) sourcepluginname = str(sourcenode.getAttribute('plugin'))
if not self.dialog.sourcedata.combobox.listBox().findItem(sourcepluginname,qt.Qt.ExactMatch): if not self.dialog.sourcedata.combobox.listBox().findItem(sourcepluginname,qt.TQt.ExactMatch):
raise "There exists no plugin with the name \"%s\"." % sourcepluginname raise "There exists no plugin with the name \"%s\"." % sourcepluginname
self.dialog.sourcedata.combobox.setCurrentText(sourcepluginname) self.dialog.sourcedata.combobox.setCurrentText(sourcepluginname)
destinationpluginname = str(destinationnode.getAttribute('plugin')) destinationpluginname = str(destinationnode.getAttribute('plugin'))
if not self.dialog.destinationdata.combobox.listBox().findItem(destinationpluginname,qt.Qt.ExactMatch): if not self.dialog.destinationdata.combobox.listBox().findItem(destinationpluginname,qt.TQt.ExactMatch):
raise "There exists no plugin with the name \"%s\"." % destinationpluginname raise "There exists no plugin with the name \"%s\"." % destinationpluginname
self.dialog.destinationdata.combobox.setCurrentText(destinationpluginname) self.dialog.destinationdata.combobox.setCurrentText(destinationpluginname)
@ -206,7 +206,7 @@ def runGuiApp(copycenter, name):
def openClicked(self): def openClicked(self):
text = str(self.jobfilecombobox.currentText()) text = str(self.jobfilecombobox.currentText())
if text == "": text = self.dialog.copycenter.homepath if text == "": text = self.dialog.copycenter.homepath
filename = str(qt.QFileDialog.getOpenFileName(text,"*.copycenterjob.xml;;*",self.dialog)) filename = str(qt.TQFileDialog.getOpenFileName(text,"*.copycenterjob.xml;;*",self.dialog))
if filename != "": self.jobfilecombobox.setCurrentText(filename) if filename != "": self.jobfilecombobox.setCurrentText(filename)
def escape(self,s): def escape(self,s):
@ -225,7 +225,7 @@ def runGuiApp(copycenter, name):
if text == "": if text == "":
import os import os
text = os.path.join(self.dialog.copycenter.homepath,"default.copycenterjob.xml") text = os.path.join(self.dialog.copycenter.homepath,"default.copycenterjob.xml")
filename = str(qt.QFileDialog.getSaveFileName(text,"*.copycenterjob.xml;;*",self.dialog)) filename = str(qt.TQFileDialog.getSaveFileName(text,"*.copycenterjob.xml;;*",self.dialog))
if str(filename) == "": return if str(filename) == "": return
f = open(filename, "w") f = open(filename, "w")
f.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") f.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
@ -240,40 +240,40 @@ def runGuiApp(copycenter, name):
def addItem(self, pluginimpl, afteritem = None, parentitem = None): def addItem(self, pluginimpl, afteritem = None, parentitem = None):
#print "CopyJobWidget.addItem" #print "CopyJobWidget.addItem"
class ListViewItem(qt.QListViewItem): class ListViewItem(qt.TQListViewItem):
def __init__(self, pluginimpl, listview, parentitem = None, afteritem = None): def __init__(self, pluginimpl, listview, parentitem = None, afteritem = None):
self.pluginimpl = pluginimpl self.pluginimpl = pluginimpl
if parentitem == None: if parentitem == None:
qt.QListViewItem.__init__(self,listview) qt.TQListViewItem.__init__(self,listview)
self.setOpen(True) self.setOpen(True)
else: else:
if afteritem == None: if afteritem == None:
qt.QListViewItem.__init__(self,parentitem) qt.TQListViewItem.__init__(self,parentitem)
else: else:
qt.QListViewItem.__init__(self,parentitem,afteritem) qt.TQListViewItem.__init__(self,parentitem,afteritem)
self.setRenameEnabled(1,True) self.setRenameEnabled(1,True)
def startRename(self, columnindex): def startRename(self, columnindex):
qt.QListViewItem.startRename(self,columnindex) qt.TQListViewItem.startRename(self,columnindex)
#lineedit = self.listView().viewport().child("qt_renamebox") #lineedit = self.listView().viewport().child("qt_renamebox")
#if lineedit: #if lineedit:
# regexp = qt.QRegExp("^[_A-Z]+[_A-Z0-9]*$", False) # regexp = qt.TQRegExp("^[_A-Z]+[_A-Z0-9]*$", False)
# v = qt.QRegExpValidator(regexp, self.listView()); # v = qt.TQRegExpValidator(regexp, self.listView());
# lineedit.setValidator(v) # lineedit.setValidator(v)
def okRename(self, columnindex): def okRename(self, columnindex):
if columnindex == 1: if columnindex == 1:
n = str(self.text(0)) n = str(self.text(0))
if not self.pluginimpl.options.has_key(n): if not self.pluginimpl.options.has_key(n):
raise "No such option \"%s\"" % n raise "No such option \"%s\"" % n
qt.QListViewItem.okRename(self,columnindex) qt.TQListViewItem.okRename(self,columnindex)
v = str(qt.QListViewItem.text(self,1)) v = str(qt.TQListViewItem.text(self,1))
print "Option \"%s\" has value \"%s\" now." % (n,v) print "Option \"%s\" has value \"%s\" now." % (n,v)
self.pluginimpl.options[n] = v self.pluginimpl.options[n] = v
def text(self, columnindex): def text(self, columnindex):
if columnindex == 1: if columnindex == 1:
if qt.QListViewItem.text(self,0).contains("password"): if qt.TQListViewItem.text(self,0).contains("password"):
return "*" * len(str(qt.QListViewItem.text(self,1))) return "*" * len(str(qt.TQListViewItem.text(self,1)))
return qt.QListViewItem.text(self,columnindex) return qt.TQListViewItem.text(self,columnindex)
return ListViewItem(pluginimpl, self.listview, parentitem, afteritem) return ListViewItem(pluginimpl, self.listview, parentitem, afteritem)
def updateItem(self,pluginname,pluginimpl): def updateItem(self,pluginname,pluginimpl):
@ -303,47 +303,47 @@ def runGuiApp(copycenter, name):
#-------------------------------------------------------------------- #--------------------------------------------------------------------
class ProgressDialog(qt.QDialog): class ProgressDialog(qt.TQDialog):
def __init__(self, dialog): def __init__(self, dialog):
self.dialog = dialog self.dialog = dialog
self.starttime = None self.starttime = None
qt.QDialog.__init__(self, dialog, "ProgressDialog", 1) qt.TQDialog.__init__(self, dialog, "ProgressDialog", 1)
self.setCaption("Copying...") self.setCaption("Copying...")
layout = qt.QVBoxLayout(self) layout = qt.TQVBoxLayout(self)
box = qt.QVBox(self) box = qt.TQVBox(self)
box.setSpacing(6) box.setSpacing(6)
box.setMargin(6) box.setMargin(6)
layout.addWidget(box) layout.addWidget(box)
self.textbrowser = qt.QTextBrowser(box) self.textbrowser = qt.TQTextBrowser(box)
self.textbrowser.setWordWrap(qt.QTextEdit.WidgetWidth) self.textbrowser.setWordWrap(qt.TQTextEdit.WidgetWidth)
self.textbrowser.setTextFormat(qt.Qt.RichText) self.textbrowser.setTextFormat(qt.TQt.RichText)
statusbox = qt.QFrame(box) statusbox = qt.TQFrame(box)
layout = qt.QGridLayout(statusbox,4,2,0,2) layout = qt.TQGridLayout(statusbox,4,2,0,2)
layout.addWidget(qt.QLabel("Number of records done:",statusbox),0,0) layout.addWidget(qt.TQLabel("Number of records done:",statusbox),0,0)
self.donecounter = 0 self.donecounter = 0
self.donelabel = qt.QLabel("-",statusbox) self.donelabel = qt.TQLabel("-",statusbox)
layout.addWidget(self.donelabel,0,1) layout.addWidget(self.donelabel,0,1)
layout.addWidget(qt.QLabel("Successfully copied records:",statusbox),1,0) layout.addWidget(qt.TQLabel("Successfully copied records:",statusbox),1,0)
self.successcounter = 0 self.successcounter = 0
self.successlabel = qt.QLabel("-",statusbox) self.successlabel = qt.TQLabel("-",statusbox)
layout.addWidget(self.successlabel,1,1) layout.addWidget(self.successlabel,1,1)
layout.addWidget(qt.QLabel("Failed to copy records:",statusbox),2,0) layout.addWidget(qt.TQLabel("Failed to copy records:",statusbox),2,0)
self.failedcounter = 0 self.failedcounter = 0
self.failedlabel = qt.QLabel("-",statusbox) self.failedlabel = qt.TQLabel("-",statusbox)
layout.addWidget(self.failedlabel,2,1) layout.addWidget(self.failedlabel,2,1)
layout.addWidget(qt.QLabel("Elapsed time in seconds:",statusbox),3,0) layout.addWidget(qt.TQLabel("Elapsed time in seconds:",statusbox),3,0)
self.elapsedlabel = qt.QLabel("-",statusbox) self.elapsedlabel = qt.TQLabel("-",statusbox)
layout.addWidget(self.elapsedlabel,3,1) layout.addWidget(self.elapsedlabel,3,1)
btnbox = qt.QHBox(box) btnbox = qt.TQHBox(box)
btnbox.setSpacing(6) btnbox.setSpacing(6)
self.donebtn = qt.QPushButton(btnbox) self.donebtn = qt.TQPushButton(btnbox)
self.donebtn.setText("Done") self.donebtn.setText("Done")
self.donebtn.setEnabled(False) self.donebtn.setEnabled(False)
qt.QObject.connect(self.donebtn,qt.SIGNAL("clicked()"),self.close) qt.TQObject.connect(self.donebtn,qt.SIGNAL("clicked()"),self.close)
self.cancelbtn = qt.QPushButton(btnbox) self.cancelbtn = qt.TQPushButton(btnbox)
self.cancelbtn.setText("Cancel") self.cancelbtn.setText("Cancel")
qt.QObject.connect(self.cancelbtn,qt.SIGNAL("clicked()"),self.close) qt.TQObject.connect(self.cancelbtn,qt.SIGNAL("clicked()"),self.close)
box.setMinimumSize( qt.QSize(500,380) ) box.setMinimumSize( qt.TQSize(500,380) )
def updateStates(self): def updateStates(self):
if self.starttime != None: if self.starttime != None:
@ -373,9 +373,9 @@ def runGuiApp(copycenter, name):
copierer.writeSuccess = self.writeSuccess copierer.writeSuccess = self.writeSuccess
copierer.writeFailed = self.writeFailed copierer.writeFailed = self.writeFailed
self.starttime = qt.QTime() self.starttime = qt.TQTime()
self.updatetimer = qt.QTimer(self) self.updatetimer = qt.TQTimer(self)
qt.QObject.connect(self.updatetimer,qt.SIGNAL("timeout()"),self.updateStates) qt.TQObject.connect(self.updatetimer,qt.SIGNAL("timeout()"),self.updateStates)
# Initialize the source # Initialize the source
sourcename = self.dialog.getSourcePluginName() sourcename = self.dialog.getSourcePluginName()
@ -426,13 +426,13 @@ def runGuiApp(copycenter, name):
self.starttime = None self.starttime = None
def show(self): def show(self):
qt.QDialog.show(self) qt.TQDialog.show(self)
qt.QTimer.singleShot(10,self.startCopy) qt.TQTimer.singleShot(10,self.startCopy)
qt.tqApp.processEvents() qt.tqApp.processEvents()
def closeEvent(self, closeevent): def closeEvent(self, closeevent):
if not self.dialog.getSourcePluginImpl().isFinished(): if not self.dialog.getSourcePluginImpl().isFinished():
if qt.QMessageBox.warning(self,"Abort?","Abort the copy?",qt.QMessageBox.Yes,qt.QMessageBox.No) != qt.QMessageBox.Yes: if qt.TQMessageBox.warning(self,"Abort?","Abort the copy?",qt.TQMessageBox.Yes,qt.TQMessageBox.No) != qt.TQMessageBox.Yes:
closeevent.ignore() closeevent.ignore()
return return
self.dialog.getSourcePluginImpl().finish() self.dialog.getSourcePluginImpl().finish()
@ -441,35 +441,35 @@ def runGuiApp(copycenter, name):
#-------------------------------------------------------------------- #--------------------------------------------------------------------
class DataSelector(qt.QVGroupBox): class DataSelector(qt.TQVGroupBox):
def __init__(self, plugintype, title, caption, parent, dialog, items): def __init__(self, plugintype, title, caption, parent, dialog, items):
self.plugintype = plugintype self.plugintype = plugintype
self.pluginimpl = None self.pluginimpl = None
self.dialog = dialog self.dialog = dialog
self.mainbox = None self.mainbox = None
qt.QVGroupBox.__init__(self,title,parent) qt.TQVGroupBox.__init__(self,title,parent)
self.setInsideMargin(6) self.setInsideMargin(6)
self.setInsideSpacing(0) self.setInsideSpacing(0)
typebox = qt.QHBox(self) typebox = qt.TQHBox(self)
label = qt.QLabel(caption,typebox) label = qt.TQLabel(caption,typebox)
self.combobox = qt.QComboBox(typebox) self.combobox = qt.TQComboBox(typebox)
for item in items: for item in items:
self.combobox.insertItem(str(item)) self.combobox.insertItem(str(item))
label.setBuddy(self.combobox) label.setBuddy(self.combobox)
typebox.setStretchFactor(self.combobox,1) typebox.setStretchFactor(self.combobox,1)
self.scrollview = qt.QScrollView(self) self.scrollview = qt.TQScrollView(self)
try: try:
self.scrollview.setResizePolicy(qt.QScrollView.AutoOne) self.scrollview.setResizePolicy(qt.TQScrollView.AutoOne)
self.scrollview.setFrameStyle(qt.QFrame.NoFrame); self.scrollview.setFrameStyle(qt.TQFrame.NoFrame);
self.scrollview.setResizePolicy(qt.QScrollView.AutoOneFit); self.scrollview.setResizePolicy(qt.TQScrollView.AutoOneFit);
self.scrollview.viewport().setPaletteBackgroundColor(self.paletteBackgroundColor()) self.scrollview.viewport().setPaletteBackgroundColor(self.paletteBackgroundColor())
except: except:
import traceback import traceback
print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ) print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) )
qt.QObject.connect(self.combobox, qt.SIGNAL("activated(int)"), self.activated) qt.TQObject.connect(self.combobox, qt.SIGNAL("activated(int)"), self.activated)
def updatePlugin(self): def updatePlugin(self):
print "DataSelector.updatePlugin" print "DataSelector.updatePlugin"
@ -490,7 +490,7 @@ def runGuiApp(copycenter, name):
def updateMainBox(self): def updateMainBox(self):
print "DataSelector.updateMainBox" print "DataSelector.updateMainBox"
self.removeMainBox() self.removeMainBox()
self.mainbox = qt.QVBox( self.scrollview.viewport() ) self.mainbox = qt.TQVBox( self.scrollview.viewport() )
self.mainbox.setSpacing(2) self.mainbox.setSpacing(2)
if self.pluginimpl != None: if self.pluginimpl != None:
try: try:
@ -498,7 +498,7 @@ def runGuiApp(copycenter, name):
except: except:
import traceback import traceback
print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ) print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) )
self.mainbox.setStretchFactor(qt.QWidget(self.mainbox), 1) self.mainbox.setStretchFactor(qt.TQWidget(self.mainbox), 1)
self.mainbox.show() self.mainbox.show()
self.scrollview.addChild(self.mainbox) self.scrollview.addChild(self.mainbox)
@ -509,7 +509,7 @@ def runGuiApp(copycenter, name):
def maybeUpdate(self): def maybeUpdate(self):
print "DataSelector.maybeUpdate" print "DataSelector.maybeUpdate"
self.removeMainBox() self.removeMainBox()
qt.QTimer.singleShot(50, self.activated) qt.TQTimer.singleShot(50, self.activated)
def maybeDone(self): def maybeDone(self):
print "DataSelector.maybeDone" print "DataSelector.maybeDone"
@ -519,30 +519,30 @@ def runGuiApp(copycenter, name):
#-------------------------------------------------------------------- #--------------------------------------------------------------------
class Dialog(qt.QDialog): class Dialog(qt.TQDialog):
def __init__(self, copycenter, parent): def __init__(self, copycenter, parent):
self.copycenter = copycenter self.copycenter = copycenter
import qt from TQt import qt
import os import os
import sys import sys
self.ListViewDialog = ListViewDialog self.ListViewDialog = ListViewDialog
qt.QDialog.__init__(self, parent, "Dialog", 1, qt.Qt.WDestructiveClose) qt.TQDialog.__init__(self, parent, "Dialog", 1, qt.TQt.WDestructiveClose)
self.setCaption("Copy Center") self.setCaption("Copy Center")
layout = qt.QVBoxLayout(self) layout = qt.TQVBoxLayout(self)
box = qt.QVBox(self) box = qt.TQVBox(self)
box.setMargin(6) box.setMargin(6)
box.setSpacing(6) box.setSpacing(6)
layout.addWidget(box) layout.addWidget(box)
self.tab = qt.QTabWidget(box) self.tab = qt.TQTabWidget(box)
self.tab.setMargin(6) self.tab.setMargin(6)
box.setStretchFactor(self.tab,1) box.setStretchFactor(self.tab,1)
self.jobsbox = CopyJobWidget(self,self.tab) self.jobsbox = CopyJobWidget(self,self.tab)
self.tab.addTab(self.jobsbox,"Jobs") self.tab.addTab(self.jobsbox,"Jobs")
self.splitter = qt.QSplitter(self.tab) self.splitter = qt.TQSplitter(self.tab)
sourceplugins = [] sourceplugins = []
destinationplugins = [] destinationplugins = []
@ -565,26 +565,26 @@ def runGuiApp(copycenter, name):
"Destination:", # caption "Destination:", # caption
self.splitter, self, destinationplugins) self.splitter, self, destinationplugins)
btnbox = qt.QHBox(box) btnbox = qt.TQHBox(box)
btnbox.setSpacing(6) btnbox.setSpacing(6)
okbtn = qt.QPushButton(btnbox) okbtn = qt.TQPushButton(btnbox)
okbtn.setText("Start Copy") okbtn.setText("Start Copy")
okbtn.setDefault(True) okbtn.setDefault(True)
qt.QObject.connect(okbtn,qt.SIGNAL("clicked()"),self.startCopy) qt.TQObject.connect(okbtn,qt.SIGNAL("clicked()"),self.startCopy)
cancelbtn = qt.QPushButton(btnbox) cancelbtn = qt.TQPushButton(btnbox)
cancelbtn.setText("Cancel") cancelbtn.setText("Cancel")
qt.QObject.connect(cancelbtn,qt.SIGNAL("clicked()"),self.close) qt.TQObject.connect(cancelbtn,qt.SIGNAL("clicked()"),self.close)
self.tab.addTab(self.splitter,"Copy") self.tab.addTab(self.splitter,"Copy")
self.tab.setCurrentPage(1) self.tab.setCurrentPage(1)
self.helpbrowser = qt.QTextBrowser(self.tab) self.helpbrowser = qt.TQTextBrowser(self.tab)
self.helpbrowser.setLinkUnderline(False) self.helpbrowser.setLinkUnderline(False)
self.helpbrowser.setUndoRedoEnabled(False) self.helpbrowser.setUndoRedoEnabled(False)
self.tab.addTab(self.helpbrowser,"Help") self.tab.addTab(self.helpbrowser,"Help")
qt.QObject.connect(self.tab,qt.SIGNAL("currentChanged(QWidget*)"),self.currentTabChanged) qt.TQObject.connect(self.tab,qt.SIGNAL("currentChanged(QWidget*)"),self.currentTabChanged)
box.setMinimumSize( qt.QSize(760,500) ) box.setMinimumSize( qt.TQSize(760,500) )
defaultfile = os.path.join(self.copycenter.homepath,"default.copycenterjob.xml") defaultfile = os.path.join(self.copycenter.homepath,"default.copycenterjob.xml")
if os.path.isfile(defaultfile): if os.path.isfile(defaultfile):
@ -627,7 +627,7 @@ def runGuiApp(copycenter, name):
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if name == "__main__": if name == "__main__":
qtapp = qt.QApplication(sys.argv) qtapp = qt.TQApplication(sys.argv)
else: else:
qtapp = qt.tqApp qtapp = qt.tqApp
dialog = Dialog(copycenter, qtapp.mainWidget()) dialog = Dialog(copycenter, qtapp.mainWidget())

@ -197,25 +197,25 @@ class CopyCenterPlugin:
self.copycenter = copycenter self.copycenter = copycenter
def createWidget(self, dialog, plugin, parent): 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 CopyCenter.py. The widget will be used to configure our
plugin settings. """ plugin settings. """
import qt from TQt import qt
import os import os
import re import re
self.dialog = dialog self.dialog = dialog
self.mainbox = None self.mainbox = None
class ProjectBox(qt.QHBox): class ProjectBox(qt.TQHBox):
def __init__(self,main,copycenterplugin,plugin,parent): def __init__(self,main,copycenterplugin,plugin,parent):
self.main = main self.main = main
self.copycenterplugin = copycenterplugin self.copycenterplugin = copycenterplugin
self.plugin = plugin self.plugin = plugin
qt.QHBox.__init__(self,parent) qt.TQHBox.__init__(self,parent)
prjlabel = qt.QLabel("Project File:",self) prjlabel = qt.TQLabel("Project File:",self)
self.prjcombo = qt.QComboBox(self) self.prjcombo = qt.TQComboBox(self)
self.prjcombo.setEditable(True) self.prjcombo.setEditable(True)
self.prjcombo.insertItem("") self.prjcombo.insertItem("")
@ -226,9 +226,9 @@ class CopyCenterPlugin:
self.prjcombo.insertItem(os.path.join("~",f)) self.prjcombo.insertItem(os.path.join("~",f))
prjlabel.setBuddy(self.prjcombo) prjlabel.setBuddy(self.prjcombo)
prjsavebtn = qt.QPushButton("...",self) prjsavebtn = qt.TQPushButton("...",self)
qt.QObject.connect(prjsavebtn, qt.SIGNAL("clicked()"),self.buttonClicked) qt.TQObject.connect(prjsavebtn, qt.SIGNAL("clicked()"),self.buttonClicked)
qt.QObject.connect(self.prjcombo, qt.SIGNAL("textChanged(const QString&)"), self.main.projectChanged) qt.TQObject.connect(self.prjcombo, qt.SIGNAL("textChanged(const QString&)"), self.main.projectChanged)
self.setStretchFactor(self.prjcombo,1) self.setStretchFactor(self.prjcombo,1)
def buttonClicked(self): def buttonClicked(self):
text = str(self.prjcombo.currentText()) text = str(self.prjcombo.currentText())
@ -238,31 +238,31 @@ class CopyCenterPlugin:
import os import os
text = os.path.join(self.copycenterplugin.copycenter.homepath,text[2:]) text = os.path.join(self.copycenterplugin.copycenter.homepath,text[2:])
if self.plugin.plugintype == "Source": 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": 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)) if str(filename) != "": self.prjcombo.setCurrentText(str(filename))
class DriverBox(qt.QVBox): class DriverBox(qt.TQVBox):
def __init__(self,main,parent): def __init__(self,main,parent):
qt.QVBox.__init__(self,parent) qt.TQVBox.__init__(self,parent)
self.main = main self.main = main
self.copycenterplugin = main.copycenterplugin self.copycenterplugin = main.copycenterplugin
self.plugin = main.plugin self.plugin = main.plugin
self.driver = None self.driver = None
driverbox = qt.QHBox(self) driverbox = qt.TQHBox(self)
driverlabel = qt.QLabel("Driver:",driverbox) driverlabel = qt.TQLabel("Driver:",driverbox)
self.drivercombo = qt.QComboBox(driverbox) self.drivercombo = qt.TQComboBox(driverbox)
self.drivercombo.insertItem("") self.drivercombo.insertItem("")
for driver in self.copycenterplugin.drivermanager.driverNames(): for driver in self.copycenterplugin.drivermanager.driverNames():
self.drivercombo.insertItem(driver) 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) driverlabel.setBuddy(self.drivercombo)
driverbox.setStretchFactor(self.drivercombo,1) driverbox.setStretchFactor(self.drivercombo,1)
self.box = qt.QVBox(self) self.box = qt.TQVBox(self)
self.mainbox = None self.mainbox = None
def activated(self,index): def activated(self,index):
@ -281,58 +281,58 @@ class CopyCenterPlugin:
self.driver = self.copycenterplugin.drivermanager.driver(drivertext) self.driver = self.copycenterplugin.drivermanager.driver(drivertext)
mainbox = qt.QVBox(self.box) mainbox = qt.TQVBox(self.box)
mainbox.setSpacing(2) mainbox.setSpacing(2)
if self.driver.isFileDriver(): if self.driver.isFileDriver():
filebox = qt.QHBox(mainbox) filebox = qt.TQHBox(mainbox)
filelabel = qt.QLabel("File:",filebox) filelabel = qt.TQLabel("File:",filebox)
self.fileedit = qt.QLineEdit(self.plugin.options['file'],filebox) self.fileedit = qt.TQLineEdit(self.plugin.options['file'],filebox)
filelabel.setBuddy(self.fileedit) filelabel.setBuddy(self.fileedit)
filebox.setStretchFactor(self.fileedit,1) filebox.setStretchFactor(self.fileedit,1)
filebtn = qt.QPushButton("...",filebox) filebtn = qt.TQPushButton("...",filebox)
qt.QObject.connect(filebtn, qt.SIGNAL("clicked()"), self.fileClicked) qt.TQObject.connect(filebtn, qt.SIGNAL("clicked()"), self.fileClicked)
else: else:
hostbox = qt.QHBox(mainbox) hostbox = qt.TQHBox(mainbox)
hostlabel = qt.QLabel("Hostname:",hostbox) hostlabel = qt.TQLabel("Hostname:",hostbox)
self.hostedit = qt.QLineEdit(self.plugin.options['hostname'],hostbox) self.hostedit = qt.TQLineEdit(self.plugin.options['hostname'],hostbox)
hostlabel.setBuddy(self.hostedit) hostlabel.setBuddy(self.hostedit)
hostbox.setStretchFactor(self.hostedit,1) hostbox.setStretchFactor(self.hostedit,1)
portbox = qt.QHBox(mainbox) portbox = qt.TQHBox(mainbox)
portlabel = qt.QLabel("Port:",portbox) portlabel = qt.TQLabel("Port:",portbox)
self.portedit = qt.QLineEdit(self.plugin.options['port'],portbox) self.portedit = qt.TQLineEdit(self.plugin.options['port'],portbox)
portlabel.setBuddy(self.portedit) portlabel.setBuddy(self.portedit)
portbox.setStretchFactor(self.portedit,1) portbox.setStretchFactor(self.portedit,1)
sockbox = qt.QHBox(mainbox) sockbox = qt.TQHBox(mainbox)
self.sockfilecheckbox = qt.QCheckBox("Socket File:",sockbox) self.sockfilecheckbox = qt.TQCheckBox("Socket File:",sockbox)
qt.QObject.connect(self.sockfilecheckbox, qt.SIGNAL("toggled(bool)"), self.sockfilecheckboxClicked) qt.TQObject.connect(self.sockfilecheckbox, qt.SIGNAL("toggled(bool)"), self.sockfilecheckboxClicked)
self.sockfilebox = qt.QHBox(sockbox) self.sockfilebox = qt.TQHBox(sockbox)
self.sockfileedit = qt.QLineEdit(self.plugin.options['socketfile'],self.sockfilebox) self.sockfileedit = qt.TQLineEdit(self.plugin.options['socketfile'],self.sockfilebox)
self.sockfilebox.setEnabled(False) self.sockfilebox.setEnabled(False)
sockfilebtn = qt.QPushButton("...",self.sockfilebox) sockfilebtn = qt.TQPushButton("...",self.sockfilebox)
self.sockfilecheckbox.setChecked( str(self.plugin.options['usesocketfile']) == str(True) ) 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) self.sockfilebox.setStretchFactor(self.sockfileedit,1)
sockbox.setStretchFactor(self.sockfilebox,1) sockbox.setStretchFactor(self.sockfilebox,1)
userbox = qt.QHBox(mainbox) userbox = qt.TQHBox(mainbox)
userlabel = qt.QLabel("Username:",userbox) userlabel = qt.TQLabel("Username:",userbox)
self.useredit = qt.QLineEdit(self.plugin.options['username'],userbox) self.useredit = qt.TQLineEdit(self.plugin.options['username'],userbox)
userlabel.setBuddy(self.useredit) userlabel.setBuddy(self.useredit)
userbox.setStretchFactor(self.useredit,1) userbox.setStretchFactor(self.useredit,1)
passbox = qt.QHBox(mainbox) passbox = qt.TQHBox(mainbox)
passlabel = qt.QLabel("Password:",passbox) passlabel = qt.TQLabel("Password:",passbox)
self.passedit = qt.QLineEdit(self.plugin.options['password'],passbox) self.passedit = qt.TQLineEdit(self.plugin.options['password'],passbox)
self.passedit.setEchoMode(qt.QLineEdit.Password) self.passedit.setEchoMode(qt.TQLineEdit.Password)
passlabel.setBuddy(self.passedit) passlabel.setBuddy(self.passedit)
passbox.setStretchFactor(self.passedit,1) passbox.setStretchFactor(self.passedit,1)
dbbox = qt.QHBox(mainbox) dbbox = qt.TQHBox(mainbox)
dblabel = qt.QLabel("Database:",dbbox) dblabel = qt.TQLabel("Database:",dbbox)
self.dbedit = qt.QLineEdit(self.plugin.options['database'],dbbox) self.dbedit = qt.TQLineEdit(self.plugin.options['database'],dbbox)
dblabel.setBuddy(self.dbedit) dblabel.setBuddy(self.dbedit)
dbbox.setStretchFactor(self.dbedit,1) dbbox.setStretchFactor(self.dbedit,1)
#self.tablecombo.setText("") #self.tablecombo.setText("")
@ -347,9 +347,9 @@ class CopyCenterPlugin:
text = str(self.fileedit.text()) text = str(self.fileedit.text())
if text == "": text = self.copycenterplugin.copycenter.homepath if text == "": text = self.copycenterplugin.copycenter.homepath
if self.plugin.plugintype == "Source": if self.plugin.plugintype == "Source":
filename = qt.QFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) filename = qt.TQFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog)
else: # "Destination": 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)) if str(filename) != "": self.fileedit.setText(str(filename))
def sockfilecheckboxClicked(self,checked): def sockfilecheckboxClicked(self,checked):
self.sockfilebox.setEnabled(checked) self.sockfilebox.setEnabled(checked)
@ -358,21 +358,21 @@ class CopyCenterPlugin:
text = str(self.sockfileedit.text()) text = str(self.sockfileedit.text())
if text == "": text = self.copycenterplugin.copycenter.homepath if text == "": text = self.copycenterplugin.copycenter.homepath
if self.plugin.plugintype == "Source": if self.plugin.plugintype == "Source":
filename = qt.QFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog) filename = qt.TQFileDialog.getOpenFileName(text,"*",self.copycenterplugin.dialog)
else: # "Destination": 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)) if str(filename) != "": self.sockfileedit.setText(str(filename))
class TableBox(qt.QHBox): class TableBox(qt.TQHBox):
def __init__(self,copycenterplugin,plugin,parent): def __init__(self,copycenterplugin,plugin,parent):
qt.QHBox.__init__(self,parent) qt.TQHBox.__init__(self,parent)
self.copycenterplugin = copycenterplugin self.copycenterplugin = copycenterplugin
self.plugin = plugin self.plugin = plugin
tablelabel = qt.QLabel("Table:",self) tablelabel = qt.TQLabel("Table:",self)
self.tableedit = qt.QLineEdit(self.plugin.options['table'],self) self.tableedit = qt.TQLineEdit(self.plugin.options['table'],self)
self.tablebtn = qt.QPushButton("...",self) self.tablebtn = qt.TQPushButton("...",self)
self.tablebtn.setEnabled(False) 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) tablelabel.setBuddy(self.tableedit)
self.setStretchFactor(self.tableedit,1) self.setStretchFactor(self.tableedit,1)
def buttonClicked(self): def buttonClicked(self):
@ -386,14 +386,14 @@ class CopyCenterPlugin:
item = None item = None
for table in self.mainwidget.plugin.connection.tableNames(): for table in self.mainwidget.plugin.connection.tableNames():
if item == None: if item == None:
item = qt.QListViewItem(self.listview,table) item = qt.TQListViewItem(self.listview,table)
else: else:
item = qt.QListViewItem(self.listview,item,table) item = qt.TQListViewItem(self.listview,item,table)
if table == text: if table == text:
self.listview.setSelected(item,True) self.listview.setSelected(item,True)
self.listview.ensureItemVisible(item) self.listview.ensureItemVisible(item)
qt.QObject.connect(self.listview, qt.SIGNAL("doubleClicked(QListViewItem*, const QPoint&, int)"), self.okClicked) qt.TQObject.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.okbtn, qt.SIGNAL("clicked()"), self.okClicked)
def okClicked(self): def okClicked(self):
item = self.listview.selectedItem() item = self.listview.selectedItem()
if item == None: if item == None:
@ -404,26 +404,26 @@ class CopyCenterPlugin:
dialog = TableDialog(self) dialog = TableDialog(self)
dialog.show() dialog.show()
class FieldBox(qt.QHBox): class FieldBox(qt.TQHBox):
def __init__(self,copycenterplugin,plugin,parent): def __init__(self,copycenterplugin,plugin,parent):
qt.QHBox.__init__(self,parent) qt.TQHBox.__init__(self,parent)
self.copycenterplugin = copycenterplugin self.copycenterplugin = copycenterplugin
self.plugin = plugin self.plugin = plugin
self.tablename = "" self.tablename = ""
fieldslabel = qt.QLabel("Fields:",self) fieldslabel = qt.TQLabel("Fields:",self)
self.fieldsedit = qt.QLineEdit(self.plugin.options['fields'],self) self.fieldsedit = qt.TQLineEdit(self.plugin.options['fields'],self)
self.setStretchFactor(self.fieldsedit,1) self.setStretchFactor(self.fieldsedit,1)
fieldslabel.setBuddy(self.fieldsedit) fieldslabel.setBuddy(self.fieldsedit)
self.fieldsbtn = qt.QPushButton("...",self) self.fieldsbtn = qt.TQPushButton("...",self)
self.fieldsbtn.setEnabled(False) 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): def fieldsClicked(self):
ListViewDialog = self.copycenterplugin.dialog.ListViewDialog ListViewDialog = self.copycenterplugin.dialog.ListViewDialog
class FieldsDialog(ListViewDialog): class FieldsDialog(ListViewDialog):
def __init__(self, fieldbox): def __init__(self, fieldbox):
ListViewDialog.__init__(self,fieldbox,"Fields") ListViewDialog.__init__(self,fieldbox,"Fields")
self.fieldbox = fieldbox self.fieldbox = fieldbox
self.listview.setSelectionMode(qt.QListView.Multi) self.listview.setSelectionMode(qt.TQListView.Multi)
self.listview.setSorting(-1) self.listview.setSorting(-1)
self.listview.header().setClickEnabled(False) self.listview.header().setClickEnabled(False)
self.listview.addColumn("Name") self.listview.addColumn("Name")
@ -441,7 +441,7 @@ class CopyCenterPlugin:
item = self.addItem(( field.name(),field.type(),",".join(opts) ),item) item = self.addItem(( field.name(),field.type(),",".join(opts) ),item)
if allfields or field.name() in fieldslist: if allfields or field.name() in fieldslist:
self.listview.setSelected(item,True) 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): def okClicked(self):
selitems = [] selitems = []
item = self.listview.firstChild() item = self.listview.firstChild()
@ -461,47 +461,47 @@ class CopyCenterPlugin:
return return
self.fieldsbtn.setEnabled(False) self.fieldsbtn.setEnabled(False)
class MainBox(qt.QHBox): class MainBox(qt.TQHBox):
def __init__(self,copycenterplugin,plugin,parent): def __init__(self,copycenterplugin,plugin,parent):
qt.QHBox.__init__(self,parent) qt.TQHBox.__init__(self,parent)
self.copycenterplugin = copycenterplugin self.copycenterplugin = copycenterplugin
self.plugin = plugin self.plugin = plugin
self.prjbox = ProjectBox(self,copycenterplugin,plugin,parent) self.prjbox = ProjectBox(self,copycenterplugin,plugin,parent)
self.driverbox = DriverBox(self,parent) self.driverbox = DriverBox(self,parent)
statusbar = qt.QHBox(parent) statusbar = qt.TQHBox(parent)
statusbar.setSpacing(2) statusbar.setSpacing(2)
#self.statuslabel = qt.QLabel("Disconnected",statusbar) #self.statuslabel = qt.TQLabel("Disconnected",statusbar)
#statusbar.setStretchFactor(self.statuslabel,1) #statusbar.setStretchFactor(self.statuslabel,1)
statusbar.setStretchFactor(qt.QWidget(statusbar),1) statusbar.setStretchFactor(qt.TQWidget(statusbar),1)
self.connectbtn = qt.QPushButton("Connect",statusbar) self.connectbtn = qt.TQPushButton("Connect",statusbar)
self.connectbtn.setEnabled(False) self.connectbtn.setEnabled(False)
qt.QObject.connect(self.connectbtn, qt.SIGNAL("clicked()"),self.connectClicked) qt.TQObject.connect(self.connectbtn, qt.SIGNAL("clicked()"),self.connectClicked)
self.disconnectbtn = qt.QPushButton("Disconnect",statusbar) self.disconnectbtn = qt.TQPushButton("Disconnect",statusbar)
self.disconnectbtn.setEnabled(False) 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.connectionbox = ConnectionBox(copycenterplugin,plugin,parent)
self.tablebox = TableBox(copycenterplugin,plugin,parent) self.tablebox = TableBox(copycenterplugin,plugin,parent)
self.fieldbox = FieldBox(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'] != '': if self.plugin.options['project'] != '':
self.prjbox.prjcombo.setCurrentText(self.plugin.options['project']) self.prjbox.prjcombo.setCurrentText(self.plugin.options['project'])
if self.plugin.options['driver'] != '': if self.plugin.options['driver'] != '':
try: 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.drivercombo.setCurrentText(item)
self.driverbox.activated(item) self.driverbox.activated(item)
except: except:
pass pass
if self.plugin.plugintype == "Destination": if self.plugin.plugintype == "Destination":
#typebox = qt.QHBox(parent) #typebox = qt.TQHBox(parent)
#label = qt.QLabel("Operation:",typebox) #label = qt.TQLabel("Operation:",typebox)
#combobox = qt.QComboBox(typebox) #combobox = qt.TQComboBox(typebox)
#combobox.insertItem("Append") #combobox.insertItem("Append")
#combobox.insertItem("Replace") #combobox.insertItem("Replace")
#combobox.insertItem("Update") #combobox.insertItem("Update")
@ -511,17 +511,17 @@ class CopyCenterPlugin:
#typebox.setStretchFactor(combobox,1) #typebox.setStretchFactor(combobox,1)
pass pass
elif self.plugin.plugintype == "Source": elif self.plugin.plugintype == "Source":
wherebox = qt.QHBox(parent) wherebox = qt.TQHBox(parent)
wherelabel = qt.QLabel("Where:",wherebox) wherelabel = qt.TQLabel("Where:",wherebox)
self.whereedit = qt.QLineEdit(self.plugin.options['where'],wherebox) self.whereedit = qt.TQLineEdit(self.plugin.options['where'],wherebox)
#orderbox = qt.QHBox(parent) #orderbox = qt.TQHBox(parent)
#orderlabel = qt.QLabel("Order By:",orderbox) #orderlabel = qt.TQLabel("Order By:",orderbox)
#orderedit = qt.QLineEdit("",orderbox) #orderedit = qt.TQLineEdit("",orderbox)
#errbox = qt.QHBox(parent) #errbox = qt.TQHBox(parent)
#errlabel = qt.QLabel("On Error:",errbox) #errlabel = qt.TQLabel("On Error:",errbox)
#errcombo = qt.QComboBox(errbox) #errcombo = qt.TQComboBox(errbox)
#errcombo.insertItem("Ask") #errcombo.insertItem("Ask")
#errcombo.insertItem("Skip") #errcombo.insertItem("Skip")
#errcombo.insertItem("Abort") #errcombo.insertItem("Abort")
@ -576,7 +576,7 @@ class CopyCenterPlugin:
if self.driverbox.driver.isFileDriver(): if self.driverbox.driver.isFileDriver():
file = str(self.driverbox.fileedit.text()) file = str(self.driverbox.fileedit.text())
if file == "" or not os.path.isfile(file): 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 return False
connectiondata.setFileName(file) connectiondata.setFileName(file)
connectiondata.setDatabaseName(file) connectiondata.setDatabaseName(file)
@ -592,11 +592,11 @@ class CopyCenterPlugin:
connection = self.driverbox.driver.createConnection(connectiondata) connection = self.driverbox.driver.createConnection(connectiondata)
print "Trying to connect" print "Trying to connect"
if not connection.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 return False
print "Use database \"%s\"" % connectiondata.databaseName() print "Use database \"%s\"" % connectiondata.databaseName()
if not connection.useDatabase( 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 return False
print "dbnames = %s" % connection.databaseNames() print "dbnames = %s" % connection.databaseNames()
print "tablenames = %s" % connection.tableNames() print "tablenames = %s" % connection.tableNames()
@ -608,7 +608,7 @@ class CopyCenterPlugin:
def disconnectClicked(self): def disconnectClicked(self):
if not self.plugin.connection.disconnect(): 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 return
self.updateConnectButtons() self.updateConnectButtons()

@ -1,5 +1,5 @@
""" """
CopyCenterPlugin to provide 'QtSQL'. CopyCenterPlugin to provide 'TQtSQL'.
Description: Description:
This python-script is a plugin for the CopyCenter.py. This python-script is a plugin for the CopyCenter.py.
@ -12,9 +12,9 @@ GPL v2 or higher.
""" """
class CopyCenterPlugin: class CopyCenterPlugin:
""" The CopyCenterPlugin to provide 'QtSQL' to CopyCenter.py """ """ The CopyCenterPlugin to provide 'TQtSQL' to CopyCenter.py """
name = "QtSQL Database" name = "TQtSQL Database"
""" The name this plugin has. The name should be unique and """ The name this plugin has. The name should be unique and
will be used for displaying a caption. """ will be used for displaying a caption. """
@ -52,7 +52,7 @@ class CopyCenterPlugin:
'port': 3306, 'port': 3306,
'username': 'root', #'MyUsername', 'username': 'root', #'MyUsername',
'password': '', #'MySecretPassword', 'password': '', #'MySecretPassword',
'database': '', #'MyQtSQLDatabase', 'database': '', #'MyTQtSQLDatabase',
'table': '', #'table1', 'table': '', #'table1',
'fields': '', #'f1,f2', 'fields': '', #'f1,f2',
'where': '', 'where': '',
@ -61,9 +61,9 @@ class CopyCenterPlugin:
self._init(copierer) self._init(copierer)
tablename = str(self.widget.tableedit.text()) tablename = str(self.widget.tableedit.text())
wherestatement = str(self.widget.whereedit.text()) wherestatement = str(self.widget.whereedit.text())
import qt from TQt import qt
import qtsql from TQt import qtsql
self.cursor = qtsql.QSqlCursor(tablename,True,self.database) self.cursor = qtsql.TQSqlCursor(tablename,True,self.database)
self.cursor.setFilter(wherestatement) self.cursor.setFilter(wherestatement)
if not self.cursor.select(): if not self.cursor.select():
raise "Select on cursor failed.<br>%s<br>%s" % ( str(self.cursor.lastError().driverText()),str(self.cursor.lastError().databaseText()) ) raise "Select on cursor failed.<br>%s<br>%s" % ( str(self.cursor.lastError().driverText()),str(self.cursor.lastError().databaseText()) )
@ -98,7 +98,7 @@ class CopyCenterPlugin:
'port': 3306, 'port': 3306,
'username': 'root', #'MyUsername', 'username': 'root', #'MyUsername',
'password': '', #'MySecretPassword', 'password': '', #'MySecretPassword',
'database': '', #'MyQtSQLDatabase', 'database': '', #'MyTQtSQLDatabase',
'table': '', #'table2', 'table': '', #'table2',
'fields': '', #'field1,field2', 'fields': '', #'field1,field2',
'operation': 'Insert', #'Insert','Update'... 'operation': 'Insert', #'Insert','Update'...
@ -106,8 +106,8 @@ class CopyCenterPlugin:
} }
def init(self,copierer): def init(self,copierer):
self._init(copierer) self._init(copierer)
import qt from TQt import qt
import qtsql from TQt import qtsql
self.fieldlist = [] self.fieldlist = []
for fieldname in str(self.widget.fieldedit.text()).split(","): for fieldname in str(self.widget.fieldedit.text()).split(","):
@ -115,7 +115,7 @@ class CopyCenterPlugin:
if fn != "": self.fieldlist.append(fn) if fn != "": self.fieldlist.append(fn)
tablename = str(self.widget.tableedit.text()) tablename = str(self.widget.tableedit.text())
self.cursor = qtsql.QSqlCursor(tablename,True,self.database) self.cursor = qtsql.TQSqlCursor(tablename,True,self.database)
{ {
0: self.initInsert, 0: self.initInsert,
1: self.initUpdate 1: self.initUpdate
@ -132,16 +132,16 @@ class CopyCenterPlugin:
def writeInsert(self, record): def writeInsert(self, record):
print "insert record: %s" % record print "insert record: %s" % record
import qt from TQt import qt
cursorrecord = self.cursor.primeInsert() cursorrecord = self.cursor.primeInsert()
count = len(record) count = len(record)
for i in range(len(self.fieldlist)): for i in range(len(self.fieldlist)):
if i == count: break if i == count: break
r = record[i] r = record[i]
if r == None: if r == None:
v = qt.QVariant() v = qt.TQVariant()
else: else:
v = qt.QVariant(r) v = qt.TQVariant(r)
cursorrecord.setValue(self.fieldlist[i], v) cursorrecord.setValue(self.fieldlist[i], v)
rowcount = self.cursor.insert() rowcount = self.cursor.insert()
if rowcount < 1: if rowcount < 1:
@ -162,11 +162,11 @@ class CopyCenterPlugin:
pkindex = self.cursor.index(self.indexfieldname) pkindex = self.cursor.index(self.indexfieldname)
if not pkindex: raise "Invalid index-field defined." if not pkindex: raise "Invalid index-field defined."
self.cursor.setPrimaryIndex(pkindex) self.cursor.setPrimaryIndex(pkindex)
#self.cursor.setMode( qtsql.QSqlCursor.Insert | qtsql.QSqlCursor.Update ) #self.cursor.setMode( qtsql.TQSqlCursor.Insert | qtsql.TQSqlCursor.Update )
self.copierer.appendProgressMessage("Update SQL: %s" % str(self.cursor.executedQuery())) self.copierer.appendProgressMessage("Update SQL: %s" % str(self.cursor.executedQuery()))
def writeUpdate(self, record): def writeUpdate(self, record):
import qt from TQt import qt
# determinate the primary-index # determinate the primary-index
try: try:
idx = self.fieldlist.index(self.indexfieldname) idx = self.fieldlist.index(self.indexfieldname)
@ -192,9 +192,9 @@ class CopyCenterPlugin:
if self.indexfieldname != fieldname: # don't update the indexfield! if self.indexfieldname != fieldname: # don't update the indexfield!
r = record[i] r = record[i]
if r == None: if r == None:
v = qt.QVariant() v = qt.TQVariant()
else: else:
v = qt.QVariant(r) v = qt.TQVariant(r)
cursorrecord.setValue(fieldname, v) cursorrecord.setValue(fieldname, v)
# Write updated record. # Write updated record.
rowcount = self.cursor.update() rowcount = self.cursor.update()
@ -210,11 +210,11 @@ class CopyCenterPlugin:
pass pass
def widget(self,dialog,plugin,parent): def widget(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 CopyCenter.py. The widget will be used to configure our
plugin settings. """ plugin settings. """
import qt from TQt import qt
import os import os
self.dialog = dialog self.dialog = dialog
@ -228,14 +228,14 @@ class CopyCenterPlugin:
item = None item = None
for table in self.mainwidget.plugin.database.tables(): for table in self.mainwidget.plugin.database.tables():
if item == None: if item == None:
item = qt.QListViewItem(self.listview,table) item = qt.TQListViewItem(self.listview,table)
else: else:
item = qt.QListViewItem(self.listview,item,table) item = qt.TQListViewItem(self.listview,item,table)
if table == text: if table == text:
self.listview.setSelected(item,True) self.listview.setSelected(item,True)
self.listview.ensureItemVisible(item) self.listview.ensureItemVisible(item)
qt.QObject.connect(self.listview, qt.SIGNAL("doubleClicked(QListViewItem*, const QPoint&, int)"), self.okClicked) qt.TQObject.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.okbtn, qt.SIGNAL("clicked()"), self.okClicked)
def okClicked(self): def okClicked(self):
item = self.listview.selectedItem() item = self.listview.selectedItem()
if item == None: if item == None:
@ -248,7 +248,7 @@ class CopyCenterPlugin:
def __init__(self, mainwidget): def __init__(self, mainwidget):
ListViewDialog.__init__(self,parent,"Fields") ListViewDialog.__init__(self,parent,"Fields")
self.mainwidget = mainwidget self.mainwidget = mainwidget
self.listview.setSelectionMode(qt.QListView.Multi) self.listview.setSelectionMode(qt.TQListView.Multi)
self.listview.setSorting(-1) self.listview.setSorting(-1)
self.listview.header().setClickEnabled(False) self.listview.header().setClickEnabled(False)
self.listview.addColumn("Name") self.listview.addColumn("Name")
@ -264,10 +264,10 @@ class CopyCenterPlugin:
opts = "" opts = ""
for s in ('Required','Calculated'): #,'Generated'): for s in ('Required','Calculated'): #,'Generated'):
if getattr(fieldinfo,"is%s" % s)(): opts += "%s " % s if getattr(fieldinfo,"is%s" % s)(): opts += "%s " % s
item = self.addItem((fieldinfo.name(), qt.QVariant.typeToName(fieldinfo.type()), opts),item) item = self.addItem((fieldinfo.name(), qt.TQVariant.typeToName(fieldinfo.type()), opts),item)
if allfields or fieldinfo.name() in fieldslist: if allfields or fieldinfo.name() in fieldslist:
self.listview.setSelected(item,True) 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): def okClicked(self):
selitems = [] selitems = []
item = self.listview.firstChild() item = self.listview.firstChild()
@ -279,101 +279,101 @@ class CopyCenterPlugin:
self.close() self.close()
class MainWidget(qt.QHBox): class MainWidget(qt.TQHBox):
def __init__(self,plugin,dialog,parent): def __init__(self,plugin,dialog,parent):
import qt from TQt import qt
import qtsql from TQt import qtsql
qt.QHBox.__init__(self,parent) qt.TQHBox.__init__(self,parent)
self.dialog = dialog self.dialog = dialog
self.plugin = plugin self.plugin = plugin
self.connectionbox = qt.QVBox(parent) self.connectionbox = qt.TQVBox(parent)
self.connectionbox.setSpacing(2) self.connectionbox.setSpacing(2)
driverbox = qt.QHBox(self.connectionbox) driverbox = qt.TQHBox(self.connectionbox)
driverlabel = qt.QLabel("Driver:",driverbox) driverlabel = qt.TQLabel("Driver:",driverbox)
self.driveredit = qt.QComboBox(driverbox) self.driveredit = qt.TQComboBox(driverbox)
for driver in qtsql.QSqlDatabase.drivers(): for driver in qtsql.TQSqlDatabase.drivers():
self.driveredit.insertItem(driver) self.driveredit.insertItem(driver)
if self.plugin.options['driver'] == driver: if self.plugin.options['driver'] == driver:
self.driveredit.setCurrentItem(self.driveredit.count() - 1) self.driveredit.setCurrentItem(self.driveredit.count() - 1)
driverlabel.setBuddy(self.driveredit) driverlabel.setBuddy(self.driveredit)
driverbox.setStretchFactor(self.driveredit,1) driverbox.setStretchFactor(self.driveredit,1)
hostbox = qt.QHBox(self.connectionbox) hostbox = qt.TQHBox(self.connectionbox)
hostlabel = qt.QLabel("Hostname:",hostbox) hostlabel = qt.TQLabel("Hostname:",hostbox)
self.hostedit = qt.QLineEdit(self.plugin.options['hostname'],hostbox) self.hostedit = qt.TQLineEdit(self.plugin.options['hostname'],hostbox)
hostlabel.setBuddy(self.hostedit) hostlabel.setBuddy(self.hostedit)
hostbox.setStretchFactor(self.hostedit,1) hostbox.setStretchFactor(self.hostedit,1)
portbox = qt.QHBox(self.connectionbox) portbox = qt.TQHBox(self.connectionbox)
portlabel = qt.QLabel("Port:",portbox) portlabel = qt.TQLabel("Port:",portbox)
self.portedit = qt.QLineEdit(str(self.plugin.options['port']),portbox) self.portedit = qt.TQLineEdit(str(self.plugin.options['port']),portbox)
portlabel.setBuddy(self.portedit) portlabel.setBuddy(self.portedit)
portbox.setStretchFactor(self.portedit,1) portbox.setStretchFactor(self.portedit,1)
userbox = qt.QHBox(self.connectionbox) userbox = qt.TQHBox(self.connectionbox)
userlabel = qt.QLabel("Username:",userbox) userlabel = qt.TQLabel("Username:",userbox)
self.useredit = qt.QLineEdit(self.plugin.options['username'],userbox) self.useredit = qt.TQLineEdit(self.plugin.options['username'],userbox)
userlabel.setBuddy(self.useredit) userlabel.setBuddy(self.useredit)
userbox.setStretchFactor(self.useredit,1) userbox.setStretchFactor(self.useredit,1)
passbox = qt.QHBox(self.connectionbox) passbox = qt.TQHBox(self.connectionbox)
passlabel = qt.QLabel("Password:",passbox) passlabel = qt.TQLabel("Password:",passbox)
self.passedit = qt.QLineEdit(self.plugin.options['password'],passbox) self.passedit = qt.TQLineEdit(self.plugin.options['password'],passbox)
self.passedit.setEchoMode(qt.QLineEdit.Password) self.passedit.setEchoMode(qt.TQLineEdit.Password)
passlabel.setBuddy(self.passedit) passlabel.setBuddy(self.passedit)
passbox.setStretchFactor(self.passedit,1) passbox.setStretchFactor(self.passedit,1)
dbbox = qt.QHBox(self.connectionbox) dbbox = qt.TQHBox(self.connectionbox)
dblabel = qt.QLabel("Database:",dbbox) dblabel = qt.TQLabel("Database:",dbbox)
self.dbedit = qt.QLineEdit(self.plugin.options['database'],dbbox) self.dbedit = qt.TQLineEdit(self.plugin.options['database'],dbbox)
dblabel.setBuddy(self.dbedit) dblabel.setBuddy(self.dbedit)
dbbox.setStretchFactor(self.dbedit,1) dbbox.setStretchFactor(self.dbedit,1)
statusbar = qt.QHBox(parent) statusbar = qt.TQHBox(parent)
statusbar.setSpacing(2) statusbar.setSpacing(2)
statusbar.setStretchFactor(qt.QWidget(statusbar),1) statusbar.setStretchFactor(qt.TQWidget(statusbar),1)
self.connectbtn = qt.QPushButton("Connect",statusbar) self.connectbtn = qt.TQPushButton("Connect",statusbar)
qt.QObject.connect(self.connectbtn, qt.SIGNAL("clicked()"),self.connectClicked) qt.TQObject.connect(self.connectbtn, qt.SIGNAL("clicked()"),self.connectClicked)
self.disconnectbtn = qt.QPushButton("Disconnect",statusbar) self.disconnectbtn = qt.TQPushButton("Disconnect",statusbar)
self.disconnectbtn.setEnabled(False) self.disconnectbtn.setEnabled(False)
qt.QObject.connect(self.disconnectbtn, qt.SIGNAL("clicked()"),self.disconnectClicked) qt.TQObject.connect(self.disconnectbtn, qt.SIGNAL("clicked()"),self.disconnectClicked)
tablebox = qt.QHBox(parent) tablebox = qt.TQHBox(parent)
tablelabel = qt.QLabel("Table:",tablebox) tablelabel = qt.TQLabel("Table:",tablebox)
self.tableedit = qt.QLineEdit(self.plugin.options['table'],tablebox) self.tableedit = qt.TQLineEdit(self.plugin.options['table'],tablebox)
qt.QObject.connect(self.tableedit, qt.SIGNAL("textChanged(const QString&)"), self.tableEditChanged) qt.TQObject.connect(self.tableedit, qt.SIGNAL("textChanged(const QString&)"), self.tableEditChanged)
self.tablebtn = qt.QPushButton("...",tablebox) self.tablebtn = qt.TQPushButton("...",tablebox)
self.tablebtn.setEnabled(False) self.tablebtn.setEnabled(False)
qt.QObject.connect(self.tablebtn, qt.SIGNAL("clicked()"), self.tableBtnClicked) qt.TQObject.connect(self.tablebtn, qt.SIGNAL("clicked()"), self.tableBtnClicked)
tablelabel.setBuddy(self.tableedit) tablelabel.setBuddy(self.tableedit)
tablebox.setStretchFactor(self.tableedit,1) tablebox.setStretchFactor(self.tableedit,1)
fieldbox = qt.QHBox(parent) fieldbox = qt.TQHBox(parent)
fieldlabel = qt.QLabel("Fields:",fieldbox) fieldlabel = qt.TQLabel("Fields:",fieldbox)
self.fieldedit = qt.QLineEdit(self.plugin.options['fields'],fieldbox) self.fieldedit = qt.TQLineEdit(self.plugin.options['fields'],fieldbox)
self.fieldbtn = qt.QPushButton("...",fieldbox) self.fieldbtn = qt.TQPushButton("...",fieldbox)
self.fieldbtn.setEnabled(False) self.fieldbtn.setEnabled(False)
qt.QObject.connect(self.fieldbtn, qt.SIGNAL("clicked()"), self.fieldBtnClicked) qt.TQObject.connect(self.fieldbtn, qt.SIGNAL("clicked()"), self.fieldBtnClicked)
fieldlabel.setBuddy(self.fieldedit) fieldlabel.setBuddy(self.fieldedit)
fieldbox.setStretchFactor(self.fieldedit,1) fieldbox.setStretchFactor(self.fieldedit,1)
if self.plugin.plugintype == "Source": if self.plugin.plugintype == "Source":
box = qt.QHBox(parent) box = qt.TQHBox(parent)
wherelabel = qt.QLabel("Where:",box) wherelabel = qt.TQLabel("Where:",box)
self.whereedit = qt.QLineEdit(self.plugin.options['where'],box) self.whereedit = qt.TQLineEdit(self.plugin.options['where'],box)
wherelabel.setBuddy(self.whereedit) wherelabel.setBuddy(self.whereedit)
box.setStretchFactor(self.whereedit,1) box.setStretchFactor(self.whereedit,1)
elif self.plugin.plugintype == "Destination": elif self.plugin.plugintype == "Destination":
class OperationBox(qt.QVBox): class OperationBox(qt.TQVBox):
def __init__(self, mainwidget, parent): def __init__(self, mainwidget, parent):
self.mainwidget = mainwidget self.mainwidget = mainwidget
qt.QVBox.__init__(self, parent) qt.TQVBox.__init__(self, parent)
opbox = qt.QHBox(self) opbox = qt.TQHBox(self)
operationlabel = qt.QLabel("Operation:",opbox) operationlabel = qt.TQLabel("Operation:",opbox)
self.mainwidget.operationedit = qt.QComboBox(opbox) self.mainwidget.operationedit = qt.TQComboBox(opbox)
for op in ('Insert','Update'): for op in ('Insert','Update'):
self.mainwidget.operationedit.insertItem(op) self.mainwidget.operationedit.insertItem(op)
if self.mainwidget.plugin.options['operation'] == op: if self.mainwidget.plugin.options['operation'] == op:
@ -381,7 +381,7 @@ class CopyCenterPlugin:
operationlabel.setBuddy(self.mainwidget.operationedit) operationlabel.setBuddy(self.mainwidget.operationedit)
opbox.setStretchFactor(self.mainwidget.operationedit,1) opbox.setStretchFactor(self.mainwidget.operationedit,1)
self.box = None self.box = None
qt.QObject.connect(self.mainwidget.operationedit, qt.SIGNAL("activated(int)"), self.operationActivated) qt.TQObject.connect(self.mainwidget.operationedit, qt.SIGNAL("activated(int)"), self.operationActivated)
self.operationActivated() self.operationActivated()
def operationActivated(self, **args): def operationActivated(self, **args):
if self.box: if self.box:
@ -391,9 +391,9 @@ class CopyCenterPlugin:
def showInsert(self): def showInsert(self):
pass pass
def showUpdate(self): def showUpdate(self):
self.box = qt.QHBox(self) self.box = qt.TQHBox(self)
indexlabel = qt.QLabel("Indexfield:", self.box) indexlabel = qt.TQLabel("Indexfield:", self.box)
self.mainwidget.indexedit = qt.QLineEdit(self.mainwidget.plugin.options['indexfield'], self.box) self.mainwidget.indexedit = qt.TQLineEdit(self.mainwidget.plugin.options['indexfield'], self.box)
indexlabel.setBuddy(self.mainwidget.indexedit) indexlabel.setBuddy(self.mainwidget.indexedit)
self.box.setStretchFactor(self.mainwidget.indexedit,1) self.box.setStretchFactor(self.mainwidget.indexedit,1)
{ {
@ -451,14 +451,14 @@ class CopyCenterPlugin:
return True return True
print "trying to connect..." print "trying to connect..."
import qtsql from TQt import qtsql
drivername = str(self.driveredit.currentText()) drivername = str(self.driveredit.currentText())
print "drivername: %s" % drivername print "drivername: %s" % drivername
connectionname = "CopyCenter%s" % self.plugin.plugintype connectionname = "CopyCenter%s" % self.plugin.plugintype
print "connectionname: %s" % connectionname print "connectionname: %s" % connectionname
self.plugin.database = qtsql.QSqlDatabase.addDatabase(drivername,connectionname) self.plugin.database = qtsql.TQSqlDatabase.addDatabase(drivername,connectionname)
if not self.plugin.database: if not self.plugin.database:
qt.QMessageBox.critical(self,"Failed to connect","<qt>Failed to create database for driver \"%s\"</qt>" % drivername) qt.TQMessageBox.critical(self,"Failed to connect","<qt>Failed to create database for driver \"%s\"</qt>" % drivername)
return False return False
hostname = str(self.hostedit.text()) hostname = str(self.hostedit.text())
@ -477,7 +477,7 @@ class CopyCenterPlugin:
self.plugin.database.setDatabaseName(databasename) self.plugin.database.setDatabaseName(databasename)
if not self.plugin.database.open(): if not self.plugin.database.open():
qt.QMessageBox.critical(self,"Failed to connect","<qt>%s<br><br>%s</qt>" % (self.plugin.database.lastError().driverText(),self.plugin.database.lastError().databaseText())) qt.TQMessageBox.critical(self,"Failed to connect","<qt>%s<br><br>%s</qt>" % (self.plugin.database.lastError().driverText(),self.plugin.database.lastError().databaseText()))
return False return False
print "database is opened now!" print "database is opened now!"
self.updateConnectState() self.updateConnectState()

@ -16,30 +16,30 @@ Dual-licensed under LGPL v2+higher and the BSD license.
import os, sys import os, sys
try: try:
import qt from TQt import qt
except (ImportError): except (ImportError):
raise "Failed to import the required PyQt python module." raise "Failed to import the required PyTQt python module."
class Dialog(qt.QDialog): class Dialog(tqt.QDialog):
def __init__(self, scriptpath, parent): def __init__(self, scriptpath, parent):
self.scriptpath = scriptpath self.scriptpath = scriptpath
import krosskspreadcore import krosskspreadcore
self.doc = krosskspreadcore.get("KSpreadDocument") self.doc = krosskspreadcore.get("KSpreadDocument")
import qt from TQt import qt
qt.QDialog.__init__(self, parent, "Dialog", 1, qt.Qt.WDestructiveClose) qt.TQDialog.__init__(self, parent, "Dialog", 1, qt.TQt.WDestructiveClose)
self.setCaption("Export to HTML File") self.setCaption("Export to HTML File")
layout = qt.QVBoxLayout(self) layout = qt.TQVBoxLayout(self)
box = qt.QVBox(self) box = qt.TQVBox(self)
box.setMargin(10) box.setMargin(10)
box.setSpacing(10) box.setSpacing(10)
layout.addWidget(box) layout.addWidget(box)
sheetbox = qt.QHBox(box) sheetbox = qt.TQHBox(box)
sheetbox.setSpacing(6) sheetbox.setSpacing(6)
sheetlabel = qt.QLabel("Sheet:",sheetbox) sheetlabel = qt.TQLabel("Sheet:",sheetbox)
self.sheetcombo = qt.QComboBox(sheetbox) self.sheetcombo = qt.TQComboBox(sheetbox)
currentsheetname = self.doc.currentSheet().name() currentsheetname = self.doc.currentSheet().name()
for sheetname in self.doc.sheetNames(): for sheetname in self.doc.sheetNames():
self.sheetcombo.insertItem(sheetname) self.sheetcombo.insertItem(sheetname)
@ -65,10 +65,10 @@ class Dialog(qt.QDialog):
, ,
} }
stylebox = qt.QHBox(box) stylebox = qt.TQHBox(box)
stylebox.setSpacing(6) stylebox.setSpacing(6)
stylelabel = qt.QLabel("Style:",stylebox) stylelabel = qt.TQLabel("Style:",stylebox)
self.stylecombo = qt.QComboBox(stylebox) self.stylecombo = qt.TQComboBox(stylebox)
stylenames = self.styles.keys() stylenames = self.styles.keys()
stylenames.sort() stylenames.sort()
for stylename in stylenames: for stylename in stylenames:
@ -76,30 +76,30 @@ class Dialog(qt.QDialog):
stylelabel.setBuddy(self.stylecombo) stylelabel.setBuddy(self.stylecombo)
stylebox.setStretchFactor(self.stylecombo,1) stylebox.setStretchFactor(self.stylecombo,1)
filebox = qt.QHBox(box) filebox = qt.TQHBox(box)
filebox.setSpacing(6) filebox.setSpacing(6)
filelabel = qt.QLabel("File:",filebox) filelabel = qt.TQLabel("File:",filebox)
self.fileedit = qt.QLineEdit(self.getDefaultFile(),filebox) self.fileedit = qt.TQLineEdit(self.getDefaultFile(),filebox)
btn = qt.QPushButton("...",filebox) btn = qt.TQPushButton("...",filebox)
qt.QObject.connect(btn, qt.SIGNAL("clicked()"),self.browseClicked) qt.TQObject.connect(btn, qt.SIGNAL("clicked()"),self.browseClicked)
filelabel.setBuddy(self.fileedit) filelabel.setBuddy(self.fileedit)
filebox.setStretchFactor(self.fileedit,1) filebox.setStretchFactor(self.fileedit,1)
btnbox = qt.QHBox(box) btnbox = qt.TQHBox(box)
btnbox.setSpacing(6) btnbox.setSpacing(6)
okbtn = qt.QPushButton(btnbox) okbtn = qt.TQPushButton(btnbox)
okbtn.setText("Export") okbtn.setText("Export")
okbtn.setDefault(True) okbtn.setDefault(True)
qt.QObject.connect(okbtn,qt.SIGNAL("clicked()"),self.startExport) qt.TQObject.connect(okbtn,qt.SIGNAL("clicked()"),self.startExport)
cancelbtn = qt.QPushButton(btnbox) cancelbtn = qt.TQPushButton(btnbox)
cancelbtn.setText("Cancel") cancelbtn.setText("Cancel")
qt.QObject.connect(cancelbtn,qt.SIGNAL("clicked()"),self.close) qt.TQObject.connect(cancelbtn,qt.SIGNAL("clicked()"),self.close)
box.setMinimumWidth(480) box.setMinimumWidth(480)
def browseClicked(self): def browseClicked(self):
import qt from TQt import qt
filename = str( qt.QFileDialog.getSaveFileName(str(self.fileedit.text()),"*.htm *.html *.xhtml;;*", self) ) filename = str( qt.TQFileDialog.getSaveFileName(str(self.fileedit.text()),"*.htm *.html *.xhtml;;*", self) )
if filename != "": self.fileedit.setText(filename) if filename != "": self.fileedit.setText(filename)
def getDefaultFile(self): def getDefaultFile(self):
@ -119,7 +119,7 @@ class Dialog(qt.QDialog):
return os.path.join(homepath, "kspreadexport.html") return os.path.join(homepath, "kspreadexport.html")
def startExport(self): def startExport(self):
import qt from TQt import qt
sheetname = str( self.sheetcombo.currentText() ) sheetname = str( self.sheetcombo.currentText() )
sheet = self.doc.sheetByName( sheetname ) sheet = self.doc.sheetByName( sheetname )
@ -129,7 +129,7 @@ class Dialog(qt.QDialog):
try: try:
file = open(filename, "w") file = open(filename, "w")
except IOError, (errno, strerror): except IOError, (errno, strerror):
qt.QMessageBox.critical(self,"Error","<qt>Failed to create HTML file \"%s\"<br><br>%s</qt>" % (filename,strerror)) qt.TQMessageBox.critical(self,"Error","<qt>Failed to create HTML file \"%s\"<br><br>%s</qt>" % (filename,strerror))
return return
file.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n") file.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n")
@ -170,7 +170,7 @@ class Dialog(qt.QDialog):
if __name__ == "__main__": if __name__ == "__main__":
scriptpath = os.getcwd() scriptpath = os.getcwd()
qtapp = qt.QApplication(sys.argv) qtapp = qt.TQApplication(sys.argv)
else: else:
scriptpath = os.path.dirname(__name__) scriptpath = os.path.dirname(__name__)
qtapp = qt.tqApp qtapp = qt.tqApp

@ -14,30 +14,30 @@ Dual-licensed under LGPL v2+higher and the BSD license.
import os, sys import os, sys
try: try:
import qt from TQt import qt
except (ImportError): except (ImportError):
raise "Failed to import the required PyQt python module." raise "Failed to import the required PyTQt python module."
#################################################################################### ####################################################################################
# Samples. # Samples.
class Widget(qt.QHBox): class Widget(qt.TQHBox):
def __init__(self, parentwidget, label = None): def __init__(self, parentwidget, label = None):
self.parentwidget = parentwidget self.parentwidget = parentwidget
import qt from TQt import qt
qt.QHBox.__init__(self, parentwidget) qt.TQHBox.__init__(self, parentwidget)
self.setMargin(4) self.setMargin(4)
self.setSpacing(4) self.setSpacing(4)
if label != None: qt.QLabel(label, self) if label != None: qt.TQLabel(label, self)
def value(self): def value(self):
return None return None
class ListWidget(Widget): class ListWidget(Widget):
def __init__(self, parentwidget, label): def __init__(self, parentwidget, label):
import qt from TQt import qt
global Widget global Widget
Widget.__init__(self, parentwidget, label) Widget.__init__(self, parentwidget, label)
self.combo = qt.QComboBox(self) self.combo = qt.TQComboBox(self)
self.combo.setEditable(True) self.combo.setEditable(True)
self.setStretchFactor(self.combo,1) self.setStretchFactor(self.combo,1)
def value(self): def value(self):
@ -45,10 +45,10 @@ class ListWidget(Widget):
class EditWidget(Widget): class EditWidget(Widget):
def __init__(self, parentwidget, label): def __init__(self, parentwidget, label):
import qt from TQt import qt
global Widget global Widget
Widget.__init__(self, parentwidget, label) Widget.__init__(self, parentwidget, label)
self.edit = qt.QLineEdit(self) self.edit = qt.TQLineEdit(self)
self.setStretchFactor(self.edit,1) self.setStretchFactor(self.edit,1)
def value(self): def value(self):
return self.edit.text() return self.edit.text()
@ -57,20 +57,20 @@ class FileWidget(Widget):
def __init__(self, parentwidget, label, filtermask, openfiledialog = True): def __init__(self, parentwidget, label, filtermask, openfiledialog = True):
self.filtermask = filtermask self.filtermask = filtermask
self.openfiledialog = openfiledialog self.openfiledialog = openfiledialog
import qt from TQt import qt
global Widget global Widget
Widget.__init__(self, parentwidget, label) Widget.__init__(self, parentwidget, label)
self.edit = qt.QLineEdit(self) self.edit = qt.TQLineEdit(self)
self.setStretchFactor(self.edit,1) self.setStretchFactor(self.edit,1)
btn = qt.QPushButton("...",self) btn = qt.TQPushButton("...",self)
qt.QObject.connect(btn, qt.SIGNAL("clicked()"), self.btnClicked) qt.TQObject.connect(btn, qt.SIGNAL("clicked()"), self.btnClicked)
def btnClicked(self): def btnClicked(self):
import qt from TQt import qt
text = str( self.edit.text() ) text = str( self.edit.text() )
if self.openfiledialog: if self.openfiledialog:
filename = str( qt.QFileDialog.getOpenFileName(text, self.filtermask, self.parentwidget) ) filename = str( qt.TQFileDialog.getOpenFileName(text, self.filtermask, self.parentwidget) )
else: else:
filename = qt.QFileDialog.getSaveFileName(text, self.filtermask, self.parentwidget) filename = qt.TQFileDialog.getSaveFileName(text, self.filtermask, self.parentwidget)
if filename != "": self.edit.setText( filename ) if filename != "": self.edit.setText( filename )
def value(self): def value(self):
return self.edit.text() return self.edit.text()
@ -383,8 +383,8 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'# Import the PyQt module.', '# Import the PyTQt module.',
'import qt', 'from TQt import qt',
'', '',
'def loadFile(filename):', 'def loadFile(filename):',
' # Import the krosskspreadcore module.', ' # Import the krosskspreadcore module.',
@ -395,7 +395,7 @@ class Samples:
' xml = file.read()', ' xml = file.read()',
' file.close()', ' file.close()',
' except IOError, (errno, strerror):', ' except IOError, (errno, strerror):',
' qt.QMessageBox.critical(self,"Error","<qt>Failed to read file %s<br><br>%s</qt>" % (filename,strerror))', ' qt.TQMessageBox.critical(self,"Error","<qt>Failed to read file %s<br><br>%s</qt>" % (filename,strerror))',
' return', ' return',
'', '',
' # Get the current document.', ' # Get the current document.',
@ -405,7 +405,7 @@ class Samples:
'', '',
'# Show the openfile dialog', '# Show the openfile dialog',
'filename = "{FileName}"', 'filename = "{FileName}"',
'openfilename = qt.QFileDialog.getOpenFileName(filename,"*.xml;;*", self)', 'openfilename = qt.TQFileDialog.getOpenFileName(filename,"*.xml;;*", self)',
'if str(openfilename) != "":', 'if str(openfilename) != "":',
' loadFile( openfilename )', ' loadFile( openfilename )',
) )
@ -420,8 +420,8 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'# Import the PyQt module.', '# Import the PyTQt module.',
'import qt', 'from TQt import qt',
'', '',
'def saveFile(filename):', 'def saveFile(filename):',
' # Import the krosskspreadcore module.', ' # Import the krosskspreadcore module.',
@ -430,7 +430,7 @@ class Samples:
' try:', ' try:',
' file = open(filename, "w")', ' file = open(filename, "w")',
' except IOError, (errno, strerror):', ' except IOError, (errno, strerror):',
' qt.QMessageBox.critical(self,"Error","<qt>Failed to create file %s<br><br>%s</qt>" % (filename,strerror))', ' qt.TQMessageBox.critical(self,"Error","<qt>Failed to create file %s<br><br>%s</qt>" % (filename,strerror))',
' return', ' return',
' # Get the current document.', ' # Get the current document.',
' document = krosskspreadcore.get("KSpreadDocument")', ' document = krosskspreadcore.get("KSpreadDocument")',
@ -443,7 +443,7 @@ class Samples:
'', '',
'# Show the savefile dialog', '# Show the savefile dialog',
'filename = "{FileName}"', 'filename = "{FileName}"',
'savefilename = qt.QFileDialog.getSaveFileName(filename,"*.xml;;*", self)', 'savefilename = qt.TQFileDialog.getSaveFileName(filename,"*.xml;;*", self)',
'if str(savefilename) != "":', 'if str(savefilename) != "":',
' saveFile( savefilename )', ' saveFile( savefilename )',
) )
@ -554,9 +554,9 @@ class Samples:
#################################################################################### ####################################################################################
# PyQt # PyTQt
class PyQt: class PyTQt:
def __init__(self, parentwidget): def __init__(self, parentwidget):
self.parentwidget = parentwidget self.parentwidget = parentwidget
@ -570,8 +570,8 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'import qt', 'from TQt import qt',
'openfilename = qt.QFileDialog.getOpenFileName("{FileName}","*.txt *.html;;*", self)', 'openfilename = qt.TQFileDialog.getOpenFileName("{FileName}","*.txt *.html;;*", self)',
'print "openfile=%s" % openfilename', 'print "openfile=%s" % openfilename',
) )
@ -585,8 +585,8 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'import qt', 'from TQt import qt',
'savefilename = qt.QFileDialog.getSaveFileName("{FileName}","*.txt *.html;;*", self)', 'savefilename = qt.TQFileDialog.getSaveFileName("{FileName}","*.txt *.html;;*", self)',
'print "savefile=%s" % savefilename', 'print "savefile=%s" % savefilename',
) )
@ -599,18 +599,18 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'import qt', 'from TQt import qt',
'', '',
'class MyDialog(qt.QDialog):', 'class MyDialog(qt.TQDialog):',
' def __init__(self, parent):', ' def __init__(self, parent):',
' import qt', ' from TQt import qt',
' qt.QDialog.__init__(self, parent, "MyDialog", 1, qt.Qt.WDestructiveClose)', ' qt.TQDialog.__init__(self, parent, "MyDialog", 1, qt.TQt.WDestructiveClose)',
' self.setCaption("My Dialog")', ' self.setCaption("My Dialog")',
' btn = qt.QPushButton("Click me",self)', ' btn = qt.TQPushButton("Click me",self)',
' qt.QObject.connect(btn, qt.SIGNAL("clicked()"), self.buttonClicked)', ' qt.TQObject.connect(btn, qt.SIGNAL("clicked()"), self.buttonClicked)',
' def buttonClicked(self):', ' def buttonClicked(self):',
' import qt', ' from TQt import qt',
' qt.QMessageBox.information(self, "The Caption", "This is the message string.")', ' qt.TQMessageBox.information(self, "The Caption", "This is the message string.")',
'', '',
'dialog = MyDialog(self)', 'dialog = MyDialog(self)',
'dialog.exec_loop()', 'dialog.exec_loop()',
@ -627,9 +627,9 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'import qt', 'from TQt import qt',
'', '',
'text, ok = qt.QInputDialog.getText("{Caption}", "{Message}", qt.QLineEdit.Normal, "")', 'text, ok = qt.TQInputDialog.getText("{Caption}", "{Message}", qt.TQLineEdit.Normal, "")',
'if ok:', 'if ok:',
' print "Text defined: %s" % text', ' print "Text defined: %s" % text',
'else:', 'else:',
@ -651,12 +651,13 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'import qt, tdecore, dcop, dcopext', 'from TQt import qt',
'import tdecore, dcop, dcopext',
'dcopclient = tdecore.TDEApplication.dcopClient()', 'dcopclient = tdecore.TDEApplication.dcopClient()',
'apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith("klipper") ]', 'apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith("klipper") ]',
'd = dcopext.DCOPApp(apps[0], dcopclient)', 'd = dcopext.DCOPApp(apps[0], dcopclient)',
'result,typename,data = d.appclient.call(apps[0],"klipper","getClipboardContents()","")', 'result,typename,data = d.appclient.call(apps[0],"klipper","getClipboardContents()","")',
'ds = qt.QDataStream(data, qt.IO_ReadOnly)', 'ds = qt.TQDataStream(data, qt.IO_ReadOnly)',
'print "Clipboard content:\\n%s" % tdecore.dcop_next(ds, TQSTRING_OBJECT_NAME_STRING)', 'print "Clipboard content:\\n%s" % tdecore.dcop_next(ds, TQSTRING_OBJECT_NAME_STRING)',
) )
@ -668,7 +669,8 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'import qt, tdecore, dcop, dcopext', 'from TQt import qt',
'import tdecore, dcop, dcopext',
'', '',
'dcopclient = tdecore.TDEApplication.dcopClient()', 'dcopclient = tdecore.TDEApplication.dcopClient()',
'apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith("amarok") ]', 'apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith("amarok") ]',
@ -676,8 +678,9 @@ class Samples:
'd = dcopext.DCOPApp(app, dcopclient)', 'd = dcopext.DCOPApp(app, dcopclient)',
'', '',
'def dataToList(data, types = []):', 'def dataToList(data, types = []):',
' import qt, tdecore', ' from TQt import qt',
' ds = qt.QDataStream(data, qt.IO_ReadOnly)', ' import tdecore',
' ds = qt.TQDataStream(data, qt.IO_ReadOnly)',
' return [ tdecore.dcop_next(ds, t) for t in types ]', ' return [ tdecore.dcop_next(ds, t) for t in types ]',
'', '',
'for funcname in ["totalAlbums","totalArtists","totalCompilations","totalGenres","totalTracks"]:', 'for funcname in ["totalAlbums","totalArtists","totalCompilations","totalGenres","totalTracks"]:',
@ -693,7 +696,8 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'import qt, tdecore, dcop, dcopext', 'from TQt import qt',
'import tdecore, dcop, dcopext',
'', '',
'dcopclient = tdecore.TDEApplication.dcopClient()', 'dcopclient = tdecore.TDEApplication.dcopClient()',
'apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith("kopete") ]', 'apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith("kopete") ]',
@ -703,7 +707,7 @@ class Samples:
'(state,rtype,rdata) = d.appclient.call("kopete", "KopeteIface", "contacts()","")', '(state,rtype,rdata) = d.appclient.call("kopete", "KopeteIface", "contacts()","")',
'if not state: raise "Failed to call the kopete contacts-function"', 'if not state: raise "Failed to call the kopete contacts-function"',
'', '',
'ds = qt.QDataStream(rdata.data(), qt.IO_ReadOnly)', 'ds = qt.TQDataStream(rdata.data(), qt.IO_ReadOnly)',
'sl = tdecore.dcop_next (ds, TQSTRINGLIST_OBJECT_NAME_STRING)', 'sl = tdecore.dcop_next (ds, TQSTRINGLIST_OBJECT_NAME_STRING)',
'print "contacts=%s" % [ str(s) for s in sl ]', 'print "contacts=%s" % [ str(s) for s in sl ]',
) )
@ -716,16 +720,19 @@ class Samples:
} }
def getCode(self): def getCode(self):
return ( return (
'import qt, tdecore, dcop, dcopext', 'from TQt import qt',
'import tdecore, dcop, dcopext',
'', '',
'def dataToList(data, types = []):', 'def dataToList(data, types = []):',
' import qt, tdecore', ' from TQt import qt',
' ds = qt.QDataStream(data, qt.IO_ReadOnly)', ' import tdecore',
' ds = qt.TQDataStream(data, qt.IO_ReadOnly)',
' return [ tdecore.dcop_next(ds, t) for t in types ]', ' return [ tdecore.dcop_next(ds, t) for t in types ]',
'def listToData(listdict):', 'def listToData(listdict):',
' import qt, tdecore', ' from TQt import qt',
' ba= qt.QByteArray()', ' import tdecore',
' ds = qt.QDataStream(ba, qt.IO_WriteOnly)', ' ba= qt.TQByteArray()',
' ds = qt.TQDataStream(ba, qt.IO_WriteOnly)',
' for (typename,value) in listdict:', ' for (typename,value) in listdict:',
' tdecore.dcop_add (ds, value, typename)', ' tdecore.dcop_add (ds, value, typename)',
' return ba', ' return ba',
@ -758,48 +765,48 @@ class Samples:
#################################################################################### ####################################################################################
# Dialog implementations. # Dialog implementations.
class SampleDialog(qt.QDialog): class SampleDialog(qt.TQDialog):
def __init__(self, parent, sampleclazz, samplechildclazz): def __init__(self, parent, sampleclazz, samplechildclazz):
import qt from TQt import qt
qt.QDialog.__init__(self, parent, "SampleDialog", 1) qt.TQDialog.__init__(self, parent, "SampleDialog", 1)
layout = qt.QVBoxLayout(self) layout = qt.TQVBoxLayout(self)
box = qt.QVBox(self) box = qt.TQVBox(self)
box.setMargin(4) box.setMargin(4)
box.setSpacing(10) box.setSpacing(10)
layout.addWidget(box) layout.addWidget(box)
self.scrollview = qt.QScrollView(box) self.scrollview = qt.TQScrollView(box)
self.scrollview.setResizePolicy(qt.QScrollView.AutoOne) self.scrollview.setResizePolicy(qt.TQScrollView.AutoOne)
#self.scrollview.setFrameStyle(qt.QFrame.NoFrame); #self.scrollview.setFrameStyle(qt.TQFrame.NoFrame);
self.scrollview.setResizePolicy(qt.QScrollView.AutoOneFit); self.scrollview.setResizePolicy(qt.TQScrollView.AutoOneFit);
self.scrollview.viewport().setPaletteBackgroundColor(self.paletteBackgroundColor()) self.scrollview.viewport().setPaletteBackgroundColor(self.paletteBackgroundColor())
mainbox = qt.QVBox( self.scrollview.viewport() ) mainbox = qt.TQVBox( self.scrollview.viewport() )
mainbox.setMargin(6) mainbox.setMargin(6)
mainbox.setSpacing(6) mainbox.setSpacing(6)
desclabel = qt.QLabel(mainbox) desclabel = qt.TQLabel(mainbox)
qt.QFrame(mainbox).setFrameStyle( qt.QFrame.HLine | qt.QFrame.Sunken ) qt.TQFrame(mainbox).setFrameStyle( qt.TQFrame.HLine | qt.TQFrame.Sunken )
self.sample = sampleclazz( mainbox ) self.sample = sampleclazz( mainbox )
self.samplechild = samplechildclazz( self.sample ) self.samplechild = samplechildclazz( self.sample )
desclabel.setText( "<qt>%s</qt>" % self.samplechild.__doc__ ) desclabel.setText( "<qt>%s</qt>" % self.samplechild.__doc__ )
mainbox.setStretchFactor(qt.QWidget(mainbox), 1) mainbox.setStretchFactor(qt.TQWidget(mainbox), 1)
mainbox.show() mainbox.show()
self.scrollview.addChild(mainbox) self.scrollview.addChild(mainbox)
btnbox = qt.QHBox(box) btnbox = qt.TQHBox(box)
btnbox.setMargin(6) btnbox.setMargin(6)
btnbox.setSpacing(6) btnbox.setSpacing(6)
okbtn = qt.QPushButton(btnbox) okbtn = qt.TQPushButton(btnbox)
okbtn.setText("Ok") okbtn.setText("Ok")
qt.QObject.connect(okbtn, qt.SIGNAL("clicked()"), self.okClicked) qt.TQObject.connect(okbtn, qt.SIGNAL("clicked()"), self.okClicked)
cancelbtn = qt.QPushButton(btnbox) cancelbtn = qt.TQPushButton(btnbox)
cancelbtn.setText("Cancel") cancelbtn.setText("Cancel")
qt.QObject.connect(cancelbtn, qt.SIGNAL("clicked()"), self.close) qt.TQObject.connect(cancelbtn, qt.SIGNAL("clicked()"), self.close)
self.setCaption(self.samplechild.name) self.setCaption(self.samplechild.name)
box.setMinimumSize(qt.QSize(500,340)) box.setMinimumSize(qt.TQSize(500,340))
def okClicked(self): def okClicked(self):
self.code = self.samplechild.getCode() self.code = self.samplechild.getCode()
@ -816,7 +823,7 @@ class SampleDialog(qt.QDialog):
code = code.replace("{%s}" % widgetname, str(value)) code = code.replace("{%s}" % widgetname, str(value))
return code return code
class MainDialog(qt.QDialog): class MainDialog(qt.TQDialog):
def __init__(self, scriptpath, parent): def __init__(self, scriptpath, parent):
self.scriptpath = scriptpath self.scriptpath = scriptpath
if not hasattr(__main__,"scripteditorfilename"): if not hasattr(__main__,"scripteditorfilename"):
@ -825,118 +832,119 @@ class MainDialog(qt.QDialog):
import krosskspreadcore import krosskspreadcore
self.doc = krosskspreadcore.get("KSpreadDocument") self.doc = krosskspreadcore.get("KSpreadDocument")
import os, qt import os
qt.QDialog.__init__(self, parent, "MainDialog", 1, qt.Qt.WDestructiveClose) from TQt import qt
qt.TQDialog.__init__(self, parent, "MainDialog", 1, qt.TQt.WDestructiveClose)
self.setCaption("Script Editor") self.setCaption("Script Editor")
layout = qt.QVBoxLayout(self) layout = qt.TQVBoxLayout(self)
box = qt.QVBox(self) box = qt.TQVBox(self)
box.setMargin(4) box.setMargin(4)
box.setSpacing(10) box.setSpacing(10)
layout.addWidget(box) layout.addWidget(box)
menu = qt.QMenuBar(box) menu = qt.TQMenuBar(box)
splitter = qt.QSplitter(box) splitter = qt.TQSplitter(box)
splitter.setOrientation(qt.Qt.Vertical) splitter.setOrientation(qt.TQt.Vertical)
self.scripttext = qt.QMultiLineEdit(splitter) self.scripttext = qt.TQMultiLineEdit(splitter)
self.scripttext.setWordWrap( qt.QTextEdit.NoWrap ) self.scripttext.setWordWrap( qt.TQTextEdit.NoWrap )
self.scripttext.setTextFormat( qt.Qt.PlainText ) self.scripttext.setTextFormat( qt.TQt.PlainText )
qt.QObject.connect(self.scripttext, qt.SIGNAL("cursorPositionChanged(int,int)"),self.cursorPositionChanged) qt.TQObject.connect(self.scripttext, qt.SIGNAL("cursorPositionChanged(int,int)"),self.cursorPositionChanged)
self.console = qt.QTextBrowser(splitter) self.console = qt.TQTextBrowser(splitter)
splitter.setResizeMode(self.console, qt.QSplitter.KeepSize) splitter.setResizeMode(self.console, qt.TQSplitter.KeepSize)
statusbar = qt.QStatusBar(box) statusbar = qt.TQStatusBar(box)
self.messagestatus = qt.QLabel(statusbar) self.messagestatus = qt.TQLabel(statusbar)
statusbar.addWidget(self.messagestatus,1) statusbar.addWidget(self.messagestatus,1)
self.cursorstatus = qt.QLabel(statusbar) self.cursorstatus = qt.TQLabel(statusbar)
statusbar.addWidget(self.cursorstatus) statusbar.addWidget(self.cursorstatus)
self.cursorPositionChanged() self.cursorPositionChanged()
box.setMinimumSize( qt.QSize(680,540) ) box.setMinimumSize( qt.TQSize(680,540) )
filemenu = qt.QPopupMenu(menu) filemenu = qt.TQPopupMenu(menu)
menu.insertItem("&File", filemenu) menu.insertItem("&File", filemenu)
newaction = qt.QAction("New", qt.QKeySequence("CTRL+N"), self) newaction = qt.TQAction("New", qt.TQKeySequence("CTRL+N"), self)
qt.QObject.connect(newaction, qt.SIGNAL("activated()"), self.newFile) qt.TQObject.connect(newaction, qt.SIGNAL("activated()"), self.newFile)
newaction.addTo(filemenu) newaction.addTo(filemenu)
openaction = qt.QAction("Open...", qt.QKeySequence("CTRL+O"), self) openaction = qt.TQAction("Open...", qt.TQKeySequence("CTRL+O"), self)
qt.QObject.connect(openaction, qt.SIGNAL("activated()"), self.openFileAs) qt.TQObject.connect(openaction, qt.SIGNAL("activated()"), self.openFileAs)
openaction.addTo(filemenu) openaction.addTo(filemenu)
saveaction = qt.QAction("Save", qt.QKeySequence("CTRL+S"), self) saveaction = qt.TQAction("Save", qt.TQKeySequence("CTRL+S"), self)
qt.QObject.connect(saveaction, qt.SIGNAL("activated()"), self.saveFile) qt.TQObject.connect(saveaction, qt.SIGNAL("activated()"), self.saveFile)
saveaction.addTo(filemenu) saveaction.addTo(filemenu)
saveasaction = qt.QAction("Save as...", qt.QKeySequence("CTRL+A"), self) saveasaction = qt.TQAction("Save as...", qt.TQKeySequence("CTRL+A"), self)
qt.QObject.connect(saveasaction, qt.SIGNAL("activated()"), self.saveFileAs) qt.TQObject.connect(saveasaction, qt.SIGNAL("activated()"), self.saveFileAs)
saveasaction.addTo(filemenu) saveasaction.addTo(filemenu)
filemenu.insertSeparator() filemenu.insertSeparator()
quitaction = qt.QAction("Quit", qt.QKeySequence("CTRL+Q"), self) quitaction = qt.TQAction("Quit", qt.TQKeySequence("CTRL+Q"), self)
qt.QObject.connect(quitaction, qt.SIGNAL("activated()"), self.close) qt.TQObject.connect(quitaction, qt.SIGNAL("activated()"), self.close)
quitaction.addTo(filemenu) quitaction.addTo(filemenu)
editmenu = qt.QPopupMenu(menu) editmenu = qt.TQPopupMenu(menu)
menu.insertItem("&Edit", editmenu) menu.insertItem("&Edit", editmenu)
undoaction = qt.QAction("Undo", qt.QKeySequence("CTRL+Z"), self) undoaction = qt.TQAction("Undo", qt.TQKeySequence("CTRL+Z"), self)
qt.QObject.connect(undoaction, qt.SIGNAL("activated()"), self.scripttext.undo) qt.TQObject.connect(undoaction, qt.SIGNAL("activated()"), self.scripttext.undo)
undoaction.addTo(editmenu) undoaction.addTo(editmenu)
redoaction = qt.QAction("Redo", qt.QKeySequence("CTRL+Shift+Z"), self) redoaction = qt.TQAction("Redo", qt.TQKeySequence("CTRL+Shift+Z"), self)
qt.QObject.connect(redoaction, qt.SIGNAL("activated()"), self.scripttext.redo) qt.TQObject.connect(redoaction, qt.SIGNAL("activated()"), self.scripttext.redo)
redoaction.addTo(editmenu) redoaction.addTo(editmenu)
editmenu.insertSeparator() editmenu.insertSeparator()
cutaction = qt.QAction("Cut", qt.QKeySequence("CTRL+X"), self) cutaction = qt.TQAction("Cut", qt.TQKeySequence("CTRL+X"), self)
qt.QObject.connect(cutaction, qt.SIGNAL("activated()"), self.scripttext.cut) qt.TQObject.connect(cutaction, qt.SIGNAL("activated()"), self.scripttext.cut)
cutaction.addTo(editmenu) cutaction.addTo(editmenu)
copyaction = qt.QAction("Copy", qt.QKeySequence("CTRL+C"), self) copyaction = qt.TQAction("Copy", qt.TQKeySequence("CTRL+C"), self)
qt.QObject.connect(copyaction, qt.SIGNAL("activated()"), self.scripttext.copy) qt.TQObject.connect(copyaction, qt.SIGNAL("activated()"), self.scripttext.copy)
copyaction.addTo(editmenu) copyaction.addTo(editmenu)
pasteaction = qt.QAction("Paste", qt.QKeySequence("CTRL+V"), self) pasteaction = qt.TQAction("Paste", qt.TQKeySequence("CTRL+V"), self)
qt.QObject.connect(pasteaction, qt.SIGNAL("activated()"), self.scripttext.paste) qt.TQObject.connect(pasteaction, qt.SIGNAL("activated()"), self.scripttext.paste)
pasteaction.addTo(editmenu) pasteaction.addTo(editmenu)
clearaction = qt.QAction("Clear", qt.QKeySequence("CTRL+Shift+X"), self) clearaction = qt.TQAction("Clear", qt.TQKeySequence("CTRL+Shift+X"), self)
qt.QObject.connect(clearaction, qt.SIGNAL("activated()"), self.scripttext.clear) qt.TQObject.connect(clearaction, qt.SIGNAL("activated()"), self.scripttext.clear)
clearaction.addTo(editmenu) clearaction.addTo(editmenu)
editmenu.insertSeparator() editmenu.insertSeparator()
selallaction = qt.QAction("Select All", 0, self) selallaction = qt.TQAction("Select All", 0, self)
qt.QObject.connect(selallaction, qt.SIGNAL("activated()"), self.scripttext.selectAll) qt.TQObject.connect(selallaction, qt.SIGNAL("activated()"), self.scripttext.selectAll)
selallaction.addTo(editmenu) selallaction.addTo(editmenu)
scriptmenu = qt.QPopupMenu(menu) scriptmenu = qt.TQPopupMenu(menu)
menu.insertItem("&Script", scriptmenu) menu.insertItem("&Script", scriptmenu)
compileaction = qt.QAction("Compile", qt.QKeySequence("F9"), self) compileaction = qt.TQAction("Compile", qt.TQKeySequence("F9"), self)
qt.QObject.connect(compileaction, qt.SIGNAL("activated()"), self.compileScript) qt.TQObject.connect(compileaction, qt.SIGNAL("activated()"), self.compileScript)
compileaction.addTo(scriptmenu) compileaction.addTo(scriptmenu)
executeaction = qt.QAction("Execute", qt.QKeySequence("F10"), self) executeaction = qt.TQAction("Execute", qt.TQKeySequence("F10"), self)
qt.QObject.connect(executeaction, qt.SIGNAL("activated()"), self.executeScript) qt.TQObject.connect(executeaction, qt.SIGNAL("activated()"), self.executeScript)
executeaction.addTo(scriptmenu) executeaction.addTo(scriptmenu)
self.samplemenu = qt.QPopupMenu(menu) self.samplemenu = qt.TQPopupMenu(menu)
menu.insertItem("&Samples", self.samplemenu) menu.insertItem("&Samples", self.samplemenu)
itemid = 500 itemid = 500
global Samples global Samples
for samplename in dir(Samples): for samplename in dir(Samples):
if samplename.startswith("_"): continue if samplename.startswith("_"): continue
itemid += 1 itemid += 1
menu = qt.QPopupMenu(self.samplemenu) menu = qt.TQPopupMenu(self.samplemenu)
qt.QObject.connect(menu, qt.SIGNAL("activated(int)"), self.sampleActivated) qt.TQObject.connect(menu, qt.SIGNAL("activated(int)"), self.sampleActivated)
self.samplemenu.insertItem(samplename, menu, -1, self.samplemenu.count() - 1) self.samplemenu.insertItem(samplename, menu, -1, self.samplemenu.count() - 1)
attr = getattr(Samples,samplename) attr = getattr(Samples,samplename)
for a in dir(attr): for a in dir(attr):
@ -1040,7 +1048,7 @@ class MainDialog(qt.QDialog):
def newFile(self): def newFile(self):
self.console.clear() self.console.clear()
#if qt.QMessageBox.warning(self,"Remove?","Remove the selected item?",qt.QMessageBox.Yes,qt.QMessageBox.Cancel) != qt.QMessageBox.Yes: #if qt.TQMessageBox.warning(self,"Remove?","Remove the selected item?",qt.TQMessageBox.Yes,qt.TQMessageBox.Cancel) != qt.TQMessageBox.Yes:
self.scripttext.clear() self.scripttext.clear()
def openFile(self, filename): def openFile(self, filename):
@ -1051,12 +1059,12 @@ class MainDialog(qt.QDialog):
file.close() file.close()
__main__.scripteditorfilename = filename __main__.scripteditorfilename = filename
except IOError, (errno, strerror): except IOError, (errno, strerror):
qt.QMessageBox.critical(self,"Error","<qt>Failed to open script file \"%s\"<br><br>%s</qt>" % (filename,strerror)) qt.TQMessageBox.critical(self,"Error","<qt>Failed to open script file \"%s\"<br><br>%s</qt>" % (filename,strerror))
def openFileAs(self): def openFileAs(self):
import qt from TQt import qt
self.console.clear() self.console.clear()
filename = str( qt.QFileDialog.getOpenFileName(__main__.scripteditorfilename,"*.py;;*", self) ) filename = str( qt.TQFileDialog.getOpenFileName(__main__.scripteditorfilename,"*.py;;*", self) )
if filename == "": return if filename == "": return
self.openFile(filename) self.openFile(filename)
@ -1066,11 +1074,11 @@ class MainDialog(qt.QDialog):
file.write( str( self.scripttext.text() ) ) file.write( str( self.scripttext.text() ) )
file.close() file.close()
except IOError, (errno, strerror): except IOError, (errno, strerror):
qt.QMessageBox.critical(self,"Error","<qt>Failed to open script file \"%s\"<br><br>%s</qt>" % (__main__.scripteditorfilename,strerror)) qt.TQMessageBox.critical(self,"Error","<qt>Failed to open script file \"%s\"<br><br>%s</qt>" % (__main__.scripteditorfilename,strerror))
def saveFileAs(self): def saveFileAs(self):
import qt from TQt import qt
filename = str( qt.QFileDialog.getSaveFileName(__main__.scripteditorfilename,"*.py;;*", self) ) filename = str( qt.TQFileDialog.getSaveFileName(__main__.scripteditorfilename,"*.py;;*", self) )
if filename == "": return if filename == "": return
__main__.scripteditorfilename = filename __main__.scripteditorfilename = filename
self.saveFile() self.saveFile()
@ -1080,7 +1088,7 @@ class MainDialog(qt.QDialog):
if __name__ == "__main__": if __name__ == "__main__":
scriptpath = os.getcwd() scriptpath = os.getcwd()
qtapp = qt.QApplication(sys.argv) qtapp = qt.TQApplication(sys.argv)
else: else:
scriptpath = os.path.dirname(__name__) scriptpath = os.path.dirname(__name__)
qtapp = qt.tqApp qtapp = qt.tqApp

@ -18,7 +18,7 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
""" """
from qt import * from PyTQt.qt import *
class BasicElement: class BasicElement:
@ -26,8 +26,8 @@ class BasicElement:
def __init__(self, parent): def __init__(self, parent):
self.parent = parent self.parent = parent
self.size = QSize() self.size = TQSize()
self.pos = QPoint() self.pos = TQPoint()
def x(self): return self.pos.x() def x(self): return self.pos.x()
@ -48,7 +48,7 @@ class BasicElement:
x += element.x() x += element.x()
y += element.y() y += element.y()
element = element.parent element = element.parent
return QPoint(x, y) return TQPoint(x, y)
def elementAt(self, point, startPoint): def elementAt(self, point, startPoint):
"""Returns the element that is at position point. """Returns the element that is at position point.
@ -132,7 +132,7 @@ class SequenceElement (BasicElement):
r = BasicElement.elementAt(self, point, startPoint) r = BasicElement.elementAt(self, point, startPoint)
if r != None: if r != None:
for child in self.children: for child in self.children:
r = child.elementAt(point, QPoint(startPoint.x()+child.x(), r = child.elementAt(point, TQPoint(startPoint.x()+child.x(),
startPoint.y()+child.y())) startPoint.y()+child.y()))
if r != None: if r != None:
return r return r
@ -236,13 +236,13 @@ class SequenceElement (BasicElement):
for child in self.children: for child in self.children:
cX = child.x() cX = child.x()
cY = child.y() cY = child.y()
child.draw(painter, styleContext, QPoint(x+cX, y+cY)) child.draw(painter, styleContext, TQPoint(x+cX, y+cY))
# Debug # Debug
#painter.setPen(Qt.green) #painter.setPen(TQt.green)
#painter.drawRect(x, y, self.width(), self.height()) #painter.drawRect(x, y, self.width(), self.height())
else: else:
painter.setPen(Qt.blue) painter.setPen(TQt.blue)
painter.drawRect(x, y, self.width(), self.height()) painter.drawRect(x, y, self.width(), self.height())
def calcSizes(self, styleContext): def calcSizes(self, styleContext):
@ -494,27 +494,27 @@ class IndexElement (BasicElement):
r = BasicElement.elementAt(self, point, startPoint) r = BasicElement.elementAt(self, point, startPoint)
if r != None: if r != None:
x, y = startPoint.x(), startPoint.y() x, y = startPoint.x(), startPoint.y()
r = self.content.elementAt(point, QPoint(x+self.content.x(), r = self.content.elementAt(point, TQPoint(x+self.content.x(),
y+self.content.y())) y+self.content.y()))
if r != None: return r if r != None: return r
if self.upperRight != None: if self.upperRight != None:
r = self.upperRight.elementAt(point, QPoint(x+self.upperRight.x(), r = self.upperRight.elementAt(point, TQPoint(x+self.upperRight.x(),
y+self.upperRight.y())) y+self.upperRight.y()))
if r != None: return r if r != None: return r
if self.upperLeft != None: if self.upperLeft != None:
r = self.upperLeft.elementAt(point, QPoint(x+self.upperLeft.x(), r = self.upperLeft.elementAt(point, TQPoint(x+self.upperLeft.x(),
y+self.upperLeft.y())) y+self.upperLeft.y()))
if r != None: return r if r != None: return r
if self.lowerRight != None: if self.lowerRight != None:
r = self.lowerRight.elementAt(point, QPoint(x+self.lowerRight.x(), r = self.lowerRight.elementAt(point, TQPoint(x+self.lowerRight.x(),
y+self.lowerRight.y())) y+self.lowerRight.y()))
if r != None: return r if r != None: return r
if self.lowerLeft != None: if self.lowerLeft != None:
r = self.lowerLeft.elementAt(point, QPoint(x+self.lowerLeft.x(), r = self.lowerLeft.elementAt(point, TQPoint(x+self.lowerLeft.x(),
y+self.lowerLeft.y())) y+self.lowerLeft.y()))
if r != None: return r if r != None: return r
@ -662,27 +662,27 @@ class IndexElement (BasicElement):
def draw(self, painter, styleContext, startPoint): def draw(self, painter, styleContext, startPoint):
x, y = startPoint.x(), startPoint.y() x, y = startPoint.x(), startPoint.y()
self.content.draw(painter, styleContext, self.content.draw(painter, styleContext,
QPoint(x+self.content.x(), TQPoint(x+self.content.x(),
y+self.content.y())) y+self.content.y()))
if self.upperLeft != None: if self.upperLeft != None:
self.upperLeft.draw(painter, styleContext, self.upperLeft.draw(painter, styleContext,
QPoint(x+self.upperLeft.x(), TQPoint(x+self.upperLeft.x(),
y+self.upperLeft.y())) y+self.upperLeft.y()))
if self.upperRight != None: if self.upperRight != None:
self.upperRight.draw(painter, styleContext, self.upperRight.draw(painter, styleContext,
QPoint(x+self.upperRight.x(), TQPoint(x+self.upperRight.x(),
y+self.upperRight.y())) y+self.upperRight.y()))
if self.lowerLeft != None: if self.lowerLeft != None:
self.lowerLeft.draw(painter, styleContext, self.lowerLeft.draw(painter, styleContext,
QPoint(x+self.lowerLeft.x(), TQPoint(x+self.lowerLeft.x(),
y+self.lowerLeft.y())) y+self.lowerLeft.y()))
if self.lowerRight != None: if self.lowerRight != None:
self.lowerRight.draw(painter, styleContext, self.lowerRight.draw(painter, styleContext,
QPoint(x+self.lowerRight.x(), TQPoint(x+self.lowerRight.x(),
y+self.lowerRight.y())) y+self.lowerRight.y()))
# Debug # Debug
painter.setPen(Qt.red) painter.setPen(TQt.red)
painter.drawRect(x, y, self.width(), self.height()) painter.drawRect(x, y, self.width(), self.height())
@ -896,14 +896,14 @@ class Cursor:
x = min(point.x(), markPoint.x()) x = min(point.x(), markPoint.x())
width = abs(point.x() - markPoint.x()) width = abs(point.x() - markPoint.x())
painter.setRasterOp(Qt.XorROP) painter.setRasterOp(TQt.XorROP)
#painter.setRasterOp(Qt.OrROP) #painter.setRasterOp(TQt.OrROP)
painter.fillRect(x, point.y(), width, height, QBrush(Qt.white)) painter.fillRect(x, point.y(), width, height, TQBrush(TQt.white))
#painter.drawLine(point.x(), point.y()-2, #painter.drawLine(point.x(), point.y()-2,
# point.x(), point.y()+height+2) # point.x(), point.y()+height+2)
painter.setRasterOp(Qt.CopyROP) painter.setRasterOp(TQt.CopyROP)
else: else:
painter.setPen(Qt.blue) painter.setPen(TQt.blue)
painter.drawLine(point.x(), point.y()-2, painter.drawLine(point.x(), point.y()-2,
point.x(), point.y()+height+2) point.x(), point.y()+height+2)
@ -943,7 +943,7 @@ class Cursor:
def addTextElement(self, char): def addTextElement(self, char):
textElement = TextElement(self.sequenceElement, QString(char)) textElement = TextElement(self.sequenceElement, TQString(char))
self.sequenceElement.insertChild(self, textElement) self.sequenceElement.insertChild(self, textElement)
@ -984,39 +984,39 @@ class Cursor:
else: else:
if Qt.Key_BackSpace == action: if TQt.Key_BackSpace == action:
self.sequenceElement.removeChildBefore(self) self.sequenceElement.removeChildBefore(self)
return return
elif Qt.Key_Delete == action: elif TQt.Key_Delete == action:
self.sequenceElement.removeChildAt(self) self.sequenceElement.removeChildAt(self)
return return
self.selectionFlag = state & Qt.ShiftButton self.selectionFlag = state & TQt.ShiftButton
if Qt.Key_Left == action: if TQt.Key_Left == action:
if state & Qt.ControlButton: if state & TQt.ControlButton:
self.sequenceElement.moveHome(self) self.sequenceElement.moveHome(self)
else: else:
self.sequenceElement.moveLeft(self, self.sequenceElement) self.sequenceElement.moveLeft(self, self.sequenceElement)
elif Qt.Key_Right == action: elif TQt.Key_Right == action:
if state & Qt.ControlButton: if state & TQt.ControlButton:
self.sequenceElement.moveEnd(self) self.sequenceElement.moveEnd(self)
else: else:
self.sequenceElement.moveRight(self, self.sequenceElement) self.sequenceElement.moveRight(self, self.sequenceElement)
elif Qt.Key_Up == action: elif TQt.Key_Up == action:
self.sequenceElement.moveUp(self, self.sequenceElement) self.sequenceElement.moveUp(self, self.sequenceElement)
elif Qt.Key_Down == action: elif TQt.Key_Down == action:
self.sequenceElement.moveDown(self, self.sequenceElement) self.sequenceElement.moveDown(self, self.sequenceElement)
elif Qt.Key_Home == action: elif TQt.Key_Home == action:
self.sequenceElement.formula().moveHome(self) self.sequenceElement.formula().moveHome(self)
elif Qt.Key_End == action: elif TQt.Key_End == action:
self.sequenceElement.formula().moveEnd(self) self.sequenceElement.formula().moveEnd(self)
# Qt.Key_PageUp, Qt.Key_PageDown, # TQt.Key_PageUp, TQt.Key_PageDown,
def handleMousePress(self, mouseEvent): def handleMousePress(self, mouseEvent):
formula = self.sequenceElement.formula() formula = self.sequenceElement.formula()
element = formula.elementAt(mouseEvent.pos(), QPoint(0, 0)) element = formula.elementAt(mouseEvent.pos(), TQPoint(0, 0))
if element != None: if element != None:
if element.parent != None: if element.parent != None:
element.moveLeft(self, element.parent) element.moveLeft(self, element.parent)
@ -1032,7 +1032,7 @@ class Cursor:
def handleMouseMove(self, mouseEvent): def handleMouseMove(self, mouseEvent):
self.selectionFlag = 1 self.selectionFlag = 1
formula = self.sequenceElement.formula() formula = self.sequenceElement.formula()
element = formula.elementAt(mouseEvent.pos(), QPoint(0, 0)) element = formula.elementAt(mouseEvent.pos(), TQPoint(0, 0))
if element != None: if element != None:
if element.parent != None: if element.parent != None:
element.parent.moveLeft(self, element) element.parent.moveLeft(self, element)
@ -1057,21 +1057,21 @@ class StyleContext:
draw a formula.""" draw a formula."""
def __init__(self): def __init__(self):
self.font = QFont("helvetica", 18) self.font = TQFont("helvetica", 18)
def setupPainter(self, painter): def setupPainter(self, painter):
painter.setFont(self.font) painter.setFont(self.font)
painter.setPen(Qt.black) painter.setPen(TQt.black)
def fontMetrics(self): def fontMetrics(self):
return QFontMetrics(self.font) return TQFontMetrics(self.font)
class Widget(QWidget): class Widget(TQWidget):
"""The widget that contains a formula.""" """The widget that contains a formula."""
def __init__(self): def __init__(self):
QWidget.__init__(self) TQWidget.__init__(self)
f = self.formula = FormulaElement(self) f = self.formula = FormulaElement(self)
self.cursor = Cursor(self.formula) self.cursor = Cursor(self.formula)
self.styleContext = StyleContext() self.styleContext = StyleContext()
@ -1150,10 +1150,10 @@ class Widget(QWidget):
self.formula.calcSizes(self.styleContext) self.formula.calcSizes(self.styleContext)
self.changedFlag = 0 self.changedFlag = 0
painter = QPainter() painter = TQPainter()
painter.begin(self) painter.begin(self)
try: try:
self.formula.draw(painter, self.styleContext, QPoint(0, 0)) self.formula.draw(painter, self.styleContext, TQPoint(0, 0))
self.cursor.draw(painter) self.cursor.draw(painter)
finally: finally:
painter.end() painter.end()
@ -1177,4 +1177,3 @@ class Widget(QWidget):
def mouseMoveEvent(self, e): def mouseMoveEvent(self, e):
self.cursor.handleMouseMove(e) self.cursor.handleMouseMove(e)
self.update() self.update()

@ -1,11 +1,11 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
from qt import * from TQt.qt import *
from engine import Widget from engine import Widget
a = QApplication(sys.argv) a = TQApplication(sys.argv)
mw = Widget() mw = Widget()
mw.setCaption('Prototype of the formula engine') mw.setCaption('Prototype of the formula engine')
mw.show() mw.show()

@ -1,18 +1,18 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
from qt import * from TQt.qt import *
from xml.sax import saxutils, handler, make_parser from xml.sax import saxutils, handler, make_parser
class Form1(QWidget): class Form1(TQWidget):
def __init__(self,parent = None,name = None,fl = 0): def __init__(self,parent = None,name = None,fl = 0):
QWidget.__init__(self,parent,name,fl) TQWidget.__init__(self,parent,name,fl)
if name == None: if name == None:
self.setName('Form1') self.setName('Form1')
self.setCaption(self.tr('Form1')) self.setCaption(self.tr('Form1'))
grid = QGridLayout(self) grid = TQGridLayout(self)
grid.setSpacing(6) grid.setSpacing(6)
grid.setMargin(11) grid.setMargin(11)
@ -23,18 +23,18 @@ class Form1(QWidget):
end = 256 end = 256
for i in range(begin, end): for i in range(begin, end):
charLabel = QLabel(self,'charLabel' + chr(i)) charLabel = TQLabel(self,'charLabel' + chr(i))
charLabel.setFont(QFont("symbol", 16)) charLabel.setFont(TQFont("symbol", 16))
charLabel.setText(self.tr(chr(i))) charLabel.setText(self.tr(chr(i)))
grid.addWidget(charLabel, i-begin, 0) grid.addWidget(charLabel, i-begin, 0)
number = QLineEdit(self,'Number' + chr(i)) number = TQLineEdit(self,'Number' + chr(i))
grid.addWidget(number, i-begin, 1) grid.addWidget(number, i-begin, 1)
latexName = QLineEdit(self,'latexName' + chr(i)) latexName = TQLineEdit(self,'latexName' + chr(i))
grid.addWidget(latexName, i-begin, 2) grid.addWidget(latexName, i-begin, 2)
charClass = QLineEdit(self,'charClass' + chr(i)) charClass = TQLineEdit(self,'charClass' + chr(i))
grid.addWidget(charClass, i-begin, 3) grid.addWidget(charClass, i-begin, 3)
self.chars[i] = (charLabel, number, latexName, charClass) self.chars[i] = (charLabel, number, latexName, charClass)
@ -52,7 +52,7 @@ class Form1(QWidget):
self.fontName = fontName self.fontName = fontName
for i in self.chars: for i in self.chars:
charLabel, number, latexName, charClass = self.chars[i] charLabel, number, latexName, charClass = self.chars[i]
charLabel.setFont(QFont(fontName, 16)) charLabel.setFont(TQFont(fontName, 16))
number.setText("") number.setText("")
latexName.setText("") latexName.setText("")
charClass.setText("") charClass.setText("")
@ -65,43 +65,43 @@ class Form1(QWidget):
charClassWidget.setText(charClass) charClassWidget.setText(charClass)
class Widget(QWidget): class Widget(TQWidget):
def __init__(self): def __init__(self):
QWidget.__init__(self) TQWidget.__init__(self)
vbox = QVBoxLayout(self) vbox = TQVBoxLayout(self)
vbox.setSpacing(6) vbox.setSpacing(6)
vbox.setMargin(0) vbox.setMargin(0)
hbox = QHBoxLayout() hbox = TQHBoxLayout()
hbox.setSpacing(6) hbox.setSpacing(6)
hbox.setMargin(0) hbox.setMargin(0)
loadButton = QPushButton("load", self) loadButton = TQPushButton("load", self)
saveButton = QPushButton("save", self) saveButton = TQPushButton("save", self)
QObject.connect(loadButton, SIGNAL("pressed()"), self.load) TQObject.connect(loadButton, SIGNAL("pressed()"), self.load)
QObject.connect(saveButton, SIGNAL("pressed()"), self.save) TQObject.connect(saveButton, SIGNAL("pressed()"), self.save)
hbox.addWidget(loadButton) hbox.addWidget(loadButton)
hbox.addWidget(saveButton) hbox.addWidget(saveButton)
vbox.addLayout(hbox) vbox.addLayout(hbox)
splitter = QSplitter(self) splitter = TQSplitter(self)
splitter.setOrientation(Qt.Vertical) splitter.setOrientation(TQt.Vertical)
self.listbox = QListBox(splitter) self.listbox = TQListBox(splitter)
sv = QScrollView(splitter) sv = TQScrollView(splitter)
big_box = QVBox(sv.viewport()) big_box = TQVBox(sv.viewport())
sv.addChild(big_box, 0, 0) sv.addChild(big_box, 0, 0)
self.child = Form1(big_box) self.child = Form1(big_box)
vbox.addWidget(splitter) vbox.addWidget(splitter)
self.connect(self.listbox, SIGNAL('highlighted( const QString& )'), self.connect(self.listbox, SIGNAL('highlighted( const TQString& )'),
self.fontHighlighted) self.fontHighlighted)
def fontHighlighted(self, fontStr): def fontHighlighted(self, fontStr):
@ -178,7 +178,7 @@ class ContentGenerator(handler.ContentHandler):
def main(): def main():
a = QApplication(sys.argv) a = TQApplication(sys.argv)
mw = Widget() mw = Widget()
mw.setCaption('Unicode mapping util') mw.setCaption('Unicode mapping util')

@ -20,7 +20,7 @@
""" """
import sys import sys
import string import string
import qt from TQt import qt
def decode( fd, font, line ): def decode( fd, font, line ):
begin = string.find( line, '"' ) begin = string.find( line, '"' )
@ -39,10 +39,10 @@ def decode( fd, font, line ):
char_list.append( string.atoi( second, 16 ) ) char_list.append( string.atoi( second, 16 ) )
else: else:
char_list.append( string.atoi ( unicode, 16 ) ) char_list.append( string.atoi ( unicode, 16 ) )
fm = qt.QFontMetrics( qt.QFont( font ) ) fm = qt.TQFontMetrics( qt.TQFont( font ) )
in_font = True in_font = True
for c in char_list: for c in char_list:
if not fm.inFont( qt.QChar( c ) ): if not fm.inFont( qt.TQChar( c ) ):
in_font = False in_font = False
fd.write( unicode + ' ' + str( in_font ) + '\n') fd.write( unicode + ' ' + str( in_font ) + '\n')
@ -56,7 +56,7 @@ def parse( file, font ):
line = fd.readline() line = fd.readline()
if __name__ == '__main__': if __name__ == '__main__':
a = qt.QApplication( sys.argv ) a = qt.TQApplication( sys.argv )
if len( sys.argv ) == 2: if len( sys.argv ) == 2:
sys.argv.append( 'Arev Sans' ) sys.argv.append( 'Arev Sans' )
parse ( sys.argv[1], sys.argv[2] ) parse ( sys.argv[1], sys.argv[2] )

@ -180,68 +180,68 @@ class TkDialog:
def close(self): def close(self):
self.root.destroy() self.root.destroy()
class QtDialog: class TQtDialog:
""" This class is used to wrap pyQt/pyKDE into a more abstract interface.""" """ This class is used to wrap PyTQt/PyTDE into a more abstract interface."""
def __init__(self, title): def __init__(self, title):
import qt from TQt import qt
class Dialog(qt.QDialog): class Dialog(qt.TQDialog):
def __init__(self, parent = None, name = None, modal = 0, fl = 0): def __init__(self, parent = None, name = None, modal = 0, fl = 0):
qt.QDialog.__init__(self, parent, name, modal, fl) qt.TQDialog.__init__(self, parent, name, modal, fl)
qt.QDialog.accept = self.accept qt.TQDialog.accept = self.accept
self.layout = qt.QVBoxLayout(self) self.layout = qt.TQVBoxLayout(self)
self.layout.setSpacing(6) self.layout.setSpacing(6)
self.layout.setMargin(11) self.layout.setMargin(11)
class Label(qt.QLabel): class Label(qt.TQLabel):
def __init__(self, dialog, parent, caption): def __init__(self, dialog, parent, caption):
qt.QLabel.__init__(self, parent) qt.TQLabel.__init__(self, parent)
self.setText("<qt>%s</qt>" % caption.replace("\n","<br>")) self.setText("<qt>%s</qt>" % caption.replace("\n","<br>"))
class Frame(qt.QHBox): class Frame(qt.TQHBox):
def __init__(self, dialog, parent): def __init__(self, dialog, parent):
qt.QHBox.__init__(self, parent) qt.TQHBox.__init__(self, parent)
self.widget = self self.widget = self
self.setSpacing(6) self.setSpacing(6)
class Edit(qt.QHBox): class Edit(qt.TQHBox):
def __init__(self, dialog, parent, caption, text): def __init__(self, dialog, parent, caption, text):
qt.QHBox.__init__(self, parent) qt.TQHBox.__init__(self, parent)
self.setSpacing(6) self.setSpacing(6)
label = qt.QLabel(caption, self) label = qt.TQLabel(caption, self)
self.edit = qt.QLineEdit(self) self.edit = qt.TQLineEdit(self)
self.edit.setText( str(text) ) self.edit.setText( str(text) )
self.setStretchFactor(self.edit, 1) self.setStretchFactor(self.edit, 1)
label.setBuddy(self.edit) label.setBuddy(self.edit)
def get(self): def get(self):
return self.edit.text() return self.edit.text()
class Button(qt.QPushButton): class Button(qt.TQPushButton):
#def __init__(self, *args): #def __init__(self, *args):
def __init__(self, dialog, parent, caption, commandmethod): def __init__(self, dialog, parent, caption, commandmethod):
#apply(qt.QPushButton.__init__, (self,) + args) #apply(qt.TQPushButton.__init__, (self,) + args)
qt.QPushButton.__init__(self, parent) qt.TQPushButton.__init__(self, parent)
self.commandmethod = commandmethod self.commandmethod = commandmethod
self.setText(caption) self.setText(caption)
qt.QObject.connect(self, qt.SIGNAL("clicked()"), self.commandmethod) qt.TQObject.connect(self, qt.SIGNAL("clicked()"), self.commandmethod)
class CheckBox(qt.QCheckBox): class CheckBox(qt.TQCheckBox):
def __init__(self, dialog, parent, caption, checked = True): def __init__(self, dialog, parent, caption, checked = True):
#TkDialog.Widget.__init__(self, dialog, parent) #TkDialog.Widget.__init__(self, dialog, parent)
qt.QCheckBox.__init__(self, parent) qt.TQCheckBox.__init__(self, parent)
self.setText(caption) self.setText(caption)
self.setChecked(checked) self.setChecked(checked)
#def isChecked(self): #def isChecked(self):
# return self.isChecked() # return self.isChecked()
class List(qt.QHBox): class List(qt.TQHBox):
def __init__(self, dialog, parent, caption, items): def __init__(self, dialog, parent, caption, items):
qt.QHBox.__init__(self, parent) qt.TQHBox.__init__(self, parent)
self.setSpacing(6) self.setSpacing(6)
label = qt.QLabel(caption, self) label = qt.TQLabel(caption, self)
self.combo = qt.QComboBox(self) self.combo = qt.TQComboBox(self)
self.setStretchFactor(self.combo, 1) self.setStretchFactor(self.combo, 1)
label.setBuddy(self.combo) label.setBuddy(self.combo)
for item in items: for item in items:
@ -251,24 +251,24 @@ class QtDialog:
def set(self, index): def set(self, index):
self.combo.setCurrentItem(index) self.combo.setCurrentItem(index)
class FileChooser(qt.QHBox): class FileChooser(qt.TQHBox):
def __init__(self, dialog, parent, caption, initialfile = None, filetypes = None): def __init__(self, dialog, parent, caption, initialfile = None, filetypes = None):
#apply(qt.QHBox.__init__, (self,) + args) #apply(qt.TQHBox.__init__, (self,) + args)
qt.QHBox.__init__(self, parent) qt.TQHBox.__init__(self, parent)
self.setMinimumWidth(400) self.setMinimumWidth(400)
self.initialfile = initialfile self.initialfile = initialfile
self.filetypes = filetypes self.filetypes = filetypes
self.setSpacing(6) self.setSpacing(6)
label = qt.QLabel(caption, self) label = qt.TQLabel(caption, self)
self.edit = qt.QLineEdit(self) self.edit = qt.TQLineEdit(self)
self.edit.setText(self.initialfile) self.edit.setText(self.initialfile)
self.setStretchFactor(self.edit, 1) self.setStretchFactor(self.edit, 1)
label.setBuddy(self.edit) label.setBuddy(self.edit)
browsebutton = Button(dialog, self, "...", self.browseButtonClicked) browsebutton = Button(dialog, self, "...", self.browseButtonClicked)
#qt.QObject.connect(browsebutton, qt.SIGNAL("clicked()"), self.browseButtonClicked) #qt.TQObject.connect(browsebutton, qt.SIGNAL("clicked()"), self.browseButtonClicked)
def get(self): def get(self):
return self.edit.text() return self.edit.text()
@ -289,14 +289,14 @@ class QtDialog:
filename = None filename = None
try: try:
print "QtDialog.FileChooser.browseButtonClicked() tdefile.KFileDialog" print "TQtDialog.FileChooser.browseButtonClicked() tdefile.KFileDialog"
# try to use the tdefile module included in pytde # try to use the tdefile module included in pytde
import tdefile import tdefile
filename = tdefile.KFileDialog.getOpenFileName(self.initialfile, filtermask, self, "Save to file") filename = tdefile.KFileDialog.getOpenFileName(self.initialfile, filtermask, self, "Save to file")
except: except:
print "QtDialog.FileChooser.browseButtonClicked() qt.QFileDialog" print "TQtDialog.FileChooser.browseButtonClicked() qt.TQFileDialog"
# fallback to Qt filedialog # fallback to TQt filedialog
filename = qt.QFileDialog.getOpenFileName(self.initialfile, filtermask, self, "Save to file") filename = qt.TQFileDialog.getOpenFileName(self.initialfile, filtermask, self, "Save to file")
if filename != None and filename != "": if filename != None and filename != "":
self.edit.setText(filename) self.edit.setText(filename)
@ -309,19 +309,19 @@ class QtDialog:
def show(self): def show(self):
result = 1 result = 1
if self.typename == "okcancel": if self.typename == "okcancel":
result = qt.QMessageBox.question(self.widget, self.caption, self.message, "&Ok", "&Cancel", "", 1) result = qt.TQMessageBox.question(self.widget, self.caption, self.message, "&Ok", "&Cancel", "", 1)
else: else:
qt.QMessageBox.information(self.widget, self.caption, self.message, "&Ok") qt.TQMessageBox.information(self.widget, self.caption, self.message, "&Ok")
result = 0 result = 0
if result == 0: if result == 0:
return True return True
return False return False
self.app = qt.tqApp self.app = qt.tqApp
self.dialog = Dialog(self.app.mainWidget(), "Dialog", 1, qt.Qt.WDestructiveClose) self.dialog = Dialog(self.app.mainWidget(), "Dialog", 1, qt.TQt.WDestructiveClose)
self.dialog.setCaption(title) self.dialog.setCaption(title)
self.widget = qt.QVBox(self.dialog) self.widget = qt.TQVBox(self.dialog)
self.widget.setSpacing(6) self.widget.setSpacing(6)
self.dialog.layout.addWidget(self.widget) self.dialog.layout.addWidget(self.widget)
@ -335,13 +335,13 @@ class QtDialog:
self.MessageBox = MessageBox self.MessageBox = MessageBox
def show(self): def show(self):
import qt from TQt import qt
qt.QApplication.setOverrideCursor(qt.Qt.arrowCursor) qt.TQApplication.setOverrideCursor(qt.TQt.arrowCursor)
self.dialog.exec_loop() self.dialog.exec_loop()
qt.QApplication.restoreOverrideCursor() qt.TQApplication.restoreOverrideCursor()
def close(self): def close(self):
print "QtDialog.close()" print "TQtDialog.close()"
self.dialog.close() self.dialog.close()
#self.dialog.deleteLater() #self.dialog.deleteLater()
@ -352,17 +352,16 @@ class Dialog:
self.dialog = None self.dialog = None
try: try:
print "Trying to import PyQt..." print "Trying to import PyTQt..."
self.dialog = QtDialog(title) self.dialog = TQtDialog(title)
print "PyQt is our toolkit!" print "PyTQt is our toolkit!"
except: except:
try: try:
print "Failed to import PyQt. Trying to import TkInter..." print "Failed to import PyTQt. Trying to import TkInter..."
self.dialog = TkDialog(title) self.dialog = TkDialog(title)
print "Falling back to TkInter as our toolkit!" print "Falling back to TkInter as our toolkit!"
except: except:
raise "Failed to import GUI-toolkit. Please install the PyQt or the Tkinter python module." raise "Failed to import GUI-toolkit. Please install the PyTQt or the Tkinter python module."
self.widget = self.dialog.widget self.widget = self.dialog.widget
def show(self): def show(self):

@ -11,7 +11,7 @@
# print "testobjectCallbackWithParams() argument = %s" % str(argument) # print "testobjectCallbackWithParams() argument = %s" % str(argument)
# return "this is the __main__.testobjectCallbackWithParams() returnvalue!" # return "this is the __main__.testobjectCallbackWithParams() returnvalue!"
#def testQtObject(self): #def testQtObject(self):
## Get the QtObject instance to access the QObject. ## Get the TQtObject instance to access the TQObject.
##testobject = get("TestObject") ##testobject = get("TestObject")
#testobject = self.get("TestObject") #testobject = self.get("TestObject")
#if testobject == None: raise "Object 'TestObject' undefined !!!" #if testobject == None: raise "Object 'TestObject' undefined !!!"
@ -23,7 +23,7 @@
#print testobject.call("testSlot2()"); #print testobject.call("testSlot2()");
#print testobject.call("testSignal()"); #print testobject.call("testSignal()");
##print testobject.call() #KrossTest: List::item index=0 is out of bounds. Raising TypeException. ##print testobject.call() #KrossTest: List::item index=0 is out of bounds. Raising TypeException.
## Each slot a QObject spends is a object itself. ## Each slot a TQObject spends is a object itself.
#myslot = testobject.get("testSlot()") #myslot = testobject.get("testSlot()")
#print "myslotevent = %s" % str(myslot) #print "myslotevent = %s" % str(myslot)
#print myslot.call() #print myslot.call()

@ -35,39 +35,39 @@ class TkTest:
import tkMessageBox import tkMessageBox
tkMessageBox.showinfo("Callback2", "Callback2 called.") tkMessageBox.showinfo("Callback2", "Callback2 called.")
class QtTest: class TQtTest:
def __init__(self): def __init__(self):
import qt from TQt import qt
class Button(qt.QPushButton): class Button(qt.TQPushButton):
def __init__(self, *args): def __init__(self, *args):
apply(qt.QPushButton.__init__, (self,) + args) apply(qt.TQPushButton.__init__, (self,) + args)
class ComboBox(qt.QHBox): class ComboBox(qt.TQHBox):
def __init__(self, parent, caption, items = []): def __init__(self, parent, caption, items = []):
qt.QHBox.__init__(self, parent) qt.TQHBox.__init__(self, parent)
self.setSpacing(6) self.setSpacing(6)
label = qt.QLabel(str(caption), self) label = qt.TQLabel(str(caption), self)
self.combobox = qt.QComboBox(self) self.combobox = qt.TQComboBox(self)
self.setStretchFactor(self.combobox, 1) self.setStretchFactor(self.combobox, 1)
label.setBuddy(self.combobox) label.setBuddy(self.combobox)
for item in items: for item in items:
self.combobox.insertItem( str(item) ) self.combobox.insertItem( str(item) )
class FileChooser(qt.QHBox): class FileChooser(qt.TQHBox):
def __init__(self, *args): def __init__(self, *args):
apply(qt.QHBox.__init__, (self,) + args) apply(qt.TQHBox.__init__, (self,) + args)
self.defaultfilename = "~/output.html" self.defaultfilename = "~/output.html"
self.setSpacing(6) self.setSpacing(6)
label = qt.QLabel("File:", self) label = qt.TQLabel("File:", self)
self.edit = qt.QLineEdit(self) self.edit = qt.TQLineEdit(self)
self.edit.setText(self.defaultfilename) self.edit.setText(self.defaultfilename)
self.setStretchFactor(self.edit, 1) self.setStretchFactor(self.edit, 1)
label.setBuddy(self.edit) label.setBuddy(self.edit)
browsebutton = Button("...", self) browsebutton = Button("...", self)
qt.QObject.connect(browsebutton, qt.SIGNAL("clicked()"), self.browseButtonClicked) qt.TQObject.connect(browsebutton, qt.SIGNAL("clicked()"), self.browseButtonClicked)
def file(self): def file(self):
return self.edit.text() return self.edit.text()
@ -79,23 +79,23 @@ class QtTest:
import tdefile import tdefile
filename = tdefile.KFileDialog.getOpenFileName(self.defaultfilename, "*.html", self, "Save to file") filename = tdefile.KFileDialog.getOpenFileName(self.defaultfilename, "*.html", self, "Save to file")
except: except:
# fallback to Qt filedialog # fallback to TQt filedialog
filename = qt.QFileDialog.getOpenFileName(self.defaultfilename, "*.html", self, "Save to file") filename = qt.TQFileDialog.getOpenFileName(self.defaultfilename, "*.html", self, "Save to file")
if filename != None and filename != "": if filename != None and filename != "":
self.edit.setText(filename) self.edit.setText(filename)
class Dialog(qt.QDialog): class Dialog(qt.TQDialog):
def __init__(self, parent = None, name = None, modal = 0, fl = 0): def __init__(self, parent = None, name = None, modal = 0, fl = 0):
qt.QDialog.__init__(self, parent, name, modal, fl) qt.TQDialog.__init__(self, parent, name, modal, fl)
qt.QDialog.accept = self.accept qt.TQDialog.accept = self.accept
self.setCaption("Export to HTML") self.setCaption("Export to HTML")
#self.layout() #self.layout()
self.layout = qt.QVBoxLayout(self) self.layout = qt.TQVBoxLayout(self)
self.layout.setSpacing(6) self.layout.setSpacing(6)
self.layout.setMargin(11) self.layout.setMargin(11)
infolabel = qt.QLabel("Export the data of a table or a query to a HTML-file.", self) infolabel = qt.TQLabel("Export the data of a table or a query to a HTML-file.", self)
self.layout.addWidget(infolabel) self.layout.addWidget(infolabel)
source = ComboBox(self, "Datasource:") source = ComboBox(self, "Datasource:")
@ -107,21 +107,21 @@ class QtTest:
self.filechooser = FileChooser(self) self.filechooser = FileChooser(self)
self.layout.addWidget(self.filechooser) self.layout.addWidget(self.filechooser)
buttonbox = qt.QHBox(self) buttonbox = qt.TQHBox(self)
buttonbox.setSpacing(6) buttonbox.setSpacing(6)
self.layout.addWidget(buttonbox) self.layout.addWidget(buttonbox)
savebutton = Button("Save", buttonbox) savebutton = Button("Save", buttonbox)
qt.QObject.connect(savebutton, qt.SIGNAL("clicked()"), self, qt.SLOT("accept()")) qt.TQObject.connect(savebutton, qt.SIGNAL("clicked()"), self, qt.SLOT("accept()"))
#qt.QObject.connect(savebutton, qt.SIGNAL("clicked()"), self.exportButtonClicked) #qt.TQObject.connect(savebutton, qt.SIGNAL("clicked()"), self.exportButtonClicked)
cancelbutton = Button("Cancel", buttonbox) cancelbutton = Button("Cancel", buttonbox)
qt.QObject.connect(cancelbutton, qt.SIGNAL("clicked()"), self, qt.SLOT("close()")) qt.TQObject.connect(cancelbutton, qt.SIGNAL("clicked()"), self, qt.SLOT("close()"))
def accept(self): def accept(self):
print "ACCEPTTTTTTTT !!!!!!!!!!!!!!!!!!!!!!!!!!!!" print "ACCEPTTTTTTTT !!!!!!!!!!!!!!!!!!!!!!!!!!!!"
file = qt.QFile( self.filechooser.file() ) file = qt.TQFile( self.filechooser.file() )
#if not file.exists(): #if not file.exists():
# print "File '%s' does not exist." % self.filechooser.file() # print "File '%s' does not exist." % self.filechooser.file()
#else: #else:
@ -137,7 +137,7 @@ class QtTest:
print "=> Dialog.event %s" % e print "=> Dialog.event %s" % e
#self.deleteLater() #self.deleteLater()
#support.swapThreadState() # calls appropriate c-function #support.swapThreadState() # calls appropriate c-function
return qt.QDialog.event(self, e) return qt.TQDialog.event(self, e)
app = qt.tqApp app = qt.tqApp
dialog = Dialog(app.mainWidget(), "Dialog", 1) dialog = Dialog(app.mainWidget(), "Dialog", 1)
@ -145,5 +145,5 @@ class QtTest:
print "################## BEGIN" print "################## BEGIN"
#TkTest() #TkTest()
QtTest() TQtTest()
print "################## END" print "################## END"

Loading…
Cancel
Save