diff options
Diffstat (limited to 'model.py')
-rw-r--r-- | model.py | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -31,9 +31,14 @@ class MindMapModel(gtk.TreeStore): self._thoughts_by_id = {} self._thoughts = [] - def create_new_thought(self, name='', x=0, y=0, color=''): + def create_new_thought(self, name='', x=0, y=0, color='', parent_id=None): thought_id = self._next_thought_id - self.append(None, (thought_id, name, x, y, color)) + + parent = None + if parent_id is not None: + parent = self.find_by_id(parent_id).iter + + self.append(parent, (thought_id, name, x, y, color)) self._next_thought_id += 1 return thought_id @@ -68,5 +73,11 @@ class MindMapModel(gtk.TreeStore): for row in rows: if row[0] == thought_id: return row - self.find_by_id(thought_id, row.iterchildren()) + + children = row.iterchildren() + found_row = self.find_by_id(thought_id, children) + if found_row is not None: + return found_row + + return None |