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
cbfc3f0a
Commit
cbfc3f0a
authored
10 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
Wot view : implement search function
todo: arc expire date and color based on currency certifications config
parent
62c897e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cutecoin/wot/qt/form.py
+35
-32
35 additions, 32 deletions
src/cutecoin/wot/qt/form.py
src/cutecoin/wot/qt/view.py
+1
-11
1 addition, 11 deletions
src/cutecoin/wot/qt/view.py
with
36 additions
and
43 deletions
src/cutecoin/wot/qt/form.py
+
35
−
32
View file @
cbfc3f0a
...
...
@@ -2,15 +2,13 @@
import
time
import
datetime
import
hashlib
from
PyQt5.QtWidgets
import
QWidget
from
cutecoin.gen_resources.wot_form_uic
import
Ui_Form
import
cutecoin.wot.mapi
as
mapi
from
cutecoin.wot.qt.view
import
NODE_STATUS_HIGHLIGHTED
,
NODE_STATUS_SELECTED
,
ARC_STATUS_STRONG
,
ARC_STATUS_WEAK
from
ucoinpy.api
import
bma
class
Form
(
QWidget
,
Ui_Form
):
def
__init__
(
self
,
account
,
community
,
parent
=
None
):
"""
...
...
@@ -35,9 +33,8 @@ class Form(QWidget, Ui_Form):
self
.
account
=
account
self
.
community
=
community
self
.
nodes
=
[]
self
.
graph
=
{}
# nodes list for menu from search
self
.
nodes
=
list
()
self
.
signature_validity
=
86400
*
365
self
.
ARC_STATUS_STRONG_time
=
self
.
signature_validity
-
(
86400
*
165
)
self
.
draw_graph
(
self
.
account
.
pubkey
)
...
...
@@ -48,19 +45,17 @@ class Form(QWidget, Ui_Form):
:param public_key: Public key of the identity
"""
self
.
graph
=
dict
()
graph
=
dict
()
# add wallet node
node_status
=
(
NODE_STATUS_HIGHLIGHTED
and
(
public_key
==
self
.
account
.
pubkey
))
or
0
node_status
+=
NODE_STATUS_SELECTED
certifiers
=
self
.
community
.
request
(
bma
.
wot
.
CertifiersOf
,
{
'
search
'
:
public_key
})
self
.
graph
[
public_key
]
=
{
'
arcs
'
:
[],
'
text
'
:
certifiers
[
'
uid
'
],
'
tooltip
'
:
public_key
,
'
status
'
:
node_status
}
graph
[
public_key
]
=
{
'
arcs
'
:
[],
'
text
'
:
certifiers
[
'
uid
'
],
'
tooltip
'
:
public_key
,
'
status
'
:
node_status
}
# add certifiers of uid
#for certifier in self.community.request(mapi.get_sig_to(public_key):
for
certifier
in
certifiers
[
'
certifications
'
]:
if
certifier
[
'
pubkey
'
]
in
self
.
graph
.
keys
():
continue
if
(
time
.
time
()
-
certifier
[
'
cert_time
'
][
'
medianTime
'
])
>
self
.
ARC_STATUS_STRONG_time
:
arc_status
=
ARC_STATUS_WEAK
else
:
...
...
@@ -72,19 +67,18 @@ class Form(QWidget, Ui_Form):
certifier
[
'
cert_time
'
][
'
medianTime
'
]
+
self
.
signature_validity
).
strftime
(
"
%Y/%m/%d
"
)
}
node_status
=
(
NODE_STATUS_HIGHLIGHTED
and
(
certifier
[
'
pubkey
'
]
==
self
.
account
.
pubkey
))
or
0
self
.
graph
[
certifier
[
'
pubkey
'
]]
=
{
'
arcs
'
:
[
arc
],
'
text
'
:
certifier
[
'
uid
'
],
'
tooltip
'
:
public_key
,
'
status
'
:
node_status
}
if
certifier
[
'
pubkey
'
]
not
in
graph
.
keys
():
node_status
=
(
NODE_STATUS_HIGHLIGHTED
and
(
certifier
[
'
pubkey
'
]
==
self
.
account
.
pubkey
))
or
0
graph
[
certifier
[
'
pubkey
'
]]
=
{
'
arcs
'
:
[
arc
],
'
text
'
:
certifier
[
'
uid
'
],
'
tooltip
'
:
certifier
[
'
pubkey
'
],
'
status
'
:
node_status
}
# add certified by uid
#for certified in mapi.get_sig_from(public_key):
for
certified
in
self
.
community
.
request
(
bma
.
wot
.
CertifiedBy
,
{
'
search
'
:
public_key
})[
'
certifications
'
]:
if
certified
[
'
pubkey
'
]
in
self
.
graph
.
keys
():
continue
if
(
time
.
time
()
-
certified
[
'
cert_time
'
][
'
medianTime
'
])
>
self
.
ARC_STATUS_STRONG_time
:
arc_status
=
ARC_STATUS_WEAK
else
:
...
...
@@ -96,17 +90,18 @@ class Form(QWidget, Ui_Form):
certified
[
'
cert_time
'
][
'
medianTime
'
]
+
self
.
signature_validity
).
strftime
(
"
%Y/%m/%d
"
)
}
node_status
=
(
NODE_STATUS_HIGHLIGHTED
and
(
certified
[
'
pubkey
'
]
==
self
.
account
.
pubkey
))
or
0
self
.
graph
[
certified
[
'
pubkey
'
]]
=
{
'
arcs
'
:
[],
'
text
'
:
certified
[
'
uid
'
],
'
tooltip
'
:
public_key
,
'
status
'
:
node_status
}
self
.
graph
[
public_key
][
'
arcs
'
].
append
(
arc
)
graph
[
public_key
][
'
arcs
'
].
append
(
arc
)
if
certified
[
'
pubkey
'
]
not
in
graph
.
keys
():
node_status
=
(
NODE_STATUS_HIGHLIGHTED
and
(
certified
[
'
pubkey
'
]
==
self
.
account
.
pubkey
))
or
0
graph
[
certified
[
'
pubkey
'
]]
=
{
'
arcs
'
:
list
(),
'
text
'
:
certified
[
'
uid
'
],
'
tooltip
'
:
certified
[
'
pubkey
'
],
'
status
'
:
node_status
}
# draw graph in qt scene
self
.
graphicsView
.
scene
().
update_wot
(
self
.
graph
)
self
.
graphicsView
.
scene
().
update_wot
(
graph
)
def
reset
(
self
):
"""
...
...
@@ -128,12 +123,20 @@ class Form(QWidget, Ui_Form):
"""
if
len
(
text
)
<
2
:
return
False
self
.
nodes
=
mapi
.
search
(
text
)
if
self
.
nodes
:
response
=
self
.
community
.
request
(
bma
.
wot
.
Lookup
,
{
'
search
'
:
text
})
nodes
=
{}
for
identity
in
response
[
'
results
'
]:
if
identity
[
'
uids
'
][
0
][
'
others
'
]:
nodes
[
identity
[
'
pubkey
'
]]
=
identity
[
'
uids
'
][
0
][
'
uid
'
]
if
nodes
:
self
.
nodes
=
list
()
self
.
comboBoxSearch
.
clear
()
self
.
comboBoxSearch
.
lineEdit
().
setText
(
text
)
for
node
in
self
.
nodes
:
self
.
comboBoxSearch
.
addItem
(
node
[
'
uid
'
])
for
pubkey
,
uid
in
nodes
.
items
():
self
.
nodes
.
append
({
'
pubkey
'
:
pubkey
,
'
uid
'
:
uid
})
self
.
comboBoxSearch
.
addItem
(
uid
)
self
.
comboBoxSearch
.
showPopup
()
def
select_node
(
self
,
index
):
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/wot/qt/view.py
+
1
−
11
View file @
cbfc3f0a
...
...
@@ -119,8 +119,6 @@ class Scene(QGraphicsScene):
root_node
=
self
.
add_node
(
selected_id
,
selected_node
,
(
0
,
0
))
done
=
[
selected_id
]
# add certified by selected node
y
=
0
x
=
200
...
...
@@ -134,23 +132,15 @@ class Scene(QGraphicsScene):
for
_id
,
items
in
nodes
:
node
=
self
.
add_node
(
_id
,
items
[
'
node
'
],
(
x
,
y
))
self
.
add_arc
(
root_node
,
node
,
items
[
'
arc
'
])
graph
.
pop
(
_id
)
y
+=
50
done
.
append
(
_id
)
# add certifiers of selected node
y
=
0
x
=
-
200
# capture nodes for sorting by text
nodes
=
dict
()
for
_id
,
certifier_node
in
graph
.
items
():
nodes
[
_id
]
=
certifier_node
# sort by text
nodes
=
((
k
,
v
)
for
(
k
,
v
)
in
sorted
(
nodes
.
items
(),
key
=
lambda
kv
:
kv
[
1
][
'
text
'
].
lower
()))
nodes
=
((
k
,
v
)
for
(
k
,
v
)
in
sorted
(
graph
.
items
(),
key
=
lambda
kv
:
kv
[
1
][
'
text
'
].
lower
())
if
selected_id
in
(
arc
[
'
id
'
]
for
arc
in
v
[
'
arcs
'
])
)
# add nodes and arcs
for
_id
,
certifier_node
in
nodes
:
if
_id
in
done
:
continue
node
=
self
.
add_node
(
_id
,
certifier_node
,
(
x
,
y
))
for
arc
in
certifier_node
[
'
arcs
'
]:
if
arc
[
'
id
'
]
==
selected_id
:
...
...
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