Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EO Time Series Viewer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
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
Benjamin Jakimow
EO Time Series Viewer
Commits
3657ee67
Commit
3657ee67
authored
6 years ago
by
Benjamin Jakimow
Browse files
Options
Downloads
Patches
Plain Diff
tbd
parent
3acca3f9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/gridwidgets.py
+8
-92
8 additions, 92 deletions
test/gridwidgets.py
with
8 additions
and
92 deletions
test/gridwidgets.py
+
8
−
92
View file @
3657ee67
...
...
@@ -6,98 +6,14 @@ from qgis.PyQt.QtWidgets import *
from
timeseriesviewer.utils
import
*
viewModes
=
[
'
timeXmapview
'
,
'
mapviewXtime
'
,
'
time2Xmapview
'
]
class
MapViewGridLayout
(
QGridLayout
):
def
__init__
(
self
):
pass
class
GridWidgetModel
(
QAbstractTableModel
):
def
__init__
(
self
):
super
(
GridWidgetModel
,
self
).
__init__
()
def
columnNames
(
self
)
->
list
:
"""
Returns the column names
:return: [list-of-str]
"""
return
[
self
.
mColLabel
,
self
.
mColName
,
self
.
mColColor
]
def
rowCount
(
self
,
parent
:
QModelIndex
=
None
):
"""
Returns the number of row / ClassInfos
:param parent: QModelIndex
:return: int
"""
return
len
(
self
.
mClasses
)
def
columnCount
(
self
,
parent
:
QModelIndex
=
None
):
return
len
(
self
.
columnNames
())
def
index2ClassInfo
(
self
,
index
)
->
ClassInfo
:
if
isinstance
(
index
,
QModelIndex
):
index
=
index
.
row
()
return
self
.
mClasses
[
index
]
def
classInfo2index
(
self
,
classInfo
:
ClassInfo
)
->
QModelIndex
:
row
=
self
.
mClasses
.
index
(
classInfo
)
return
self
.
createIndex
(
row
,
0
)
def
data
(
self
,
index
:
QModelIndex
,
role
:
int
=
Qt
.
DisplayRole
):
if
not
index
.
isValid
():
return
None
value
=
None
col
=
index
.
column
()
row
=
index
.
row
()
classInfo
=
self
.
index2ClassInfo
(
row
)
if
role
==
Qt
.
DisplayRole
:
if
col
==
0
:
return
classInfo
.
label
()
if
col
==
1
:
return
classInfo
.
name
()
if
col
==
2
:
return
classInfo
.
color
().
name
()
if
role
==
Qt
.
ForegroundRole
:
if
col
==
self
.
mColColor
:
return
QBrush
(
getTextColorWithContrast
(
classInfo
.
color
()))
if
role
==
Qt
.
BackgroundColorRole
:
if
col
==
2
:
return
QBrush
(
classInfo
.
color
())
if
role
==
Qt
.
AccessibleTextRole
:
if
col
==
0
:
return
str
(
classInfo
.
label
())
if
col
==
1
:
return
classInfo
.
name
()
if
col
==
2
:
return
classInfo
.
color
().
name
()
if
role
==
Qt
.
ToolTipRole
:
if
col
==
0
:
return
'
Class label
"
{}
"'
.
format
(
classInfo
.
label
())
if
col
==
1
:
return
'
Class name
"
{}
"'
.
format
(
classInfo
.
name
())
if
col
==
2
:
return
'
Class color
"
{}
"'
.
format
(
classInfo
.
color
().
name
())
if
role
==
Qt
.
EditRole
:
if
col
==
1
:
return
classInfo
.
name
()
if
col
==
2
:
return
classInfo
.
color
()
if
role
==
Qt
.
UserRole
:
return
classInfo
return
None
def
setViewMode
(
self
,
viewMode
=
str
):
assert
viewMode
in
viewModes
...
...
@@ -107,10 +23,10 @@ if __name__ == '__main__':
app
=
initQgisApplication
()
vie
w
=
Q
TableView
()
view
.
resize
(
QSize
(
300
,
200
)
)
view
.
show
(
)
w
=
Q
Widget
()
l
=
MapViewGridLayout
()
w
.
setLayout
(
l
)
w
.
show
(
)
w
.
resize
(
QSize
(
300
,
200
)
)
app
.
exec_
()
\ No newline at end of file
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