From dae91b715973cf9594edf485cabdfec2ccf499f5 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Mon, 4 Feb 2013 19:38:31 +0100 Subject: [PATCH] Move instance data to implementation --- .../OakFileBrowser/src/io/FSDataSource.h | 3 --- .../OakFileBrowser/src/io/FSDataSource.mm | 14 +++++------ .../src/io/FSDirectoryDataSource.h | 11 --------- .../src/io/FSDirectoryDataSource.mm | 14 ++++++++++- Frameworks/OakFileBrowser/src/io/FSItem.h | 13 ---------- Frameworks/OakFileBrowser/src/io/FSItem.mm | 24 +++++++++---------- .../src/io/FSVolumesDataSource.h | 2 -- 7 files changed, 30 insertions(+), 51 deletions(-) diff --git a/Frameworks/OakFileBrowser/src/io/FSDataSource.h b/Frameworks/OakFileBrowser/src/io/FSDataSource.h index 228ea535..714724e8 100644 --- a/Frameworks/OakFileBrowser/src/io/FSDataSource.h +++ b/Frameworks/OakFileBrowser/src/io/FSDataSource.h @@ -3,9 +3,6 @@ extern NSString* const FSItemDidReloadNotification; @class FSItem; @interface FSDataSource : NSObject -{ - FSItem* rootItem; -} + (NSArray*)sortArray:(NSArray*)anArray usingOptions:(NSUInteger)someOptions; @property (nonatomic, retain) FSItem* rootItem; diff --git a/Frameworks/OakFileBrowser/src/io/FSDataSource.mm b/Frameworks/OakFileBrowser/src/io/FSDataSource.mm index 6e17b9c8..7b99866e 100644 --- a/Frameworks/OakFileBrowser/src/io/FSDataSource.mm +++ b/Frameworks/OakFileBrowser/src/io/FSDataSource.mm @@ -37,8 +37,6 @@ FSDataSource* DataSourceForURL (NSURL* anURL, NSUInteger someOptions) } @implementation FSDataSource { OBJC_WATCH_LEAKS(FSDataSource); } -@synthesize rootItem; - + (NSArray*)sortArray:(NSArray*)anArray usingOptions:(NSUInteger)someOptions { NSMutableArray* descriptors = [NSMutableArray array]; @@ -71,7 +69,7 @@ FSDataSource* DataSourceForURL (NSURL* anURL, NSUInteger someOptions) - (NSInteger)outlineView:(NSOutlineView*)anOutlineView numberOfChildrenOfItem:(FSItem*)item { - return [(item ?: rootItem).children count]; + return [(item ?: self.rootItem).children count]; } - (BOOL)outlineView:(NSOutlineView*)anOutlineView isItemExpandable:(FSItem*)item @@ -81,7 +79,7 @@ FSDataSource* DataSourceForURL (NSURL* anURL, NSUInteger someOptions) - (id)outlineView:(NSOutlineView*)anOutlineView child:(NSInteger)childIndex ofItem:(FSItem*)item { - return [(item ?: rootItem).children objectAtIndex:childIndex]; + return [(item ?: self.rootItem).children objectAtIndex:childIndex]; } - (id)outlineView:(NSOutlineView*)anOutlineView objectValueForTableColumn:(NSTableColumn*)tableColumn byItem:(FSItem*)item @@ -200,14 +198,14 @@ static ino_t inode (std::string const& path) - (NSDragOperation)outlineView:(NSOutlineView*)anOutlineView validateDrop:(id )info proposedItem:(FSItem*)item proposedChildIndex:(NSInteger)childIndex { - if(item.leaf || ![(item ?: rootItem).url isFileURL]) + if(item.leaf || ![(item ?: self.rootItem).url isFileURL]) return NSDragOperationNone; [anOutlineView setDropItem:item dropChildIndex:NSOutlineViewDropOnItemIndex]; NSPasteboard* pboard = [info draggingPasteboard]; NSArray* draggedPaths = [pboard propertyListForType:NSFilenamesPboardType]; - NSString* dropPath = [(item ?: rootItem).url path]; + NSString* dropPath = [(item ?: self.rootItem).url path]; dev_t targetDevice = path::device([dropPath fileSystemRepresentation]); BOOL linkOperation = ([[NSApp currentEvent] modifierFlags] & NSControlKeyMask) == NSControlKeyMask; @@ -240,10 +238,10 @@ static NSDragOperation filter (NSDragOperation mask) - (BOOL)outlineView:(NSOutlineView*)anOutlineView acceptDrop:(id )info item:(FSItem*)item childIndex:(NSInteger)childIndex { - if(item.leaf || ![(item ?: rootItem).url isFileURL]) + if(item.leaf || ![(item ?: self.rootItem).url isFileURL]) return NO; - std::string const dropPath = [[(item ?: rootItem).url path] fileSystemRepresentation]; + std::string const dropPath = [[(item ?: self.rootItem).url path] fileSystemRepresentation]; NSDragOperation const op = filter([info draggingSourceOperationMask]); if(op == 0) return fprintf(stderr, "Unsupported drag operation %02lx for %s\n", [info draggingSourceOperationMask], dropPath.c_str()), NO; diff --git a/Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.h b/Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.h index 800a660f..cb312362 100644 --- a/Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.h +++ b/Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.h @@ -1,16 +1,5 @@ #import "FSDataSource.h" -#import -#import @interface FSDirectoryDataSource : FSDataSource -{ - NSUInteger dataSourceOptions; - - fs::event_callback_t* callback; - - scm::callback_t* scmCallback; - std::map scmDrivers; - std::map scmReferenceCounts; -} - (id)initWithURL:(NSURL*)anURL options:(NSUInteger)someOptions; @end diff --git a/Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.mm b/Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.mm index bfc3aa5c..679334ae 100644 --- a/Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.mm +++ b/Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.mm @@ -5,6 +5,7 @@ #import #import #import +#import #import #import #import @@ -16,7 +17,18 @@ OAK_DEBUG_VAR(FileBrowser_DSDirectory); -@interface FSDirectoryDataSource () { OBJC_WATCH_LEAKS(FSDirectoryDataSource); } +@interface FSDirectoryDataSource () +{ + OBJC_WATCH_LEAKS(FSDirectoryDataSource); + + NSUInteger dataSourceOptions; + + fs::event_callback_t* callback; + + scm::callback_t* scmCallback; + std::map scmDrivers; + std::map scmReferenceCounts; +} @property (nonatomic, retain) NSMutableDictionary* visible; - (void)internalReloadItem:(FSItem*)anItem requested:(BOOL)flag; - (void)lostItems:(NSArray*)someItems; diff --git a/Frameworks/OakFileBrowser/src/io/FSItem.h b/Frameworks/OakFileBrowser/src/io/FSItem.h index ba3b2c2a..04198f40 100644 --- a/Frameworks/OakFileBrowser/src/io/FSItem.h +++ b/Frameworks/OakFileBrowser/src/io/FSItem.h @@ -3,19 +3,6 @@ enum FSItemURLType { FSItemURLTypeUnknown = 0, FSItemURLTypeFile, FSItemURLTypeFolder, FSItemURLTypePackage, FSItemURLTypeAlias, FSItemURLTypeMissing }; @interface FSItem : NSObject -{ - NSImage* icon; - NSString* name; - NSString* toolTip; - NSInteger labelIndex; - NSURL* url; - NSURL* target; - FSItemURLType urlType; - NSArray* children; - BOOL leaf; - BOOL group; - BOOL sortAsFolder; -} @property (nonatomic, retain) NSImage* icon; @property (nonatomic, retain) NSString* name; @property (nonatomic, retain) NSString* toolTip; diff --git a/Frameworks/OakFileBrowser/src/io/FSItem.mm b/Frameworks/OakFileBrowser/src/io/FSItem.mm index 768cc302..03ed12e2 100644 --- a/Frameworks/OakFileBrowser/src/io/FSItem.mm +++ b/Frameworks/OakFileBrowser/src/io/FSItem.mm @@ -6,8 +6,6 @@ #import @implementation FSItem { OBJC_WATCH_LEAKS(FSItem); } -@synthesize icon, name, toolTip, labelIndex, url, urlType, target, children, leaf, group, sortAsFolder; - - (FSItem*)initWithURL:(NSURL*)anURL { if((self = [super init])) @@ -37,12 +35,12 @@ - (BOOL)isEqual:(id)otherObject { - return [otherObject isKindOfClass:[self class]] && [url isEqual:[otherObject url]]; + return [otherObject isKindOfClass:[self class]] && [self.url isEqual:[otherObject url]]; } - (NSString*)description { - return [NSString stringWithFormat:@"FSItem: %@", [url absoluteString]]; + return [NSString stringWithFormat:@"FSItem: %@", [self.url absoluteString]]; } - (NSString*)path @@ -52,20 +50,20 @@ - (FSItemURLType)urlType { - if(urlType == FSItemURLTypeUnknown && [(target ?: url) isFileURL]) + if(_urlType == FSItemURLTypeUnknown && [(self.target ?: self.url) isFileURL]) { - uint32_t flags = path::info([[(target ?: url) path] fileSystemRepresentation]); - if(!path::exists([[(target ?: url) path] fileSystemRepresentation])) - urlType = FSItemURLTypeMissing; + uint32_t flags = path::info([[(self.target ?: self.url) path] fileSystemRepresentation]); + if(!path::exists([[(self.target ?: self.url) path] fileSystemRepresentation])) + _urlType = FSItemURLTypeMissing; else if(flags & path::flag::alias) - urlType = FSItemURLTypeAlias; + _urlType = FSItemURLTypeAlias; else if(flags & path::flag::package) - urlType = FSItemURLTypePackage; + _urlType = FSItemURLTypePackage; else if(flags & path::flag::directory) - urlType = FSItemURLTypeFolder; + _urlType = FSItemURLTypeFolder; else if(flags & path::flag::file) - urlType = FSItemURLTypeFile; + _urlType = FSItemURLTypeFile; } - return urlType; + return _urlType; } @end diff --git a/Frameworks/OakFileBrowser/src/io/FSVolumesDataSource.h b/Frameworks/OakFileBrowser/src/io/FSVolumesDataSource.h index 1c1eed12..e2b88520 100644 --- a/Frameworks/OakFileBrowser/src/io/FSVolumesDataSource.h +++ b/Frameworks/OakFileBrowser/src/io/FSVolumesDataSource.h @@ -1,7 +1,5 @@ #import "FSDataSource.h" @interface FSVolumesDataSource : FSDataSource -{ -} - (id)initWithURL:(NSURL*)anURL options:(NSUInteger)someOptions; @end