7 Module implementing a dialog to generate code for a Qt4 dialog. |
7 Module implementing a dialog to generate code for a Qt4 dialog. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 |
11 |
12 from PyQt4.QtCore import QMetaObject, QByteArray, QRegExp, Qt, pyqtSlot, QMetaMethod |
12 from PyQt4.QtCore import QMetaObject, QByteArray, QRegExp, Qt, pyqtSlot, QMetaMethod, \ |
|
13 qVersion |
13 from PyQt4.QtGui import QWidget, QSortFilterProxyModel, QStandardItemModel, QDialog, \ |
14 from PyQt4.QtGui import QWidget, QSortFilterProxyModel, QStandardItemModel, QDialog, \ |
14 QBrush, QStandardItem, QDialogButtonBox, QAction |
15 QBrush, QStandardItem, QDialogButtonBox, QAction |
15 from PyQt4 import uic |
16 from PyQt4 import uic |
16 |
17 |
17 from E5Gui.E5Application import e5App |
18 from E5Gui.E5Application import e5App |
232 itm = QStandardItem("{0} ({1})".format(name, className)) |
233 itm = QStandardItem("{0} ({1})".format(name, className)) |
233 self.slotsModel.appendRow(itm) |
234 self.slotsModel.appendRow(itm) |
234 for index in range(metaObject.methodCount()): |
235 for index in range(metaObject.methodCount()): |
235 metaMethod = metaObject.method(index) |
236 metaMethod = metaObject.method(index) |
236 if metaMethod.methodType() == QMetaMethod.Signal: |
237 if metaMethod.methodType() == QMetaMethod.Signal: |
237 itm2 = QStandardItem("on_{0}_{1}".format( |
238 if qVersion() >= "5.0.0": |
238 name, metaMethod.signature())) |
239 itm2 = QStandardItem("on_{0}_{1}".format( |
|
240 name, bytes(metaMethod.methodSignature()).decode())) |
|
241 else: |
|
242 itm2 = QStandardItem("on_{0}_{1}".format( |
|
243 name, metaMethod.signature())) |
239 itm.appendRow(itm2) |
244 itm.appendRow(itm2) |
240 if self.__module is not None: |
245 if self.__module is not None: |
241 method = "on_{0}_{1}".format( |
246 if qVersion() >= "5.0.0": |
242 name, metaMethod.signature().split("(")[0]) |
247 method = "on_{0}_{1}".format( |
|
248 name, bytes(metaMethod.methodSignature()).decode()\ |
|
249 .split("(")[0]) |
|
250 else: |
|
251 method = "on_{0}_{1}".format( |
|
252 name, metaMethod.signature().split("(")[0]) |
243 method2 = "{0}({1})".format(method, |
253 method2 = "{0}({1})".format(method, |
244 ", ".join([self.__mapType(t) |
254 ", ".join([self.__mapType(t) |
245 for t in metaMethod.parameterTypes()])) |
255 for t in metaMethod.parameterTypes()])) |
246 |
256 |
247 if method2 in signatureList or method in signatureList: |
257 if method2 in signatureList or method in signatureList: |
262 QByteArray("p{0:d}".format(index)) |
272 QByteArray("p{0:d}".format(index)) |
263 methNamesSig = \ |
273 methNamesSig = \ |
264 ", ".join([bytes(n).decode() for n in parameterNames]) |
274 ", ".join([bytes(n).decode() for n in parameterNames]) |
265 |
275 |
266 if methNamesSig: |
276 if methNamesSig: |
267 pythonSignature = "on_{0}_{1}(self, {2})".format( |
277 if qVersion() >= "5.0.0": |
268 name, |
278 pythonSignature = "on_{0}_{1}(self, {2})".format( |
269 metaMethod.signature().split("(")[0], |
279 name, |
270 methNamesSig) |
280 bytes(metaMethod.methodSignature()).decode()\ |
|
281 .split("(")[0], |
|
282 methNamesSig) |
|
283 else: |
|
284 pythonSignature = "on_{0}_{1}(self, {2})".format( |
|
285 name, |
|
286 metaMethod.signature().split("(")[0], |
|
287 methNamesSig) |
271 else: |
288 else: |
272 pythonSignature = "on_{0}_{1}(self)".format( |
289 if qVersion() >= "5.0.0": |
273 name, |
290 pythonSignature = "on_{0}_{1}(self)".format( |
274 metaMethod.signature().split("(")[0]) |
291 name, |
|
292 bytes(metaMethod.methodSignature()).decode()\ |
|
293 .split("(")[0]) |
|
294 else: |
|
295 pythonSignature = "on_{0}_{1}(self)".format( |
|
296 name, |
|
297 metaMethod.signature().split("(")[0]) |
275 itm2.setData(pyqtSignature, pyqtSignatureRole) |
298 itm2.setData(pyqtSignature, pyqtSignatureRole) |
276 itm2.setData(pythonSignature, pythonSignatureRole) |
299 itm2.setData(pythonSignature, pythonSignatureRole) |
277 |
300 |
278 itm2.setFlags(Qt.ItemFlags( |
301 itm2.setFlags(Qt.ItemFlags( |
279 Qt.ItemIsUserCheckable | \ |
302 Qt.ItemIsUserCheckable | \ |