show database tasks!
authorEduardo <[email protected]>
Mon, 2 Oct 2023 01:15:43 +0000 (03:15 +0200)
committerEduardo <[email protected]>
Mon, 2 Oct 2023 01:15:43 +0000 (03:15 +0200)
scenes/todo_list/ToDoList.gd

index 11d745c8c9382fbb11f945441b41796d85a2df69..d9024a9ae74d0648feb668bfd25c04dd252540e7 100644 (file)
@@ -20,6 +20,16 @@ func _on_Back_pressed():
        # return to menu
        emit_signal("scene_changed", "res://scenes/main_menu/MainMenu.tscn")
 
+func load_tasks():
+       var tasks := DB.get_todo_tasks(false)
+
+       for task in tasks:
+               var el = load("res://custom_elements/todo_list_elements/todo_element.tscn").instantiate()
+               reorderable_list.call_deferred("add_child", el)
+               el.call_deferred("set_task", task["rowid"], task["task"], task["done"], 0, task["priority"], "", "")
+               # TODO: make sure thre is no null before doing set_task
+       _add_empty_entry_at_bottom(3)
+
 func DEBUG_put_lots_of_tasks(how_many: int):
        var text_arr := [
                "text 1",
@@ -49,5 +59,5 @@ func _add_empty_entry_at_bottom(how_many: int):
 
 func _on_ready():
        bg = Thread.new()
-       bg.start(DEBUG_put_lots_of_tasks.bind(20))
+       bg.start(load_tasks)