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
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
2ba62f7d
Commit
2ba62f7d
authored
10 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Adding missing files
parent
ee967ed7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
res/ui/network_tab.ui
+38
-0
38 additions, 0 deletions
res/ui/network_tab.ui
src/cutecoin/gui/network_tab.py
+28
-0
28 additions, 0 deletions
src/cutecoin/gui/network_tab.py
src/cutecoin/models/network.py
+95
-0
95 additions, 0 deletions
src/cutecoin/models/network.py
with
161 additions
and
0 deletions
res/ui/network_tab.ui
0 → 100644
+
38
−
0
View file @
2ba62f7d
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
NetworkTabWidget
</class>
<widget
class=
"QWidget"
name=
"NetworkTabWidget"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
400
</width>
<height>
300
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
<item>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"QTableView"
name=
"table_network"
>
<attribute
name=
"horizontalHeaderShowSortIndicator"
stdset=
"0"
>
<bool>
true
</bool>
</attribute>
<attribute
name=
"horizontalHeaderStretchLastSection"
>
<bool>
true
</bool>
</attribute>
<attribute
name=
"verticalHeaderVisible"
>
<bool>
false
</bool>
</attribute>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
This diff is collapsed.
Click to expand it.
src/cutecoin/gui/network_tab.py
0 → 100644
+
28
−
0
View file @
2ba62f7d
'''
Created on 20 févr. 2015
@author: inso
'''
from
PyQt5.QtWidgets
import
QWidget
from
..models.network
import
NetworkTableModel
,
NetworkFilterProxyModel
from
..gen_resources.network_tab_uic
import
Ui_NetworkTabWidget
class
NetworkTabWidget
(
QWidget
,
Ui_NetworkTabWidget
):
'''
classdocs
'''
def
__init__
(
self
,
community
):
'''
Constructor
'''
super
().
__init__
()
self
.
setupUi
(
self
)
model
=
NetworkTableModel
(
community
)
proxy
=
NetworkFilterProxyModel
()
proxy
.
setSourceModel
(
model
)
self
.
table_network
.
setModel
(
proxy
)
This diff is collapsed.
Click to expand it.
src/cutecoin/models/network.py
0 → 100644
+
95
−
0
View file @
2ba62f7d
'''
Created on 5 févr. 2014
@author: inso
'''
import
logging
from
..core.transfer
import
Transfer
,
Received
from
..core.person
import
Person
from
..tools.exceptions
import
PersonNotFoundError
from
ucoinpy.documents.peer
import
BMAEndpoint
from
ucoinpy.api
import
bma
from
PyQt5.QtCore
import
QAbstractTableModel
,
Qt
,
QVariant
,
QSortFilterProxyModel
,
\
QDateTime
from
PyQt5.QtGui
import
QFont
,
QColor
class
NetworkFilterProxyModel
(
QSortFilterProxyModel
):
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
)
self
.
community
=
None
def
columnCount
(
self
,
parent
):
return
self
.
sourceModel
().
columnCount
(
None
)
def
setSourceModel
(
self
,
sourceModel
):
self
.
community
=
sourceModel
.
community
super
().
setSourceModel
(
sourceModel
)
def
lessThan
(
self
,
left
,
right
):
"""
Sort table by given column number.
"""
left_data
=
self
.
sourceModel
().
data
(
left
,
Qt
.
DisplayRole
)
right_data
=
self
.
sourceModel
().
data
(
right
,
Qt
.
DisplayRole
)
return
(
left_data
<
right_data
)
def
data
(
self
,
index
,
role
):
source_index
=
self
.
mapToSource
(
index
)
source_data
=
self
.
sourceModel
().
data
(
source_index
,
role
)
return
source_data
class
NetworkTableModel
(
QAbstractTableModel
):
'''
A Qt abstract item model to display
'''
def
__init__
(
self
,
community
,
parent
=
None
):
'''
Constructor
'''
super
().
__init__
(
parent
)
self
.
community
=
community
self
.
column_types
=
(
'
address
'
,
'
port
'
)
@property
def
peers
(
self
):
return
self
.
community
.
peers
def
rowCount
(
self
,
parent
):
return
len
(
self
.
peers
)
def
columnCount
(
self
,
parent
):
return
len
(
self
.
column_types
)
def
headerData
(
self
,
section
,
orientation
,
role
):
return
self
.
column_types
[
section
]
def
data_peer
(
self
,
peer
):
e
=
next
((
e
for
e
in
peer
.
endpoints
if
type
(
e
)
is
BMAEndpoint
))
informations
=
bma
.
network
.
peering
.
Peers
(
e
.
conn_handler
()).
get
()
if
e
.
server
:
address
=
e
.
server
elif
e
.
ipv4
:
address
=
e
.
port
def
data
(
self
,
index
,
role
):
row
=
index
.
row
()
col
=
index
.
column
()
if
not
index
.
isValid
():
return
QVariant
()
peer
=
self
.
peers
[
row
]
if
role
==
Qt
.
DisplayRole
:
return
self
.
data_peer
(
peer
)[
col
]
def
flags
(
self
,
index
):
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