Beispiel #1
0
        public void UpdateTask(SqliteTask task)
        {
            // Set the task in the store so the model will update the UI.
            Gtk.TreeIter iter;

            if (!taskIters.ContainsKey(task.SqliteId))
            {
                return;
            }

            iter = taskIters [task.SqliteId];

            if (task.State == TaskState.Deleted)
            {
                taskIters.Remove(task.SqliteId);
                if (!taskStore.Remove(ref iter))
                {
                    Logger.Debug("Successfully deleted from taskStore: {0}",
                                 task.Name);
                }
                else
                {
                    Logger.Debug("Problem removing from taskStore: {0}",
                                 task.Name);
                }
            }
            else
            {
                taskStore.SetValue(iter, 0, task);
            }
        }
Beispiel #2
0
        public void RefreshTasks()
        {
            Gtk.TreeIter iter;
            SqliteTask   newTask;
            bool         hasValues = false;

            string        command = "SELECT id,Category,Name,DueDate,CompletionDate,Priority, State FROM Tasks";
            SqliteCommand cmd     = db.Connection.CreateCommand();

            cmd.CommandText = command;
            SqliteDataReader dataReader = cmd.ExecuteReader();

            while (dataReader.Read())
            {
                int    id             = dataReader.GetInt32(0);
                int    category       = dataReader.GetInt32(1);
                string name           = dataReader.GetString(2);
                long   dueDate        = dataReader.GetInt64(3);
                long   completionDate = dataReader.GetInt64(4);
                int    priority       = dataReader.GetInt32(5);
                int    state          = dataReader.GetInt32(6);

                hasValues = true;

                newTask = new SqliteTask(this, id, category,
                                         name, dueDate, completionDate,
                                         priority, state);
                iter = taskStore.AppendNode();
                taskStore.SetValue(iter, 0, newTask);
                taskIters [newTask.SqliteId] = iter;
            }

            dataReader.Close();
            cmd.Dispose();

            if (!hasValues)
            {
                newTask          = new SqliteTask(this, "Create some tasks");
                newTask.Category = defaultCategory;
                newTask.DueDate  = DateTime.Now;
                newTask.Priority = TaskPriority.Medium;
                iter             = taskStore.AppendNode();
                taskStore.SetValue(iter, 0, newTask);
                taskIters [newTask.SqliteId] = iter;
            }
        }
Beispiel #3
0
        public ITask CreateTask(string taskName, ICategory category)
        {
            // not sure what to do here with the category
            SqliteTask task = new SqliteTask(this, taskName);

            // Determine and set the task category
            if (category == null || category is Tasque.AllCategory)
            {
                task.Category = defaultCategory;                 // Default to work
            }
            else
            {
                task.Category = category;
            }

            Gtk.TreeIter iter = taskStore.AppendNode();
            taskStore.SetValue(iter, 0, task);
            taskIters [task.SqliteId] = iter;

            return(task);
        }
Beispiel #4
0
        public void RefreshTasks()
        {
            SqliteTask newTask;
            var hasValues = false;

            var command = "SELECT id,Category,Name,DueDate,CompletionDate,Priority, State FROM Tasks";
            var cmd = Database.Connection.CreateCommand ();
            cmd.CommandText = command;
            var dataReader = cmd.ExecuteReader ();
            while (dataReader.Read()) {
                var id = dataReader.GetInt32 (0);
                var category = dataReader.GetInt32 (1);
                var name = dataReader.GetString (2);
                var dueDate = dataReader.GetInt64 (3);
                var completionDate = dataReader.GetInt64 (4);
                var priority = dataReader.GetInt32 (5);
                var state = dataReader.GetInt32 (6);

                hasValues = true;

                newTask = new SqliteTask (this, id, category, name, dueDate,
                                          completionDate, priority, state);
                Categories.ElementAt (category).Add (newTask);
            }

            dataReader.Close ();
            cmd.Dispose ();

            if (!hasValues) {
                var task = CreateTask (Catalog.GetString ("Create some tasks"));
                defaultCategory.Add (task);
            }
        }
Beispiel #5
0
        public void UpdateTask(SqliteTask task)
        {
            // Set the task in the store so the model will update the UI.
            Gtk.TreeIter iter;

            if (!taskIters.ContainsKey (task.SqliteId))
                return;

            iter = taskIters [task.SqliteId];

            if (task.State == TaskState.Deleted) {
                taskIters.Remove (task.SqliteId);
                if (!taskStore.Remove (ref iter)) {
                    Logger.Debug ("Successfully deleted from taskStore: {0}",
                        task.Name);
                } else {
                    Logger.Debug ("Problem removing from taskStore: {0}",
                        task.Name);
                }
            } else {
                taskStore.SetValue (iter, 0, task);
            }
        }
Beispiel #6
0
        public void RefreshTasks()
        {
            Gtk.TreeIter iter;
            SqliteTask newTask;
            bool hasValues = false;

            string command = "SELECT id,Category,Name,DueDate,CompletionDate,Priority, State FROM Tasks";
            SqliteCommand cmd = db.Connection.CreateCommand();
            cmd.CommandText = command;
            SqliteDataReader dataReader = cmd.ExecuteReader();
            while(dataReader.Read()) {
                int id = dataReader.GetInt32(0);
                int category = dataReader.GetInt32(1);
                string name = dataReader.GetString(2);
                long dueDate = dataReader.GetInt64(3);
                long completionDate = dataReader.GetInt64(4);
                int priority = dataReader.GetInt32(5);
                int state = dataReader.GetInt32(6);

                hasValues = true;

                newTask = new SqliteTask(this, id, category,
                                         name, dueDate, completionDate,
                                         priority, state);
                iter = taskStore.AppendNode();
                taskStore.SetValue (iter, 0, newTask);
                taskIters [newTask.SqliteId] = iter;
            }

            dataReader.Close();
            cmd.Dispose();

            if(!hasValues)
            {
                newTask = new SqliteTask (this, "Create some tasks");
                newTask.Category = defaultCategory;
                newTask.DueDate = DateTime.Now;
                newTask.Priority = TaskPriority.Medium;
                iter = taskStore.AppendNode ();
                taskStore.SetValue (iter, 0, newTask);
                taskIters [newTask.SqliteId] = iter;
            }
        }
Beispiel #7
0
        public ITask CreateTask(string taskName, ICategory category)
        {
            // not sure what to do here with the category
            SqliteTask task = new SqliteTask (this, taskName);

            // Determine and set the task category
            if (category == null || category is Tasque.AllCategory)
                task.Category = defaultCategory; // Default to work
            else
                task.Category = category;

            Gtk.TreeIter iter = taskStore.AppendNode ();
            taskStore.SetValue (iter, 0, task);
            taskIters [task.SqliteId] = iter;

            return task;
        }