Move instance data to implementation

This commit is contained in:
Allan Odgaard
2013-02-04 19:38:31 +01:00
parent 4712515e8b
commit dae91b7159
7 changed files with 30 additions and 51 deletions

View File

@@ -3,9 +3,6 @@ extern NSString* const FSItemDidReloadNotification;
@class FSItem;
@interface FSDataSource : NSObject <NSOutlineViewDataSource>
{
FSItem* rootItem;
}
+ (NSArray*)sortArray:(NSArray*)anArray usingOptions:(NSUInteger)someOptions;
@property (nonatomic, retain) FSItem* rootItem;

View File

@@ -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 <NSDraggingInfo>)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 <NSDraggingInfo>)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;

View File

@@ -1,16 +1,5 @@
#import "FSDataSource.h"
#import <io/events.h>
#import <scm/scm.h>
@interface FSDirectoryDataSource : FSDataSource
{
NSUInteger dataSourceOptions;
fs::event_callback_t* callback;
scm::callback_t* scmCallback;
std::map<std::string, scm::info_ptr> scmDrivers;
std::map<std::string, size_t> scmReferenceCounts;
}
- (id)initWithURL:(NSURL*)anURL options:(NSUInteger)someOptions;
@end

View File

@@ -5,6 +5,7 @@
#import <OakAppKit/OakFileIconImage.h>
#import <oak/server.h>
#import <io/entries.h>
#import <io/events.h>
#import <io/path.h>
#import <regexp/glob.h>
#import <regexp/format_string.h>
@@ -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<std::string, scm::info_ptr> scmDrivers;
std::map<std::string, size_t> scmReferenceCounts;
}
@property (nonatomic, retain) NSMutableDictionary* visible;
- (void)internalReloadItem:(FSItem*)anItem requested:(BOOL)flag;
- (void)lostItems:(NSArray*)someItems;

View File

@@ -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;

View File

@@ -6,8 +6,6 @@
#import <oak/debug.h>
@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

View File

@@ -1,7 +1,5 @@
#import "FSDataSource.h"
@interface FSVolumesDataSource : FSDataSource
{
}
- (id)initWithURL:(NSURL*)anURL options:(NSUInteger)someOptions;
@end