From bc70501373c7ce6b62f2b23e92da8cd6b6865512 Mon Sep 17 00:00:00 2001 From: Olivier Keshavjee Date: Thu, 9 Nov 2017 20:30:54 +0100 Subject: [PATCH] Fixes a bug when entering non-digit values for item's goal in metadata --- manuskript/functions.py | 9 ++++++--- manuskript/ui/views/propertiesView.py | 2 ++ manuskript/ui/views/propertiesView_ui.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/manuskript/functions.py b/manuskript/functions.py index b7873ad7..04d57b7a 100644 --- a/manuskript/functions.py +++ b/manuskript/functions.py @@ -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): diff --git a/manuskript/ui/views/propertiesView.py b/manuskript/ui/views/propertiesView.py index e0fa7191..30857ef8 100644 --- a/manuskript/ui/views/propertiesView.py +++ b/manuskript/ui/views/propertiesView.py @@ -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""" diff --git a/manuskript/ui/views/propertiesView_ui.py b/manuskript/ui/views/propertiesView_ui.py index 5b8a7e11..e4846fae 100644 --- a/manuskript/ui/views/propertiesView_ui.py +++ b/manuskript/ui/views/propertiesView_ui.py @@ -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!