00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "intpropertywidgetitem.h"
00023
00024 #include <QtGui/QSpinBox>
00025 #include <QtCore/QDebug>
00026
00027 REGISTER_PROPERTYWIDGETITEM( GluonCreator, IntPropertyWidgetItem )
00028
00029 using namespace GluonCreator;
00030
00031 IntPropertyWidgetItem::IntPropertyWidgetItem( QWidget* parent, Qt::WindowFlags f )
00032 : PropertyWidgetItem( parent, f )
00033 {
00034 }
00035
00036 IntPropertyWidgetItem::~IntPropertyWidgetItem()
00037 {
00038
00039 }
00040
00041 QStringList
00042 IntPropertyWidgetItem::supportedDataTypes() const
00043 {
00044 QStringList supportedTypes;
00045 supportedTypes.append( "int" );
00046 supportedTypes.append( "uint" );
00047 return supportedTypes;
00048 }
00049
00050 PropertyWidgetItem*
00051 IntPropertyWidgetItem::instantiate()
00052 {
00053 return new IntPropertyWidgetItem();
00054 }
00055
00056 void
00057 IntPropertyWidgetItem::setEditValue( const QVariant& value )
00058 {
00059 editWidget()->setProperty( "value", value );
00060 }
00061
00062 void
00063 IntPropertyWidgetItem::intValueChanged( int value )
00064 {
00065 PropertyWidgetItem::valueChanged( QVariant( value ) );
00066 }
00067
00068 void
00069 IntPropertyWidgetItem::uintValueChanged( int value )
00070 {
00071 PropertyWidgetItem::valueChanged( QVariant::fromValue<uint>( value ) );
00072 }
00073
00074 void IntPropertyWidgetItem::setEditProperty( const QString& propertyName )
00075 {
00076 QSpinBox* spinBox = new QSpinBox( this );
00077 setEditWidget( spinBox );
00078
00079 qDebug() << editObject()->property( propertyName.toUtf8() ).typeName();
00080 if( editObject()->property( propertyName.toUtf8() ).typeName() == QString( "uint" ) )
00081 {
00082 spinBox->setMinimum( 3 );
00083 connect( spinBox, SIGNAL( valueChanged( int ) ), this, SLOT( uintValueChanged( int ) ) );
00084 }
00085 else
00086 {
00087 connect( spinBox, SIGNAL( valueChanged( int ) ), this, SLOT( intValueChanged( int ) ) );
00088 }
00089
00090 GluonCreator::PropertyWidgetItem::setEditProperty( propertyName );
00091 }
00092
00093
00094