From d21b808e07041f4a6b1fe1aface9d52cb3fcc2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Luis=20Cerc=C3=B3s=20Pita?= Date: Thu, 5 Jan 2012 14:56:26 +0100 Subject: [PATCH] Fixed QtCore.Qt.ImhFormattedNumbersOnly backward compatibility --- src/Mod/Ship/shipOutlineDraw/TaskPanel.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Mod/Ship/shipOutlineDraw/TaskPanel.py b/src/Mod/Ship/shipOutlineDraw/TaskPanel.py index 3861027e36..07c8c18a0d 100644 --- a/src/Mod/Ship/shipOutlineDraw/TaskPanel.py +++ b/src/Mod/Ship/shipOutlineDraw/TaskPanel.py @@ -76,7 +76,11 @@ class TaskPanel: mw = self.getMainWindow() form = mw.findChild(QtGui.QWidget, "TaskPanel") form.sections = form.findChild(QtGui.QTableWidget, "Sections") - form.sections.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly) + try: + form.sections.setInputMethodHints(QtCore.Qt.ImhFormattedNumbersOnly) + except: + msg = Translator.translate("QtCore.Qt.ImhFormattedNumbersOnly not supported, will not used.\n") + App.Console.PrintWarning(msg) form.sectionType = form.findChild(QtGui.QComboBox, "SectionType") form.deleteButton = form.findChild(QtGui.QPushButton, "DeleteButton") form.nSections = form.findChild(QtGui.QSpinBox, "NSections") @@ -201,10 +205,20 @@ class TaskPanel: if(item.text() != ''): self.form.sections.setRowCount(nRow+1) # Ensure that new item is a number + ID = self.form.sectionType.currentIndex() + if ID == 0: + SectionList = self.LSections[:] + elif ID == 1: + SectionList = self.BSections[:] + elif ID == 2: + SectionList = self.TSections[:] item = self.form.sections.item(row,column) (number,flag) = item.text().toFloat() if not flag: - number = 0.0 + if len(SectionList) > nRow-1: + number = SectionList[nRow-1] + else: + number = 0.0 string = '%f' % (number) item.setText(string) # Regenerate the list