Revision: 4427
http://skim-app.svn.sourceforge.net/skim-app/?rev=4427&view=rev
Author: hofman
Date: 2008-08-19 09:53:00 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
Class factory methods for bookmarks.
Modified Paths:
--------------
trunk/SKBookmark.h
trunk/SKBookmark.m
trunk/SKBookmarkController.m
Modified: trunk/SKBookmark.h
===================================================================
--- trunk/SKBookmark.h 2008-08-18 20:17:13 UTC (rev 4426)
+++ trunk/SKBookmark.h 2008-08-19 09:53:00 UTC (rev 4427)
@@ -49,11 +49,19 @@
SKBookmark *parent;
}
++ (id)bookmarkWithPath:(NSString *)aPath pageIndex:(unsigned)aPageIndex
label:(NSString *)aLabel;
++ (id)bookmarkWithSetup:(NSDictionary *)aSetupDict label:(NSString *)aLabel;
++ (id)bookmarktFolderWithChildren:(NSArray *)aChildren label:(NSString
*)aLabel;
++ (id)bookmarkSessionWithChildren:(NSArray *)aChildren label:(NSString
*)aLabel;
++ (id)bookmarkFolderWithLabel:(NSString *)aLabel;
++ (id)bookmarkSeparator;
++ (id)bookmarkWithProperties:(NSDictionary *)dictionary;
+
- (id)initWithPath:(NSString *)aPath pageIndex:(unsigned)aPageIndex
label:(NSString *)aLabel;
- (id)initWithSetup:(NSDictionary *)aSetupDict label:(NSString *)aLabel;
- (id)initFolderWithChildren:(NSArray *)aChildren label:(NSString *)aLabel;
+- (id)initFolderWithLabel:(NSString *)aLabel;
- (id)initSessionWithChildren:(NSArray *)aChildren label:(NSString *)aLabel;
-- (id)initFolderWithLabel:(NSString *)aLabel;
- (id)initSeparator;
- (id)initWithProperties:(NSDictionary *)dictionary;
Modified: trunk/SKBookmark.m
===================================================================
--- trunk/SKBookmark.m 2008-08-18 20:17:13 UTC (rev 4426)
+++ trunk/SKBookmark.m 2008-08-19 09:53:00 UTC (rev 4427)
@@ -98,6 +98,34 @@
return SKBookmarkClass == self ? defaultPlaceholderBookmark : [super
allocWithZone:aZone];
}
++ (id)bookmarkWithPath:(NSString *)aPath pageIndex:(unsigned)aPageIndex
label:(NSString *)aLabel {
+ return [[[[self class] alloc] initWithPath:aPath pageIndex:aPageIndex
label:aLabel] autorelease];
+}
+
++ (id)bookmarkWithSetup:(NSDictionary *)aSetupDict label:(NSString *)aLabel {
+ return [[[[self class] alloc] initWithSetup:aSetupDict label:aLabel]
autorelease];
+}
+
++ (id)bookmarkFolderWithChildren:(NSArray *)aChildren label:(NSString *)aLabel
{
+ return [[[[self class] alloc] initFolderWithChildren:aChildren
label:aLabel] autorelease];
+}
+
++ (id)bookmarkFolderWithLabel:(NSString *)aLabel {
+ return [[[[self class] alloc] initFolderWithLabel:aLabel] autorelease];
+}
+
++ (id)bookmarkSessionWithChildren:(NSArray *)aChildren label:(NSString
*)aLabel {
+ return [[[[self class] alloc] initSessionWithChildren:aChildren
label:aLabel] autorelease];
+}
+
++ (id)bookmarkSeparator {
+ return [[[[self class] alloc] initSeparator] autorelease];
+}
+
++ (id)bookmarkWithProperties:(NSDictionary *)dictionary {
+ return [[[[self class] alloc] initWithProperties:dictionary] autorelease];
+}
+
- (id)initWithPath:(NSString *)aPath pageIndex:(unsigned)aPageIndex
label:(NSString *)aLabel {
[self doesNotRecognizeSelector:_cmd];
return nil;
@@ -236,7 +264,7 @@
NSDictionary *dict;
NSMutableArray *newChildren = [NSMutableArray array];
while (dict = [dictEnum nextObject])
- [newChildren addObject:[[[SKBookmark alloc]
initWithProperties:dict] autorelease]];
+ [newChildren addObject:[SKBookmark bookmarkWithProperties:dict]];
return [[bookmarkClass alloc] initFolderWithChildren:newChildren
label:[dictionary objectForKey:SKBookmarkLabelKey]];
} else {
return [[SKFileBookmark alloc] initWithAlias:[BDAlias
aliasWithData:[dictionary objectForKey:SKBookmarkAliasDataKey]]
pageIndex:[[dictionary objectForKey:SKBookmarkPageIndexKey] unsignedIntValue]
label:[dictionary objectForKey:SKBookmarkLabelKey]];
Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m 2008-08-18 20:17:13 UTC (rev 4426)
+++ trunk/SKBookmarkController.m 2008-08-19 09:53:00 UTC (rev 4427)
@@ -131,10 +131,9 @@
NSDictionary *dict;
while (dict = [dictEnum nextObject]) {
- SKBookmark *bookmark = [[SKBookmark alloc]
initWithProperties:dict];
+ SKBookmark *bookmark = [SKBookmark
bookmarkWithProperties:dict];
if (bookmark)
[bookmarks addObject:bookmark];
- [bookmark release];
}
}
@@ -228,20 +227,16 @@
- (void)addBookmarkForPath:(NSString *)path pageIndex:(unsigned)pageIndex
label:(NSString *)label toFolder:(SKBookmark *)folder {
if (folder == nil) folder = bookmarkRoot;
- SKBookmark *bookmark = [[SKBookmark alloc] initWithPath:path
pageIndex:pageIndex label:label];
- if (bookmark) {
+ SKBookmark *bookmark = [SKBookmark bookmarkWithPath:path
pageIndex:pageIndex label:label];
+ if (bookmark)
[folder insertObject:bookmark inChildrenAtIndex:[folder
countOfChildren]];
- [bookmark release];
- }
}
- (void)addBookmarkForSetup:(NSDictionary *)setupDict label:(NSString *)label
toFolder:(SKBookmark *)folder {
if (folder == nil) folder = bookmarkRoot;
- SKBookmark *bookmark = [[SKBookmark alloc] initWithSetup:setupDict
label:label];
- if (bookmark) {
+ SKBookmark *bookmark = [SKBookmark bookmarkWithSetup:setupDict
label:label];
+ if (bookmark)
[folder insertObject:bookmark inChildrenAtIndex:[folder
countOfChildren]];
- [bookmark release];
- }
}
- (void)addBookmarkForPaths:(NSArray *)paths pageIndexes:(NSArray
*)pageIndexes label:(NSString *)label toFolder:(SKBookmark *)folder {
@@ -252,17 +247,12 @@
NSMutableArray *children = [NSMutableArray array];
SKBookmark *bookmark;
while ((path = [pathEnum nextObject]) && (page = [pageEnum nextObject])) {
- bookmark = [[SKBookmark alloc] initWithPath:path pageIndex:[page
unsignedIntValue] label:[path lastPathComponent]];
- if (bookmark) {
+ if (bookmark = [SKBookmark bookmarkWithPath:path pageIndex:[page
unsignedIntValue] label:[path lastPathComponent]])
[children addObject:bookmark];
- [bookmark release];
- }
}
if (folder == nil) folder = bookmarkRoot;
- if (bookmark = [[SKBookmark alloc] initSessionWithChildren:children
label:label]) {
+ if (bookmark = [SKBookmark bookmarkSessionWithChildren:children
label:label])
[folder insertObject:bookmark inChildrenAtIndex:[folder
countOfChildren]];
- [bookmark release];
- }
}
- (void)addBookmarkForSetups:(NSArray *)setupDicts label:(NSString *)label
toFolder:(SKBookmark *)folder {
@@ -271,17 +261,12 @@
NSMutableArray *children = [NSMutableArray array];
SKBookmark *bookmark;
while (setup = [setupEnum nextObject]) {
- bookmark = [[SKBookmark alloc] initWithSetup:setup label:@""];
- if (bookmark) {
+ if (bookmark = [SKBookmark bookmarkWithSetup:setup label:@""])
[children addObject:bookmark];
- [bookmark release];
- }
}
if (folder == nil) folder = bookmarkRoot;
- if (bookmark = [[SKBookmark alloc] initSessionWithChildren:children
label:label]) {
+ if (bookmark = [SKBookmark bookmarkSessionWithChildren:children
label:label])
[folder insertObject:bookmark inChildrenAtIndex:[folder
countOfChildren]];
- [bookmark release];
- }
}
- (NSArray *)draggedBookmarks {
@@ -427,7 +412,7 @@
}
- (IBAction)insertBookmarkFolder:(id)sender {
- SKBookmark *folder = [[[SKBookmark alloc]
initFolderWithLabel:NSLocalizedString(@"Folder", @"default folder name")]
autorelease];
+ SKBookmark *folder = [SKBookmark
bookmarkFolderWithLabel:NSLocalizedString(@"Folder", @"default folder name")];
int rowIndex = [[outlineView selectedRowIndexes] lastIndex];
SKBookmark *item = bookmarkRoot;
unsigned int idx = [bookmarkRoot countOfChildren];
@@ -450,7 +435,7 @@
}
- (IBAction)insertBookmarkSeparator:(id)sender {
- SKBookmark *separator = [[[SKBookmark alloc] initSeparator] autorelease];
+ SKBookmark *separator = [SKBookmark bookmarkSeparator];
int rowIndex = [[outlineView selectedRowIndexes] lastIndex];
SKBookmark *item = bookmarkRoot;
unsigned int idx = [bookmarkRoot countOfChildren];
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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit