Re: [Planner Dev] First patch for task removal undo



Hi!

The problem is solved in the last patch I have sent to the devel list.
Richard, sorry for sending so many patches that aren't incremental. 

Cheers 


El sáb, 03-04-2004 a las 10:43, Alvaro del Castillo escribió:
> Hi!
> 
> Thanks Lincoln, I will test it and try to solve it ASAP :)
> 
> I am very near to have a first implementation with undo also for
> relations for your testing pleasure :)
> 
> Cheers
> 
> El sáb, 03-04-2004 a las 06:35, lincoln phipps openmutual net escribió:
> > Do this on new planner ,
> > 
> > Insert task,
> > Insert task,
> > Insert task,
> > Select All -> remove
> > Undo,
> > Undo,
> > Undo,
> > * - notice out of sync and more Undo to go*
> > Undo,
> > Undo,
> > Undo,
> > Redo x 6 until it goes unselectable,
> > then....
> > Undo, Undo, Undo now adds tasks 4,5,6
> > 
> > /Lincoln.
> > 
> > Alvaro del Castillo wrote:
> > 
> > > Hi guys!
> > > 
> > > Here goes the first patch for task removal undo. It currently only
> > > recovers all the tree correctly but not relations between tasks, that it
> > > the next point I am working on.
> > > 
> > > The best test unit I have found is the project model file that I attach.
> > > You can load it, then select all the tasks, remove them and undo the
> > > removal. Then save the "new" project model file and diff it with the
> > > original. I will follow this kind of tests and if you can think in a
> > > better test we can use it also.
> > > 
> > > Cheers
> > > 
> > > -- Alvaro
> > > 
> > > 
> > > 
> > > 
> > > ------------------------------------------------------------------------
> > > 
> > > Index: ChangeLog
> > > ===================================================================
> > > RCS file: /cvs/gnome/planner/ChangeLog,v
> > > retrieving revision 1.79
> > > diff -r1.79 ChangeLog
> > > 0a1,5
> > > 
> > >>2004-04-03 Alvaro del Castillo  <acs barrapunto com>
> > >>
> > >>	* src/planner-task-tree.c: implemented task remove undo
> > >>	Currently only recovers the task and the position in the tasks tree 
> > >>
> > > 
> > > Index: src/planner-task-tree.c
> > > ===================================================================
> > > RCS file: /cvs/gnome/planner/src/planner-task-tree.c,v
> > > retrieving revision 1.14
> > > diff -r1.14 planner-task-tree.c
> > > 154a155,157
> > > 
> > >>static PlannerCmd *task_cmd_remove                     (PlannerTaskTree      *tree,
> > >>							GtkTreePath          *path,
> > >>							MrpTask              *task);
> > > 
> > > 170d172
> > > < 	gchar           *name;
> > > 207d208
> > > < 			     "name", cmd->name ? cmd->name : "",
> > > 352a354,551
> > > 
> > >>typedef struct {
> > >>	PlannerCmd       base;
> > >>
> > >>	PlannerTaskTree *tree;
> > >>	MrpProject      *project;
> > >>
> > >>	GtkTreePath     *path;
> > >>	MrpTask         *task;
> > >>	GList           *childs;
> > >>} TaskCmdRemove;
> > >>
> > >>static void 
> > >>task_cmd_save_childs (TaskCmdRemove *cmd)
> > >>{
> > >>	gint childs, i;
> > >>	
> > >>	childs = mrp_task_get_n_children (cmd->task);
> > >>
> > >>	for (i = 0; i < childs; i++) {
> > >>		MrpTask           *task;
> > >>		TaskCmdRemove     *cmd_child;
> > >>		GtkTreePath       *path;
> > >>		PlannerGanttModel *model;
> > >>		
> > >>		model = PLANNER_GANTT_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (cmd->tree)));
> > >>		task = mrp_task_get_nth_child (cmd->task, i);
> > >>		
> > >>		path = planner_gantt_model_get_path_from_task (model, task);
> > >>		
> > >>		/* We don't use this command for the undo system */
> > >>		cmd_child = g_new0 (TaskCmdRemove, 1);
> > >>		cmd_child->tree = cmd->tree;
> > >>		cmd_child->project = task_tree_get_project (cmd->tree);		
> > >>		cmd_child->path = gtk_tree_path_copy (path);		
> > >>		cmd_child->task = g_object_ref (task);
> > >>		
> > >>		cmd->childs = g_list_append (cmd->childs, cmd_child);
> > >>		
> > >>		task_cmd_save_childs (cmd_child);
> > >>	}
> > >>
> > >>	if (g_getenv ("PLANNER_DEBUG_UNDO_TASK")) {
> > >>		if (cmd->childs != NULL) {
> > >>			GList *l;
> > >>			for (l = cmd->childs; l; l = l->next) {
> > >>				TaskCmdRemove *cmd_child = l->data;
> > >>				g_message ("Child saved: %s", mrp_task_get_name (cmd_child->task));
> > >>			}
> > >>		}
> > >>	}
> > >>	
> > >>}
> > >>
> > >>static void
> > >>task_cmd_remove_do (PlannerCmd *cmd_base)
> > >>{
> > >>	TaskCmdRemove *cmd;
> > >>	gint           childs;
> > >>
> > >>	cmd = (TaskCmdRemove*) cmd_base;
> > >>
> > >>	childs = mrp_task_get_n_children (cmd->task);
> > >>
> > >>	if (childs > 0 && cmd->childs == NULL) task_cmd_save_childs (cmd);	
> > >>
> > >>	mrp_project_remove_task (cmd->project, cmd->task);
> > >>}
> > >>
> > >>static void
> > >>task_cmd_restore_childs (TaskCmdRemove *cmd)
> > >>{
> > >>	PlannerGanttModel *model;
> > >>	gint               position, depth;
> > >>	GtkTreePath       *path;
> > >>	MrpTask           *parent;
> > >>	GList             *l;
> > >>
> > >>	for (l = cmd->childs; l; l = l->next) {
> > >>		TaskCmdRemove *cmd_child;			
> > >>		
> > >>		cmd_child = l->data;
> > >>
> > >>		path = gtk_tree_path_copy (cmd_child->path);
> > >>		model = PLANNER_GANTT_MODEL (gtk_tree_view_get_model 
> > >>					     (GTK_TREE_VIEW (cmd_child->tree)));
> > >>		
> > >>		depth = gtk_tree_path_get_depth (path);
> > >>		position = gtk_tree_path_get_indices (path)[depth - 1];
> > >>		
> > >>		if (depth > 1) {
> > >>			gtk_tree_path_up (path);
> > >>			parent = task_tree_get_task_from_path (cmd_child->tree, path);
> > >>		} else {
> > >>			parent = NULL;
> > >>		}
> > >>		
> > >>		gtk_tree_path_free (path);
> > >>		
> > >>		mrp_project_insert_task (cmd_child->project,
> > >>					 parent,
> > >>					 position,
> > >>					 cmd_child->task);
> > >>		
> > >>		task_cmd_restore_childs (cmd_child);
> > >>	}
> > >>}
> > >>
> > >>static void
> > >>task_cmd_remove_undo (PlannerCmd *cmd_base)
> > >>{
> > >>	PlannerGanttModel *model;
> > >>	TaskCmdRemove     *cmd;
> > >>	gint               position, depth;
> > >>	GtkTreePath       *path;
> > >>	MrpTask           *parent;
> > >>	MrpTask           *child_parent;
> > >>	
> > >>	cmd = (TaskCmdRemove*) cmd_base;
> > >>
> > >>	path = gtk_tree_path_copy (cmd->path);
> > >>	model = PLANNER_GANTT_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (cmd->tree)));
> > >>
> > >>	depth = gtk_tree_path_get_depth (path);
> > >>	position = gtk_tree_path_get_indices (path)[depth - 1];
> > >>
> > >> 	if (depth > 1) {
> > >>		gtk_tree_path_up (path);
> > >>		parent = task_tree_get_task_from_path (cmd->tree, path);
> > >>	} else {
> > >>		parent = NULL;
> > >>	}
> > >>	
> > >>	gtk_tree_path_free (path);
> > >>
> > >>	mrp_project_insert_task (cmd->project,
> > >>				 parent,
> > >>				 position,
> > >>				 cmd->task);
> > >>
> > >>	child_parent = planner_gantt_model_get_indent_task_target (model, cmd->task);
> > >>
> > >>	if (cmd->childs != NULL) task_cmd_restore_childs (cmd);
> > >>
> > >>	
> > >>}
> > >>
> > >>static void
> > >>task_cmd_remove_free (PlannerCmd *cmd_base)
> > >>{
> > >>	TaskCmdRemove *cmd;
> > >>	GList         *l;
> > >>
> > >>	cmd = (TaskCmdRemove*) cmd_base;
> > >>
> > >>	for (l = cmd->childs; l; l = l->next)
> > >>		task_cmd_remove_free (l->data);
> > >>
> > >>	g_object_unref (cmd->task);
> > >>	g_list_free (cmd->childs);
> > >>	g_free (cmd_base->label);
> > >>	gtk_tree_path_free (cmd->path);
> > >>	g_free (cmd);
> > >>	cmd = NULL;
> > >>}
> > >>
> > >>static PlannerCmd *
> > >>task_cmd_remove (PlannerTaskTree *tree,
> > >>		 GtkTreePath     *path,
> > >>		 MrpTask         *task)
> > >>{
> > >>	PlannerTaskTreePriv *priv = tree->priv;
> > >>	PlannerCmd          *cmd_base;
> > >>	TaskCmdRemove       *cmd;
> > >>
> > >>	g_return_val_if_fail (MRP_IS_TASK (task), NULL);
> > >>		
> > >>	cmd = g_new0 (TaskCmdRemove, 1);
> > >>
> > >>	cmd_base = (PlannerCmd*) cmd;
> > >>	cmd_base->label = g_strdup (_("Remove task"));
> > >>	cmd_base->do_func = task_cmd_remove_do;
> > >>	cmd_base->undo_func = task_cmd_remove_undo;
> > >>	cmd_base->free_func = task_cmd_remove_free;
> > >>
> > >>	cmd->tree = tree;
> > >>	cmd->project = task_tree_get_project (tree);
> > >>
> > >>	cmd->path = gtk_tree_path_copy (path);
> > >>
> > >>	cmd->task = g_object_ref (task);
> > >>	
> > >>	planner_cmd_manager_insert_and_do (planner_window_get_cmd_manager (priv->main_window),
> > >>					   cmd_base);
> > >>
> > >>	return cmd_base;
> > >>}
> > >>
> > >>
> > > 
> > > 1822,1824c2021,2022
> > > < 	GList *list, *l;
> > > < 
> > > < 	/* FIXME: undo */
> > > ---
> > > 
> > >>	GList         *list, *l;
> > >>	TaskCmdRemove *cmd;
> > > 
> > > 1825a2024
> > > 
> > > 1832c2031,2041
> > > < 		mrp_project_remove_task (tree->priv->project, l->data);
> > > ---
> > > 
> > >>		MrpTask             *task = l->data;
> > >>		PlannerGanttModel   *model;
> > >>		GtkTreePath         *path;
> > >>
> > >>		model = PLANNER_GANTT_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (tree)));
> > >>		path = planner_gantt_model_get_path_from_task (model, task);
> > >>
> > >>		/* childs are removed with the parent */
> > >>		if (path != NULL)
> > >>			cmd = (TaskCmdRemove*) task_cmd_remove (tree, path, task);
> > >>		/* mrp_project_remove_task (tree->priv->project, l->data); */
> > >>
> > >>
> > >>------------------------------------------------------------------------
> > >>
> > >><?xml version="1.0"?>
> > >><project name="" company="" manager="" phase="" project-start="20040331T000000Z" mrproject-version="2" calendar="1">
> > >>  <properties>
> > >>    <property name="cost" type="cost" owner="resource" label="Cost" description="standard cost for a resource"/>
> > >>  </properties>
> > >>  <phases/>
> > >>  <calendars>
> > >>    <day-types>
> > >>      <day-type id="0" name="Working" description="A default working day"/>
> > >>      <day-type id="1" name="Nonworking" description="A default non working day"/>
> > >>      <day-type id="2" name="Use base" description="Use day from base calendar"/>
> > >>    </day-types>
> > >>    <calendar id="1" name="Default">
> > >>      <default-week mon="0" tue="0" wed="0" thu="0" fri="0" sat="1" sun="1"/>
> > >>      <overridden-day-types>
> > >>        <overridden-day-type id="0">
> > >>          <interval start="0800" end="1200"/>
> > >>          <interval start="1300" end="1700"/>
> > >>        </overridden-day-type>
> > >>      </overridden-day-types>
> > >>      <days/>
> > >>    </calendar>
> > >>  </calendars>
> > >>  <tasks>
> > >>    <task id="1" name="t1" note="" work="57600" start="20040331T000000Z" end="20040401T170000Z" percent-complete="0" type="normal" scheduling="fixed-work">
> > >>      <task id="2" name="t11" note="" work="57600" start="20040331T000000Z" end="20040401T170000Z" percent-complete="0" type="normal" scheduling="fixed-work">
> > >>        <task id="3" name="t111" note="" work="57600" start="20040331T000000Z" end="20040401T170000Z" percent-complete="0" type="normal" scheduling="fixed-work">
> > >>          <task id="4" name="t1111" note="" work="57600" start="20040331T000000Z" end="20040401T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>        </task>
> > >>        <task id="5" name="t112" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>        <task id="6" name="t113" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work">
> > >>          <task id="7" name="t1131" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="8" name="t1132" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="9" name="t1133" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="10" name="t1134" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="11" name="t1135" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="12" name="t1136" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="13" name="t1137" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="14" name="t1138" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="15" name="t1139" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="16" name="t11310" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="17" name="t11311" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>          <task id="18" name="t11312" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>        </task>
> > >>      </task>
> > >>    </task>
> > >>    <task id="19" name="t2" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work">
> > >>      <task id="20" name="t21" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>    </task>
> > >>    <task id="21" name="t3" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>    <task id="22" name="t4" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work">
> > >>      <task id="23" name="t41" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work">
> > >>        <task id="24" name="t411" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>      </task>
> > >>    </task>
> > >>    <task id="25" name="t5" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>    <task id="26" name="t6" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>    <task id="27" name="t7" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work">
> > >>      <task id="28" name="t71" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>      <task id="29" name="t72" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>    </task>
> > >>    <task id="30" name="t8" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>    <task id="31" name="t9" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work">
> > >>      <task id="32" name="t91" note="" work="28800" start="20040331T000000Z" end="20040331T170000Z" percent-complete="0" type="normal" scheduling="fixed-work"/>
> > >>    </task>
> > >>  </tasks>
> > >>  <resource-groups/>
> > >>  <resources/>
> > >>  <allocations/>
> > >></project>
> > >>
> > >>
> > >>------------------------------------------------------------------------
> > >>
> > >>_______________________________________________
> > >>Planner-dev mailing list
> > >>Planner-dev lists imendio com
> > >>http://lists.imendio.com/mailman/listinfo/planner-dev
> > _______________________________________________
> > Planner-dev mailing list
> > Planner-dev lists imendio com
> > http://lists.imendio.com/mailman/listinfo/planner-dev
> > 
> 
> _______________________________________________
> Planner-dev mailing list
> Planner-dev lists imendio com
> http://lists.imendio.com/mailman/listinfo/planner-dev
> 

Attachment: signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]