Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor 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
schwede
openstructure
Commits
8ae81db9
Commit
8ae81db9
authored
12 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
added GUI table class
parent
2f3da810
Branches
Branches containing commit
Tags
Tags containing commit
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/gui/pymod/CMakeLists.txt
+1
-0
1 addition, 0 deletions
modules/gui/pymod/CMakeLists.txt
modules/gui/pymod/table.py
+49
-0
49 additions, 0 deletions
modules/gui/pymod/table.py
with
50 additions
and
0 deletions
modules/gui/pymod/CMakeLists.txt
+
1
−
0
View file @
8ae81db9
...
...
@@ -85,6 +85,7 @@ set(OST_GUI_PYMOD_MODULES
init_splash.py
traj.py
helpwidget.py
table.py
)
set
(
OST_GUI_PYMOD_DNG_MODULES
...
...
This diff is collapsed.
Click to expand it.
modules/gui/pymod/table.py
0 → 100644
+
49
−
0
View file @
8ae81db9
from
PyQt4.QtGui
import
*
from
PyQt4.QtCore
import
*
__all__
=
(
'
Table
'
,
)
class
TableModel
(
QAbstractTableModel
):
def
__init__
(
self
,
table
,
parent
=
None
):
QAbstractTableModel
.
__init__
(
self
,
parent
)
self
.
table
=
table
def
rowCount
(
self
,
index
):
return
len
(
self
.
table
.
rows
)
def
headerData
(
self
,
section
,
orientation
,
role
):
if
role
!=
Qt
.
DisplayRole
or
orientation
!=
Qt
.
Horizontal
:
return
QVariant
()
return
self
.
table
.
col_names
[
section
]
def
columnCount
(
self
,
index
):
return
len
(
self
.
table
.
col_names
)
def
sort
(
self
,
column
,
order
):
o
=
'
+
'
if
order
!=
Qt
.
AscendingOrder
:
o
=
'
-
'
self
.
table
.
Sort
(
by
=
self
.
table
.
col_names
[
column
],
order
=
o
)
self
.
reset
()
def
data
(
self
,
index
,
role
):
if
not
index
.
isValid
()
or
role
!=
Qt
.
DisplayRole
:
return
QVariant
()
row
=
self
.
table
.
rows
[
index
.
row
()]
return
QVariant
(
row
[
index
.
column
()])
class
Table
(
QTableView
):
def
__init__
(
self
,
table
):
QTableView
.
__init__
(
self
)
self
.
_model
=
TableModel
(
table
)
self
.
setFrameShape
(
QFrame
.
NoFrame
)
self
.
setAttribute
(
Qt
.
WA_MacSmallSize
)
self
.
setShowGrid
(
False
)
#self.horizontalHeader().setStretchLastSection(True)
self
.
setContextMenuPolicy
(
Qt
.
CustomContextMenu
)
self
.
setSelectionBehavior
(
QAbstractItemView
.
SelectRows
)
self
.
setSizePolicy
(
QSizePolicy
.
MinimumExpanding
,
QSizePolicy
.
MinimumExpanding
)
self
.
setSortingEnabled
(
True
)
self
.
setModel
(
self
.
_model
)
\ 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