Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/model.py
diff options
context:
space:
mode:
Diffstat (limited to 'model.py')
-rw-r--r--model.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/model.py b/model.py
index 38d1ca6..f15758b 100644
--- a/model.py
+++ b/model.py
@@ -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