Commit a1b98cc5 authored by Robert Frohl's avatar Robert Frohl
Browse files

[FIX] - right click works again in the network editor, removing a selected...

[FIX] - right click works again in the network editor, removing a selected item with DEL or BACKSPACE should work now in the network editor too
parent 6c70f300
......@@ -104,11 +104,12 @@ WQtControlPanel::WQtControlPanel( WMainWindow* parent )
m_deleteModuleAction = new QAction( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "remove" ), "Remove Module", m_moduleTreeWidget );
{
// Set the key for removing modules
m_deleteModuleAction->setShortcutContext( Qt::WidgetShortcut );
//m_deleteModuleAction->setShortcutContext( Qt::WidgetShortcut );
m_deleteModuleAction->setShortcutContext( Qt::WidgetWithChildrenShortcut );
m_deleteModuleAction->setShortcut( QKeySequence::Delete );
m_deleteModuleAction->setIconVisibleInMenu( true );
}
connect( m_deleteModuleAction, SIGNAL( triggered() ), this, SLOT( deleteModuleTreeItem() ) );
connect( m_deleteModuleAction, SIGNAL( triggered() ), this, SLOT( deleteModule() ) );
m_moduleTreeWidget->addAction( m_deleteModuleAction );
// a separator to clean up the tree widget's context menu
......@@ -122,20 +123,18 @@ WQtControlPanel::WQtControlPanel( WMainWindow* parent )
m_missingModuleAction->setIconVisibleInMenu( true );
m_moduleTreeWidget->addAction( m_missingModuleAction );
// Disabled Network Editor due to bug: #11
// // the network editor also needs the context menu
// // TODO(rfrohl): context menu gets not opened if a graphicitem is clicked. This should be fixed.
// if( m_mainWindow->getNetworkEditor() )
// {
// m_mainWindow->getNetworkEditor()->setContextMenuPolicy( Qt::ActionsContextMenu );
// m_mainWindow->getNetworkEditor()->addAction( m_connectWithPrototypeAction );
// m_mainWindow->getNetworkEditor()->addAction( m_connectWithModuleAction );
// m_mainWindow->getNetworkEditor()->addAction( m_disconnectAction );
// m_mainWindow->getNetworkEditor()->addAction( separator );
// m_mainWindow->getNetworkEditor()->addAction( m_deleteModuleAction );
// m_mainWindow->getNetworkEditor()->addAction( separator );
// m_mainWindow->getNetworkEditor()->addAction( m_missingModuleAction );
// }
// the network editor also needs the context menu
if( m_mainWindow->getNetworkEditor() )
{
m_mainWindow->getNetworkEditor()->setContextMenuPolicy( Qt::ActionsContextMenu );
m_mainWindow->getNetworkEditor()->addAction( m_connectWithPrototypeAction );
m_mainWindow->getNetworkEditor()->addAction( m_connectWithModuleAction );
m_mainWindow->getNetworkEditor()->addAction( m_disconnectAction );
m_mainWindow->getNetworkEditor()->addAction( separator );
m_mainWindow->getNetworkEditor()->addAction( m_deleteModuleAction );
m_mainWindow->getNetworkEditor()->addAction( separator );
m_mainWindow->getNetworkEditor()->addAction( m_missingModuleAction );
}
m_colormapper = new WQtColormapper( m_mainWindow );
m_colormapper->setToolTip( "Reorder the textures." );
......@@ -1082,9 +1081,8 @@ QAction* WQtControlPanel::toggleViewAction() const
return result;
}
void WQtControlPanel::deleteModuleTreeItem()
void WQtControlPanel::deleteModule()
{
// TODO(rfrohl): check if there is a better way to check for focus
if( m_moduleTreeWidget->hasFocus() )
{
if( m_moduleTreeWidget->selectedItems().count() > 0 )
......@@ -1102,6 +1100,15 @@ void WQtControlPanel::deleteModuleTreeItem()
}
}
}
else if( m_mainWindow->getNetworkEditor()->hasFocus() )
{
if( m_mainWindow->getNetworkEditor()->selectedItems().count() > 0 )
// This method deep removes the module ( it also removes depending modules )
WKernel::getRunningKernel()->getRootContainer()->remove(
static_cast< WQtNetworkItem* >( m_mainWindow->getNetworkEditor()->selectedItems().at( 0 ) )->getModule()
);
}
}
void WQtControlPanel::deleteROITreeItem()
......
......@@ -419,9 +419,9 @@ private slots:
void deleteROITreeItem();
/**
* delete a module tree item
* delete a module
*/
void deleteModuleTreeItem();
void deleteModule();
/**
* function to notify the roi manager of any drag&drop action in the roi tree
......
......@@ -245,7 +245,6 @@ void WQtTreeItem::updateState()
if( m_deleteInProgress && !m_module->isRunning().get() && m_needPostDeleteEvent )
{
m_needPostDeleteEvent = false; // this ensures the event is only posted once
// Diabled Network Editor due to bug: #11
QCoreApplication::postEvent( WQt4Gui::getMainWindow()->getNetworkEditor(), new WModuleDeleteEvent( this ) );
QCoreApplication::postEvent( WQt4Gui::getMainWindow()->getControlPanel(), new WModuleDeleteEvent( this ) );
}
......
......@@ -64,6 +64,7 @@ WQtNetworkEditor::WQtNetworkEditor( WMainWindow* parent )
view->setDragMode( QGraphicsView::RubberBandDrag );
view->setRenderHint( QPainter::Antialiasing );
view->setMinimumSize( 20, 20 );
this->setFocusProxy( view );
m_scene = new WQtNetworkScene();
m_scene->setSceneRect( m_scene->itemsBoundingRect() );
......@@ -100,6 +101,11 @@ WQtNetworkEditor::~WQtNetworkEditor()
delete m_layout;
}
QList<QGraphicsItem *> WQtNetworkEditor::selectedItems() const
{
return m_scene->selectedItems();
}
void WQtNetworkEditor::selectItem()
{
boost::shared_ptr< WModule > module;
......
......@@ -81,6 +81,11 @@ public:
**/
void deleteSelectedItems();
/**
* TODO
**/
QList<QGraphicsItem *> selectedItems() const;
protected:
/**
......
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