Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
05ee3689
Commit
05ee3689
authored
10 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
Network table relooking
parent
36da49f9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cutecoin/gui/network_tab.py
+1
-1
1 addition, 1 deletion
src/cutecoin/gui/network_tab.py
src/cutecoin/models/network.py
+40
-28
40 additions, 28 deletions
src/cutecoin/models/network.py
with
41 additions
and
29 deletions
src/cutecoin/gui/network_tab.py
+
1
−
1
View file @
05ee3689
...
@@ -28,7 +28,7 @@ class NetworkTabWidget(QWidget, Ui_NetworkTabWidget):
...
@@ -28,7 +28,7 @@ class NetworkTabWidget(QWidget, Ui_NetworkTabWidget):
proxy
.
setSourceModel
(
model
)
proxy
.
setSourceModel
(
model
)
self
.
table_network
.
setModel
(
proxy
)
self
.
table_network
.
setModel
(
proxy
)
self
.
table_network
.
sortByColumn
(
0
,
Qt
.
DescendingOrder
)
self
.
table_network
.
sortByColumn
(
0
,
Qt
.
DescendingOrder
)
self
.
table_network
.
resizeColumnsToContents
()
community
.
network
.
nodes_changed
.
connect
(
self
.
refresh_nodes
)
community
.
network
.
nodes_changed
.
connect
(
self
.
refresh_nodes
)
def
refresh_nodes
(
self
):
def
refresh_nodes
(
self
):
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/models/network.py
+
40
−
28
View file @
05ee3689
...
@@ -35,14 +35,16 @@ class NetworkFilterProxyModel(QSortFilterProxyModel):
...
@@ -35,14 +35,16 @@ class NetworkFilterProxyModel(QSortFilterProxyModel):
if
role
!=
Qt
.
DisplayRole
:
if
role
!=
Qt
.
DisplayRole
:
return
QVariant
()
return
QVariant
()
header_names
=
{
'
pubkey
'
:
'
Pubkey
'
,
header_names
=
{
'
is_member
'
:
'
Member
'
,
'
uid
'
:
'
UID
'
,
'
address
'
:
'
Address
'
,
'
address
'
:
'
Address
'
,
'
port
'
:
'
Port
'
,
'
port
'
:
'
Port
'
,
'
current_block
'
:
'
Block
'
}
'
current_block
'
:
'
Block
'
,
type
=
self
.
sourceModel
().
headerData
(
section
,
orientation
,
role
)
'
uid
'
:
'
UID
'
,
return
header_names
[
type
]
'
is_member
'
:
'
Member
'
,
'
pubkey
'
:
'
Pubkey
'
}
_type
=
self
.
sourceModel
().
headerData
(
section
,
orientation
,
role
)
return
header_names
[
_type
]
def
data
(
self
,
index
,
role
):
def
data
(
self
,
index
,
role
):
source_index
=
self
.
mapToSource
(
index
)
source_index
=
self
.
mapToSource
(
index
)
...
@@ -53,11 +55,17 @@ class NetworkFilterProxyModel(QSortFilterProxyModel):
...
@@ -53,11 +55,17 @@ class NetworkFilterProxyModel(QSortFilterProxyModel):
and
role
==
Qt
.
DisplayRole
:
and
role
==
Qt
.
DisplayRole
:
value
=
{
True
:
'
yes
'
,
False
:
'
no
'
,
None
:
'
offline
'
}
value
=
{
True
:
'
yes
'
,
False
:
'
no
'
,
None
:
'
offline
'
}
return
value
[
source_data
]
return
value
[
source_data
]
if
role
==
Qt
.
TextAlignmentRole
:
if
source_index
.
column
()
==
self
.
sourceModel
().
column_types
.
index
(
'
address
'
)
or
source_index
.
column
()
==
self
.
sourceModel
().
column_types
.
index
(
'
current_block
'
):
return
Qt
.
AlignRight
|
Qt
.
AlignVCenter
if
source_index
.
column
()
==
self
.
sourceModel
().
column_types
.
index
(
'
is_member
'
):
return
Qt
.
AlignCenter
return
source_data
return
source_data
class
NetworkTableModel
(
QAbstractTableModel
):
class
NetworkTableModel
(
QAbstractTableModel
):
'''
'''
A Qt abstract item model to display
A Qt abstract item model to display
'''
'''
...
@@ -69,13 +77,25 @@ class NetworkTableModel(QAbstractTableModel):
...
@@ -69,13 +77,25 @@ class NetworkTableModel(QAbstractTableModel):
super
().
__init__
(
parent
)
super
().
__init__
(
parent
)
self
.
community
=
community
self
.
community
=
community
self
.
column_types
=
(
self
.
column_types
=
(
'
pubkey
'
,
'
is_member
'
,
'
uid
'
,
'
address
'
,
'
address
'
,
'
port
'
,
'
port
'
,
'
current_block
'
'
current_block
'
,
'
uid
'
,
'
is_member
'
,
'
pubkey
'
)
)
self
.
node_colors
=
{
Node
.
ONLINE
:
QColor
(
'
#99ff99
'
),
Node
.
OFFLINE
:
QColor
(
'
#ff9999
'
),
Node
.
DESYNCED
:
QColor
(
'
#ffbd81
'
),
Node
.
CORRUPTED
:
QColor
(
Qt
.
lightGray
)
}
self
.
node_states
=
{
Node
.
ONLINE
:
'
Online
'
,
Node
.
OFFLINE
:
'
Offline
'
,
Node
.
DESYNCED
:
'
Unsynchronized
'
,
Node
.
CORRUPTED
:
'
Corrupted
'
}
@property
@property
def
nodes
(
self
):
def
nodes
(
self
):
...
@@ -114,7 +134,7 @@ class NetworkTableModel(QAbstractTableModel):
...
@@ -114,7 +134,7 @@ class NetworkTableModel(QAbstractTableModel):
address
=
node
.
endpoint
.
ipv6
address
=
node
.
endpoint
.
ipv6
port
=
node
.
endpoint
.
port
port
=
node
.
endpoint
.
port
return
node
.
pubkey
,
is_member
,
node
.
uid
,
address
,
port
,
node
.
block
return
address
,
port
,
node
.
block
,
node
.
uid
,
is_member
,
node
.
pubkey
def
data
(
self
,
index
,
role
):
def
data
(
self
,
index
,
role
):
row
=
index
.
row
()
row
=
index
.
row
()
...
@@ -127,19 +147,11 @@ class NetworkTableModel(QAbstractTableModel):
...
@@ -127,19 +147,11 @@ class NetworkTableModel(QAbstractTableModel):
if
role
==
Qt
.
DisplayRole
:
if
role
==
Qt
.
DisplayRole
:
return
self
.
data_node
(
node
)[
col
]
return
self
.
data_node
(
node
)[
col
]
if
role
==
Qt
.
BackgroundColorRole
:
if
role
==
Qt
.
BackgroundColorRole
:
colors
=
{
Node
.
ONLINE
:
QVariant
(),
return
self
.
node_colors
[
node
.
state
]
Node
.
OFFLINE
:
QColor
(
Qt
.
darkRed
),
if
role
==
Qt
.
ToolTipRole
:
Node
.
DESYNCED
:
QColor
(
Qt
.
gray
),
return
self
.
node_states
[
node
.
state
]
Node
.
CORRUPTED
:
QColor
(
Qt
.
darkRed
)
}
return
QVariant
()
return
colors
[
node
.
state
]
if
role
==
Qt
.
ForegroundRole
:
colors
=
{
Node
.
ONLINE
:
QVariant
(),
Node
.
OFFLINE
:
QColor
(
Qt
.
lightGray
),
Node
.
DESYNCED
:
QColor
(
Qt
.
black
),
Node
.
CORRUPTED
:
QColor
(
Qt
.
lightGray
)
}
return
colors
[
node
.
state
]
def
flags
(
self
,
index
):
def
flags
(
self
,
index
):
return
Qt
.
ItemIsSelectable
|
Qt
.
ItemIsEnabled
return
Qt
.
ItemIsSelectable
|
Qt
.
ItemIsEnabled
...
...
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