예제 #1
0
        // TODO: Move this method into a property of ICategory.TaskCount
        private int GetTaskCountInCategory(ICategory category)
        {
            // This is disgustingly inefficient, but, oh well
            int count = 0;

            Gtk.TreeIter iter;
            Gtk.TreeModel model = Application.Backend.Tasks;

            if (!model.GetIterFirst (out iter))
                return 0;

            do {
                ITask task = model.GetValue (iter, 0) as ITask;
                if (task == null)
                    continue;
                if (task.State != TaskState.Active
                        && task.State != TaskState.Inactive)
                    continue;

                if (category.ContainsTask (task))
                    count++;
            } while (model.IterNext (ref iter));

            return count;
        }