* Headers/Foundation/NSMetadata.h: Declaratioins for constants and

NSMetadataItem.
	* Source/NSMetadata.m: Implementation of NSMetadataItem and definition
	of constants.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35809 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
gcasa 2012-11-20 17:58:34 +00:00
parent dab6880359
commit fd5ced2a49
3 changed files with 110 additions and 7 deletions

View file

@ -1,3 +1,10 @@
2012-11-20 12:50-EST Gregory John Casamento <greg.casamento@gmail.com>
* Headers/Foundation/NSMetadata.h: Declaratioins for constants and
NSMetadataItem.
* Source/NSMetadata.m: Implementation of NSMetadataItem and definition
of constants.
2012-11-19 18:54-CET Ivan Vučica <ivan@vucica.net>
* Source/GSInvocation.h: Renamed GSFrameInvocation to

View file

@ -24,20 +24,58 @@
AutogsdocSource: NSMetadataQuery.h
*/
#ifndef __NSMetadataQuery_h_GNUSTEP_BASE_INCLUDE
#define __NSMetadataQuery_h_GNUSTEP_BASE_INCLUDE
#ifndef __NSMetadata_h_GNUSTEP_BASE_INCLUDE
#define __NSMetadata_h_GNUSTEP_BASE_INCLUDE
#import <Foundation/NSObject.h>
#import <Foundation/NSTimer.h>
@class NSPredicate;
@class NSPredicate, NSMutableDictionary, NSDictionary;
@protocol NSMetadataQueryDelegate;
// Metadata item constants...
GS_EXPORT NSString * const NSMetadataItemFSNameKey;
GS_EXPORT NSString * const NSMetadataItemDisplayNameKey;
GS_EXPORT NSString * const NSMetadataItemURLKey;
GS_EXPORT NSString * const NSMetadataItemPathKey;
GS_EXPORT NSString * const NSMetadataItemFSSizeKey;
GS_EXPORT NSString * const NSMetadataItemFSCreationDateKey;
GS_EXPORT NSString * const NSMetadataItemFSContentChangeDateKey;
@interface NSMetadataItem : NSObject
{
NSMutableDictionary *attributes;
}
- (NSArray *)attributes;
- (id)valueForAttribute: (NSString *)key;
- (NSDictionary *)valuesForAttributes: (NSArray *)keys;
@end
// Metdata Query Constants...
GS_EXPORT NSString * const NSMetadataQueryUserHomeScope;
GS_EXPORT NSString * const NSMetadataQueryLocalComputerScope;
GS_EXPORT NSString * const NSMetadataQueryNetworkScope;
GS_EXPORT NSString * const NSMetadataQueryUbiquitousDocumentsScope;
GS_EXPORT NSString * const NSMetadataQueryUbiquitousDataScope;
GS_EXPORT NSString * const NSMetadataQueryDidFinishGatheringNotification;
GS_EXPORT NSString * const NSMetadataQueryDidStartGatheringNotification;
GS_EXPORT NSString * const NSMetadataQueryDidUpdateNotification;
GS_EXPORT NSString * const NSMetadataQueryGatheringProgressNotification;
/* Abstract interface for metadata query... */
@interface NSMetadataQuery : NSObject
{
NSUInteger _flags;
NSTimeInterval _interval;
NSMutableDictionary *_results;
}
/* Instance methods */
- (id)valueOfAttribute:(id)attr forResultAtIndex:(NSUInteger)index;
- (NSArray *)groupedResults;
- (NSArray *)valueLists;
- (NSDictionary *)valueLists;
- (NSUInteger)indexOfResult:(id)result;
- (NSArray *)results;
- (id)resultAtIndex:(NSUInteger)index;
@ -74,16 +112,24 @@
// Sort descriptors
- (void)setSortDescriptors:(NSArray *)attrs;
- (id)sortDescriptors;
- (NSArray *)sortDescriptors;
// Predicate
- (void)setPredicate:(NSPredicate *)predicate;
- (NSPredicate *)predicate;
// Delegate
- (void)setDelegate:(id)delegate;
- (id)delegate;
- (void)setDelegate:(id<NSMetadataQueryDelegate>)delegate;
- (id<NSMetadataQueryDelegate>)delegate;
@end
@protocol NSMetadataQueryDelegate
#ifdef __OBJC2__
@optional
#endif
- (id)metadataQuery:(NSMetadataQuery *)query replacementObjectForResultObject:(NSMetadataItem *)result;
- (id)metadataQuery:(NSMetadataQuery *)query replacementValueForAttribute:(NSString *)attribute value:(id)attributeValue;
@end
#endif

View file

@ -26,8 +26,58 @@
#import <Foundation/NSMetadata.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import "GNUstepBase/NSObject+GNUstepBase.h"
// Metadata item constants...
NSString * const NSMetadataItemFSNameKey = @"NSMetadataItemFSNameKey";
NSString * const NSMetadataItemDisplayNameKey = @"NSMetadataItemDisplayNameKey";
NSString * const NSMetadataItemURLKey = @"NSMetadataItemURLKey";
NSString * const NSMetadataItemPathKey = @"NSMetadataItemPathKey";
NSString * const NSMetadataItemFSSizeKey = @"NSMetadataItemFSSizeKey";
NSString * const NSMetadataItemFSCreationDateKey = @"NSMetadataItemFSCreationDateKey";
NSString * const NSMetadataItemFSContentChangeDateKey = @"NSMetadataItemFSContentChangeDateKey";
@implementation NSMetadataItem
- (NSArray *)attributes
{
return [attributes allKeys];
}
- (id)valueForAttribute: (NSString *)key
{
return [attributes objectForKey: key];
}
- (NSDictionary *)valuesForAttributes: (NSArray *)keys
{
NSMutableDictionary *results = [NSMutableDictionary dictionary];
NSEnumerator *en = [keys objectEnumerator];
id key = nil;
while((key = [en nextObject]) != nil)
{
id value = [self valueForAttribute: key];
[results setObject: value forKey: key];
}
return results;
}
@end
// Metdata Query Constants...
NSString * const NSMetadataQueryUserHomeScope = @"NSMetadataQueryUserHomeScope";
NSString * const NSMetadataQueryLocalComputerScope = @"NSMetadataQueryLocalComputerScope";
NSString * const NSMetadataQueryNetworkScope = @"NSMetadataQueryNetworkScope";
NSString * const NSMetadataQueryUbiquitousDocumentsScope = @"NSMetadataQueryUbiquitousDocumentsScope";
NSString * const NSMetadataQueryUbiquitousDataScope = @"NSMetadataQueryUbiquitousDataScope";
NSString * const NSMetadataQueryDidFinishGatheringNotification = @"NSMetadataQueryDidFinishGatheringNotification";
NSString * const NSMetadataQueryDidStartGatheringNotification = @"NSMetadataQueryDidStartGatheringNotification";
NSString * const NSMetadataQueryDidUpdateNotification = @"NSMetadataQueryDidUpdateNotification";
NSString * const NSMetadataQueryGatheringProgressNotification = @"NSMetadataQueryGatheringProgressNotification";
@implementation NSMetadataQuery
/* Instance methods */