diff --git a/Cog.xcodeproj/project.pbxproj b/Cog.xcodeproj/project.pbxproj index e8ce2478d..d4c75decd 100644 --- a/Cog.xcodeproj/project.pbxproj +++ b/Cog.xcodeproj/project.pbxproj @@ -79,6 +79,7 @@ 17A8F6870D6A7FCA0095DA13 /* repeat_one.png in Resources */ = {isa = PBXBuildFile; fileRef = 17A8F6840D6A7FCA0095DA13 /* repeat_one.png */; }; 17A8F71A0D6A89730095DA13 /* repeat_album.png in Resources */ = {isa = PBXBuildFile; fileRef = 17A8F7190D6A89730095DA13 /* repeat_album.png */; }; 17B6FA7F0D48225300C3BEF1 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17BF2B270CDD77EB007E1295 /* Sparkle.framework */; }; + 17B7DD7D0D7CD10D00320E70 /* BlankZeroFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 17B7DD7C0D7CD10D00320E70 /* BlankZeroFormatter.m */; }; 17BB5CED0B8A86010009ACB1 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17BB5CEC0B8A86010009ACB1 /* AudioToolbox.framework */; }; 17BB5CF90B8A86350009ACB1 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17BB5CF60B8A86350009ACB1 /* AudioUnit.framework */; }; 17BB5CFA0B8A86350009ACB1 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17BB5CF70B8A86350009ACB1 /* CoreAudio.framework */; }; @@ -593,6 +594,8 @@ 17A8F6830D6A7FCA0095DA13 /* repeat_none.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_none.png; path = Images/repeat_none.png; sourceTree = ""; }; 17A8F6840D6A7FCA0095DA13 /* repeat_one.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_one.png; path = Images/repeat_one.png; sourceTree = ""; }; 17A8F7190D6A89730095DA13 /* repeat_album.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_album.png; path = Images/repeat_album.png; sourceTree = ""; }; + 17B7DD7B0D7CD10D00320E70 /* BlankZeroFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlankZeroFormatter.h; sourceTree = ""; }; + 17B7DD7C0D7CD10D00320E70 /* BlankZeroFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BlankZeroFormatter.m; sourceTree = ""; }; 17BB5CEC0B8A86010009ACB1 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = ""; }; 17BB5CF60B8A86350009ACB1 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = /System/Library/Frameworks/AudioUnit.framework; sourceTree = ""; }; 17BB5CF70B8A86350009ACB1 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = /System/Library/Frameworks/CoreAudio.framework; sourceTree = ""; }; @@ -1237,6 +1240,8 @@ 17A8F6360D6A7B0F0095DA13 /* RepeatTransformers.m */, 170B55920D6E5E7B006B9E92 /* StatusImageTransformer.h */, 170B55930D6E5E7B006B9E92 /* StatusImageTransformer.m */, + 17B7DD7B0D7CD10D00320E70 /* BlankZeroFormatter.h */, + 17B7DD7C0D7CD10D00320E70 /* BlankZeroFormatter.m */, ); path = Playlist; sourceTree = ""; @@ -1722,6 +1727,7 @@ 171192BD0D691ED600FD76C5 /* PathWatcher.m in Sources */, 17A8F6370D6A7B0F0095DA13 /* RepeatTransformers.m in Sources */, 170B55940D6E5E7B006B9E92 /* StatusImageTransformer.m in Sources */, + 17B7DD7D0D7CD10D00320E70 /* BlankZeroFormatter.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Playlist/BlankZeroFormatter.h b/Playlist/BlankZeroFormatter.h new file mode 100644 index 000000000..4368b2520 --- /dev/null +++ b/Playlist/BlankZeroFormatter.h @@ -0,0 +1,17 @@ +// +// BlankZeroFormatter.h +// Cog +// +// Created by Vincent Spader on 3/3/08. +// Copyright 2008 __MyCompanyName__. All rights reserved. +// + +#import + + +@interface BlankZeroFormatter : NSObject { + + +} + +@end diff --git a/Playlist/BlankZeroFormatter.m b/Playlist/BlankZeroFormatter.m new file mode 100644 index 000000000..7c62c848e --- /dev/null +++ b/Playlist/BlankZeroFormatter.m @@ -0,0 +1,50 @@ +// +// BlankZeroFormatter.m +// Cog +// +// Created by Vincent Spader on 3/3/08. +// Copyright 2008 __MyCompanyName__. All rights reserved. +// + +#import "BlankZeroFormatter.h" + + +@implementation BlankZeroFormatter + +- (NSString *) stringForObjectValue:(id)object +{ + NSString *result = nil; + int value; + + if(nil == object || NO == [object isKindOfClass:[NSNumber class]]) { + return nil; + } + + value = [object intValue]; + + if (value) + result = [NSString stringWithFormat:@"%i", value]; + + return result; +} + +- (BOOL) getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error +{ + if(NULL != object) { + *object = [NSNumber numberWithInt:[string intValue]]; + + return YES; + } + + return NO; +} + +- (NSAttributedString *) attributedStringForObjectValue:(id)object withDefaultAttributes:(NSDictionary *)attributes +{ + NSAttributedString *result = nil; + + result = [[NSAttributedString alloc] initWithString:[self stringForObjectValue:object] attributes:attributes]; + return [result autorelease]; +} + +@end diff --git a/Playlist/PlaylistEntry.h b/Playlist/PlaylistEntry.h index da160ef45..fe511beae 100644 --- a/Playlist/PlaylistEntry.h +++ b/Playlist/PlaylistEntry.h @@ -29,7 +29,7 @@ NSString *album; NSString *title; NSString *genre; - NSString *year; + NSNumber *year; NSNumber *track; long long totalFrames; @@ -78,7 +78,7 @@ @property(retain) NSString *album; @property(retain) NSString *title; @property(retain) NSString *genre; -@property(retain) NSString *year; +@property(retain) NSNumber *year; @property(retain) NSNumber *track; @property long long totalFrames; diff --git a/Playlist/PlaylistView.m b/Playlist/PlaylistView.m index 992d39bf7..e2c82c266 100644 --- a/Playlist/PlaylistView.m +++ b/Playlist/PlaylistView.m @@ -12,6 +12,7 @@ #import "IndexFormatter.h" #import "SecondsFormatter.h" +#import "BlankZeroFormatter.h" #import "PlaylistEntry.h" #import "CogAudio/Status.h" @@ -53,6 +54,11 @@ NSFormatter *indexFormatter = [[IndexFormatter alloc] init]; [[[self tableColumnWithIdentifier:@"index"] dataCell] setFormatter:indexFormatter]; [indexFormatter release]; + + NSFormatter *blankZeroFormatter = [[BlankZeroFormatter alloc] init]; + [[[self tableColumnWithIdentifier:@"track"] dataCell] setFormatter:blankZeroFormatter]; + [[[self tableColumnWithIdentifier:@"year"] dataCell] setFormatter:blankZeroFormatter]; + [blankZeroFormatter release]; //end setting up formatters [self setVerticalMotionCanBeginDrag:YES]; diff --git a/Plugins/TagLib/TagLibMetadataReader.m b/Plugins/TagLib/TagLibMetadataReader.m index 5118f622f..7c1c0edcf 100644 --- a/Plugins/TagLib/TagLibMetadataReader.m +++ b/Plugins/TagLib/TagLibMetadataReader.m @@ -37,23 +37,15 @@ if (!pArtist.isNull()) lArtist = [NSString stringWithUTF8String:pArtist.toCString(true)]; - else - lArtist = @""; if (!pAlbum.isNull()) lAlbum = [NSString stringWithUTF8String:pAlbum.toCString(true)]; - else - lAlbum = @""; if (!pTitle.isNull()) lTitle = [NSString stringWithUTF8String:pTitle.toCString(true)]; - else - lTitle = @""; if (!pGenre.isNull()) lGenre = [NSString stringWithUTF8String:pGenre.toCString(true)]; - else - lGenre = @""; } } @@ -62,7 +54,7 @@ lTitle, @"title", lAlbum, @"album", lGenre, @"genre", - [[NSNumber numberWithInt: lYear] stringValue], @"year", + [NSNumber numberWithInt: lYear], @"year", [NSNumber numberWithInt: lTrack], @"track", nil]; }