A property value managing red and bold indicators for constant and touched states, respectively. More...
#include <PropertyValue.h>
Public Slots | |
void | touched () |
Signals | |
void | constantChanged (bool c) |
void | touched (PropertyValue *p) |
Public Member Functions | |
bool | constant () const |
void | freeze (bool f) |
int | id () const |
bool | isFrozen () const |
bool | isTouched () const |
QWidget * | label () const |
PropertyValue (int id, QWidget *w, QWidget *label, int widgetType) | |
void | reset () |
void | setTouched (bool t=true) |
void | setValue (QVariant val) |
QVariant | value () const |
QWidget * | widget () const |
int | widgetType () const |
A property value managing red and bold indicators for constant and touched states, respectively.
A class that records a property value. A property can be shared by various objects. It means that changing its value may alter various objects. To know if all objects have already the same value and if the value displayed in a control is really shared by all objects, the label of the control is colored. A red color indicates that all objects have currently not the same value. Hence, changing this value will uniformize these object reagarding this property. This is the "constant" state.
QGpGuiTools::PropertyValue::PropertyValue | ( | int | id, |
QWidget * | w, | ||
QWidget * | label, | ||
int | widgetType | ||
) |
Constructor. w or label can be null. w and label can point to the same widget (e.g. for a checkbox).
References id(), label(), TRACE, and widgetType().
{ TRACE; _id=id; _widget=w; _label=label; _widgetType=widgetType; _constant=true; _frozen=false; _touched=false; }
bool QGpGuiTools::PropertyValue::constant | ( | ) | const [inline] |
{return _constant;}
void QGpGuiTools::PropertyValue::constantChanged | ( | bool | c | ) | [signal] |
Referenced by reset(), and setValue().
void QGpGuiTools::PropertyValue::freeze | ( | bool | f | ) | [inline] |
Referenced by QGpGuiTools::PropertyWidget::setWidgets(), and QGpGuiTools::PropertyWidget::touched().
{_frozen=f;}
int QGpGuiTools::PropertyValue::id | ( | ) | const [inline] |
Referenced by PropertyValue(), and QGpGuiTools::PropertyWidget::touched().
{return _id;}
bool QGpGuiTools::PropertyValue::isFrozen | ( | ) | const [inline] |
Referenced by QGpGuiTools::PropertyWidget::setWidgets().
{return _frozen;}
bool QGpGuiTools::PropertyValue::isTouched | ( | ) | const [inline] |
Referenced by GroupView::properties(), and GroupProperties::setProperties().
{return _touched;}
QWidget* QGpGuiTools::PropertyValue::label | ( | ) | const [inline] |
Referenced by PropertyValue().
{return _label;}
void QGpGuiTools::PropertyValue::reset | ( | ) |
Set current value as invalid, constant and untouched
References constantChanged().
Referenced by touched().
{ if(!_constant && _label) { QPalette palette; palette.setColor(QPalette::Foreground, Qt::black); _label->setPalette(palette); } _constant=true; emit constantChanged(true); _value=QVariant(); }
void QGpGuiTools::PropertyValue::setTouched | ( | bool | t = true | ) | [inline] |
Referenced by GroupProperties::on_folderTree_clicked().
{_touched=t;}
void QGpGuiTools::PropertyValue::setValue | ( | QVariant | val | ) |
Set current value to val. It the current value is already valid and if it differs from val, the contant state is changed to false and the color of label is set to red.
References constantChanged(), and TRACE.
Referenced by QGpGuiTools::PropertyWidget::setValue().
{ TRACE; if(_constant && _value.isValid()) { if(val.type()>=QVariant::UserType) { // TODO a possibility to compare user types } else if(val!=_value) { // QVariant does not support comparison operator for non standard types _constant=false; if(_label) { QPalette palette; palette.setColor(QPalette::Foreground, Qt::red); _label->setPalette(palette); } emit constantChanged(false); } } _value=val; }
void QGpGuiTools::PropertyValue::touched | ( | ) | [inline, slot] |
void QGpGuiTools::PropertyValue::touched | ( | PropertyValue * | p | ) | [signal] |
QVariant QGpGuiTools::PropertyValue::value | ( | ) | const [inline] |
{return _value;}
QWidget* QGpGuiTools::PropertyValue::widget | ( | ) | const [inline] |
{return _widget;}
int QGpGuiTools::PropertyValue::widgetType | ( | ) | const [inline] |
Referenced by PropertyValue().
{return _widgetType;}