diff options
Diffstat (limited to 'view.py')
-rw-r--r-- | view.py | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -113,18 +113,27 @@ class MindMapView(GtkView): raise ValueError('Rect %r and line %r dont intersect!' % (rect, line,)) - def _connect_items(self, parent_view, thought_view): - line = Line() - self.canvas.add(line) - + def _update_connection(self, parent_view, thought_view): handle_tool = tool.ConnectHandleTool() + if thought_view.line_to_parent is None: + line = Line() + self.canvas.add(line) + thought_view.line_to_parent = line + else: + line = thought_view.line_to_parent + line_handle = line.handles()[0] + handle_tool.disconnect(self, line, line_handle) + handle_tool.disconnect(self, line, line.opposite(line_handle)) + start, end = self._calculate_ports(thought_view, parent_view) line_handle = line.handles()[0] handle_tool.connect(self, line, line_handle, start) handle_tool.connect(self, line, line.opposite(line_handle), end) + self.canvas.request_update(line) + def __row_changed_cb(self, model, path, iter): row = model[iter] #logging.debug('__row_changed_cb %r' % ((row[0], row[1], row[2], row[3], row[4],),)) @@ -133,17 +142,20 @@ class MindMapView(GtkView): if thought_view is None: thought_view = ThoughtView(row[0], row[1], row[2], row[3], row[4]) self.canvas.add(thought_view) - - if row.parent is not None: - parent_view = self._get_thought_by_id(row.parent[0]) - gobject.idle_add(lambda: self._connect_items(parent_view, - thought_view)) else: thought_view.name = row[1] thought_view.set_position(row[2], row[3]) thought_view.color = row[4] - self.canvas.request_update(thought_view) + self.canvas.request_update(thought_view) + + if row.parent is not None: + parent_view = self._get_thought_by_id(row.parent[0]) + self._update_connection(parent_view, thought_view) + + for child in row.iterchildren(): + child_view = self._get_thought_by_id(child[0]) + self._update_connection(thought_view, child_view) def __row_deleted_cb(self, model, path): logging.debug('__row_deleted_cb %r' % path) |