Added transformers for menu item title. There must be a better way...

CQTexperiment
vspader 2008-03-08 23:58:52 +00:00
parent 3375e15a83
commit 637c0d598e
2 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,16 @@
//
// ToggleQueueTitleTransformer.h
// Cog
//
// Created by Vincent Spader on 3/8/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface ToggleQueueTitleTransformer : NSObject {
}
@end

View File

@ -0,0 +1,50 @@
//
// ToggleQueueTitleTransformer.m
// Cog
//
// Created by Vincent Spader on 3/8/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "ToggleQueueTitleTransformer.h"
@implementation ToggleQueueTitleTransformer
+ (Class)transformedValueClass { return [NSArray class]; }
+ (BOOL)allowsReverseTransformation { return NO; }
// Convert from NSNumber to NSString
- (id)transformedValue:(id)value {
if (value == nil) return nil;
if ([value count] == 0) return nil;
BOOL trueFound = NO;
BOOL falseFound = NO;
for (NSNumber *q in value) {
BOOL queued = [q boolValue];
if (queued)
{
trueFound = YES;
}
else if (!queued)
{
falseFound = YES;
}
}
if (trueFound && !falseFound)
return @"Remove from Queue";
else if (falseFound && !trueFound)
return @"Add to Queue";
else
return @"Toggle Queued";
}
@end