[Planner Dev] Patch for planner Bugzilla 138595 Task up and down should work on selections.
- From: "lincoln phipps openmutual net" <lincoln phipps openmutual net>
- To: Planner Project Manager - Development List <planner-dev lists imendio com>
- Subject: [Planner Dev] Patch for planner Bugzilla 138595 Task up and down should work on selections.
- Date: Tue, 06 Apr 2004 02:03:56 +0100
http://bugzilla.gnome.org/show_bug.cgi?id=138595
(Task up and down should work on selections.)
Attached is a standalone patch that allows you to select a
range of tasks and do a move up and move down within gantt
and task view. A very handy feature when rearranging your
schedule :)
Before only individual tasks could be moved which meant
that shifting your task schedule design could be tedious.
It handles all sane selections including ctrl-clicking a
discountinuous list of tasks (which would be a weird
thing to do in practice but it works anyway).
Rgds,
Lincoln.
Index: src/planner-task-tree.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-task-tree.c,v
retrieving revision 1.14
diff -u -b -B -p -r1.14 planner-task-tree.c
--- src/planner-task-tree.c 28 Mar 2004 23:03:49 -0000 1.14
+++ src/planner-task-tree.c 31 Mar 2004 08:43:13 -0000
@@ -2163,9 +2243,11 @@ planner_task_tree_move_task_up (PlannerT
GtkTreeModel *model;
GtkTreePath *path;
MrpProject *project;
- MrpTask *task, *parent, *sibling;
- GList *list;
+ MrpTask *task, *parent, *sibling, *temptask;
+ GList *list, *l, *m;
guint position;
+ gboolean proceed, skip;
+ gint count;
/* FIXME: undo */
@@ -2180,15 +2262,33 @@ planner_task_tree_move_task_up (PlannerT
return;
}
- task = list->data;
+ proceed = TRUE; /* seed this */
+ count = 0 ;
+
+ for (l = list; l; l = l->next) {
+ count++;
+ task = l->data;
position = mrp_task_get_position (task);
parent = mrp_task_get_parent (task);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
- if (position == 0) {
- /* Task on the top of the list */
- } else {
+ /* We now check if the parent is selected as well me. as If it is then
+ * we skip checks on our position and skip moving because its just not relevant !
+ */
+ skip = FALSE;
+ for (m = list; m; m = m->next) {
+ temptask = m->data;
+ if (temptask == parent ) {
+ skip = TRUE;
+ }
+ }
+
+ if (position == 0 && count ==1) {
+ /* We should stop everything if at top of list and first task else just stop moving this one task */
+ proceed = FALSE;
+ }
+ if (skip == FALSE && position != 0 && proceed) {
sibling = mrp_task_get_nth_child (parent,
position - 1);
@@ -2199,6 +2299,7 @@ planner_task_tree_move_task_up (PlannerT
PLANNER_GANTT_MODEL (model), task);
gtk_tree_selection_select_path (selection, path);
}
+ }
task_tree_unblock_selection_changed (tree);
}
@@ -2210,9 +2311,11 @@ planner_task_tree_move_task_down (Planne
GtkTreeModel *model;
GtkTreePath *path;
MrpProject *project;
- MrpTask *task, *parent, *sibling;
- GList *list;
+ MrpTask *task, *parent, *sibling, *temptask;
+ GList *list, *l , *m;
guint position;
+ gboolean proceed, skip;
+ gint count;
/* FIXME: undo */
@@ -2225,16 +2328,38 @@ planner_task_tree_move_task_down (Planne
if (list == NULL) {
/* Nothing selected */
return;
- } else {
- task = list->data;
+ }
+
+ list = g_list_reverse (list); /* swap the selection around */
+
+ proceed = TRUE; /* seed this */
+ count = 0 ;
+
+ for (l = list; l; l = l->next) {
+ count++;
+ task = l->data;
position = mrp_task_get_position (task);
parent = mrp_task_get_parent (task);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
- if (position == (mrp_task_get_n_children (parent) - 1) ) {
- /* The task is in the bottom of the list */
- } else {
+ /* We now check if the parent is selected as well me. If it is then we skip checks on our position AS its not relevant */
+ skip = FALSE;
+ for (m = list; m; m = m->next) {
+ temptask = m->data;
+ if (temptask == parent ) {
+ skip = TRUE;
+ }
+ }
+
+ if (position == (mrp_task_get_n_children (mrp_project_get_root_task (project)) - 1) && count ==1) {
+ /* We should stop everything if at bottom of project and first attempt at moving stuff else just stop moving this one task */
+ proceed = FALSE;
+ } else if ((skip == FALSE) && (position == (mrp_task_get_n_children (parent) - 1)) && (count ==1)) {
+ /* If the parent task is selected then we don't care if we are at the bottom of our particular position */
+ proceed = FALSE;
+ }
+ if (skip == FALSE && position <= (mrp_task_get_n_children (parent) - 1) && proceed) {
sibling = mrp_task_get_nth_child (parent, position + 1);
/* Moving task from 'position' to 'position + 1' */
mrp_project_move_task (project, task, sibling,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]