Change the int type identification
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 5 Feb 2009 10:24:44 +0000 (10:24 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 5 Feb 2009 10:24:44 +0000 (10:24 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2264 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BModulePage.py
wizard/bertos_utils.py

index 71a2f2e60bf831f0c0ad4b53cec23d1dc94b1f49..c98ce937ac6140efc2f2857f176089c0c3b15641 100644 (file)
@@ -102,24 +102,28 @@ class BModulePage(BWizardPage):
                 ## int, long or undefined type property
                 spinBox = QSpinBox()
                 self.pageContent.propertyTable.setCellWidget(index, 1, spinBox)
+                if bertos_utils.isInt(configurations[property]):
+                    minimum = -32768
+                    maximmum = 32767
+                    suff = ""
+                elif bertos_utils.isLong(configurations[property]):
+                    minimum = -2147483648
+                    maximum = 2147483647
+                    suff = "L"
+                elif bertos_utils.isUnsigned(configurations[property]):
+                    minimum = 0
+                    maximum = 65535
+                    suff = "U"
+                elif bertos_utils.isUnsignedLong(configurations[property]):
+                    minimum = 0
+                    maximum = 4294967295
+                    suff = "UL"
                 if "min" in configurations[property]["informations"].keys():
                     minimum = int(configurations[property]["informations"]["min"])
-                else:
-                    minimum = -32768
-                spinBox.setMinimum(minimum)
                 if "max" in configurations[property]["informations"].keys():
                     maximum = int(configurations[property]["informations"]["max"])
-                else:
-                    maximum = 32767
-                spinBox.setMaximum(maximum)
-                if "unsigned" in configurations[property]["informations"].keys() and configurations[property]["informations"]["unsigned"]:
-                    suff = str(spinBox.suffix())
-                    suff += "U"
-                    spinBox.setSuffix(suff)
-                if "long" in configurations[property]["informations"].keys() and configurations[property]["informations"]["long"]:
-                    suff = str(spinBox.suffix())
-                    suff += "L"
-                    spinBox.setSuffix(suff)
+                spinBox.setRange(minimum, maximum)
+                spinBox.setSuffix(suff)
                 spinBox.setValue(int(configurations[property]["value"].replace("L", "").replace("U", "")))
                 self._controlGroup.addControl(index, spinBox)
     
index 5436a3b3bd5afb53e9bc88ac61ef1d791f6ec575..f224c6b0b122e142ca244636b657f47150caee5b 100644 (file)
@@ -287,3 +287,39 @@ def sub(string, parameter, value):
     Substitute the given value at the given parameter define in the given string
     """
     return re.sub(r"(?P<define>#define\s+" + parameter + r"\s+)([^\s]+)", r"\g<define>" + value, string)
+
+def isInt(value):
+    """
+    Return True if the value is a simple int.
+    """
+    if "long" not in value["informations"].keys() and "unsigned" not in value["informations"].keys():
+        return True
+    else:
+        return False
+
+def isLong(value):
+    """
+    Return True if the value is a long.
+    """
+    if "long" not in value["informations"].keys() and value["informations"]["long"] and "unsigned" not in value["informations"].key():
+        return True
+    else:
+        return False
+
+def isUnsigned(value):
+    """
+    Return True if the value is an unsigned.
+    """
+    if "unsigned" not in value["informations"].keys() and value["informations"]["unsigned"] and "long" not in value["informations"].key():
+        return True
+    else:
+        return False
+
+def isUnsignedLong(value):
+    """
+    Return True if the value is an unsigned long.
+    """
+    if "unsigned" in value["informations"].keys() and "long" in value["informations"].keys() and value["informations"]["unsigned"] and value["informations"]["long"]:
+        return True
+    else:
+        return False
\ No newline at end of file