Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
beat.editor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
11
Issues
11
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
beat
beat.editor
Commits
99f52216
Commit
99f52216
authored
Nov 26, 2019
by
Flavio TARSETTI
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[widgets][toolchaineditor] refactor item deletion/added connection selection/connection deletion
parent
2c8ba0ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
34 deletions
+50
-34
beat/editor/widgets/toolchaineditor.py
beat/editor/widgets/toolchaineditor.py
+50
-34
No files found.
beat/editor/widgets/toolchaineditor.py
View file @
99f52216
...
@@ -289,10 +289,22 @@ class Connection(QGraphicsPathItem):
...
@@ -289,10 +289,22 @@ class Connection(QGraphicsPathItem):
self
.
set_style
(
style
)
self
.
set_style
(
style
)
def
itemChange
(
self
,
change
,
value
):
if
change
==
self
.
ItemSelectedChange
:
if
value
:
color
=
QColor
(
"red"
)
else
:
color
=
QColor
(
*
self
.
connection_color
)
pen
=
self
.
pen
()
pen
.
setColor
(
color
)
self
.
setPen
(
pen
)
return
QGraphicsItem
.
itemChange
(
self
,
change
,
value
)
def
set_style
(
self
,
config
):
def
set_style
(
self
,
config
):
# Highlight
# Highlight
self
.
setAcceptHoverEvents
(
True
)
self
.
setAcceptHoverEvents
(
True
)
self
.
setFlag
(
QGraphicsItem
.
ItemIsSelectable
,
True
)
# Geometry and color settings
# Geometry and color settings
self
.
connection_color
=
config
[
"color"
]
self
.
connection_color
=
config
[
"color"
]
...
@@ -1321,7 +1333,7 @@ class ToolchainView(QGraphicsView):
...
@@ -1321,7 +1333,7 @@ class ToolchainView(QGraphicsView):
"""Focus on the toolchain when F key pressed"""
"""Focus on the toolchain when F key pressed"""
if
event
.
key
()
==
Qt
.
Key_F
:
if
event
.
key
()
==
Qt
.
Key_F
:
self
.
custom_focus
()
self
.
custom_focus
()
if
event
.
key
()
==
Qt
.
Key_
D
:
if
event
.
key
()
==
Qt
.
Key_
Backspace
or
event
.
key
()
==
Qt
.
Key_Delete
:
self
.
delete_blocks
()
self
.
delete_blocks
()
def
custom_focus
(
self
):
def
custom_focus
(
self
):
...
@@ -1351,41 +1363,45 @@ class ToolchainView(QGraphicsView):
...
@@ -1351,41 +1363,45 @@ class ToolchainView(QGraphicsView):
def
delete_blocks
(
self
):
def
delete_blocks
(
self
):
"""Custom deletion on toolchain"""
"""Custom deletion on toolchain"""
selected_blocks
=
self
.
scene
().
selectedItems
()
if
selected_blocks
:
selected_items
=
self
.
scene
().
selectedItems
()
details
=
{}
if
selected_items
:
for
block
in
selected_blocks
:
for
item
in
selected_items
:
num_connections
=
0
if
isinstance
(
item
,
Connection
):
for
connection
in
self
.
toolchain
.
connections
:
self
.
toolchain
.
connections
.
remove
(
item
)
if
(
self
.
scene
().
removeItem
(
item
)
block
.
name
==
connection
.
start_block_name
self
.
toolchain
.
dataChanged
.
emit
()
or
block
.
name
==
connection
.
end_block_name
elif
isinstance
(
item
,
Block
):
):
num_connections
=
0
num_connections
+=
1
for
connection
in
self
.
toolchain
.
connections
:
if
num_connections
>
0
:
details
[
"block"
]
=
num_connections
if
len
(
details
.
keys
()):
warning
=
QMessageBox
()
warning
.
setIcon
(
QMessageBox
.
Warning
)
warning
.
setWindowTitle
(
self
.
tr
(
"Deleting connected block"
))
warning
.
setInformativeText
(
self
.
tr
(
"You can't delete a connected block!"
)
)
warning
.
setStandardButtons
(
QMessageBox
.
Ok
)
warning
.
exec_
()
else
:
for
block
in
selected_blocks
:
if
block
.
type
==
BlockType
.
DATASETS
.
name
:
if
(
if
(
block
.
name
item
.
name
==
connection
.
start_block_
name
in
self
.
toolchain
.
web_representation
[
"channel_colors"
]
or
item
.
name
==
connection
.
end_block_name
):
):
self
.
toolchain
.
web_representation
[
"channel_colors"
].
pop
(
num_connections
+=
1
block
.
name
if
num_connections
>
0
:
)
warning
=
QMessageBox
()
self
.
toolchain
.
blocks
.
remove
(
block
)
warning
.
setIcon
(
QMessageBox
.
Warning
)
self
.
scene
().
removeItem
(
block
)
warning
.
setWindowTitle
(
self
.
tr
(
"Deleting connected block"
))
self
.
toolchain
.
dataChanged
.
emit
()
warning
.
setInformativeText
(
self
.
tr
(
"You can't delete a connected block!"
)
)
warning
.
setStandardButtons
(
QMessageBox
.
Ok
)
warning
.
exec_
()
else
:
if
item
.
type
==
BlockType
.
DATASETS
.
name
:
if
(
item
.
name
in
self
.
toolchain
.
web_representation
[
"channel_colors"
]
):
self
.
toolchain
.
web_representation
[
"channel_colors"
].
pop
(
item
.
name
)
self
.
toolchain
.
web_representation
[
"blocks"
].
pop
(
item
.
name
)
self
.
toolchain
.
blocks
.
remove
(
item
)
self
.
scene
().
removeItem
(
item
)
self
.
toolchain
.
dataChanged
.
emit
()
class
Toolchain
(
QWidget
):
class
Toolchain
(
QWidget
):
...
...
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