propertywidgetproxy.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "propertywidgetproxy.h"
00021
00022 #include <qlayout.h>
00023
00024 #include "propertywidget.h"
00025 #include "propertymachinefactory.h"
00026
00027 namespace PropertyLib{
00028
00029 PropertyWidgetProxy::PropertyWidgetProxy(QWidget *parent, const char *name)
00030 :QWidget(parent, name), mp(0), m_propertyType(Property::Invalid), m_editor(0)
00031 {
00032 p = new Property();
00033 m_layout = new QHBoxLayout(this, 0, 0);
00034 }
00035
00036 PropertyWidgetProxy::~PropertyWidgetProxy()
00037 {
00038 delete mp;
00039 delete p;
00040 }
00041
00042 void PropertyWidgetProxy::setPropertyType(int propertyType)
00043 {
00044 m_propertyType = static_cast<Property::PropertyType>(propertyType);
00045 setWidget();
00046 }
00047
00048 void PropertyWidgetProxy::setPropertyType2(PropertyType propertyType)
00049 {
00050 m_propertyType = propertyType;
00051 setWidget();
00052 }
00053
00054 void PropertyWidgetProxy::setWidget()
00055 {
00056 if (m_editor)
00057 delete m_editor;
00058 p->setType(m_propertyType);
00059 mp = new MultiProperty(p);
00060 m_editor = PropertyMachineFactory::getInstance()->machineForProperty(mp)->propertyEditor;
00061 if (m_editor)
00062 {
00063 m_editor->reparent(this, QPoint(0,0), true);
00064 m_layout->addWidget(m_editor);
00065 }
00066 }
00067
00068 QVariant PropertyWidgetProxy::value() const
00069 {
00070 if (m_editor)
00071 return m_editor->value();
00072 else
00073 return QVariant();
00074 }
00075
00076 void PropertyWidgetProxy::setValue(const QVariant &value)
00077 {
00078 if (m_editor)
00079 m_editor->setValue(value, false);
00080 }
00081
00082 bool PropertyWidgetProxy::setProperty( const char * name, const QVariant & value )
00083 {
00084 if( strcmp( name, "value") == 0 )
00085 {
00086 setPropertyType((int) value.type() );
00087 setValue( value );
00088 return true;
00089 }
00090 else
00091 return QWidget::setProperty(name, value);
00092 }
00093
00094 QVariant PropertyWidgetProxy::property( const char * name ) const
00095 {
00096 if( strcmp( name, "value") == 0 )
00097 return value( );
00098 else
00099 return QWidget::property(name);
00100 }
00101
00102 }
00103 #include "propertywidgetproxy.moc"
This file is part of the documentation for KDevelop Version 3.1.2.