Author: aschnell
Date: Fri Feb 6 11:52:25 2009
New Revision: 55294
URL: http://svn.opensuse.org/viewcvs/yast?rev=55294&view=rev
Log:
- handle rounding and precision in size input fields (bnc #466304)
Modified:
branches/SuSE-Code-11-Branch/storage/VERSION
branches/SuSE-Code-11-Branch/storage/package/yast2-storage.changes
branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-hd-dialogs.ycp
branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-loop-dialogs.ycp
branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-lvm-dialogs.ycp
branches/SuSE-Code-11-Branch/storage/storage/src/modules/Storage.ycp
Modified: branches/SuSE-Code-11-Branch/storage/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/storage/VERSION?rev=55294&r1=55293&r2=55294&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/storage/VERSION (original)
+++ branches/SuSE-Code-11-Branch/storage/VERSION Fri Feb 6 11:52:25 2009
@@ -1 +1 @@
-2.17.69
+2.17.70
Modified: branches/SuSE-Code-11-Branch/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/storage/package/yast2-storage.changes?rev=55294&r1=55293&r2=55294&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/storage/package/yast2-storage.changes (original)
+++ branches/SuSE-Code-11-Branch/storage/package/yast2-storage.changes Fri Feb 6 11:52:25 2009
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Fri Feb 06 11:04:35 CET 2009 - aschnell@suse.de
+
+- handle rounding and precision in size input fields (bnc #466304)
+- 2.17.70
+
+-------------------------------------------------------------------
Thu Jan 29 15:22:35 CET 2009 - aschnell@suse.de
- changed method to disable automounter (since "overnight" GNOME
Modified: branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-hd-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-hd-dialogs.ycp?rev=55294&r1=55293&r2=55294&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-hd-dialogs.ycp (original)
+++ branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-hd-dialogs.ycp Fri Feb 6 11:52:25 2009
@@ -187,17 +187,7 @@
case `manual_size:
{
string tmp = (string) UI::QueryWidget(`id(`size_input), `Value);
- if (!Storage::HumanStringToKByte(tmp, size_k))
- {
- // error popup, %1 and %2 are replaced by sizes
- Popup::Error(sformat(_("The size entered is invalid. Enter a value like \"%1\" or \"%2\"."),
- Storage::KByteToHumanString(500*1024),
- Storage::KByteToHumanString(1024*1024)));
- UI::SetFocus(`id(`size_input));
- widget = `again;
- continue;
- }
- else if (size_k < min_size_k || size_k > max_size_k)
+ if (!Storage::HumanStringToKByteWithRangeCheck(tmp, size_k, min_size_k, max_size_k))
{
// error popup, %1 and %2 are replaced by sizes
Popup::Error(sformat(_("The size entered is invalid. Enter a size between %1 and %2."),
Modified: branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-loop-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-loop-dialogs.ycp?rev=55294&r1=55293&r2=55294&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-loop-dialogs.ycp (original)
+++ branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-loop-dialogs.ycp Fri Feb 6 11:52:25 2009
@@ -117,14 +117,7 @@
if (create_file)
{
string tmp = (string) UI::QueryWidget(`id(`size), `Value);
- if (!Storage::HumanStringToKByte(tmp, size_k))
- {
- // error popup, %1 and %2 are replaced by sizes
- Popup::Error(sformat(_("The size entered is invalid. Enter a value like \"%1\" or \"%2\"."),
- Storage::KByteToHumanString(500*1024), Storage::KByteToHumanString(1024*1024)));
- widget = `again;
- }
- else if (size_k < min_size_k)
+ if (!Storage::HumanStringToKByteWithRangeCheck(tmp, size_k, min_size_k, nil))
{
// error popup, %1 is replaced by size
Popup::Error(sformat(_("The size entered is invalid. Enter a size of at least %1."),
Modified: branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-lvm-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-lvm-dialogs.ycp?rev=55294&r1=55293&r2=55294&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-lvm-dialogs.ycp (original)
+++ branches/SuSE-Code-11-Branch/storage/storage/src/include/ep-lvm-dialogs.ycp Fri Feb 6 11:52:25 2009
@@ -439,13 +439,7 @@
if (what == `manual_size)
{
string tmp = (string) UI::QueryWidget(`id(`size_input), `Value);
- if (!Storage::HumanStringToKByte(tmp, size_k))
- {
- Popup::Error(sformat(_("The size entered is invalid. Enter a value like \"%1\" or \"%2\"."),
- Storage::KByteToHumanString(500*1024), Storage::KByteToHumanString(1024*1024)));
- widget = `again;
- }
- else if (size_k < min_size_k || size_k > max_size_k)
+ if (!Storage::HumanStringToKByteWithRangeCheck(tmp, size_k, min_size_k, max_size_k))
{
Popup::Error(sformat(_("The size entered is invalid. Enter a size between %1 and %2."),
Storage::KByteToHumanString(min_size_k),
Modified: branches/SuSE-Code-11-Branch/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/storage/storage/src/modules/Storage.ycp?rev=55294&r1=55293&r2=55294&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/storage/storage/src/modules/Storage.ycp (original)
+++ branches/SuSE-Code-11-Branch/storage/storage/src/modules/Storage.ycp Fri Feb 6 11:52:25 2009
@@ -400,6 +400,35 @@
}
+/**
+ * Converts a string into a integer and checks the allowed range for the
+ * integer. The range check is a bit sloppy to compensate rounding issues but
+ * it's guaranteed that the result lies within the allowed range.
+ */
+global boolean HumanStringToKByteWithRangeCheck(string str, integer& bytes_k, integer min_k,
+ integer max_k)
+{
+ if (!HumanStringToKByte(str, bytes_k))
+ return false;
+
+ if (min_k != nil && bytes_k < min_k)
+ {
+ if (KByteToHumanString(bytes_k) != KByteToHumanString(min_k))
+ return false;
+ bytes_k = min_k;
+ }
+
+ if (max_k != nil && bytes_k > max_k)
+ {
+ if (KByteToHumanString(bytes_k) != KByteToHumanString(max_k))
+ return false;
+ bytes_k = max_k;
+ }
+
+ return true;
+}
+
+
global define map