# HG changeset patch # User Chris Cannam # Date 1172844012 0 # Node ID 4cd620bd4c619a2ddaa5dc1b6c4495c8ab2847c7 # Parent 85bf384db35f7c210ecfdbf100a4c06dacf1fbc2 * Make getPropertyRangeAndValue return the default separately from the current value. Previously some contexts were incorrectly treating the current value as a default. diff -r 85bf384db35f -r 4cd620bd4c61 base/Preferences.cpp --- 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; } diff -r 85bf384db35f -r 4cd620bd4c61 base/Preferences.h --- 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; diff -r 85bf384db35f -r 4cd620bd4c61 base/PropertyContainer.cpp --- 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); } diff -r 85bf384db35f -r 4cd620bd4c61 base/PropertyContainer.h --- 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