diff --git a/src/sakia/gui/graphs/base/controller.py b/src/sakia/gui/graphs/base/controller.py index b849958a8bf236391d4ff49be2e5934cb7c03dcc..a022ed896e1d9b689b24243dd58921a08455d26f 100644 --- a/src/sakia/gui/graphs/base/controller.py +++ b/src/sakia/gui/graphs/base/controller.py @@ -2,9 +2,8 @@ from ...component.controller import ComponentController from PyQt5.QtCore import pyqtSlot from PyQt5.QtGui import QCursor from sakia.tools.decorators import asyncify, once_at_a_time -from .view import BaseGraphView -from .model import BaseGraphModel from ...widgets.context_menu import ContextMenu +import asyncio class BaseGraphController(ComponentController): @@ -35,7 +34,7 @@ class BaseGraphController(ComponentController): @pyqtSlot(str, dict) def handle_node_click(self, pubkey, metadata): identity = self.model.get_identity_from_data(metadata, pubkey) - self.draw_graph(identity) + asyncio.ensure_future(self.draw_graph(identity)) async def draw_graph(self, identity): """ diff --git a/src/sakia/gui/graphs/explorer/controller.py b/src/sakia/gui/graphs/explorer/controller.py index b8b3593fc2b49ea675f52c92d35c28f058bfbd89..2c2a195272e3f71b9d83012892b77fb5616212a7 100644 --- a/src/sakia/gui/graphs/explorer/controller.py +++ b/src/sakia/gui/graphs/explorer/controller.py @@ -3,7 +3,7 @@ from sakia.tools.decorators import asyncify, once_at_a_time from .view import ExplorerView from .model import ExplorerModel from ...search_user.controller import SearchUserController - +import asyncio class ExplorerController(BaseGraphController): """ @@ -22,6 +22,14 @@ class ExplorerController(BaseGraphController): self.reset() self.view.button_go.clicked.connect(lambda checked: self.refresh()) + def center_on_identity(self, identity): + """ + Draw community graph centered on the identity + + :param sakia.core.registry.Identity identity: Center identity + """ + asyncio.ensure_future(self.draw_graph(identity)) + @property def view(self) -> ExplorerView: return self._view @@ -42,7 +50,7 @@ class ExplorerController(BaseGraphController): search_user = SearchUserController.create(explorer, app, **{'account': account, 'community': community}) explorer.view.set_search_user(search_user.view) - search_user.identity_selected.connect(explorer.refresh) + search_user.identity_selected.connect(explorer.center_on_identity) return explorer async def draw_graph(self, identity): @@ -60,12 +68,12 @@ class ExplorerController(BaseGraphController): @once_at_a_time @asyncify - async def refresh(self, identity=None): + async def refresh(self): """ Refresh graph scene to current metadata """ self.model.graph.stop_exploration() - await self.draw_graph(identity) + await self.draw_graph(self.model.identity) self.view.update_wot(self.model.graph.nx_graph, self.model.identity) @once_at_a_time diff --git a/src/sakia/gui/graphs/wot/controller.py b/src/sakia/gui/graphs/wot/controller.py index a1aceca66ce42684d89a63224644faa0c67d9a1a..9cebbaf1137666fbd90edb7a574a88ffd16e04fe 100644 --- a/src/sakia/gui/graphs/wot/controller.py +++ b/src/sakia/gui/graphs/wot/controller.py @@ -2,6 +2,8 @@ from ..base.controller import BaseGraphController from sakia.tools.decorators import asyncify, once_at_a_time from .view import WotView from .model import WotModel +from ...search_user.controller import SearchUserController +import asyncio class WotController(BaseGraphController): @@ -29,6 +31,10 @@ class WotController(BaseGraphController): model = WotModel(None, app, account, community) wot = cls(parent, view, model) model.setParent(wot) + search_user = SearchUserController.create(wot, app, **{'account': account, + 'community': community}) + wot.view.set_search_user(search_user.view) + search_user.identity_selected.connect(wot.center_on_identity) return wot @property @@ -39,6 +45,14 @@ class WotController(BaseGraphController): def model(self) -> WotModel: return self._model + def center_on_identity(self, identity): + """ + Draw community graph centered on the identity + + :param sakia.core.registry.Identity identity: Center identity + """ + asyncio.ensure_future(self.draw_graph(identity)) + async def draw_graph(self, identity): """ Draw community graph centered on the identity diff --git a/src/sakia/gui/graphs/wot/view.py b/src/sakia/gui/graphs/wot/view.py index 1aca74f77f9c16b5915da9c855e5ee28648c1108..75b61f644ff53cfceb8a6e5ab879f599388228b5 100644 --- a/src/sakia/gui/graphs/wot/view.py +++ b/src/sakia/gui/graphs/wot/view.py @@ -1,4 +1,3 @@ -from PyQt5.QtCore import QEvent from ..base.view import BaseGraphView from .wot_tab_uic import Ui_WotWidget @@ -15,6 +14,14 @@ class WotView(BaseGraphView, Ui_WotWidget): super().__init__(parent) self.setupUi(self) + def set_search_user(self, search_user): + """ + Set the search user view in the gui + :param sakia.gui.search_user.view.SearchUserView search_user: the view + :return: + """ + self.layout().insertWidget(0, search_user) + def scene(self): """ Get the scene of the underlying graphics view @@ -39,4 +46,4 @@ class WotView(BaseGraphView, Ui_WotWidget): :param path: :return: """ - self.ui.graphicsView.scene().update_path(nx_graph, path) + self.graphicsView.scene().update_path(nx_graph, path) diff --git a/src/sakia/gui/graphs/wot/wot_tab.ui b/src/sakia/gui/graphs/wot/wot_tab.ui index 70b8a9f412b5eb014c6f5a28cc3cd1331a25f8f6..c54c8b61d7f40b52315fa428f8036ba6014f868b 100644 --- a/src/sakia/gui/graphs/wot/wot_tab.ui +++ b/src/sakia/gui/graphs/wot/wot_tab.ui @@ -13,8 +13,8 @@ <property name="windowTitle"> <string>Form</string> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> <widget class="WotGraphicsView" name="graphics_view"> <property name="viewportUpdateMode"> <enum>QGraphicsView::BoundingRectViewportUpdate</enum>