Fixes a bug when entering non-digit values for item's goal in metadata

This commit is contained in:
Olivier Keshavjee 2017-11-09 20:30:54 +01:00
parent 15ccaa513b
commit bc70501373
3 changed files with 9 additions and 4 deletions

View file

@ -24,9 +24,12 @@ def wordCount(text):
def toInt(text):
if text:
return int(text)
else:
return 0
try:
return int(text)
except ValueError:
pass
return 0
def toFloat(text):

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python
# --!-- coding: utf8 --!--
from PyQt5.QtWidgets import QWidget
from PyQt5.QtGui import QIntValidator
from manuskript.enums import Outline
from manuskript.ui.views.propertiesView_ui import Ui_propertiesView
@ -19,6 +20,7 @@ class propertiesView(QWidget, Ui_propertiesView):
self.chkCompile.setModel(mdlOutline)
self.txtTitle.setModel(mdlOutline)
self.txtGoal.setModel(mdlOutline)
self.txtGoal.setValidator(QIntValidator(0, 9999999))
def getIndexes(self, sourceView):
"""Returns a list of indexes from list of QItemSelectionRange"""

View file

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'manuskript/ui/views/propertiesView_ui.ui'
#
# Created by: PyQt5 UI code generator 5.4.2
# Created by: PyQt5 UI code generator 5.9
#
# WARNING! All changes made in this file will be lost!