Plugins/PluginWizardQFileDialog.py

branch
Py2 comp.
changeset 3142
55030c09e142
parent 3060
5883ce99ee12
parent 3122
4bcf6c0f4432
child 3145
a9de05d4a22f
equal deleted inserted replaced
3141:72f3bde98c58 3142:55030c09e142
6 """ 6 """
7 Module implementing the QFileDialog wizard plugin. 7 Module implementing the QFileDialog wizard plugin.
8 """ 8 """
9 9
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 10 from __future__ import unicode_literals # __IGNORE_WARNING__
11
12 import re
11 13
12 from PyQt4.QtCore import QObject 14 from PyQt4.QtCore import QObject
13 from PyQt4.QtGui import QDialog 15 from PyQt4.QtGui import QDialog
14 16
15 from E5Gui.E5Application import e5App 17 from E5Gui.E5Application import e5App
42 44
43 @param ui reference to the user interface object (UI.UserInterface) 45 @param ui reference to the user interface object (UI.UserInterface)
44 """ 46 """
45 super(FileDialogWizard, self).__init__(ui) 47 super(FileDialogWizard, self).__init__(ui)
46 self.__ui = ui 48 self.__ui = ui
49
50 self.__pyqtRe = re.compile(r"(?:import|from)\s+PyQt([45])")
47 51
48 def activate(self): 52 def activate(self):
49 """ 53 """
50 Public method to activate this plugin. 54 Public method to activate this plugin.
51 55
97 Private method to display a dialog and get the code. 101 Private method to display a dialog and get the code.
98 102
99 @param editor reference to the current editor 103 @param editor reference to the current editor
100 @return the generated code (string) 104 @return the generated code (string)
101 """ 105 """
106 match = self.__pyqtRe.search(editor.text())
107 if match is None:
108 pyqtVariant = 0 # unknown
109 else:
110 pyqtVariant = int(match.group(1)) # 4 or 5
111
102 from WizardPlugins.FileDialogWizard.FileDialogWizardDialog import \ 112 from WizardPlugins.FileDialogWizard.FileDialogWizardDialog import \
103 FileDialogWizardDialog 113 FileDialogWizardDialog
104 dlg = FileDialogWizardDialog(None) 114 dlg = FileDialogWizardDialog(pyqtVariant, None)
105 if dlg.exec_() == QDialog.Accepted: 115 if dlg.exec_() == QDialog.Accepted:
106 line, index = editor.getCursorPosition() 116 line, index = editor.getCursorPosition()
107 indLevel = editor.indentation(line) // editor.indentationWidth() 117 indLevel = editor.indentation(line) // editor.indentationWidth()
108 if editor.indentationsUseTabs(): 118 if editor.indentationsUseTabs():
109 indString = '\t' 119 indString = '\t'

eric ide

mercurial