Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
1382c85f
Commit
1382c85f
authored
May 20, 2019
by
Samuel GAIST
Browse files
[widgets][protocoltemplateeditor] Port to ScrollWidget
parent
5514b43f
Pipeline
#30350
passed with stage
in 9 minutes and 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/widgets/protocoltemplateeditor.py
View file @
1382c85f
...
...
@@ -34,7 +34,6 @@ from PyQt5.QtWidgets import QHeaderView
from
PyQt5.QtWidgets
import
QInputDialog
from
PyQt5.QtWidgets
import
QLineEdit
from
PyQt5.QtWidgets
import
QPushButton
from
PyQt5.QtWidgets
import
QScrollArea
from
PyQt5.QtWidgets
import
QStyledItemDelegate
from
PyQt5.QtWidgets
import
QTableWidget
from
PyQt5.QtWidgets
import
QTableWidgetItem
...
...
@@ -46,6 +45,8 @@ from ..utils import frozen
from
..backend.assetmodel
import
AssetType
from
..backend.assetmodel
import
AssetModel
from
.scrollwidget
import
ScrollWidget
from
.editor
import
AbstractAssetEditor
...
...
@@ -205,29 +206,27 @@ class ProtocolTemplateEditor(AbstractAssetEditor):
self
.
setObjectName
(
self
.
__class__
.
__name__
)
self
.
set_title
(
self
.
tr
(
"Protocol Template"
))
self
.
set_widgets
=
[]
self
.
dataformat_model
=
AssetModel
()
self
.
dataformat_model
.
asset_type
=
AssetType
.
DATAFORMAT
container_widget
=
QWidget
()
self
.
container_widget_layout
=
QVBoxLayout
(
container_widget
)
self
.
container_widget_layout
.
addStretch
(
1
)
self
.
scroll_area
=
QScrollArea
()
self
.
scroll_area
.
setWidget
(
container_widget
)
self
.
scroll_area
.
setWidgetResizable
(
True
)
self
.
scroll_widget
=
ScrollWidget
()
self
.
add_set_button
=
QPushButton
(
self
.
tr
(
"+"
))
self
.
add_set_button
.
setFixedSize
(
30
,
30
)
self
.
layout
().
addWidget
(
self
.
scroll_
area
,
1
)
self
.
layout
().
addWidget
(
self
.
scroll_
widget
,
1
)
self
.
layout
().
addWidget
(
self
.
add_set_button
,
1
)
self
.
scroll_widget
.
dataChanged
.
connect
(
self
.
dataChanged
)
self
.
add_set_button
.
clicked
.
connect
(
self
.
__addSet
)
self
.
contextChanged
.
connect
(
lambda
:
self
.
dataformat_model
.
setPrefixPath
(
self
.
prefix_path
)
)
@
property
def
set_widgets
(
self
):
return
self
.
scroll_widget
.
widget_list
@
pyqtSlot
()
def
__onRemoveRequested
(
self
):
"""Remove the widget clicked"""
...
...
@@ -237,10 +236,7 @@ class ProtocolTemplateEditor(AbstractAssetEditor):
def
__remove_widget
(
self
,
widget
):
"""Removes the widget that which signal triggered this slot"""
self
.
container_widget_layout
.
removeWidget
(
widget
)
self
.
set_widgets
.
pop
(
self
.
set_widgets
.
index
(
widget
))
widget
.
setParent
(
None
)
self
.
dataChanged
.
emit
()
self
.
scroll_widget
.
removeWidget
(
widget
)
@
pyqtSlot
()
def
__addSet
(
self
):
...
...
@@ -276,7 +272,7 @@ class ProtocolTemplateEditor(AbstractAssetEditor):
"""Ensure that the latest set is visible"""
if
self
.
set_widgets
:
self
.
scroll_
area
.
ensureWidgetVisible
(
self
.
set_widgets
[
-
1
],
10
,
10
)
self
.
scroll_
widget
.
ensureWidgetVisible
(
self
.
set_widgets
[
-
1
],
10
,
10
)
def
__load_json
(
self
,
json_object
):
"""Load the json object passed as parameter"""
...
...
@@ -284,10 +280,7 @@ class ProtocolTemplateEditor(AbstractAssetEditor):
for
set_
in
json_object
[
"sets"
]:
set_widget
=
SetWidget
(
self
.
dataformat_model
)
set_widget
.
load
(
set_
)
self
.
set_widgets
.
append
(
set_widget
)
index
=
self
.
container_widget_layout
.
count
()
-
1
self
.
container_widget_layout
.
insertWidget
(
index
,
set_widget
,
2
)
set_widget
.
dataChanged
.
connect
(
self
.
dataChanged
)
self
.
scroll_widget
.
addWidget
(
set_widget
)
set_widget
.
deletionRequested
.
connect
(
self
.
__onRemoveRequested
)
if
self
.
set_widgets
:
...
...
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