Revision: 2920
http://skim-app.svn.sourceforge.net/skim-app/?rev=2920&view=rev
Author: hofman
Date: 2007-09-13 12:36:58 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
Fix adding bookmark folders.
Modified Paths:
--------------
trunk/SKBookmarkController.m
Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m 2007-09-13 16:49:57 UTC (rev 2919)
+++ trunk/SKBookmarkController.m 2007-09-13 19:36:58 UTC (rev 2920)
@@ -169,9 +169,7 @@
}
- (unsigned int)indexOfChildBookmark:(SKBookmark *)bookmark {
- SKBookmark *parent = [bookmark parent];
- NSArray *children = parent ? [parent children] : bookmarks;
- return [children indexOfObject:bookmark];
+ return [[self childrenOfBookmark:[bookmark parent]]
indexOfObject:bookmark];
}
- (void)bookmark:(SKBookmark *)bookmark insertChildBookmark:(SKBookmark
*)child atIndex:(unsigned int)index {
@@ -327,20 +325,14 @@
if (rowIndex != NSNotFound) {
SKBookmark *selectedItem = [outlineView itemAtRow:rowIndex];
if ([outlineView isItemExpanded:selectedItem]) {
- item = [selectedItem parent];
- if (item)
- index = [[item children] indexOfObject:selectedItem] + 1;
- else
- index = [bookmarks indexOfObject:selectedItem] + 1;
- } else {
item = selectedItem;
index = [[item children] count];
+ } else {
+ item = [selectedItem parent];
+ index = [self indexOfChildBookmark:selectedItem] + 1;
}
}
- if (item)
- [item insertChild:folder atIndex:index];
- else
- [self insertObject:folder inBookmarksAtIndex:index];
+ [self bookmark:item insertChildBookmark:folder atIndex:index];
}
#pragma mark Undo support
@@ -425,8 +417,13 @@
SKBookmark *bookmark = [outlineView itemAtRow:draggedRow];
if ([(SKBookmark *)item isDescendantOf:bookmark])
return NO;
- if ([bookmark parent] == item && index > (int)[self
indexOfChildBookmark:bookmark])
- index--;
+ if ([bookmark parent] == item) {
+ int draggedIndex = [self indexOfChildBookmark:bookmark];
+ if (index > draggedIndex)
+ index--;
+ if (index == draggedIndex)
+ return NO;
+ }
[bookmark retain];
[self removeChildBookmark:bookmark];
[self bookmark:item insertChildBookmark:bookmark atIndex:index];
@@ -584,6 +581,13 @@
[super dealloc];
}
+- (NSString *)description {
+ if (bookmarkType == SKBookmarkTypeFolder)
+ return [NSString stringWithFormat:@"<%@: label=%@, children=%@>",
[self class], label, children];
+ else
+ return [NSString stringWithFormat:@"<%@: label=%@, path=%@, page=%i>",
[self class], label, path, pageIndex];
+}
+
- (NSDictionary *)dictionaryValue {
if (bookmarkType == SKBookmarkTypeFolder)
return [NSDictionary dictionaryWithObjectsAndKeys:@"folder", @"type",
[children valueForKey:@"dictionaryValue"], @"children", label, @"label", nil];
@@ -666,6 +670,7 @@
- (void)removeChild:(SKBookmark *)child {
NSUndoManager *undoManager = [[SKBookmarkController
sharedBookmarkController] undoManager];
[(SKBookmark *)[undoManager prepareWithInvocationTarget:self]
insertChild:child atIndex:[[self children] indexOfObject:child]];
+ [child setParent:nil];
[children removeObject:child];
[[NSNotificationCenter defaultCenter]
postNotificationName:SKBookmarkChangedNotification object:self];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit