Project/CreateDialogCodeDialog.py

branch
Py2 comp.
changeset 3060
5883ce99ee12
parent 3058
0a02c433f52d
parent 3038
7fe9a53280bd
child 3142
55030c09e142
equal deleted inserted replaced
3058:0a02c433f52d 3060:5883ce99ee12
184 cls = self.__module.classes[clsName] 184 cls = self.__module.classes[clsName]
185 for meth in list(cls.methods.values()): 185 for meth in list(cls.methods.values()):
186 if meth.name.startswith("on_"): 186 if meth.name.startswith("on_"):
187 if meth.pyqtSignature is not None: 187 if meth.pyqtSignature is not None:
188 sig = ", ".join( 188 sig = ", ".join(
189 [bytes(QMetaObject.normalizedType(t)).decode() 189 [bytes(QMetaObject.normalizedType(t)).decode()
190 for t in meth.pyqtSignature.split(",")]) 190 for t in meth.pyqtSignature.split(",")])
191 signatures.append("{0}({1})".format(meth.name, sig)) 191 signatures.append("{0}({1})".format(meth.name, sig))
192 else: 192 else:
193 signatures.append(meth.name) 193 signatures.append(meth.name)
194 return signatures 194 return signatures
256 itm.appendRow(itm2) 256 itm.appendRow(itm2)
257 if self.__module is not None: 257 if self.__module is not None:
258 if qVersion() >= "5.0.0": 258 if qVersion() >= "5.0.0":
259 method = "on_{0}_{1}".format( 259 method = "on_{0}_{1}".format(
260 name, 260 name,
261 bytes(metaMethod.methodSignature())\ 261 bytes(metaMethod.methodSignature())
262 .decode().split("(")[0]) 262 .decode().split("(")[0])
263 else: 263 else:
264 method = "on_{0}_{1}".format( 264 method = "on_{0}_{1}".format(
265 name, metaMethod.signature().split("(")[0]) 265 name, metaMethod.signature().split("(")[0])
266 method2 = "{0}({1})".format( 266 method2 = "{0}({1})".format(
267 method, ", ".join( 267 method, ", ".join(
292 if methNamesSig: 292 if methNamesSig:
293 if qVersion() >= "5.0.0": 293 if qVersion() >= "5.0.0":
294 pythonSignature = \ 294 pythonSignature = \
295 "on_{0}_{1}(self, {2})".format( 295 "on_{0}_{1}(self, {2})".format(
296 name, 296 name,
297 bytes(metaMethod.methodSignature())\ 297 bytes(metaMethod.methodSignature())
298 .decode().split("(")[0], 298 .decode().split("(")[0],
299 methNamesSig) 299 methNamesSig)
300 else: 300 else:
301 pythonSignature = \ 301 pythonSignature = \
302 "on_{0}_{1}(self, {2})".format( 302 "on_{0}_{1}(self, {2})".format(
303 name, 303 name,
304 metaMethod.signature().split("(")[0], 304 metaMethod.signature().split("(")[0],
305 methNamesSig) 305 methNamesSig)
306 else: 306 else:
307 if qVersion() >= "5.0.0": 307 if qVersion() >= "5.0.0":
308 pythonSignature = "on_{0}_{1}(self)".format( 308 pythonSignature = "on_{0}_{1}(self)".format(
309 name, 309 name,
310 bytes(metaMethod.methodSignature())\ 310 bytes(metaMethod.methodSignature())
311 .decode().split("(")[0]) 311 .decode().split("(")[0])
312 else: 312 else:
313 pythonSignature = "on_{0}_{1}(self)".format( 313 pythonSignature = "on_{0}_{1}(self)".format(
314 name, 314 name,
315 metaMethod.signature().split("(")[0]) 315 metaMethod.signature().split("(")[0])
316 itm2.setData(pyqtSignature, pyqtSignatureRole) 316 itm2.setData(pyqtSignature, pyqtSignatureRole)
317 itm2.setData(pythonSignature, pythonSignatureRole) 317 itm2.setData(pythonSignature, pythonSignatureRole)
318 318
319 itm2.setFlags(Qt.ItemFlags( 319 itm2.setFlags(Qt.ItemFlags(
320 Qt.ItemIsUserCheckable | \ 320 Qt.ItemIsUserCheckable |
321 Qt.ItemIsEnabled | \ 321 Qt.ItemIsEnabled |
322 Qt.ItemIsSelectable) 322 Qt.ItemIsSelectable)
323 ) 323 )
324 itm2.setCheckState(Qt.Unchecked) 324 itm2.setCheckState(Qt.Unchecked)
325 325
326 self.slotsView.sortByColumn(0, Qt.AscendingOrder) 326 self.slotsView.sortByColumn(0, Qt.AscendingOrder)
397 E5MessageBox.critical( 397 E5MessageBox.critical(
398 self, 398 self,
399 self.trUtf8("Code Generation"), 399 self.trUtf8("Code Generation"),
400 self.trUtf8( 400 self.trUtf8(
401 """<p>Could not open the code template file""" 401 """<p>Could not open the code template file"""
402 """ "{0}".</p><p>Reason: {1}</p>""")\ 402 """ "{0}".</p><p>Reason: {1}</p>""")
403 .format(tmplName, str(why))) 403 .format(tmplName, str(why)))
404 return 404 return
405 405
406 objName = self.__objectName() 406 objName = self.__objectName()
407 if objName: 407 if objName:
408 template = template\ 408 template = template\
433 E5MessageBox.critical( 433 E5MessageBox.critical(
434 self, 434 self,
435 self.trUtf8("Code Generation"), 435 self.trUtf8("Code Generation"),
436 self.trUtf8( 436 self.trUtf8(
437 """<p>Could not open the source file "{0}".</p>""" 437 """<p>Could not open the source file "{0}".</p>"""
438 """<p>Reason: {1}</p>""")\ 438 """<p>Reason: {1}</p>""")
439 .format(self.srcFile, str(why))) 439 .format(self.srcFile, str(why)))
440 return 440 return
441 441
442 cls = self.__module.classes[self.classNameCombo.currentText()] 442 cls = self.__module.classes[self.classNameCombo.currentText()]
443 if cls.endlineno == len(sourceImpl) or cls.endlineno == -1: 443 if cls.endlineno == len(sourceImpl) or cls.endlineno == -1:
444 appendAtIndex = -1 444 appendAtIndex = -1
511 except IOError as why: 511 except IOError as why:
512 E5MessageBox.critical( 512 E5MessageBox.critical(
513 self, 513 self,
514 self.trUtf8("Code Generation"), 514 self.trUtf8("Code Generation"),
515 self.trUtf8("""<p>Could not write the source file "{0}".</p>""" 515 self.trUtf8("""<p>Could not write the source file "{0}".</p>"""
516 """<p>Reason: {1}</p>""")\ 516 """<p>Reason: {1}</p>""")
517 .format(self.filenameEdit.text(), str(why))) 517 .format(self.filenameEdit.text(), str(why)))
518 return 518 return
519 519
520 self.project.appendFile(self.filenameEdit.text()) 520 self.project.appendFile(self.filenameEdit.text())
521 521
522 @pyqtSlot(int) 522 @pyqtSlot(int)
524 """ 524 """
525 Private slot to handle the activated signal of the classname combo. 525 Private slot to handle the activated signal of the classname combo.
526 526
527 @param index index of the activated item (integer) 527 @param index index of the activated item (integer)
528 """ 528 """
529 if (self.classNameCombo.currentText() == 529 if (self.classNameCombo.currentText() ==
530 CreateDialogCodeDialog.Separator): 530 CreateDialogCodeDialog.Separator):
531 self.okButton.setEnabled(False) 531 self.okButton.setEnabled(False)
532 self.filterEdit.clear() 532 self.filterEdit.clear()
533 self.slotsModel.clear() 533 self.slotsModel.clear()
534 self.slotsModel.setHorizontalHeaderLabels([""]) 534 self.slotsModel.setHorizontalHeaderLabels([""])

eric ide

mercurial