Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
a60792b4
Commit
a60792b4
authored
Mar 13, 2011
by
Robert Frohl
Browse files
[FIX] - deleting moduls should work with NetworkEditor
parent
3f9c8622
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
71 additions
and
75 deletions
+71
-75
src/gui/qt4/controlPanel/WQtControlPanel.cpp
src/gui/qt4/controlPanel/WQtControlPanel.cpp
+18
-10
src/gui/qt4/controlPanel/WQtTreeWidget.cpp
src/gui/qt4/controlPanel/WQtTreeWidget.cpp
+0
-1
src/gui/qt4/networkEditor/WQtNetworkEditor.cpp
src/gui/qt4/networkEditor/WQtNetworkEditor.cpp
+46
-0
src/gui/qt4/networkEditor/WQtNetworkEditor.h
src/gui/qt4/networkEditor/WQtNetworkEditor.h
+5
-0
src/gui/qt4/networkEditor/WQtNetworkItem.cpp
src/gui/qt4/networkEditor/WQtNetworkItem.cpp
+2
-1
src/gui/qt4/networkEditor/WQtNetworkScene.cpp
src/gui/qt4/networkEditor/WQtNetworkScene.cpp
+0
-55
src/gui/qt4/networkEditor/WQtNetworkScene.h
src/gui/qt4/networkEditor/WQtNetworkScene.h
+0
-8
No files found.
src/gui/qt4/controlPanel/WQtControlPanel.cpp
View file @
a60792b4
...
...
@@ -1070,20 +1070,28 @@ QAction* WQtControlPanel::toggleViewAction() const
void
WQtControlPanel
::
deleteModuleTreeItem
()
{
if
(
m_moduleTreeWidget
->
selectedItems
().
count
()
>
0
)
// TODO(rfrohl): check if there is a better way to check for focus
if
(
m_moduleTreeWidget
->
hasFocus
()
)
{
if
(
(
m_moduleTreeWidget
->
selectedItems
().
at
(
0
)
->
type
()
==
MODULE
)
||
(
m_moduleTreeWidget
->
selectedItems
().
at
(
0
)
->
type
()
==
DATASET
)
)
if
(
m_moduleTreeWidget
->
selectedItems
().
count
()
>
0
)
{
// remove from the container. It will create a new event in the GUI after it has been removed which is then handled by the tree item.
// This method deep removes the module ( it also removes depending modules )
WKernel
::
getRunningKernel
()
->
getRootContainer
()
->
removeDeep
(
static_cast
<
WQtTreeItem
*
>
(
m_moduleTreeWidget
->
selectedItems
().
at
(
0
)
)
->
getModule
()
);
// select another item
m_moduleTreeWidget
->
setCurrentItem
(
m_moduleTreeWidget
->
topLevelItem
(
0
)
);
if
(
(
m_moduleTreeWidget
->
selectedItems
().
at
(
0
)
->
type
()
==
MODULE
)
||
(
m_moduleTreeWidget
->
selectedItems
().
at
(
0
)
->
type
()
==
DATASET
)
)
{
// remove from the container. It will create a new event in the GUI after it has been removed which is then handled by the tree item.
// This method deep removes the module ( it also removes depending modules )
WKernel
::
getRunningKernel
()
->
getRootContainer
()
->
removeDeep
(
static_cast
<
WQtTreeItem
*
>
(
m_moduleTreeWidget
->
selectedItems
().
at
(
0
)
)
->
getModule
()
);
// select another item
m_moduleTreeWidget
->
setCurrentItem
(
m_moduleTreeWidget
->
topLevelItem
(
0
)
);
}
}
}
else
if
(
m_mainWindow
->
getNetworkEditor
()
->
isActiveWindow
()
)
{
m_mainWindow
->
getNetworkEditor
()
->
deleteSelectedItems
();
}
}
void
WQtControlPanel
::
deleteROITreeItem
()
...
...
src/gui/qt4/controlPanel/WQtTreeWidget.cpp
View file @
a60792b4
...
...
@@ -33,7 +33,6 @@ WQtTreeWidget::WQtTreeWidget( QWidget* parent )
setSelectionMode
(
QAbstractItemView
::
SingleSelection
);
}
WQtTreeWidget
::~
WQtTreeWidget
()
{
}
...
...
src/gui/qt4/networkEditor/WQtNetworkEditor.cpp
View file @
a60792b4
...
...
@@ -39,6 +39,8 @@
#include "WQtNetworkEditor.h"
#include "WQtNetworkPort.h"
#include "../../../kernel/combiner/WDisconnectCombiner.h"
#include "../../../kernel/WKernel.h"
#include "../../../kernel/WModule.h"
#include "../../../kernel/WModuleFactory.h"
#include "../controlPanel/WQtControlPanel.h"
...
...
@@ -122,6 +124,50 @@ void WQtNetworkEditor::selectItem()
}
}
void
WQtNetworkEditor
::
deleteSelectedItems
()
{
QList
<
WQtNetworkItem
*>
itemList
;
QList
<
WQtNetworkArrow
*>
arrowList
;
foreach
(
QGraphicsItem
*
item
,
m_scene
->
selectedItems
()
)
{
if
(
item
->
type
()
==
WQtNetworkItem
::
Type
)
{
WQtNetworkItem
*
netItem
=
qgraphicsitem_cast
<
WQtNetworkItem
*>
(
item
);
itemList
.
append
(
netItem
);
}
else
if
(
item
->
type
()
==
WQtNetworkArrow
::
Type
)
{
WQtNetworkArrow
*
netArrow
=
qgraphicsitem_cast
<
WQtNetworkArrow
*>
(
item
);
arrowList
.
append
(
netArrow
);
}
}
foreach
(
WQtNetworkArrow
*
ar
,
arrowList
)
{
if
(
ar
!=
0
)
{
boost
::
shared_ptr
<
WDisconnectCombiner
>
disconnectCombiner
=
boost
::
shared_ptr
<
WDisconnectCombiner
>
(
new
WDisconnectCombiner
(
ar
->
getStartPort
()
->
getConnector
()
->
getModule
(),
ar
->
getStartPort
()
->
getConnector
()
->
getName
(),
ar
->
getEndPort
()
->
getConnector
()
->
getModule
(),
ar
->
getEndPort
()
->
getConnector
()
->
getName
()
)
);
disconnectCombiner
->
run
();
disconnectCombiner
->
wait
();
}
}
foreach
(
WQtNetworkItem
*
it
,
itemList
)
{
if
(
it
!=
0
)
{
WKernel
::
getRunningKernel
()
->
getRootContainer
()
->
remove
(
it
->
getModule
()
);
}
}
itemList
.
clear
();
arrowList
.
clear
();
}
void
WQtNetworkEditor
::
addModule
(
boost
::
shared_ptr
<
WModule
>
module
)
{
WQtNetworkItem
*
netItem
=
new
WQtNetworkItem
(
this
,
module
);
...
...
src/gui/qt4/networkEditor/WQtNetworkEditor.h
View file @
a60792b4
...
...
@@ -89,6 +89,11 @@ public:
*/
void
itemMoved
();
/**
* Deletes all items in the scene who are selected.
**/
void
deleteSelectedItems
();
protected:
/**
...
...
src/gui/qt4/networkEditor/WQtNetworkItem.cpp
View file @
a60792b4
...
...
@@ -26,7 +26,6 @@
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <QtGui/QGraphicsRectItem>
#include <QtGui/QStyleOptionGraphicsItem>
#include "WQtNetworkArrow.h"
...
...
@@ -184,6 +183,8 @@ void WQtNetworkItem::mouseMoveEvent( QGraphicsSceneMouseEvent *mouseEvent )
void
WQtNetworkItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
// TODO(rfrohl): select the item in the module tree?
// boost::shared_ptr< WModule > m_module; //!< the module
setSelected
(
true
);
return
QGraphicsItem
::
mousePressEvent
(
event
);
}
...
...
src/gui/qt4/networkEditor/WQtNetworkScene.cpp
View file @
a60792b4
...
...
@@ -29,18 +29,13 @@
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QKeyEvent>
#include <QtGui/QGraphicsScene>
#include <QtGui/QGraphicsView>
#include <QtGui/QGraphicsItem>
#include <QtGui/QGraphicsItemGroup>
#include <QtGui/QGraphicsSceneMouseEvent>
#include "WQtNetworkScene.h"
#include "WQtNetworkItem.h"
#include "WQtNetworkPort.h"
#include "../../../kernel/combiner/WDisconnectCombiner.h"
#include "../../../kernel/WKernel.h"
WQtNetworkScene
::
WQtNetworkScene
()
:
QGraphicsScene
()
...
...
@@ -51,56 +46,6 @@ WQtNetworkScene::~WQtNetworkScene()
{
}
void
WQtNetworkScene
::
keyPressEvent
(
QKeyEvent
*
keyEvent
)
{
switch
(
keyEvent
->
key
()
)
{
case
Qt
::
Key_Delete
:
{
QList
<
WQtNetworkItem
*>
itemList
;
QList
<
WQtNetworkArrow
*>
arrowList
;
foreach
(
QGraphicsItem
*
item
,
this
->
selectedItems
()
)
{
if
(
item
->
type
()
==
WQtNetworkItem
::
Type
)
{
WQtNetworkItem
*
netItem
=
qgraphicsitem_cast
<
WQtNetworkItem
*>
(
item
);
itemList
.
append
(
netItem
);
}
else
if
(
item
->
type
()
==
WQtNetworkArrow
::
Type
)
{
WQtNetworkArrow
*
netArrow
=
qgraphicsitem_cast
<
WQtNetworkArrow
*>
(
item
);
arrowList
.
append
(
netArrow
);
}
}
foreach
(
WQtNetworkArrow
*
ar
,
arrowList
)
{
if
(
ar
!=
0
)
{
boost
::
shared_ptr
<
WDisconnectCombiner
>
disconnectCombiner
=
boost
::
shared_ptr
<
WDisconnectCombiner
>
(
new
WDisconnectCombiner
(
ar
->
getStartPort
()
->
getConnector
()
->
getModule
(),
ar
->
getStartPort
()
->
getConnector
()
->
getName
(),
ar
->
getEndPort
()
->
getConnector
()
->
getModule
(),
ar
->
getEndPort
()
->
getConnector
()
->
getName
()
)
);
disconnectCombiner
->
run
();
disconnectCombiner
->
wait
();
}
}
foreach
(
WQtNetworkItem
*
it
,
itemList
)
{
if
(
it
!=
0
)
{
WKernel
::
getRunningKernel
()
->
getRootContainer
()
->
remove
(
it
->
getModule
()
);
}
}
itemList
.
clear
();
arrowList
.
clear
();
}
}
}
void
WQtNetworkScene
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
mouseEvent
)
{
QList
<
QGraphicsItem
*>
item
=
this
->
items
(
mouseEvent
->
scenePos
()
);
...
...
src/gui/qt4/networkEditor/WQtNetworkScene.h
View file @
a60792b4
...
...
@@ -69,14 +69,6 @@ protected:
*/
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
mouseEvent
);
/**
* Controls how to respond on key events.
* Current it only delets selected items.
*
* \param keyEvent the key press event
*/
void
keyPressEvent
(
QKeyEvent
*
keyEvent
);
private:
QGraphicsItem
*
m_fakeItem
;
//!< the fakeitem for the forcebased layout
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment