Re: [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: Re: [Planner Dev] Patch for planner Bugzilla 138595 Task up and down should work on selections.
- Date: Wed, 07 Apr 2004 03:23:44 +0100
Richard,
here is the final version :) I have diffed without
the -b flag so the tabs will get sent to you as well.
I've also removed my spurious temptask variable as I know
you don't like temporary variable hacks left around like
that :)
Again its against planner-task-tree.c v1.15
Rgds,
Lincoln.
Richard Hult wrote:
Hi,
patch says that this diff has "misordered hunks". The hunks that it
succeeds in applying seems to have weird indentation so I suspect that
there is a { missing or something like that.
see above - fixed by giving you cvs diff -uBp only and its diffed against
latest v1.15 version of planner-task-tree.c
Could you please see if there is anything wrong and maybe generate a new
patch against CVS when it has synced the commits from today?
/Richard
Index: src/planner-task-tree.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-task-tree.c,v
retrieving revision 1.15
diff -u -B -p -r1.15 planner-task-tree.c
--- src/planner-task-tree.c 4 Apr 2004 15:12:34 -0000 1.15
+++ src/planner-task-tree.c 7 Apr 2004 02:19:47 -0000
@@ -2539,8 +2539,10 @@ planner_task_tree_move_task_up (PlannerT
GtkTreePath *path;
MrpProject *project;
MrpTask *task, *parent, *sibling;
- GList *list;
+ GList *list, *l, *m;
guint position;
+ gboolean proceed, skip;
+ gint count;
/* FIXME: undo */
@@ -2555,27 +2557,46 @@ planner_task_tree_move_task_up (PlannerT
return;
}
- task = list->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));
+ 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 {
- sibling = mrp_task_get_nth_child (parent,
- position - 1);
+ /* 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) {
+ if (m->data == parent ) {
+ skip = TRUE;
+ }
+ }
- /* Move task from 'position' to 'position-1' */
- mrp_project_move_task (project, task, sibling,
- parent, TRUE, NULL);
- path = planner_gantt_model_get_path_from_task (
- PLANNER_GANTT_MODEL (model), task);
- gtk_tree_selection_select_path (selection, path);
+ if (position == 0 && count ==1) {
+ /* We 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);
+
+ /* Move task from 'position' to 'position-1' */
+ mrp_project_move_task (project, task, sibling,
+ parent, TRUE, NULL);
+ path = planner_gantt_model_get_path_from_task (PLANNER_GANTT_MODEL (model),
+ task);
+ gtk_tree_selection_select_path (selection, path);
+ }
}
-
+
task_tree_unblock_selection_changed (tree);
+ g_list_free (list);
}
void
@@ -2586,8 +2607,10 @@ planner_task_tree_move_task_down (Planne
GtkTreePath *path;
MrpProject *project;
MrpTask *task, *parent, *sibling;
- GList *list;
+ GList *list, *l , *m;
guint position;
+ gboolean proceed, skip;
+ gint count;
/* FIXME: undo */
@@ -2600,18 +2623,39 @@ 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 parent is selected also. If so then we skip checks on our position as its not relevant */
+ skip = FALSE;
+ for (m = list; m; m = m->next) {
+ if (m->data == parent ) {
+ skip = TRUE;
+ }
+ }
+
+ if (position == (mrp_task_get_n_children (mrp_project_get_root_task (project)) - 1) && count ==1) {
+ /* We stop 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' */
+ /* Moving task from 'position' to 'position + 1' */
mrp_project_move_task (project, task, sibling,
parent, FALSE, NULL);
@@ -2619,8 +2663,9 @@ planner_task_tree_move_task_down (Planne
gtk_tree_selection_select_path (selection, path);
}
}
-
+
task_tree_unblock_selection_changed (tree);
+ g_list_free (list);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]