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
177c739e
Commit
177c739e
authored
5 years ago
by
Thomas Holene Løkkeborg
Browse files
Options
Downloads
Patches
Plain Diff
#98 forbedret fritekstmodul sin egne lineedit & bruker i ny modul
parent
4da7b43f
No related branches found
Branches containing commit
No related tags found
1 merge request
!73
#98 Kodefrasemodul
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
soitool/modules/module_code_phrase.py
+16
-5
16 additions, 5 deletions
soitool/modules/module_code_phrase.py
soitool/modules/module_freetext.py
+13
-15
13 additions, 15 deletions
soitool/modules/module_freetext.py
with
29 additions
and
20 deletions
soitool/modules/module_code_phrase.py
+
16
−
5
View file @
177c739e
...
...
@@ -52,12 +52,16 @@ class TableWithSizeOfContent(QTableWidget):
QHeaderView
.
ResizeMode
.
ResizeToContents
)
# TODO this would be ideal, but it massively increases the width of the thing... should only stretch until minimal sizehint of lineedit
# TODO hvis ikke kan løse, fjern border til høyre på siste kolonne :) (celle)
#self.horizontalHeader().setStretchLastSection(True)
self
.
setHorizontalScrollBarPolicy
(
QtCore
.
Qt
.
ScrollBarAlwaysOff
)
self
.
setVerticalScrollBarPolicy
(
QtCore
.
Qt
.
ScrollBarAlwaysOff
)
# Tells Qt that we'd like the widget to be the one given by
# self.sizeHint
self
.
setSizePolicy
(
QSizePolicy
.
Fixed
,
QSizePolicy
.
Fixed
)
self
.
setSizePolicy
(
QSizePolicy
.
Minimum
,
QSizePolicy
.
Fixed
)
# See class docstring
self
.
cellChanged
.
connect
(
...
...
@@ -175,8 +179,18 @@ class CodePhraseModule(QWidget):
QWidget
.
__init__
(
self
)
ModuleBase
.
__init__
(
self
)
self
.
line_edit_header
=
LineEditWithSizeOfContent
(
"
Kodefraser
"
)
self
.
line_edit_header
.
setFont
(
HEADLINE_FONT
)
self
.
table
=
TableWithSizeOfContent
(
0
,
2
)
self
.
setSizePolicy
(
QSizePolicy
.
Fixed
,
QSizePolicy
.
Fixed
)
# See class docstring
self
.
line_edit_header
.
textChanged
.
connect
(
lambda
:
(
self
.
line_edit_header
.
updateGeometry
(),
self
.
adjustSize
()))
self
.
table
.
cellChanged
.
connect
(
lambda
:
self
.
adjustSize
()
)
self
.
database
=
database
self
.
category
=
self
.
get_category
()
...
...
@@ -191,14 +205,11 @@ class CodePhraseModule(QWidget):
# than one row
self
.
add_row
()
# See class docstring
self
.
table
.
cellChanged
.
connect
(
lambda
:
(
self
.
adjustSize
())
)
self
.
layout
=
QVBoxLayout
()
self
.
layout
.
setSpacing
(
0
)
self
.
layout
.
setMargin
(
0
)
self
.
layout
.
addWidget
(
self
.
line_edit_header
)
self
.
layout
.
addWidget
(
self
.
table
)
self
.
setLayout
(
self
.
layout
)
...
...
This diff is collapsed.
Click to expand it.
soitool/modules/module_freetext.py
+
13
−
15
View file @
177c739e
...
...
@@ -29,11 +29,7 @@ class TextEditWithSizeOfContent(QTextEdit):
def
sizeHint
(
self
):
"""
Give size hint using width of text.
"""
size
=
QSize
(
self
.
document
().
size
().
toSize
())
# NOTE that the following is not respected for dimensions below 100,100
size
.
setWidth
(
max
(
100
,
size
.
width
()))
size
.
setHeight
(
max
(
100
,
size
.
height
()))
return
size
return
QSize
(
self
.
document
().
size
().
toSize
())
def
resizeEvent
(
self
,
event
):
"""
Update geometry before handling the resizeEvent.
...
...
@@ -67,18 +63,20 @@ class LineEditWithSizeOfContent(QLineEdit):
content_width
+=
10
return
QSize
(
content_width
,
size_hint_parent
.
height
())
def
resizeEvent
(
self
,
event
):
"""
Update geometry before handling
the
re
size
Eve
nt.
def
minimumSizeHint
(
self
):
"""
Overriden to set the minimal size as
the size
hi
nt.
See sources in module docstring.
Override of https://doc.qt.io/qt-5/qwidget.html#minimumSize-prop
because we are unable to `self.setMinimalSize` to a size under 87,87.
Not sure why, but simply returning our sizeHint is a valid workaround,
since we would be setting self.minimalSize to this anyway.
Parameter
s
-------
---
event : QResizeEvent
event sent by Q
t
Return
s
-------
QSize
The minimal size for this widge
t
"""
self
.
updateGeometry
()
super
(
LineEditWithSizeOfContent
,
self
).
resizeEvent
(
event
)
return
self
.
sizeHint
()
class
Meta
(
type
(
ModuleBase
),
type
(
QWidget
)):
...
...
@@ -119,7 +117,7 @@ class FreeTextModule(ModuleBase, QWidget, metaclass=Meta):
# widget will leave behind gray color when it is shrunk in the
# QGraphicsScene
self
.
line_edit_header
.
textChanged
.
connect
(
lambda
:
(
self
.
line_edit_header
.
adjustSize
(),
self
.
adjustSize
())
lambda
:
(
self
.
line_edit_header
.
updateGeometry
(),
self
.
adjustSize
())
)
self
.
text_edit_body
.
textChanged
.
connect
(
lambda
:
(
self
.
text_edit_body
.
adjustSize
(),
self
.
adjustSize
())
...
...
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