Skip to content

Commit

Permalink
Corrected splitting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rggjan committed May 21, 2010
1 parent 4788bed commit 6f55c77
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
30 changes: 14 additions & 16 deletions Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,20 @@ public void TagUpdate ()
Buffer.RemoveTag ("strikethrough", DescriptionStart, DescriptionEnd);
}
}


public void RemoveTag (Gtk.TextTag tag)
{
var end = End;

Buffer.RemoveTag (tag, Start, end);
}

public void ApplyTag (Gtk.TextTag tag)
{
var end = End;

Buffer.ApplyTag (TaskTag, Start, end);
Buffer.ApplyTag (tag, Start, end);
}

public bool LineIsEmpty ()
Expand Down Expand Up @@ -399,7 +407,6 @@ private void BufferChanged (object sender, EventArgs e)
public bool IsLastTask ()
{
var list = ContainingTaskList.Children;
Logger.Debug(list.Count.ToString());

foreach (Task task in list)
{
Expand Down Expand Up @@ -427,9 +434,8 @@ public List<Task> TasksFollowing ()
/// <summary>
/// Delete this task, it's widgets and corresponding tag representation
/// </summary>
public void Delete ()
public TaskList Delete ()
{
Logger.Debug ("deleting task");
var start = Start;
var end = DescriptionEnd;
Buffer.Delete (ref start, ref end);
Expand All @@ -440,36 +446,28 @@ public void Delete ()

Buffer.RemoveAllTags (start, end);
ContainingTaskList.Children.Remove (this);

Logger.Debug ("Tasks removed:");
ContainingTaskList.DebugPrint ();

Logger.Debug ("done!");
start = Start;
start.ForwardLine ();
//end = start;
//end.ForwardLine ();

var tasks_following = TasksFollowing ();
Logger.Debug("before if");

if (!IsLastTask ()) {
Logger.Debug("before foreach");
Logger.Debug("is not last task");
foreach (Task task in tasks_following)
{
Logger.Debug("in foreach");
ContainingTaskList.Children.Remove (task);
}
Logger.Debug("out foreach");

TaskList new_list = new TaskList (ContainingTaskList.ContainingNote, tasks_following, ContainingTaskList.Name + " 2", start);

Logger.Debug ("First List:");
ContainingTaskList.DebugPrint ();
Logger.Debug ("Second List:");
new_list.DebugPrint ();
return new_list;
}

return null;

//FIXME also for other containers?
}

Expand Down
4 changes: 3 additions & 1 deletion TaskList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public TaskList (Note note, List<Task> tasks, String name, Gtk.TextIter start)

var end = Start;
buffer.Insert (ref end, name);


start = Start;
end.ForwardChar ();
Expand All @@ -143,6 +142,7 @@ public TaskList (Note note, List<Task> tasks, String name, Gtk.TextIter start)
foreach (Task task in tasks)
{
Children.Add (task);
task.RemoveTag (task.ContainingTaskList.Tag);
task.ContainingTaskList = this;
task.ApplyTag (this.Tag);
}
Expand Down Expand Up @@ -195,6 +195,8 @@ public void DebugPrint ()
Console.WriteLine ("Tasklist '" + Description () + "':");
foreach (Task task in Children)
task.DebugPrint ();

Console.WriteLine();
}

/// <summary>
Expand Down
25 changes: 22 additions & 3 deletions TaskManagerNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ private void InitializeGui ()

task_menu.Add (show_priority);
show_priority.Toggled += OnShowPriorityActivated;

if (Tomboy.Debugging)
{
Gtk.MenuItem print_structure = new Gtk.MenuItem (Catalog.GetString ("Print Structure"));
task_menu.Add (print_structure);
print_structure.Activated += OnPrintStructureActivated;
}

Gtk.MenuToolButton menu_tool_button = new Gtk.MenuToolButton (Gtk.Stock.Strikethrough);

Expand Down Expand Up @@ -227,7 +234,7 @@ void OnAddListActivated (object sender, EventArgs args)
return;

TaskList tl = new TaskList (Note);

//tl.Name = "New TaskList!";
TaskLists.Add (tl);
}
Expand All @@ -237,6 +244,15 @@ void OnShowPriorityActivated (object sender, EventArgs args)
TogglePriorityVisibility ();
}


void OnPrintStructureActivated (object sender, EventArgs args)
{
Logger.Debug ("----------------Printing structure!------------------");
foreach (TaskList list in tasklists)
list.DebugPrint();
Logger.Debug ("-----------------------------------------------------");
}

private void TogglePriorityVisibility ()
{
if (show_priority.Active) {
Expand All @@ -251,7 +267,6 @@ private void TogglePriorityVisibility ()

}


void OnAddDuedateActivated (object sender, EventArgs args)
{
Dialog dialog = new Dialog
Expand Down Expand Up @@ -363,7 +378,10 @@ void BufferInsertText (object o, Gtk.InsertTextArgs args)
// Recursion problem without this:
Buffer.DeleteRange -= DeleteRange;

task.Delete ();
TaskList list = task.Delete ();
if (list != null)
tasklists.Add (list);

Buffer.PlaceCursor (Buffer.GetIterAtMark (Buffer.InsertMark));

Buffer.DeleteRange += DeleteRange;
Expand Down Expand Up @@ -443,6 +461,7 @@ private bool IsTextTodoItem (String text)
}

private List<TaskList> tasklists;

public List<TaskList> TaskLists {
get
{
Expand Down

0 comments on commit 6f55c77

Please sign in to comment.