31 #include <QStringList> 32 #include <QStyleOptionViewItem> 42 const QColor& default_value,
43 const QString& description,
45 const char *changed_slot,
47 :
Property( name, QVariant(), description, parent, changed_slot, receiver )
48 , color_( default_value )
55 if( new_color !=
color_ ) {
67 if( new_value.type() == QVariant::Color )
69 return setColor( new_value.value<QColor>() );
72 QColor new_color =
parseColor( new_value.toString() );
73 if( new_color.isValid() )
86 const QStyleOptionViewItem & option )
const 92 color = QColor( 200, 200, 200 );
93 painter->setPen( QColor( Qt::lightGray ) );
95 QString text =
value_.toString();
96 QRect rect = option.rect;
98 rect.adjust( rect.height() + 4, 1, 0, 0 );
99 painter->drawText( rect, text );
107 const QStyleOptionViewItem& option )
110 editor->setFrame(
false );
virtual bool paint(QPainter *painter, const QStyleOptionViewItem &option) const
Hook to provide custom painting of the value data (right-hand column) in a subclass.
void changed()
Emitted by setValue() just after the value has changed.
A single element of a property tree, with a name, value, description, and possibly children...
QVariant value_
This is the central property value. If you set it directly in a subclass, do so with care because man...
static void paintColorBox(QPainter *painter, const QRect &rect, const QColor &color)
ColorProperty(const QString &name=QString(), const QColor &default_value=Qt::black, const QString &description=QString(), Property *parent=0, const char *changed_slot=0, QObject *receiver=0)
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option)
Create an editor widget to edit the value of this property.
virtual bool setColor(const QColor &color)
QColor parseColor(const QString &color_string)
QString printColor(const QColor &color)
void aboutToChange()
Emitted by setValue() just before the value has changed.
virtual bool setValue(const QVariant &new_value)
Set the new value for this property. Returns true if the new value is different from the old value...
virtual Qt::ItemFlags getViewFlags(int column) const
Return item flags appropriate for the given column (0 or 1) for this Property.