Mercurial > hg > svcore
changeset 94:5b8392e80ed6
* Add property labels to property containers (so i18n() won't affect file format)
author | Chris Cannam |
---|---|
date | Wed, 03 May 2006 16:48:03 +0000 |
parents | 27d726916ab3 |
children | 040a151d0897 |
files | base/PropertyContainer.cpp base/PropertyContainer.h base/View.cpp base/View.h |
diffstat | 4 files changed, 38 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/base/PropertyContainer.cpp Wed May 03 16:47:04 2006 +0000 +++ b/base/PropertyContainer.cpp Wed May 03 16:48:03 2006 +0000 @@ -24,6 +24,12 @@ return PropertyList(); } +//QString +//PropertyContainer::getPropertyLabel(const PropertyName &) const +//{ +// return ""; +//} + PropertyContainer::PropertyType PropertyContainer::getPropertyType(const PropertyName &) const {
--- a/base/PropertyContainer.h Wed May 03 16:47:04 2006 +0000 +++ b/base/PropertyContainer.h Wed May 03 16:48:03 2006 +0000 @@ -44,15 +44,16 @@ /** * Get a list of the names of all the supported properties on this - * container. Note that these should already have been - * internationalized with a call to tr() or equivalent. If the - * container needs to test for equality with string literals - * subsequently, it must be sure to call tr() again on the strings - * in order to ensure they match. + * container. These should be fixed (i.e. not internationalized). */ virtual PropertyList getProperties() const; /** + * Return the human-readable (and i18n'ised) name of a property. + */ + virtual QString getPropertyLabel(const PropertyName &) const = 0; + + /** * Return the type of the given property, or InvalidProperty if * the property is not supported on this container. */
--- a/base/View.cpp Wed May 03 16:47:04 2006 +0000 +++ b/base/View.cpp Wed May 03 16:48:03 2006 +0000 @@ -69,18 +69,27 @@ View::getProperties() const { PropertyContainer::PropertyList list; - list.push_back(tr("Global Scroll")); - list.push_back(tr("Global Zoom")); - list.push_back(tr("Follow Playback")); + list.push_back("Global Scroll"); + list.push_back("Global Zoom"); + list.push_back("Follow Playback"); return list; } +QString +View::getPropertyLabel(const PropertyName &pn) const +{ + if (pn == "Global Scroll") return tr("Global Scroll"); + if (pn == "Global Zoom") return tr("Global Zoom"); + if (pn == "Follow Playback") return tr("Follow Playback"); + return ""; +} + PropertyContainer::PropertyType View::getPropertyType(const PropertyContainer::PropertyName &name) const { - if (name == tr("Global Scroll")) return PropertyContainer::ToggleProperty; - if (name == tr("Global Zoom")) return PropertyContainer::ToggleProperty; - if (name == tr("Follow Playback")) return PropertyContainer::ValueProperty; + if (name == "Global Scroll") return PropertyContainer::ToggleProperty; + if (name == "Global Zoom") return PropertyContainer::ToggleProperty; + if (name == "Follow Playback") return PropertyContainer::ValueProperty; return PropertyContainer::InvalidProperty; } @@ -88,9 +97,9 @@ View::getPropertyRangeAndValue(const PropertyContainer::PropertyName &name, int *min, int *max) const { - if (name == tr("Global Scroll")) return m_followPan; - if (name == tr("Global Zoom")) return m_followZoom; - if (name == tr("Follow Playback")) { + if (name == "Global Scroll") return m_followPan; + if (name == "Global Zoom") return m_followZoom; + if (name == "Follow Playback") { if (min) *min = 0; if (max) *max = 2; return int(m_followPlay); @@ -104,7 +113,7 @@ View::getPropertyValueLabel(const PropertyContainer::PropertyName &name, int value) const { - if (name == tr("Follow Playback")) { + if (name == "Follow Playback") { switch (value) { default: case 0: return tr("Scroll"); @@ -118,11 +127,11 @@ void View::setProperty(const PropertyContainer::PropertyName &name, int value) { - if (name == tr("Global Scroll")) { + if (name == "Global Scroll") { setFollowGlobalPan(value != 0); - } else if (name == tr("Global Zoom")) { + } else if (name == "Global Zoom") { setFollowGlobalZoom(value != 0); - } else if (name == tr("Follow Playback")) { + } else if (name == "Follow Playback") { switch (value) { default: case 0: setPlaybackFollow(PlaybackScrollContinuous); break;
--- a/base/View.h Wed May 03 16:47:04 2006 +0000 +++ b/base/View.h Wed May 03 16:48:03 2006 +0000 @@ -204,6 +204,7 @@ // PropertyContainer that we can return on request that just // delegates back to us. virtual PropertyContainer::PropertyList getProperties() const; + virtual QString getPropertyLabel(const PropertyName &) const; virtual PropertyContainer::PropertyType getPropertyType(const PropertyName &) const; virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max) const; @@ -328,6 +329,9 @@ public: ViewPropertyContainer(View *v); PropertyList getProperties() const { return m_v->getProperties(); } + QString getPropertyLabel(const PropertyName &n) const { + return m_v->getPropertyLabel(n); + } PropertyType getPropertyType(const PropertyName &n) const { return m_v->getPropertyType(n); }