Closed kateyy closed 10 years ago
Is that what you want? Seems to work with the property(gui) examples. It doesn't look so great to have this "duplicated" function, but i don't see a better solution in the moment.
This is getting too complicated, there should be no such distinction. There is a toString() method that returns the value of a property as a string - nothing more, nothing less. If there are options like "prefix" and "suffix", it's the responsibility of the GUI to respect those and concatenate a string with prefix, value and postfix before displaying it.
Also, keep in mind that the value has to be kept separate from the prefix/postfix when editing. For example, when a string property is edited, and there is a prefix and/or postfix set, those values must not end up in the string. But when we just call setText(prefix + value + postfix) on the text box, we cannot distinguish later what the user meant when changing the string, and the prefix and postfix will get into the actual property value. I'm not sure if this has already been considered in the current implementation.
edit: I see that this feature currently is only implemented for number properties, so this remark should not be relevant in that case. However, if the option should later be available for other types, we have to think about that.
Yep this would be much easier implemented in PropertyPainter::drawValue (?). Btw the QSpinBox implement these post/prefixes, just not for longlong value.
So for this PR, I could fix this code for floating point properties. Implementing the post/prefix as you would expect them to work in the Qt implementation would need some more LOC..
Okay i reverted the changes in reflectionzeug, the PropertyPainter now takes care of rendering the sufix/prefixes. For editing, the options are only supported in floating point properties, the integral editors contain only the value itself.
I think the QAbstractSpinBox actually implements the affixes in its private class. Maybe we can subclass it to use this feature, but I didn't find a way how to do this. (http://qt-project.org/wiki/Dpointer might help...)
Unfortunately no. The spin boxes already inherit from QAbstractSpinBox, but it doesn't support prefixes and suffixes.
So what about this PR? This adds affixes for NumberProperties. When editing, the affixes are only shown for floating point values, as supported by QDoubleSpinBox.
I think it's fine for now. But it's adding affixes for all properties at the moment. However, we should create an issue for refining it another day.
:shipit:
Can you please merge this? I don't have write access :smiley:
Thanks!
This adds prefix and suffix options for the SpinEdits, as discussed in #69