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
01bb594b
Commit
01bb594b
authored
May 20, 2019
by
Samuel GAIST
Browse files
[widgets][dataformateditor] Port to ScrollWidget
parent
501aa573
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/widgets/dataformateditor.py
View file @
01bb594b
...
...
@@ -36,7 +36,6 @@ from PyQt5.QtWidgets import QLabel
from
PyQt5.QtWidgets
import
QLineEdit
from
PyQt5.QtWidgets
import
QMenu
from
PyQt5.QtWidgets
import
QPushButton
from
PyQt5.QtWidgets
import
QScrollArea
from
PyQt5.QtWidgets
import
QSpinBox
from
PyQt5.QtWidgets
import
QVBoxLayout
from
PyQt5.QtWidgets
import
QWidget
...
...
@@ -47,6 +46,8 @@ from ..utils import dataformat_basetypes
from
..backend.assetmodel
import
AssetType
from
..backend.assetmodel
import
AssetModel
from
.scrollwidget
import
ScrollWidget
from
.editor
import
AbstractAssetEditor
...
...
@@ -556,8 +557,6 @@ class DataformatEditor(AbstractAssetEditor):
self
.
setObjectName
(
self
.
__class__
.
__name__
)
self
.
set_title
(
self
.
tr
(
"Dataformat"
))
self
.
dataformat_widgets
=
[]
self
.
dataformat_model
=
AssetModel
()
self
.
dataformat_model
.
asset_type
=
AssetType
.
DATAFORMAT
...
...
@@ -568,13 +567,7 @@ class DataformatEditor(AbstractAssetEditor):
self
.
tr
(
"Schema version"
),
self
.
schema_version_label
)
container_widget
=
QWidget
()
self
.
container_widget_layout
=
QVBoxLayout
(
container_widget
)
self
.
container_widget_layout
.
addStretch
(
1
)
scroll_area
=
QScrollArea
()
scroll_area
.
setWidget
(
container_widget
)
scroll_area
.
setWidgetResizable
(
True
)
self
.
scroll_widget
=
ScrollWidget
()
(
button_layout
,
...
...
@@ -584,9 +577,10 @@ class DataformatEditor(AbstractAssetEditor):
self
.
add_object_array_action
,
)
=
create_add_button_layout
()
self
.
layout
().
addWidget
(
scroll_
area
,
1
)
self
.
layout
().
addWidget
(
self
.
scroll_
widget
,
1
)
self
.
layout
().
addLayout
(
button_layout
)
self
.
scroll_widget
.
dataChanged
.
connect
(
self
.
dataChanged
)
self
.
add_type_action
.
triggered
.
connect
(
lambda
:
self
.
__add_entry
(
default_dataformat
())
)
...
...
@@ -604,6 +598,10 @@ class DataformatEditor(AbstractAssetEditor):
lambda
:
self
.
dataformat_model
.
setPrefixPath
(
self
.
prefix_path
)
)
@
property
def
dataformat_widgets
(
self
):
return
self
.
scroll_widget
.
widget_list
def
__add_entry
(
self
,
content
):
"""Add a new dataformat entry to the editor
...
...
@@ -629,10 +627,7 @@ class DataformatEditor(AbstractAssetEditor):
def
__remove_widget
(
self
,
widget
):
"""Removes the widget that which signal triggered this slot"""
self
.
container_widget_layout
.
removeWidget
(
widget
)
self
.
dataformat_widgets
.
pop
(
self
.
dataformat_widgets
.
index
(
widget
))
widget
.
setParent
(
None
)
self
.
dataChanged
.
emit
()
self
.
scroll_widget
.
removeWidget
(
widget
)
def
_load_json
(
self
,
json_object
):
"""Re-impl Load the json object passed as parameter"""
...
...
@@ -671,11 +666,7 @@ class DataformatEditor(AbstractAssetEditor):
dataformat_widget
=
klass
(
self
.
dataformat_model
)
dataformat_widget
.
load
(
name
,
type_
)
index
=
self
.
container_widget_layout
.
count
()
-
1
self
.
container_widget_layout
.
insertWidget
(
index
,
dataformat_widget
)
self
.
dataformat_widgets
.
append
(
dataformat_widget
)
dataformat_widget
.
dataChanged
.
connect
(
self
.
dataChanged
)
self
.
scroll_widget
.
addWidget
(
dataformat_widget
)
dataformat_widget
.
deletionRequested
.
connect
(
self
.
__onRemoveRequested
)
def
_dump_json
(
self
):
...
...
@@ -702,10 +693,7 @@ class DataformatEditor(AbstractAssetEditor):
self
.
blockSignals
(
True
)
while
len
(
self
.
dataformat_widgets
):
widget
=
self
.
dataformat_widgets
[
0
]
self
.
__remove_widget
(
widget
)
self
.
dataformat_widgets
=
[]
self
.
scroll_widget
.
clear
()
self
.
blockSignals
(
False
)
...
...
Write
Preview
Supports
Markdown
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