Skip to content
Snippets Groups Projects
Commit 69108196 authored by Vincent Texier's avatar Vincent Texier
Browse files

Wot view : fix bug in search combo box and now search when return is pressed...

parent 868e9d32
No related branches found
No related tags found
No related merge requests found
...@@ -28,8 +28,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -28,8 +28,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
self.setupUi(self) self.setupUi(self)
# add combobox events # add combobox events
self.comboBoxSearch.lineEdit().textEdited.connect(self.search) self.comboBoxSearch.lineEdit().returnPressed.connect(self.search)
self.comboBoxSearch.lineEdit().returnPressed.connect(self.combobox_return_pressed)
# add scene events # add scene events
self.graphicsView.scene().node_clicked.connect(self.draw_graph) self.graphicsView.scene().node_clicked.connect(self.draw_graph)
...@@ -56,7 +55,6 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -56,7 +55,6 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
""" """
# reset graph # reset graph
graph = dict() graph = dict()
try: try:
certifiers = self.community.request(bma.wot.CertifiersOf, {'search': public_key}) certifiers = self.community.request(bma.wot.CertifiersOf, {'search': public_key})
except ValueError as e: except ValueError as e:
...@@ -191,24 +189,19 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -191,24 +189,19 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
self.account.pubkey self.account.pubkey
) )
def combobox_return_pressed(self): def search(self):
""" """
Search nodes when return is pressed in combobox lineEdit Search nodes when return is pressed in combobox lineEdit
""" """
self.search(self.comboBoxSearch.lineEdit().text()) text = self.comboBoxSearch.lineEdit().text()
def search(self, text):
"""
Search nodes when text is edited in combobox lineEdit
"""
if len(text) < 2: if len(text) < 2:
return False return False
response = self.community.request(bma.wot.Lookup, {'search': text}) response = self.community.request(bma.wot.Lookup, {'search': text})
nodes = {} nodes = {}
for identity in response['results']: for identity in response['results']:
if identity['uids'][0]['others']: nodes[identity['pubkey']] = identity['uids'][0]['uid']
nodes[identity['pubkey']] = identity['uids'][0]['uid']
if nodes: if nodes:
self.nodes = list() self.nodes = list()
...@@ -219,6 +212,11 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -219,6 +212,11 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
self.comboBoxSearch.addItem(uid) self.comboBoxSearch.addItem(uid)
self.comboBoxSearch.showPopup() self.comboBoxSearch.showPopup()
if len(nodes) == 1:
self.draw_graph(
list(nodes.keys())[0]
)
def select_node(self, index): def select_node(self, index):
""" """
Select node in graph when item is selected in combobox Select node in graph when item is selected in combobox
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment