diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
commit | f008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch) | |
tree | 8e9244c4d4957c36be81e15b566b4aa5ea26c982 /kspread/plugins/scripting/scripts | |
parent | 1210f27b660efb7b37ff43ec68763e85a403471f (diff) | |
download | koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip |
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kspread/plugins/scripting/scripts')
-rwxr-xr-x | kspread/plugins/scripting/scripts/exporthtml/ExportHtml.py | 10 | ||||
-rwxr-xr-x | kspread/plugins/scripting/scripts/scripteditor/ScriptEditor.py | 188 |
2 files changed, 99 insertions, 99 deletions
diff --git a/kspread/plugins/scripting/scripts/exporthtml/ExportHtml.py b/kspread/plugins/scripting/scripts/exporthtml/ExportHtml.py index 2e2dfc31..d4ab99ed 100755 --- a/kspread/plugins/scripting/scripts/exporthtml/ExportHtml.py +++ b/kspread/plugins/scripting/scripts/exporthtml/ExportHtml.py @@ -21,20 +21,20 @@ except (ImportError): raise "Failed to import the required PyQt python module." class Dialog(qt.QDialog): - def __init__(self, scriptpath, parent): + def __init__(self, scriptpath, tqparent): self.scriptpath = scriptpath import krosskspreadcore self.doc = krosskspreadcore.get("KSpreadDocument") import qt - qt.QDialog.__init__(self, parent, "Dialog", 1, qt.Qt.WDestructiveClose) + qt.QDialog.__init__(self, tqparent, "Dialog", 1, qt.Qt.WDestructiveClose) self.setCaption("Export to HTML File") - layout = qt.QVBoxLayout(self) + tqlayout = qt.QVBoxLayout(self) box = qt.QVBox(self) box.setMargin(10) box.setSpacing(10) - layout.addWidget(box) + tqlayout.addWidget(box) sheetbox = qt.QHBox(box) sheetbox.setSpacing(6) @@ -173,7 +173,7 @@ if __name__ == "__main__": qtapp = qt.QApplication(sys.argv) else: scriptpath = os.path.dirname(__name__) - qtapp = qt.qApp + qtapp = qt.tqApp dialog = Dialog(scriptpath, qtapp.mainWidget()) dialog.exec_loop() diff --git a/kspread/plugins/scripting/scripts/scripteditor/ScriptEditor.py b/kspread/plugins/scripting/scripts/scripteditor/ScriptEditor.py index f015a5f1..cedc82cc 100755 --- a/kspread/plugins/scripting/scripts/scripteditor/ScriptEditor.py +++ b/kspread/plugins/scripting/scripts/scripteditor/ScriptEditor.py @@ -22,10 +22,10 @@ except (ImportError): # Samples. class Widget(qt.QHBox): - def __init__(self, parentwidget, label = None): - self.parentwidget = parentwidget + def __init__(self, tqparentwidget, label = None): + self.tqparentwidget = tqparentwidget import qt - qt.QHBox.__init__(self, parentwidget) + qt.QHBox.__init__(self, tqparentwidget) self.setMargin(4) self.setSpacing(4) if label != None: qt.QLabel(label, self) @@ -33,10 +33,10 @@ class Widget(qt.QHBox): return None class ListWidget(Widget): - def __init__(self, parentwidget, label): + def __init__(self, tqparentwidget, label): import qt global Widget - Widget.__init__(self, parentwidget, label) + Widget.__init__(self, tqparentwidget, label) self.combo = qt.QComboBox(self) self.combo.setEditable(True) self.setStretchFactor(self.combo,1) @@ -44,22 +44,22 @@ class ListWidget(Widget): return self.combo.currentText() class EditWidget(Widget): - def __init__(self, parentwidget, label): + def __init__(self, tqparentwidget, label): import qt global Widget - Widget.__init__(self, parentwidget, label) + Widget.__init__(self, tqparentwidget, label) self.edit = qt.QLineEdit(self) self.setStretchFactor(self.edit,1) def value(self): return self.edit.text() class FileWidget(Widget): - def __init__(self, parentwidget, label, filtermask, openfiledialog = True): - self.filtermask = filtermask + def __init__(self, tqparentwidget, label, filtertqmask, openfiledialog = True): + self.filtertqmask = filtertqmask self.openfiledialog = openfiledialog import qt global Widget - Widget.__init__(self, parentwidget, label) + Widget.__init__(self, tqparentwidget, label) self.edit = qt.QLineEdit(self) self.setStretchFactor(self.edit,1) btn = qt.QPushButton("...",self) @@ -68,9 +68,9 @@ class FileWidget(Widget): import qt text = str( self.edit.text() ) if self.openfiledialog: - filename = str( qt.QFileDialog.getOpenFileName(text, self.filtermask, self.parentwidget) ) + filename = str( qt.QFileDialog.getOpenFileName(text, self.filtertqmask, self.tqparentwidget) ) else: - filename = qt.QFileDialog.getSaveFileName(text, self.filtermask, self.parentwidget) + filename = qt.QFileDialog.getSaveFileName(text, self.filtertqmask, self.tqparentwidget) if filename != "": self.edit.setText( filename ) def value(self): return self.edit.text() @@ -81,33 +81,33 @@ class Samples: # KexiDB class KexiDB: - def __init__(self, parentwidget): - self.parentwidget = parentwidget + def __init__(self, tqparentwidget): + self.tqparentwidget = tqparentwidget class _ProjectWidget(FileWidget): - def __init__(self, parentwidget): + def __init__(self, tqparentwidget): global FileWidget - FileWidget.__init__(self, parentwidget, "Project File:", "*.kexi *.kexis *.kexic;;*") + FileWidget.__init__(self, tqparentwidget, "Project File:", "*.kexi *.kexis *.kexic;;*") class _DriverWidget(ListWidget): - def __init__(self, parentwidget): + def __init__(self, tqparentwidget): global ListWidget - ListWidget.__init__(self, parentwidget, "Driver:") + ListWidget.__init__(self, tqparentwidget, "Driver:") import krosskexidb for driver in krosskexidb.DriverManager().driverNames(): self.combo.insertItem(driver) class _TableWidget(ListWidget): - def __init__(self, parentwidget): + def __init__(self, tqparentwidget): global ListWidget - ListWidget.__init__(self, parentwidget, "Table:") + ListWidget.__init__(self, tqparentwidget, "Table:") class PrintDriverDetails: """ Print a the list of available KexiDB drivers and print details about one of them. """ name = "Details about a driver" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { - "DriverName" : Samples.KexiDB._DriverWidget( parent.parentwidget ), + "DriverName" : Samples.KexiDB._DriverWidget( tqparent.tqparentwidget ), } def getCode(self): return ( @@ -125,9 +125,9 @@ class Samples: class ConnectWithFile: """ Connect with a KexiDB database by using a Kexi Connection Project File. """ name = "Connect with file" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { - "ProjectFile" : Samples.KexiDB._ProjectWidget( parent.parentwidget ), + "ProjectFile" : Samples.KexiDB._ProjectWidget( tqparent.tqparentwidget ), } def getCode(self): return ( @@ -164,10 +164,10 @@ class Samples: class IterateThroughTable: """ Iterate through a table within a connected KexiDB database. """ name = "Iterate through table" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { - "ProjectFile" : Samples.KexiDB._ProjectWidget( parent.parentwidget ), - "TableName" : Samples.KexiDB._TableWidget( parent.parentwidget ), + "ProjectFile" : Samples.KexiDB._ProjectWidget( tqparent.tqparentwidget ), + "TableName" : Samples.KexiDB._TableWidget( tqparent.tqparentwidget ), } def getCode(self): return ( @@ -216,13 +216,13 @@ class Samples: # KSpread class KSpread: - def __init__(self, parentwidget): - self.parentwidget = parentwidget + def __init__(self, tqparentwidget): + self.tqparentwidget = tqparentwidget class _SheetWidget(ListWidget): - def __init__(self, parentwidget, label = "Sheet:"): + def __init__(self, tqparentwidget, label = "Sheet:"): global ListWidget - ListWidget.__init__(self, parentwidget, label) + ListWidget.__init__(self, tqparentwidget, label) try: import krosskspreadcore @@ -235,9 +235,9 @@ class Samples: print trace class _CellsWidget(ListWidget): - def __init__(self, parentwidget): + def __init__(self, tqparentwidget): global ListWidget - ListWidget.__init__(self, parentwidget, "Cells (col1:row1 - col2:row2):") + ListWidget.__init__(self, tqparentwidget, "Cells (col1:row1 - col2:row2):") self.combo.insertItem( "1:1 - %s:%s" % (5,10) ) self.combo.insertItem( "1:1 - %s:%s" % (256,256) ) self.combo.insertItem( "1:1 - %s:%s" % (32767,32767) ) @@ -245,15 +245,15 @@ class Samples: return [ [ int(i) for i in item.split(':') ] for item in str( ListWidget.value(self) ).split('-') ] class _ValueWidget(EditWidget): - def __init__(self, parentwidget): + def __init__(self, tqparentwidget): global EditWidget - EditWidget.__init__(self, parentwidget, "Value:") + EditWidget.__init__(self, tqparentwidget, "Value:") self.edit.setText("Some text") class _ColorWidget(EditWidget): - def __init__(self, parentwidget,label,color): + def __init__(self, tqparentwidget,label,color): global EditWidget - EditWidget.__init__(self, parentwidget, "%s (RGB):" % label) + EditWidget.__init__(self, tqparentwidget, "%s (RGB):" % label) self.edit.setText(color) def value(self): return "#%s" % EditWidget.value(self) @@ -261,12 +261,12 @@ class Samples: class SetTextOfCells: """ Set the text of the defined cells. """ name = "Set text of cells" - def __init__(self, parent): + def __init__(self, tqparent): pass self.widgets = { - "SheetName" : Samples.KSpread._SheetWidget( parent.parentwidget ), - "Cells" : Samples.KSpread._CellsWidget( parent.parentwidget ), - "Value" : Samples.KSpread._ValueWidget( parent.parentwidget ), + "SheetName" : Samples.KSpread._SheetWidget( tqparent.tqparentwidget ), + "Cells" : Samples.KSpread._CellsWidget( tqparent.tqparentwidget ), + "Value" : Samples.KSpread._ValueWidget( tqparent.tqparentwidget ), } def getCode(self): return ( @@ -292,13 +292,13 @@ class Samples: class SetColorsOfCells: """ Set the colors of the defined cells. """ name = "Set colors of cells" - def __init__(self, parent): + def __init__(self, tqparent): pass self.widgets = { - "SheetName" : Samples.KSpread._SheetWidget( parent.parentwidget), - "Cells" : Samples.KSpread._CellsWidget( parent.parentwidget ), - "TextColor" : Samples.KSpread._ColorWidget( parent.parentwidget, "Textcolor", "ff0000" ), - "BackgroundColor" : Samples.KSpread._ColorWidget( parent.parentwidget, "Backgroundcolor", "c0c0c0" ), + "SheetName" : Samples.KSpread._SheetWidget( tqparent.tqparentwidget), + "Cells" : Samples.KSpread._CellsWidget( tqparent.tqparentwidget ), + "TextColor" : Samples.KSpread._ColorWidget( tqparent.tqparentwidget, "Textcolor", "ff0000" ), + "BackgroundColor" : Samples.KSpread._ColorWidget( tqparent.tqparentwidget, "Backgroundcolor", "c0c0c0" ), } def getCode(self): return ( @@ -324,10 +324,10 @@ class Samples: class IterateThroughCellsWithContent: """ Iterate over all cells in a sheet that have content (aka that are not empty). """ name = "Iterate through cells" - def __init__(self, parent): + def __init__(self, tqparent): pass self.widgets = { - "SheetName" : Samples.KSpread._SheetWidget( parent.parentwidget ), + "SheetName" : Samples.KSpread._SheetWidget( tqparent.tqparentwidget ), } def getCode(self): return ( @@ -352,9 +352,9 @@ class Samples: class PrintSheetDetails: """ Print details about the current sheet. """ name = "Details about a sheet" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { - "SheetName" : Samples.KSpread._SheetWidget( parent.parentwidget ), + "SheetName" : Samples.KSpread._SheetWidget( tqparent.tqparentwidget ), } def getCode(self): return ( @@ -376,10 +376,10 @@ class Samples: class LoadDocFromNativeXML: """ Load the document from a native XML file. """ name = "Load document from native XML File" - def __init__(self, parent): + def __init__(self, tqparent): global FileWidget self.widgets = { - "FileName" : FileWidget( parent.parentwidget, "XML File:", "*.xml;;*" ), + "FileName" : FileWidget( tqparent.tqparentwidget, "XML File:", "*.xml;;*" ), } def getCode(self): return ( @@ -413,10 +413,10 @@ class Samples: class SaveDocToNativeXML: """ Save the document to a native XML file. """ name = "Save document to native XML File" - def __init__(self, parent): + def __init__(self, tqparent): global FileWidget self.widgets = { - "FileName" : FileWidget( parent.parentwidget, "XML File:", "*.xml;;*", False ), + "FileName" : FileWidget( tqparent.tqparentwidget, "XML File:", "*.xml;;*", False ), } def getCode(self): return ( @@ -451,10 +451,10 @@ class Samples: class CopySheets: """ Copy the text-content from one sheet to another. """ name = "Copy sheets" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { - "SourceSheet" : Samples.KSpread._SheetWidget( parent.parentwidget, "Source sheet:" ), - "TargetSheet" : Samples.KSpread._SheetWidget( parent.parentwidget, "Target sheet:" ), + "SourceSheet" : Samples.KSpread._SheetWidget( tqparent.tqparentwidget, "Source sheet:" ), + "TargetSheet" : Samples.KSpread._SheetWidget( tqparent.tqparentwidget, "Target sheet:" ), } def getCode(self): return ( @@ -480,10 +480,10 @@ class Samples: class LoadSheetFromCSV: """ Load the content of a CSV file into a KSpread sheet. """ name = "Load data from CSV file into sheet" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { - "Sheet" : Samples.KSpread._SheetWidget( parent.parentwidget ), - "FileName" : FileWidget( parent.parentwidget, "CSV File:", "*.csv;;*", True ), + "Sheet" : Samples.KSpread._SheetWidget( tqparent.tqparentwidget ), + "FileName" : FileWidget( tqparent.tqparentwidget, "CSV File:", "*.csv;;*", True ), } def getCode(self): return ( @@ -519,10 +519,10 @@ class Samples: class SaveSheetToCSV: """ Save the content of a KSpread sheet into a CSV file. """ name = "Save data from a sheet into a CSV file" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { - "Sheet" : Samples.KSpread._SheetWidget( parent.parentwidget ), - "FileName" : FileWidget( parent.parentwidget, "CSV File:", "*.csv;;*", False ), + "Sheet" : Samples.KSpread._SheetWidget( tqparent.tqparentwidget ), + "FileName" : FileWidget( tqparent.tqparentwidget, "CSV File:", "*.csv;;*", False ), } def getCode(self): return ( @@ -557,16 +557,16 @@ class Samples: # PyQt class PyQt: - def __init__(self, parentwidget): - self.parentwidget = parentwidget + def __init__(self, tqparentwidget): + self.tqparentwidget = tqparentwidget class OpenFileDialog: """ Show the usage of the openfile dialog with QFileDialog. """ name = "Open File Dialog" - def __init__(self, parent): + def __init__(self, tqparent): pass self.widgets = { - "FileName" : FileWidget( parent.parentwidget, "Open File:", "*.txt *.html;;*" ), + "FileName" : FileWidget( tqparent.tqparentwidget, "Open File:", "*.txt *.html;;*" ), } def getCode(self): return ( @@ -578,10 +578,10 @@ class Samples: class SaveFileDialog: """ Show the usage of the savefile dialog with QFileDialog. """ name = "Save File Dialog" - def __init__(self, parent): + def __init__(self, tqparent): pass self.widgets = { - "FileName" : FileWidget( parent.parentwidget, "Save File:", "*.txt *.html;;*", False ), + "FileName" : FileWidget( tqparent.tqparentwidget, "Save File:", "*.txt *.html;;*", False ), } def getCode(self): return ( @@ -593,7 +593,7 @@ class Samples: class CustomDialog: """ Show a custom dialog that inherits a QDialog. """ name = "Custom Dialog" - def __init__(self, parent): + def __init__(self, tqparent): pass self.widgets = { } @@ -602,9 +602,9 @@ class Samples: 'import qt', '', 'class MyDialog(qt.QDialog):', - ' def __init__(self, parent):', + ' def __init__(self, tqparent):', ' import qt', - ' qt.QDialog.__init__(self, parent, "MyDialog", 1, qt.Qt.WDestructiveClose)', + ' qt.QDialog.__init__(self, tqparent, "MyDialog", 1, qt.Qt.WDestructiveClose)', ' self.setCaption("My Dialog")', ' btn = qt.QPushButton("Click me",self)', ' qt.QObject.connect(btn, qt.SIGNAL("clicked()"), self.buttonClicked)', @@ -619,11 +619,11 @@ class Samples: class InputDialog: """ Show how to use a QInputDialog. """ name = "Input Dialog" - def __init__(self, parent): + def __init__(self, tqparent): global EditWidget self.widgets = { - "Caption" : EditWidget( parent.parentwidget, "Caption" ), - "Message" : EditWidget( parent.parentwidget, "Message" ), + "Caption" : EditWidget( tqparent.tqparentwidget, "Caption" ), + "Message" : EditWidget( tqparent.tqparentwidget, "Message" ), } def getCode(self): return ( @@ -640,13 +640,13 @@ class Samples: # DCOP class DCOP: - def __init__(self, parentwidget): - self.parentwidget = parentwidget + def __init__(self, tqparentwidget): + self.tqparentwidget = tqparentwidget class PrintClipboard: """ Print the content from the clipper via DCOP. """ name = "Clipboard content" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { } def getCode(self): @@ -657,13 +657,13 @@ class Samples: 'd = dcopext.DCOPApp(apps[0], dcopclient)', 'result,typename,data = d.appclient.call(apps[0],"klipper","getClipboardContents()","")', 'ds = qt.QDataStream(data, qt.IO_ReadOnly)', - 'print "Clipboard content:\\n%s" % kdecore.dcop_next(ds, "QString")', + 'print "Clipboard content:\\n%s" % kdecore.dcop_next(ds, TQSTRING_OBJECT_NAME_STRING)', ) class AmarokCollectionInfos: """ Fetch some collection informations from the amarok collection via DCOP. """ name = "amarok collection infos" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { } def getCode(self): @@ -688,7 +688,7 @@ class Samples: class KopeteContacts: """ Print the names of all contacts Kopete knows via DCOP. """ name = "Kopete contacts" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { } def getCode(self): @@ -704,14 +704,14 @@ class Samples: 'if not state: raise "Failed to call the kopete contacts-function"', '', 'ds = qt.QDataStream(rdata.data(), qt.IO_ReadOnly)', - 'sl = kdecore.dcop_next (ds, "QStringList")', + 'sl = kdecore.dcop_next (ds, TQSTRINGLIST_OBJECT_NAME_STRING)', 'print "contacts=%s" % [ str(s) for s in sl ]', ) class KWordSelectedText: """ Get the selected text from a KWord instance via DCOP. """ name = "KWord selected text" - def __init__(self, parent): + def __init__(self, tqparent): self.widgets = { } def getCode(self): @@ -752,22 +752,22 @@ class Samples: '', '# Get the selected text.', '(state,rtype,rdata) = d.appclient.call(appname, frameset.obj(), "selectedText()", "")', - 'print "Selected Text: %s" % dataToList( rdata,["QString"] )[0]', + 'print "Selected Text: %s" % dataToList( rdata,[TQSTRING_OBJECT_NAME_STRING] )[0]', ) #################################################################################### # Dialog implementations. class SampleDialog(qt.QDialog): - def __init__(self, parent, sampleclazz, samplechildclazz): + def __init__(self, tqparent, sampleclazz, samplechildclazz): import qt - qt.QDialog.__init__(self, parent, "SampleDialog", 1) + qt.QDialog.__init__(self, tqparent, "SampleDialog", 1) - layout = qt.QVBoxLayout(self) + tqlayout = qt.QVBoxLayout(self) box = qt.QVBox(self) box.setMargin(4) box.setSpacing(10) - layout.addWidget(box) + tqlayout.addWidget(box) self.scrollview = qt.QScrollView(box) self.scrollview.setResizePolicy(qt.QScrollView.AutoOne) @@ -813,11 +813,11 @@ class SampleDialog(qt.QDialog): widget = self.samplechild.widgets[widgetname] value = widget.value() if value != None: - code = code.replace("{%s}" % widgetname, str(value)) + code = code.tqreplace("{%s}" % widgetname, str(value)) return code class MainDialog(qt.QDialog): - def __init__(self, scriptpath, parent): + def __init__(self, scriptpath, tqparent): self.scriptpath = scriptpath if not hasattr(__main__,"scripteditorfilename"): __main__.scripteditorfilename = self.getFileName("myscript.py") @@ -826,14 +826,14 @@ class MainDialog(qt.QDialog): self.doc = krosskspreadcore.get("KSpreadDocument") import os, qt - qt.QDialog.__init__(self, parent, "MainDialog", 1, qt.Qt.WDestructiveClose) + qt.QDialog.__init__(self, tqparent, "MainDialog", 1, qt.Qt.WDestructiveClose) self.setCaption("Script Editor") - layout = qt.QVBoxLayout(self) + tqlayout = qt.QVBoxLayout(self) box = qt.QVBox(self) box.setMargin(4) box.setSpacing(10) - layout.addWidget(box) + tqlayout.addWidget(box) menu = qt.QMenuBar(box) @@ -1083,7 +1083,7 @@ if __name__ == "__main__": qtapp = qt.QApplication(sys.argv) else: scriptpath = os.path.dirname(__name__) - qtapp = qt.qApp + qtapp = qt.tqApp dialog = MainDialog(scriptpath, qtapp.mainWidget()) dialog.exec_loop() |