changeset 245:4cd620bd4c61 sv1-1.0pre1

* Make getPropertyRangeAndValue return the default separately from the current value. Previously some contexts were incorrectly treating the current value as a default.
author Chris Cannam
date Fri, 02 Mar 2007 14:00:12 +0000
parents 85bf384db35f
children d7eeffbb8aaf
files base/Preferences.cpp base/Preferences.h base/PropertyContainer.cpp base/PropertyContainer.h
diffstat 4 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/base/Preferences.cpp	Fri Mar 02 13:01:41 2007 +0000
+++ b/base/Preferences.cpp	Fri Mar 02 14:00:12 2007 +0000
@@ -113,11 +113,12 @@
 
 int
 Preferences::getPropertyRangeAndValue(const PropertyName &name,
-                                      int *min, int *max) const
+                                      int *min, int *max, int *deflt) const
 {
     if (name == "Smooth Spectrogram") {
         if (min) *min = 0;
         if (max) *max = 1;
+        if (deflt) *deflt = 1;
         return m_smoothSpectrogram ? 1 : 0;
     }
 
@@ -126,18 +127,21 @@
     if (name == "Property Box Layout") {
         if (min) *min = 0;
         if (max) *max = 1;
+        if (deflt) *deflt = 0;
         return m_propertyBoxLayout == Layered ? 1 : 0;
     }        
 
     if (name == "Window Type") {
         if (min) *min = int(RectangularWindow);
         if (max) *max = int(BlackmanHarrisWindow);
+        if (deflt) *deflt = int(HanningWindow);
         return int(m_windowType);
     }
 
     if (name == "Resample Quality") {
         if (min) *min = 0;
         if (max) *max = 2;
+        if (deflt) *deflt = 1;
         return m_resampleQuality;
     }
 
--- a/base/Preferences.h	Fri Mar 02 13:01:41 2007 +0000
+++ b/base/Preferences.h	Fri Mar 02 14:00:12 2007 +0000
@@ -30,7 +30,7 @@
     virtual PropertyList getProperties() const;
     virtual QString getPropertyLabel(const PropertyName &) const;
     virtual PropertyType getPropertyType(const PropertyName &) const;
-    virtual int getPropertyRangeAndValue(const PropertyName &, int *, int *) const;
+    virtual int getPropertyRangeAndValue(const PropertyName &, int *, int *, int *) const;
     virtual QString getPropertyValueLabel(const PropertyName &, int value) const;
     virtual QString getPropertyContainerName() const;
     virtual QString getPropertyContainerIconName() const;
--- a/base/PropertyContainer.cpp	Fri Mar 02 13:01:41 2007 +0000
+++ b/base/PropertyContainer.cpp	Fri Mar 02 14:00:12 2007 +0000
@@ -47,10 +47,12 @@
 }
 
 int
-PropertyContainer::getPropertyRangeAndValue(const PropertyName &, int *min, int *max) const
+PropertyContainer::getPropertyRangeAndValue(const PropertyName &,
+                                            int *min, int *max, int *deflt) const
 {
     if (min) *min = 0;
     if (max) *max = 0;
+    if (deflt) *deflt = 0;
     return 0;
 }
 
@@ -75,7 +77,7 @@
 void
 PropertyContainer::setPropertyWithCommand(const PropertyName &name, int value)
 {
-    int currentValue = getPropertyRangeAndValue(name, 0, 0);
+    int currentValue = getPropertyRangeAndValue(name, 0, 0, 0);
     if (value == currentValue) return;
 
     CommandHistory::getInstance()->addCommand
@@ -176,7 +178,7 @@
     case ValueProperty:
     {
         int min, max;
-        getPropertyRangeAndValue(name, &min, &max);
+        getPropertyRangeAndValue(name, &min, &max, 0);
         for (int i = min; i <= max; ++i) {
             if (valueString == getPropertyValueLabel(name, i)) {
                 value = i;
@@ -211,7 +213,7 @@
     if (success) return true;
 
     int min, max;
-    getPropertyRangeAndValue(name, &min, &max);
+    getPropertyRangeAndValue(name, &min, &max, 0);
     
     bool ok = false;
     int i = valueString.toInt(&ok);
@@ -240,7 +242,7 @@
 void
 PropertyContainer::SetPropertyCommand::execute()
 {
-    m_oldValue = m_pc->getPropertyRangeAndValue(m_pn, 0, 0);
+    m_oldValue = m_pc->getPropertyRangeAndValue(m_pn, 0, 0, 0);
     m_pc->setProperty(m_pn, m_value);
 }
 
--- a/base/PropertyContainer.h	Fri Mar 02 13:01:41 2007 +0000
+++ b/base/PropertyContainer.h	Fri Mar 02 14:00:12 2007 +0000
@@ -76,7 +76,7 @@
      * passed as NULL if their values are not required.
      */
     virtual int getPropertyRangeAndValue(const PropertyName &,
-					 int *min, int *max) const;
+					 int *min, int *max, int *deflt) const;
 
     /**
      * If the given property is a ValueProperty, return the display