Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
soitool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bachelor-paa-bittet
soitool
Commits
05bd3f9f
Commit
05bd3f9f
authored
5 years ago
by
Thomas Holene Løkkeborg
Browse files
Options
Downloads
Plain Diff
Merge branch 'oversett-sort-i-oppsett' into 'master'
#134 Sort endret i oppsett See merge request
!76
parents
d1f001b0
bf8cdf1d
No related branches found
No related tags found
1 merge request
!76
#134 Sort endret i oppsett
Pipeline
#83743
passed
5 years ago
Stage: lint
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
soitool/setup_settings.py
+56
-31
56 additions, 31 deletions
soitool/setup_settings.py
with
56 additions
and
31 deletions
soitool/setup_settings.py
+
56
−
31
View file @
05bd3f9f
...
...
@@ -16,7 +16,6 @@ from PySide2.QtWidgets import (
from
soitool.soi
import
(
STRING_TO_ALGORITHM_RECTPACK_BIN
,
STRING_TO_ALGORITHM_RECTPACK_PACK
,
STRING_TO_ALGORITHM_INITIAL_SORT
,
)
from
soitool.accept_reject_dialog
import
AcceptRejectDialog
...
...
@@ -38,7 +37,7 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
The SOI-instance to change
"""
def
__init__
(
self
,
soi
):
# pylint: disable = R0915
def
__init__
(
self
,
soi
):
super
().
__init__
()
self
.
soi
=
soi
...
...
@@ -66,7 +65,6 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
self
.
label_module_placement
=
QLabel
(
"
Modulplassering
"
)
# Headerdata
self
.
layout_setup
.
addWidget
(
self
.
label_header
)
self
.
label_title
=
QLabel
(
"
Tittel:
"
)
self
.
label_description
=
QLabel
(
"
Beskrivelse:
"
)
self
.
label_version
=
QLabel
(
"
Versjon:
"
)
...
...
@@ -83,12 +81,30 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
self
.
edit_valid_to
=
QLineEdit
()
self
.
edit_classification
=
QComboBox
()
self
.
edit_classification
.
addItem
(
"
UGRADERT
"
)
self
.
edit_classification
.
addItem
(
"
BEGRENSET
"
)
self
.
edit_classification
.
addItem
(
"
KONFIDENSIELT
"
)
self
.
edit_classification
.
addItem
(
"
HEMMELIG
"
)
self
.
edit_classification
.
addItem
(
"
STRENGT HEMMELIG
"
)
# Radiobuttons
self
.
rbutton_landscape
=
QRadioButton
(
"
Landskap
"
)
self
.
rbutton_portrait
=
QRadioButton
(
"
Portrett
"
)
self
.
rbutton_auto
=
QRadioButton
(
"
Automatisk
"
)
self
.
rbutton_manual
=
QRadioButton
(
"
Manuelt
"
)
self
.
rbutton_sort_none
=
QRadioButton
(
"
Ingenting
"
)
self
.
rbutton_sort_area
=
QRadioButton
(
"
Areal
"
)
self
.
rbutton_sort_width
=
QRadioButton
(
"
Bredde
"
)
self
.
rbutton_sort_height
=
QRadioButton
(
"
Høyde
"
)
# Customize ok button from superclass to something more fitting
self
.
button_ok
.
setText
(
"
Lagre
"
)
self
.
add_widgets_to_layout
()
self
.
layout_content
.
addLayout
(
self
.
layout_setup
)
def
add_widgets_to_layout
(
self
):
"""
Add each widget to layouts.
Takes the widgets created in init and adds them
the the different layouts.
"""
# Headerdata
self
.
layout_setup
.
addWidget
(
self
.
label_header
)
self
.
layout_header
.
addRow
(
self
.
label_title
,
self
.
edit_title
)
self
.
layout_header
.
addRow
(
self
.
label_description
,
self
.
edit_description
...
...
@@ -97,6 +113,11 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
self
.
layout_header
.
addRow
(
self
.
label_date
,
self
.
edit_date
)
self
.
layout_header
.
addRow
(
self
.
label_valid_from
,
self
.
edit_valid_from
)
self
.
layout_header
.
addRow
(
self
.
label_valid_to
,
self
.
edit_valid_to
)
self
.
edit_classification
.
addItem
(
"
UGRADERT
"
)
self
.
edit_classification
.
addItem
(
"
BEGRENSET
"
)
self
.
edit_classification
.
addItem
(
"
KONFIDENSIELT
"
)
self
.
edit_classification
.
addItem
(
"
HEMMELIG
"
)
self
.
edit_classification
.
addItem
(
"
STRENGT HEMMELIG
"
)
self
.
layout_header
.
addRow
(
self
.
label_classification
,
self
.
edit_classification
)
...
...
@@ -104,8 +125,6 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
# Paperorientation
self
.
layout_setup
.
addWidget
(
self
.
label_paper_orientation
)
self
.
rbutton_landscape
=
QRadioButton
(
"
Landskap
"
)
self
.
rbutton_portrait
=
QRadioButton
(
"
Portrett
"
)
self
.
layout_orientation_button
.
addWidget
(
self
.
rbutton_landscape
)
self
.
layout_orientation_button
.
addWidget
(
self
.
rbutton_portrait
)
self
.
group_orientation
.
setLayout
(
self
.
layout_orientation_button
)
...
...
@@ -113,8 +132,6 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
# Moduleplacement
self
.
layout_setup
.
addWidget
(
self
.
label_module_placement
)
self
.
rbutton_auto
=
QRadioButton
(
"
Automatisk
"
)
self
.
rbutton_manual
=
QRadioButton
(
"
Manuelt
"
)
self
.
layout_placement_button
.
addWidget
(
self
.
rbutton_auto
)
self
.
layout_placement_button
.
addWidget
(
self
.
rbutton_manual
)
self
.
group_placement
.
setLayout
(
self
.
layout_placement_button
)
...
...
@@ -128,9 +145,6 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
self
.
rbuttons_option_pack
=
[
QRadioButton
(
name
)
for
name
in
STRING_TO_ALGORITHM_RECTPACK_PACK
]
self
.
rbuttons_option_sort
=
[
QRadioButton
(
name
)
for
name
in
STRING_TO_ALGORITHM_INITIAL_SORT
]
self
.
layout_alg_button_bin
.
addWidget
(
QLabel
(
"
Bin
"
))
for
rbutton
in
self
.
rbuttons_option_bin
:
...
...
@@ -138,10 +152,12 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
self
.
layout_alg_button_pack
.
addWidget
(
QLabel
(
"
Pack
"
))
for
rbutton
in
self
.
rbuttons_option_pack
:
self
.
layout_alg_button_pack
.
addWidget
(
rbutton
)
self
.
layout_alg_button_sort
.
addWidget
(
QLabel
(
"
Sort
"
))
for
rbutton
in
self
.
rbuttons_option_sort
:
self
.
layout_alg_button_sort
.
addWidget
(
rbutton
)
self
.
layout_alg_button_sort
.
addWidget
(
QLabel
(
"
Sorter etter
"
))
self
.
layout_alg_button_sort
.
addWidget
(
self
.
rbutton_sort_none
)
self
.
layout_alg_button_sort
.
addWidget
(
self
.
rbutton_sort_area
)
self
.
layout_alg_button_sort
.
addWidget
(
self
.
rbutton_sort_width
)
self
.
layout_alg_button_sort
.
addWidget
(
self
.
rbutton_sort_height
)
self
.
group_algorithm_bin
.
setLayout
(
self
.
layout_alg_button_bin
)
self
.
group_algorithm_pack
.
setLayout
(
self
.
layout_alg_button_pack
)
self
.
group_algorithm_sort
.
setLayout
(
self
.
layout_alg_button_sort
)
...
...
@@ -150,12 +166,8 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
self
.
layout_setup
.
addWidget
(
self
.
group_algorithm_pack
)
self
.
layout_setup
.
addWidget
(
self
.
group_algorithm_sort
)
# Customize ok button from superclass to something more fitting
self
.
button_ok
.
setText
(
"
Lagre
"
)
self
.
layout_content
.
addLayout
(
self
.
layout_setup
)
def
accept
(
self
):
# Ignoring "Too many branches"
def
accept
(
self
):
# pylint: disable = R0912
"""
Save and update the SOI with the given changes.
Overriden to implement custom behavior on accept, executes superclass
'
...
...
@@ -196,9 +208,14 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
break
for
i
in
self
.
group_algorithm_sort
.
findChildren
(
QRadioButton
):
if
i
.
isChecked
():
property_changes
[
"
algorithm_sort
"
]
=
i
.
text
()
break
if
i
.
isChecked
()
and
i
.
text
()
==
"
Ingenting
"
:
property_changes
[
"
algorithm_sort
"
]
=
"
none
"
elif
i
.
isChecked
()
and
i
.
text
()
==
"
Areal
"
:
property_changes
[
"
algorithm_sort
"
]
=
"
area
"
elif
i
.
isChecked
()
and
i
.
text
()
==
"
Bredde
"
:
property_changes
[
"
algorithm_sort
"
]
=
"
width
"
elif
i
.
isChecked
()
and
i
.
text
()
==
"
Høyde
"
:
property_changes
[
"
algorithm_sort
"
]
=
"
height
"
# Pass changes as unpacked variable list
self
.
soi
.
update_properties
(
**
property_changes
)
...
...
@@ -215,7 +232,7 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
self
.
edit_valid_to
.
setText
(
self
.
soi
.
valid_to
)
self
.
edit_classification
.
setCurrentText
(
self
.
soi
.
classification
)
# Check radiobutton
s
according to
current
SOI settings
# Check
the
radiobutton according to SOI settings
if
self
.
soi
.
orientation
==
"
landscape
"
:
self
.
rbutton_landscape
.
setChecked
(
True
)
else
:
...
...
@@ -226,7 +243,10 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
else
:
self
.
rbutton_manual
.
setChecked
(
True
)
# Loop through the groupbox to find children that are radiobuttons
self
.
groupbox_find_children
()
def
groupbox_find_children
(
self
):
"""
Loop through groupbox to check radiobuttons according to SOI.
"""
for
i
in
self
.
group_algorithm_bin
.
findChildren
(
QRadioButton
):
if
i
.
text
()
==
self
.
soi
.
algorithm_bin
:
i
.
setChecked
(
True
)
...
...
@@ -238,6 +258,11 @@ class Setup(AcceptRejectDialog): # pylint: disable = R0902
break
for
i
in
self
.
group_algorithm_sort
.
findChildren
(
QRadioButton
):
if
i
.
text
()
==
self
.
soi
.
algorithm_sort
:
if
i
.
text
()
==
"
Ingenting
"
and
self
.
soi
.
algorithm_sort
==
"
none
"
:
i
.
setChecked
(
True
)
elif
i
.
text
()
==
"
Areal
"
and
self
.
soi
.
algorithm_sort
==
"
area
"
:
i
.
setChecked
(
True
)
elif
i
.
text
()
==
"
Bredde
"
and
self
.
soi
.
algorithm_sort
==
"
width
"
:
i
.
setChecked
(
True
)
elif
i
.
text
()
==
"
Høyde
"
and
self
.
soi
.
algorithm_sort
==
"
height
"
:
i
.
setChecked
(
True
)
break
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment