00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "edgepropertieswidget.h"
00021 #include "edge.h"
00022 #include "MainWindow.h"
00023 #include "model_GraphProperties.h"
00024 #include <graph.h>
00025
00026 EdgePropertiesWidget::EdgePropertiesWidget( QWidget* parent ): QWidget( parent )
00027 {
00028 setupUi( this );
00029 _edge = 0;
00030 }
00031
00032 void EdgePropertiesWidget::setEdge( Edge* e, QPointF pos )
00033 {
00034 if( _edge == e )
00035 return;
00036
00037 if( _edge )
00038 {
00039 disconnectEdge();
00040 }
00041 _edge = e;
00042 move( pos.x() + 10, pos.y() + 10 );
00043
00044 GraphPropertiesModel* model = new GraphPropertiesModel();
00045 model->setDataSource( _edge );
00046
00047 _propertiesTable->setModel( model );
00048
00049
00050 show();
00051 activateWindow();
00052 raise();
00053
00054 connect( _edge, SIGNAL( changed() ), this, SLOT( reflectAttributes() ) );
00055
00056 connect( _value, SIGNAL( textChanged( QString ) ), _edge, SLOT( setValue( QString ) ) );
00057 connect( _name, SIGNAL( textChanged( QString ) ), _edge, SLOT( setName( QString ) ) );
00058 connect( _width, SIGNAL( valueChanged( double ) ), _edge, SLOT( setWidth( double ) ) );
00059 connect( _showName, SIGNAL( toggled( bool ) ), _edge, SLOT( hideName( bool ) ) );
00060 connect( _showValue, SIGNAL( toggled( bool ) ), _edge, SLOT( hideValue( bool ) ) );
00061
00062 reflectAttributes();
00063 }
00064
00065 void EdgePropertiesWidget::reflectAttributes()
00066 {
00067 _name->setText( _edge->name() );
00068 _value->setText( _edge->value() );
00069 _color->setColor( _edge->color() );
00070 _width->setValue( _edge->width() );
00071 _propertyName->setText( "" );
00072 _propertyValue->setText( "" );
00073 _isPropertyGlobal->setCheckState( Qt::Unchecked );
00074 }
00075
00076 void EdgePropertiesWidget::on__color_activated( const QColor& c )
00077 {
00078 _edge->setColor( c.name() );
00079 }
00080
00081 void EdgePropertiesWidget::on__style_activated( int index )
00082 {
00083 switch( index )
00084 {
00085 case 0 :
00086 _edge->setStyle( "solid" );
00087 break;
00088 case 1 :
00089 _edge->setStyle( "dash" );
00090 break;
00091 case 2 :
00092 _edge->setStyle( "dot" );
00093 break;
00094 case 3 :
00095 _edge->setStyle( "dash dot" );
00096 break;
00097 }
00098 }
00099
00100 void EdgePropertiesWidget::on__addProperty_clicked()
00101 {
00102
00103
00104
00105
00106
00107
00108
00109
00110 GraphPropertiesModel* model = qobject_cast< GraphPropertiesModel*>( _propertiesTable->model() );
00111 model->addDynamicProperty( _propertyName->text(), QVariant( _propertyValue->text() ),
00112 _edge, ( _isPropertyGlobal->checkState() == Qt::Checked ) );
00113 }
00114
00115 void EdgePropertiesWidget::disconnectEdge()
00116 {
00117 disconnect( _edge, SIGNAL( changed() ), this, SLOT( reflectAttributes() ) );
00118
00119 disconnect( _value, SIGNAL( textChanged( QString ) ), _edge, SLOT( setValue( QString ) ) );
00120 disconnect( _name, SIGNAL( textChanged( QString ) ), _edge, SLOT( setName( QString ) ) );
00121 disconnect( _width, SIGNAL( valueChanged( double ) ), _edge, SLOT( setWidth( double ) ) );
00122 disconnect( _showName, SIGNAL( toggled( bool ) ), _edge, SLOT( hideName( bool ) ) );
00123 disconnect( _showValue, SIGNAL( toggled( bool ) ), _edge, SLOT( hideValue( bool ) ) );
00124 }