1
/***************************************************************************
2
* Copyright (C) 2004 by Alexander Dymo *
3
* cloudtemple@mskat.net *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU Library General Public License as *
7
* published by the Free Software Foundation; either version 2 of the *
8
* License, or (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU Library General Public *
16
* License along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
20
#include "propertywidgetproxy.h"
24
#include "propertywidget.h"
25
#include "propertymachinefactory.h"
27
namespace PropertyLib{
29
PropertyWidgetProxy::PropertyWidgetProxy(QWidget *parent, const char *name)
30
:QWidget(parent, name), mp(0), m_propertyType(Property::Invalid), m_editor(0)
33
m_layout = new QHBoxLayout(this, 0, 0);
36
PropertyWidgetProxy::~PropertyWidgetProxy()
42
void PropertyWidgetProxy::setPropertyType(int propertyType)
44
m_propertyType = static_cast<PropertyType>(propertyType);
48
void PropertyWidgetProxy::setPropertyType2(PropertyType propertyType)
50
m_propertyType = propertyType;
54
void PropertyWidgetProxy::setWidget()
58
p->setType(m_propertyType);
59
mp = new MultiProperty(p);
60
m_editor = PropertyMachineFactory::getInstance()->machineForProperty(mp)->propertyEditor;
63
m_editor->reparent(this, QPoint(0,0), true);
64
m_layout->addWidget(m_editor);
68
QVariant PropertyWidgetProxy::value() const
71
return m_editor->value();
76
void PropertyWidgetProxy::setValue(const QVariant &value)
79
m_editor->setValue(value, false);
82
bool PropertyWidgetProxy::setProperty( const char * name, const QVariant & value )
84
if( strcmp( name, "value") == 0 )
86
setPropertyType((int) value.type() );
91
return QWidget::setProperty(name, value);
94
QVariant PropertyWidgetProxy::property( const char * name ) const
96
if( strcmp( name, "value") == 0 )
99
return QWidget::property(name);
105
#include "propertywidgetproxy.moc"