Project/CreateDialogCodeDialog.py

changeset 535
4b00d7336e19
parent 427
6af5d12cfecb
child 537
72b32daeb8d6
equal deleted inserted replaced
533:bc6063d2ab83 535:4b00d7336e19
86 if os.path.exists(self.srcFile) and self.classNameCombo.count() == 0: 86 if os.path.exists(self.srcFile) and self.classNameCombo.count() == 0:
87 self.__initError = True 87 self.__initError = True
88 QMessageBox.critical(None, 88 QMessageBox.critical(None,
89 self.trUtf8("Create Dialog Code"), 89 self.trUtf8("Create Dialog Code"),
90 self.trUtf8("""The file <b>{0}</b> exists but does not contain""" 90 self.trUtf8("""The file <b>{0}</b> exists but does not contain"""
91 """ any classes.""").format(self.srcFile), 91 """ any classes.""").format(self.srcFile))
92 QMessageBox.StandardButtons(\
93 QMessageBox.Abort))
94 92
95 self.okButton.setEnabled(self.classNameCombo.count() > 0) 93 self.okButton.setEnabled(self.classNameCombo.count() > 0)
96 94
97 self.__updateSlotsModel() 95 self.__updateSlotsModel()
98 96
115 return dlg.objectName() 113 return dlg.objectName()
116 except AttributeError as err: 114 except AttributeError as err:
117 QMessageBox.critical(self, 115 QMessageBox.critical(self,
118 self.trUtf8("uic error"), 116 self.trUtf8("uic error"),
119 self.trUtf8("""<p>There was an error loading the form <b>{0}</b>.</p>""" 117 self.trUtf8("""<p>There was an error loading the form <b>{0}</b>.</p>"""
120 """<p>{1}</p>""").format(self.formFile, str(err)), 118 """<p>{1}</p>""").format(self.formFile, str(err)))
121 QMessageBox.StandardButtons(\
122 QMessageBox.Ok))
123 return "" 119 return ""
124 120
125 def __className(self): 121 def __className(self):
126 """ 122 """
127 Private method to get the class name of the dialog. 123 Private method to get the class name of the dialog.
133 return dlg.metaObject().className() 129 return dlg.metaObject().className()
134 except AttributeError as err: 130 except AttributeError as err:
135 QMessageBox.critical(self, 131 QMessageBox.critical(self,
136 self.trUtf8("uic error"), 132 self.trUtf8("uic error"),
137 self.trUtf8("""<p>There was an error loading the form <b>{0}</b>.</p>""" 133 self.trUtf8("""<p>There was an error loading the form <b>{0}</b>.</p>"""
138 """<p>{1}</p>""").format(self.formFile, str(err)), 134 """<p>{1}</p>""").format(self.formFile, str(err)))
139 QMessageBox.StandardButtons(\
140 QMessageBox.Ok))
141 return "" 135 return ""
142 136
143 def __signatures(self): 137 def __signatures(self):
144 """ 138 """
145 Private slot to get the signatures. 139 Private slot to get the signatures.
264 self.slotsView.sortByColumn(0, Qt.AscendingOrder) 258 self.slotsView.sortByColumn(0, Qt.AscendingOrder)
265 except (AttributeError, ImportError) as err: 259 except (AttributeError, ImportError) as err:
266 QMessageBox.critical(self, 260 QMessageBox.critical(self,
267 self.trUtf8("uic error"), 261 self.trUtf8("uic error"),
268 self.trUtf8("""<p>There was an error loading the form <b>{0}</b>.</p>""" 262 self.trUtf8("""<p>There was an error loading the form <b>{0}</b>.</p>"""
269 """<p>{1}</p>""").format(self.formFile, str(err)), 263 """<p>{1}</p>""").format(self.formFile, str(err)))
270 QMessageBox.StandardButtons(\
271 QMessageBox.Ok))
272 264
273 def __generateCode(self): 265 def __generateCode(self):
274 """ 266 """
275 Private slot to generate the code as requested by the user. 267 Private slot to generate the code as requested by the user.
276 """ 268 """
309 except IOError as why: 301 except IOError as why:
310 QMessageBox.critical(self, 302 QMessageBox.critical(self,
311 self.trUtf8("Code Generation"), 303 self.trUtf8("Code Generation"),
312 self.trUtf8("""<p>Could not open the code template file "{0}".</p>""" 304 self.trUtf8("""<p>Could not open the code template file "{0}".</p>"""
313 """<p>Reason: {1}</p>""")\ 305 """<p>Reason: {1}</p>""")\
314 .format(tmplName, str(why)), 306 .format(tmplName, str(why)))
315 QMessageBox.StandardButtons(\
316 QMessageBox.Ok))
317 return 307 return
318 308
319 objName = self.__objectName() 309 objName = self.__objectName()
320 if objName: 310 if objName:
321 template = template\ 311 template = template\
344 except IOError as why: 334 except IOError as why:
345 QMessageBox.critical(self, 335 QMessageBox.critical(self,
346 self.trUtf8("Code Generation"), 336 self.trUtf8("Code Generation"),
347 self.trUtf8("""<p>Could not open the source file "{0}".</p>""" 337 self.trUtf8("""<p>Could not open the source file "{0}".</p>"""
348 """<p>Reason: {1}</p>""")\ 338 """<p>Reason: {1}</p>""")\
349 .format(self.srcFile, str(why)), 339 .format(self.srcFile, str(why)))
350 QMessageBox.StandardButtons(\
351 QMessageBox.Ok))
352 return 340 return
353 341
354 cls = self.__module.classes[self.classNameCombo.currentText()] 342 cls = self.__module.classes[self.classNameCombo.currentText()]
355 if cls.endlineno == len(sourceImpl) or cls.endlineno == -1: 343 if cls.endlineno == len(sourceImpl) or cls.endlineno == -1:
356 appendAtIndex = -1 344 appendAtIndex = -1
405 except IOError as why: 393 except IOError as why:
406 QMessageBox.critical(self, 394 QMessageBox.critical(self,
407 self.trUtf8("Code Generation"), 395 self.trUtf8("Code Generation"),
408 self.trUtf8("""<p>Could not write the source file "{0}".</p>""" 396 self.trUtf8("""<p>Could not write the source file "{0}".</p>"""
409 """<p>Reason: {1}</p>""")\ 397 """<p>Reason: {1}</p>""")\
410 .format(self.filenameEdit.text(), str(why)), 398 .format(self.filenameEdit.text(), str(why)))
411 QMessageBox.StandardButtons(\
412 QMessageBox.Ok))
413 return 399 return
414 400
415 self.project.appendFile(self.filenameEdit.text()) 401 self.project.appendFile(self.filenameEdit.text())
416 402
417 @pyqtSlot(int) 403 @pyqtSlot(int)

eric ide

mercurial