00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "propertiesdock.h"
00021
00022
00023 #include <widgets/propertywidget.h>
00024 #include <engine/game.h>
00025 #include <engine/component.h>
00026 #include <objectmanager.h>
00027 #include <historymanager.h>
00028 #include <core/debughelper.h>
00029
00030 using namespace GluonCreator;
00031
00032 class PropertiesDock::PropertiesDockPrivate
00033 {
00034 public:
00035 PropertiesDockPrivate() { }
00036
00037 PropertyWidget* widget;
00038 };
00039
00040 PropertiesDock::PropertiesDock( const QString& title, QWidget* parent, Qt::WindowFlags flags )
00041 : QDockWidget( title, parent, flags ), d( new PropertiesDockPrivate )
00042 {
00043 setObjectName( "PropertiesDock" );
00044
00045 d->widget = new PropertyWidget( this );
00046 setWidget( d->widget );
00047
00048 connect( SelectionManager::instance(), SIGNAL( selectionChanged( SelectionManager::SelectionList ) ), SLOT( selectionChanged( SelectionManager::SelectionList ) ) );
00049 connect( d->widget, SIGNAL( propertyChanged( QObject*, QString, QVariant, QVariant ) ), SLOT( propertyChanged( QObject*, QString, QVariant, QVariant ) ) );
00050 connect( ObjectManager::instance(), SIGNAL( newComponent( GluonEngine::Component* ) ), SLOT( newComponent( GluonEngine::Component* ) ) );
00051 }
00052
00053 PropertiesDock::~PropertiesDock()
00054 {
00055 delete d;
00056 }
00057
00058 void PropertiesDock::selectionChanged( SelectionManager::SelectionList selection )
00059 {
00060 if( !selection.empty() )
00061 d->widget->setObject( selection.at( 0 ) );
00062 }
00063
00064 void PropertiesDock::newComponent( GluonEngine::Component* comp )
00065 {
00066 if( comp->parent() == d->widget->object() )
00067 {
00068 d->widget->setObject( d->widget->object() );
00069 }
00070 }
00071
00072 void PropertiesDock::propertyChanged( QObject* object, QString property, QVariant oldValue, QVariant newValue )
00073 {
00074 GluonCore::GluonObject* obj = qobject_cast<GluonCore::GluonObject*>( object );
00075
00076 if( obj )
00077 ObjectManager::instance()->changeProperty( obj, property, oldValue, newValue );
00078 }
00079
00080