All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Slots | Signals | Public Member Functions
QGpGuiTools::PropertyValue Class Reference

A property value managing red and bold indicators for constant and touched states, respectively. More...

#include <PropertyValue.h>

List of all members.

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

Detailed Description

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.


Constructor & Destructor Documentation

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;
}

Member Function Documentation

bool QGpGuiTools::PropertyValue::constant ( ) const [inline]
{return _constant;}

Referenced by reset(), and setValue().

void QGpGuiTools::PropertyValue::freeze ( bool  f) [inline]
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;}

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]

The property widget has been modified by user, commit changed to object

References reset().

{
  if(!_frozen) {
    _touched=true;
    emit touched(this);
    reset();
  }
}
QVariant QGpGuiTools::PropertyValue::value ( ) const [inline]
{return _value;}
QWidget* QGpGuiTools::PropertyValue::widget ( ) const [inline]
{return _widget;}

Referenced by PropertyValue().

{return _widgetType;}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines