Commits

Ivan Vučica committed 96092e0

Some attempts at making indentation changes undoable.

Comments (0)

Files changed (2)

OPML/OPMLDocument.h

 /////////////////////
 // Dynamic properties
 /////////////////////
-// @property (readonly) OPMLOutlineXMLElement * selectedElement;
+// @property (assign, nonatomic) OPMLOutlineXMLElement * selectedElement;
 -(OPMLOutlineXMLElement*)selectedElement;
+-(void)setSelectedElement:(OPMLOutlineXMLElement*)selectedElement;
 
 ////////////
 // IBActions
 //////////
 -(void)expandUsingExpansionState;
 -(void)scrollUsingVertScrollState;
+-(void)undoableInsertionOfNode:(OPMLOutlineXMLElement*)node intoParent:(OPMLOutlineXMLElement*)parent atIndex:(NSInteger)index;
 @end
 
 extern NSString *OPMLDocument_DocumentDeactivateNotification;

OPML/OPMLDocument.m

     
     [selectedElement retain];
     
+    NSInteger originalIndex = [selectedElement index];
     [parentElement removeChildAtIndex:[selectedElement index]];
     [newParentElement insertChild:selectedElement atIndex:[newParentElement childCount]];
     
+    [[self undoManager] beginUndoGrouping];
+    [[self undoManager] setActionName:@"Increase Indent"];
+    [[[self undoManager] prepareWithInvocationTarget:selectedElement] retain];
+    [[[self undoManager] prepareWithInvocationTarget:parentElement] insertChild:selectedElement atIndex:originalIndex];
+    [[[self undoManager] prepareWithInvocationTarget:selectedElement] removeFromSupernode];
+    [[[self undoManager] prepareWithInvocationTarget:selectedElement] release];
+    [[[self undoManager] prepareWithInvocationTarget:_outlineView] reloadData];
+    [[self undoManager] endUndoGrouping];
+    
     [selectedElement release];
     
     NSIndexSet * selectedRowIndexes = [_outlineView selectedRowIndexes];
     
     [selectedElement retain];
     
-    int originalIndex = [selectedElement index];
+    NSInteger originalIndex = [selectedElement index];
     [parentElement removeChildAtIndex:[selectedElement index]];
     [newParentElement insertChild:selectedElement atIndex:[parentElement index]+1];