Commit ff9ce811 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] we now have properties in separate windows. Open them by double-clicking...

[ADD] we now have properties in separate windows. Open them by double-clicking the module in the module graph.
parent 8fd9187e
......@@ -299,6 +299,21 @@ QWidget* WQtPropertyGroupWidget::createPropertyGroupBox( WQtPropertyGroupWidget*
return box;
}
QWidget* WQtPropertyGroupWidget::createPropertyGroupBox( WPropertyGroupBase::SPtr group, const QString& title, size_t depth, QWidget* parent )
{
QSizePolicy sizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
WQtPropertyGroupWidget* propWidget = new WQtPropertyGroupWidget( group, depth, parent );
propWidget->setName( title );
QWidget* tab = WQtPropertyGroupWidget::createPropertyGroupBox( propWidget, false, parent, title );
tab->setSizePolicy( sizePolicy );
tab->setWindowTitle( title );
return tab;
}
void WQtPropertyGroupWidget::addGroup( WQtPropertyGroupWidget* widget, bool asScrollArea )
{
QWidget* box = WQtPropertyGroupWidget::createPropertyGroupBox( widget, asScrollArea, this );
......
......@@ -77,6 +77,18 @@ public:
static QWidget* createPropertyGroupBox( WQtPropertyGroupWidget* widget, bool asScrollArea = false, QWidget* parent = NULL,
const QString& title = "" );
/**
* Create a property widget using the given group.
*
* \param group the property group to represent
* \param title the title of the widget
* \param depth the nesting depth
* \param parent the parent widget
*
* \return the widget.
*/
static QWidget* createPropertyGroupBox( WPropertyGroupBase::SPtr group, const QString& title = "", size_t depth = 0, QWidget* parent = 0 );
/**
* destructor
*/
......
......@@ -35,6 +35,7 @@
#include "core/common/WStringUtils.h"
#include "../controlPanel/WQtTreeItem.h"
#include "../controlPanel/WQtPropertyGroupWidget.h"
#include "WQtNetworkArrow.h"
#include "WQtNetworkItem.h"
......@@ -51,7 +52,8 @@ WQtNetworkItem::WQtNetworkItem( WQtNetworkEditor *editor, boost::shared_ptr< WMo
m_busyIsDetermined( false ),
m_busyPercent( 0.0 ),
m_busyIndicatorShow( false ),
m_forceUpdate( true )
m_forceUpdate( true ),
m_propertyToolWindow( NULL )
{
m_networkEditor = editor;
m_module = module;
......@@ -139,6 +141,12 @@ WQtNetworkItem::WQtNetworkItem( WQtNetworkEditor *editor, boost::shared_ptr< WMo
WQtNetworkItem::~WQtNetworkItem()
{
if( m_propertyToolWindow )
{
m_propertyToolWindow->close();
delete m_propertyToolWindow;
}
foreach( WQtNetworkPort *port, m_inPorts )
{
delete port;
......@@ -227,6 +235,12 @@ void WQtNetworkItem::updater()
fitLook( m_itemBestWidth, m_itemBestWidth );
}
}
else if( m_propertyToolWindow )
{
m_propertyToolWindow->close();
delete m_propertyToolWindow;
m_propertyToolWindow = NULL;
}
// show crash state as text too
if( ( m_currentState == Crashed ) && ( m_subtitleFull != "Error" ) )
......@@ -358,6 +372,44 @@ void WQtNetworkItem::mousePressEvent( QGraphicsSceneMouseEvent *event )
QGraphicsItem::mousePressEvent( event );
}
void WQtNetworkItem::mouseDoubleClickEvent( QGraphicsSceneMouseEvent* /* event */ )
{
if( m_propertyToolWindow )
{
m_propertyToolWindow->show();
m_propertyToolWindow->activateWindow();
m_propertyToolWindow->raise();
}
else
{
if( !m_module->isCrashed() )
{
std::string name = m_module->getName();
WPropertyBase::SPtr namePropCandidate = m_module->getProperties()->findProperty( "Name" );
if( namePropCandidate )
{
WPropString nameProp = namePropCandidate->toPropString();
if( nameProp )
{
name = ( name == nameProp->get() ) ? name : name + " - " + nameProp->get();
}
}
QWidget* props = WQtPropertyGroupWidget::createPropertyGroupBox(
m_module->getProperties(), QString::fromStdString( name ), 0, m_networkEditor
);
QScrollArea* sa = new QScrollArea( m_networkEditor );
sa->setWidget( props );
sa->setWidgetResizable( true );
sa->setWindowFlags( Qt::Tool );
sa->setWindowTitle( QString::fromStdString( "Properties: " + name ) );
sa->show();
m_propertyToolWindow = sa;
}
}
}
QVariant WQtNetworkItem::itemChange( GraphicsItemChange change, const QVariant &value )
{
switch( change )
......
......@@ -180,7 +180,7 @@ protected:
*
* \param mouseEvent the mouse event
*/
void mouseMoveEvent( QGraphicsSceneMouseEvent* mouseEvent );
virtual void mouseMoveEvent( QGraphicsSceneMouseEvent* mouseEvent );
/**
* Reimplemented from QGraphicsRectItem. Used to enable selection of network items
......@@ -188,21 +188,28 @@ protected:
*
* \param event the mouse event
**/
void mousePressEvent( QGraphicsSceneMouseEvent *event );
virtual void mousePressEvent( QGraphicsSceneMouseEvent *event );
/**
* Called upon double click.
*
* \param event the click event
*/
virtual void mouseDoubleClickEvent( QGraphicsSceneMouseEvent* event );
/**
* If the cursor enters the item, the item gets a green color.
*
* \param event the hover event
*/
void hoverEnterEvent( QGraphicsSceneHoverEvent* event );
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent* event );
/**
* If the cursor leaves the item, the item gets his default color.
*
* \param event the hover event
*/
void hoverLeaveEvent( QGraphicsSceneHoverEvent* event );
virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent* event );
/**
* Draw some customized stuff in the scene.
......@@ -211,7 +218,7 @@ protected:
* \param option
* \param w
*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* w );
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* w );
private:
/**
......@@ -294,5 +301,10 @@ private:
* Optimal width for this module. Calculated during construction.
*/
float m_itemBestWidth;
/**
* The property toolbox window if any.
*/
QWidget* m_propertyToolWindow;
};
#endif // WQTNETWORKITEM_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment