diff --git a/Application/AppController.m b/Application/AppController.m index f1844d071..99734569e 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -161,15 +161,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ { NSURL *url = [NSURL URLWithString:[urlComboBox stringValue]]; - PlaylistEntry *pe = [[PlaylistEntry alloc] init]; - - [pe setURL:url]; - [pe setIndex:[[playlistController arrangedObjects] count]]; - [pe setTitle:[urlComboBox stringValue]]; - - [playlistController addObject:pe]; - - [pe release]; + [playlistLoader addURLs:[NSArray arrayWithObject:url] sort:NO]; [NSApp endSheet:addURLPanel]; [addURLPanel orderOut:self]; diff --git a/Application/PlaybackController.h b/Application/PlaybackController.h index d457a8243..819dce218 100644 --- a/Application/PlaybackController.h +++ b/Application/PlaybackController.h @@ -5,10 +5,10 @@ #import #import "CogAudio/AudioPlayer.h" -#import "PlaylistController.h" #import "TrackingSlider.h" #import "AudioScrobbler.h" +@class PlaylistController; @class PlaylistView; @interface PlaybackController : NSObject diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index 6a2883b26..4072de69d 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -4,6 +4,9 @@ #import "DBLog.h" #import "CogAudio/Status.h" +#import "PlaylistController.h" +#import "PlaylistEntry.h" + @implementation PlaybackController - (id)init @@ -289,11 +292,11 @@ if ([playlistController shuffle] == YES) { - pe = [playlistController entryAtIndex:[curEntry shuffleIndex]+1]; + pe = [playlistController entryAtIndex:[[curEntry shuffleIndex] intValue] + 1]; } else { - pe = [playlistController entryAtIndex:[curEntry index]+1]; + pe = [playlistController entryAtIndex:[[curEntry index] intValue] + 1]; } if (pe == nil) diff --git a/AudioScrobbler/AudioScrobbler.m b/AudioScrobbler/AudioScrobbler.m index 9c181ba4b..40fb772c8 100644 --- a/AudioScrobbler/AudioScrobbler.m +++ b/AudioScrobbler/AudioScrobbler.m @@ -104,7 +104,7 @@ escapeForLastFM(NSString *string) escapeForLastFM([pe title]), escapeForLastFM([pe album]), @"", // TODO: MusicBrainz support - (int)([pe length]/1000.0), + (int)([[pe length] doubleValue]/1000.0), escapeForLastFM([[pe url] path]) ]]; } diff --git a/Cog.xcodeproj/project.pbxproj b/Cog.xcodeproj/project.pbxproj index 12553ff21..ef054f02f 100644 --- a/Cog.xcodeproj/project.pbxproj +++ b/Cog.xcodeproj/project.pbxproj @@ -100,6 +100,12 @@ 8E7575D009F31DCA0080F1EE /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575C809F31DCA0080F1EE /* Credits.html */; }; 8E7575D109F31DCA0080F1EE /* README in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575C909F31DCA0080F1EE /* README */; }; 8E7575DB09F31E930080F1EE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575D909F31E930080F1EE /* Localizable.strings */; }; + 8E9A2E850BA78B500091081B /* SecondsFormatter.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E9A2E830BA78B500091081B /* SecondsFormatter.h */; }; + 8E9A2E860BA78B500091081B /* SecondsFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A2E840BA78B500091081B /* SecondsFormatter.m */; }; + 8E9A2ED90BA78D9D0091081B /* IndexFormatter.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E9A2ED70BA78D9D0091081B /* IndexFormatter.h */; }; + 8E9A2EDA0BA78D9D0091081B /* IndexFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */; }; + 8E9A30150BA792DC0091081B /* NSFileHandle+CreateFile.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E9A30130BA792DC0091081B /* NSFileHandle+CreateFile.h */; }; + 8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A30140BA792DC0091081B /* NSFileHandle+CreateFile.m */; }; 8EFFCD5F0AA093AF00C458A5 /* DirectoryNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */; }; 8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD450AA093AF00C458A5 /* FileIconCell.m */; }; 8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD470AA093AF00C458A5 /* FileNode.m */; }; @@ -141,6 +147,9 @@ 170680840B950164006BA573 /* Growl.framework in CopyFiles */, 17F94CCD0B8D090800A34E87 /* Sparkle.framework in CopyFiles */, 1755E1F80BA0D2B600CA3560 /* PlaylistLoader.h in CopyFiles */, + 8E9A2E850BA78B500091081B /* SecondsFormatter.h in CopyFiles */, + 8E9A2ED90BA78D9D0091081B /* IndexFormatter.h in CopyFiles */, + 8E9A30150BA792DC0091081B /* NSFileHandle+CreateFile.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -277,6 +286,12 @@ 8E7575C909F31DCA0080F1EE /* README */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = README; sourceTree = ""; }; 8E7575DA09F31E930080F1EE /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = ""; }; 8E7575DC09F31EAF0080F1EE /* French */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = French; path = French.lproj/Localizable.strings; sourceTree = ""; }; + 8E9A2E830BA78B500091081B /* SecondsFormatter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SecondsFormatter.h; sourceTree = ""; }; + 8E9A2E840BA78B500091081B /* SecondsFormatter.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SecondsFormatter.m; sourceTree = ""; }; + 8E9A2ED70BA78D9D0091081B /* IndexFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexFormatter.h; sourceTree = ""; }; + 8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IndexFormatter.m; sourceTree = ""; }; + 8E9A30130BA792DC0091081B /* NSFileHandle+CreateFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFileHandle+CreateFile.h"; sourceTree = ""; }; + 8E9A30140BA792DC0091081B /* NSFileHandle+CreateFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSFileHandle+CreateFile.m"; sourceTree = ""; }; 8EFFCD420AA093AF00C458A5 /* DirectoryNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DirectoryNode.h; sourceTree = ""; }; 8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = DirectoryNode.m; sourceTree = ""; }; 8EFFCD440AA093AF00C458A5 /* FileIconCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileIconCell.h; sourceTree = ""; }; @@ -470,6 +485,8 @@ 177EC01B0B8BC2CF0000BC8C /* TrackingCell.m */, 177EC01C0B8BC2CF0000BC8C /* TrackingSlider.h */, 177EC01D0B8BC2CF0000BC8C /* TrackingSlider.m */, + 8E9A30130BA792DC0091081B /* NSFileHandle+CreateFile.h */, + 8E9A30140BA792DC0091081B /* NSFileHandle+CreateFile.m */, ); path = Utils; sourceTree = ""; @@ -630,6 +647,10 @@ 8E75753209F31D5A0080F1EE /* PlaylistView.m */, 8E75753309F31D5A0080F1EE /* Shuffle.h */, 8E75753409F31D5A0080F1EE /* Shuffle.m */, + 8E9A2E830BA78B500091081B /* SecondsFormatter.h */, + 8E9A2E840BA78B500091081B /* SecondsFormatter.m */, + 8E9A2ED70BA78D9D0091081B /* IndexFormatter.h */, + 8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */, ); path = Playlist; sourceTree = ""; @@ -796,6 +817,9 @@ 1766C6930B911DF1004A7AE4 /* AudioScrobbler.m in Sources */, 1766C6950B911DF1004A7AE4 /* AudioScrobblerClient.m in Sources */, 1755E1F90BA0D2B600CA3560 /* PlaylistLoader.m in Sources */, + 8E9A2E860BA78B500091081B /* SecondsFormatter.m in Sources */, + 8E9A2EDA0BA78D9D0091081B /* IndexFormatter.m in Sources */, + 8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/English.lproj/MainMenu.nib/classes.nib b/English.lproj/MainMenu.nib/classes.nib index 7c9b6d260..d15d578f9 100644 --- a/English.lproj/MainMenu.nib/classes.nib +++ b/English.lproj/MainMenu.nib/classes.nib @@ -166,6 +166,7 @@ LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + {CLASS = SecondsFormatter; LANGUAGE = ObjC; SUPERCLASS = NSFormatter; }, { ACTIONS = { changeVolume = id; diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib index fec6bb7dd..61b2b0f21 100644 --- a/English.lproj/MainMenu.nib/info.nib +++ b/English.lproj/MainMenu.nib/info.nib @@ -7,17 +7,17 @@ IBEditorPositions 1063 - 0 320 136 49 0 0 1680 1028 + 0 228 136 49 0 0 1024 746 1156 - 719 527 241 366 0 0 1680 1028 + 391 336 241 366 0 0 1024 746 1324 - 788 657 137 182 0 0 1680 1028 + 453 438 137 182 0 0 1024 746 29 - -3 975 383 44 0 0 1680 1028 + -3 696 383 44 0 0 1024 746 463 - 669 637 341 145 0 0 1680 1028 + 341 447 341 145 0 0 1024 746 513 - 352 836 125 137 0 0 1680 1028 + 204 571 125 137 0 0 1024 746 IBFramework Version 446.1 @@ -34,16 +34,16 @@ 4 IBOpenObjects + 1307 513 + 1324 + 21 463 29 - 21 - 1307 1063 1156 - 1324 IBSystem Version - 8L2127 + 8L127 diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib index d8d8b164d..aa7359f32 100644 Binary files a/English.lproj/MainMenu.nib/keyedobjects.nib and b/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/Playlist/PlaylistController.h b/Playlist/PlaylistController.h index fb248b3d6..b8b2ad72f 100644 --- a/Playlist/PlaylistController.h +++ b/Playlist/PlaylistController.h @@ -60,6 +60,6 @@ - (void)addShuffledListToFront; - (void)resetShuffleList; -- (void)handlePlaylistViewHeaderNotification:(NSNotification*)notif; +- (PlaylistEntry *)entryAtIndex:(int)i; @end diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 049f2133e..7fc72b89c 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -121,7 +121,7 @@ PlaylistEntry* pe; while (pe = [enumerator nextObject]) { - tt += [pe length]; + tt += [[pe length] doubleValue]; } int sec = (int)(tt/1000.0); @@ -148,7 +148,7 @@ PlaylistEntry *p; p = [[self arrangedObjects] objectAtIndex:j]; - [p setIndex:j]; + [p setIndex:[NSNumber numberWithInt:j]]; } } @@ -159,7 +159,7 @@ if ([a containsObject:currentEntry]) { - [currentEntry setIndex:-1]; + [currentEntry setIndex:[NSNumber numberWithInt:-1]]; } [super removeObjectsAtArrangedObjectIndexes:indexes]; @@ -281,11 +281,11 @@ { if (shuffle == YES) { - return [self shuffledEntryAtIndex:[pe shuffleIndex] + 1]; + return [self shuffledEntryAtIndex:([[pe shuffleIndex] intValue] + 1)]; } else { - return [self entryAtIndex:[pe index] + 1]; + return [self entryAtIndex:([[pe index] intValue] + 1)]; } } @@ -293,18 +293,18 @@ { if (shuffle == YES) { - return [self shuffledEntryAtIndex:[pe shuffleIndex] - 1]; + return [self shuffledEntryAtIndex:([[pe shuffleIndex] intValue] - 1)]; } else { //Fix for removing a track, then pressing prev with repeat turned on - if ([pe index] == -1) + if ([[pe index] intValue] == -1) { - return [self entryAtIndex:[pe index]]; + return [self entryAtIndex:[[pe index] intValue]]; } else { - return [self entryAtIndex:[pe index] - 1]; + return [self entryAtIndex:[[pe index] intValue] - 1]; } } } @@ -347,7 +347,7 @@ int i; for (i = 0; i < [shuffleList count]; i++) { - [[shuffleList objectAtIndex:i] setShuffleIndex:i]; + [[shuffleList objectAtIndex:i] setShuffleIndex:[NSNumber numberWithInt:i]]; } } @@ -361,7 +361,7 @@ int i; for (i = ([shuffleList count] - [newList count]); i < [shuffleList count]; i++) { - [[shuffleList objectAtIndex:i] setShuffleIndex:i]; + [[shuffleList objectAtIndex:i] setShuffleIndex:[NSNumber numberWithInt:i]]; } } @@ -372,7 +372,7 @@ [self addShuffledListToFront]; - if (currentEntry && [currentEntry index] != -1) + if (currentEntry && [[currentEntry index] intValue] != -1) { [shuffleList insertObject:currentEntry atIndex:0]; [currentEntry setShuffleIndex:0]; @@ -388,7 +388,7 @@ [shuffleList removeObjectAtIndex:i]; } - [[shuffleList objectAtIndex:i] setShuffleIndex:i]; + [[shuffleList objectAtIndex:i] setShuffleIndex:[NSNumber numberWithInt:i]]; } } } @@ -403,7 +403,7 @@ [currentEntry setCurrent:NO]; [pe setCurrent:YES]; - [tableView scrollRowToVisible:[pe index]]; + [tableView scrollRowToVisible:[[pe index] intValue]]; [pe retain]; [currentEntry release]; diff --git a/Playlist/PlaylistEntry.h b/Playlist/PlaylistEntry.h index 51da6d7fb..8ac1fa9ea 100644 --- a/Playlist/PlaylistEntry.h +++ b/Playlist/PlaylistEntry.h @@ -17,28 +17,26 @@ NSString *genre; NSString *year; - unsigned int track; + NSNumber *track; - NSString *lengthString; - - double length; - int bitrate; - int channels; - int bitsPerSample; - float sampleRate; + NSNumber *length; + NSNumber *bitrate; + NSNumber *channels; + NSNumber *bitsPerSample; + NSNumber *sampleRate; BOOL current; - int idx; //Can't use index due to some weird bug...might be fixed...should test in the future...think it was a conflict with flac, which is now an external lib - int shuffleIdx; - int displayIdx; + NSNumber *idx; + NSNumber *shuffleIndex; + NSNumber *displayIndex; } -- (void)setIndex:(int)i; -- (int)index; +- (void)setIndex:(NSNumber *)i; +- (NSNumber *)index; -- (void)setShuffleIndex:(int)si; -- (int)shuffleIndex; +- (void)setShuffleIndex:(NSNumber *)si; +- (NSNumber *)shuffleIndex; - (void)setURL:(NSURL *)u; - (NSURL *)url; @@ -54,25 +52,23 @@ - (void)setGenre:(NSString *)s; - (NSString *)genre; -- (NSString *)lengthString; -- (void)setLengthString:(double)l; - - (void)setYear:(NSString *)y; - (NSString *)year; -- (void)setTrack:(int)y; -- (int)track; +- (void)setTrack:(NSNumber *)y; +- (NSNumber *)track; -- (void)setLength:(double)l; -- (void)setBitrate:(int) br; -- (void)setChannels:(int)c; -- (void)setBitsPerSample:(int)bps; -- (void)setSampleRate:(float)s; +- (void)setLength:(NSNumber *)l; +- (NSNumber *)length; -- (double)length; -- (int)bitrate; -- (int)channels; -- (int)bitsPerSample; -- (float)sampleRate; +- (void)setBitrate:(NSNumber *) br; +- (NSNumber *)bitrate; + +- (void)setChannels:(NSNumber *)c; +- (NSNumber *)channels; +- (void)setBitsPerSample:(NSNumber *)bps; +- (NSNumber *)bitsPerSample; +- (void)setSampleRate:(NSNumber *)s; +- (NSNumber *)sampleRate; - (void)setMetadata: (NSDictionary *)m; - (void)readMetadataThread; diff --git a/Playlist/PlaylistEntry.m b/Playlist/PlaylistEntry.m index f85529e5b..142a3770e 100644 --- a/Playlist/PlaylistEntry.m +++ b/Playlist/PlaylistEntry.m @@ -17,7 +17,7 @@ self = [super init]; if (self) { - [self setIndex:0]; + [self setIndex:nil]; [self setURL:nil]; } @@ -31,37 +31,32 @@ [super dealloc]; } --(void)setShuffleIndex:(int)si +-(void)setShuffleIndex:(NSNumber *)si { - shuffleIdx = si; + [si retain]; + [shuffleIndex release]; + + shuffleIndex = si; } --(int)shuffleIndex +-(NSNumber *)shuffleIndex { - return shuffleIdx; + return shuffleIndex; } --(void)setIndex:(int)i +-(void)setIndex:(NSNumber *)i { + [i retain]; + [idx release]; + NSLog(@"INDEX: %@", i); idx = i; - [self setDisplayIndex:i+1]; } --(int)index +-(NSNumber *)index { return idx; } --(void)setDisplayIndex:(int)i -{ - displayIdx=i; -} - --(int)displayIndex -{ - return displayIdx; -} - -(void)setURL:(NSURL *)u { [u retain]; @@ -155,24 +150,25 @@ return year; } -- (void)setTrack:(int)t +- (void)setTrack:(NSNumber *)t { + [t retain]; + [track release]; + track = t; } -- (int)track +- (NSNumber *)track { return track; } - (void)setProperties:(NSDictionary *)dict { - [self setLength: [[dict objectForKey:@"length" ] doubleValue]]; - [self setBitrate: [[dict objectForKey:@"bitrate" ] intValue]]; - [self setChannels: [[dict objectForKey:@"channels" ] intValue]]; - [self setBitsPerSample: [[dict objectForKey:@"bitsPerSample"] intValue]]; - [self setSampleRate: [[dict objectForKey:@"sampleRate" ] floatValue]]; - - [self setLengthString:[[dict objectForKey:@"length"] doubleValue]]; + [self setLength: [dict objectForKey:@"length" ]]; + [self setBitrate: [dict objectForKey:@"bitrate" ]]; + [self setChannels: [dict objectForKey:@"channels" ]]; + [self setBitsPerSample: [dict objectForKey:@"bitsPerSample" ]]; + [self setSampleRate: [dict objectForKey:@"sampleRate" ]]; } - (void)readPropertiesThread @@ -182,60 +178,62 @@ [self performSelectorOnMainThread:@selector(setProperties:) withObject:properties waitUntilDone:YES]; } -- (NSString *)lengthString -{ - return lengthString; -} -- (void)setLengthString:(double)l -{ - int sec = (int)(l/1000.0); - - [lengthString release]; - lengthString = [[NSString alloc] initWithFormat:@"%i:%02i",sec/60,sec%60]; -} - - -- (void)setLength:(double)l +- (void)setLength:(NSNumber *)l { + [l retain]; + [length release]; + length = l; } -- (double)length +- (NSNumber *)length { return length; } -- (void)setBitrate:(int) br +- (void)setBitrate:(NSNumber *) br { + [br retain]; + [bitrate release]; + bitrate = br; } -- (int)bitrate +- (NSNumber *)bitrate { return bitrate; } -- (void)setChannels:(int)c +- (void)setChannels:(NSNumber *)c { + [c retain]; + [channels release]; + channels = c; } -- (int)channels +- (NSNumber *)channels { return channels; } -- (void)setBitsPerSample:(int)bps +- (void)setBitsPerSample:(NSNumber *)bps { + [bps retain]; + [bitsPerSample release]; + bitsPerSample = bps; } -- (int)bitsPerSample +- (NSNumber *)bitsPerSample { return bitsPerSample; } -- (void)setSampleRate:(float)s +- (void)setSampleRate:(NSNumber *)s { + [s retain]; + [s release]; + sampleRate = s; } -- (float)sampleRate +- (NSNumber *)sampleRate { return sampleRate; } @@ -255,7 +253,7 @@ [self setAlbum:[m objectForKey:@"album"]]; [self setGenre:[m objectForKey:@"genre"]]; [self setYear:[m objectForKey:@"year"]]; - [self setTrack:[[m objectForKey:@"track"] intValue]]; + [self setTrack:[m objectForKey:@"track"]]; } - (void)readMetadataThread @@ -268,7 +266,7 @@ - (NSString *)description { - return [NSString stringWithFormat:@"PlaylistEntry %i:(%@)",idx, url]; + return [NSString stringWithFormat:@"PlaylistEntry %i:(%@)", idx, url]; } @end diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 35f7beb2e..c07a88a0f 100755 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -10,6 +10,8 @@ #import "PlaylistController.h" #import "PlaylistEntry.h" +#import "NSFileHandle+CreateFile.h" + #import "CogAudio/AudioPlayer.h" @implementation PlaylistLoader @@ -136,8 +138,9 @@ - (BOOL)saveM3u:(NSString *)filename { - NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename]; + NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename createFile:YES]; if (!fileHandle) { + NSLog(@"Error!"); return NO; } [fileHandle truncateFileAtOffset:0]; @@ -201,7 +204,7 @@ - (BOOL)savePls:(NSString *)filename { - NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename]; + NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename createFile:YES]; if (!fileHandle) { return NO; } @@ -327,7 +330,7 @@ NSURL *url = [finalURLs objectAtIndex:i]; [pe setURL:url]; - [pe setIndex:index+i]; + [pe setIndex:[NSNumber numberWithInt:(index+i)]]; [pe setTitle:[[url path] lastPathComponent]]; [entries addObject:pe]; diff --git a/Playlist/PlaylistView.m b/Playlist/PlaylistView.m index d047f7e24..601d3a966 100644 --- a/Playlist/PlaylistView.m +++ b/Playlist/PlaylistView.m @@ -12,6 +12,9 @@ #import "PlaylistHeaderView.h" +#import "IndexFormatter.h" +#import "SecondsFormatter.h" + @implementation PlaylistView - (void)awakeFromNib @@ -31,7 +34,7 @@ [[c dataCell] setControlSize:s]; [[c dataCell] setFont:f]; } - + NSTableHeaderView *currentTableHeaderView = [self headerView]; PlaylistHeaderView *customTableHeaderView = [[PlaylistHeaderView alloc] init]; @@ -40,6 +43,14 @@ // [self setColumnAutoresizingStyle:NSTableViewNoColumnAutoresizing]; [self setHeaderView:customTableHeaderView]; + + NSFormatter *secondsFormatter = [[SecondsFormatter alloc] init]; + [[[self tableColumnWithIdentifier:@"length"] dataCell] setFormatter:secondsFormatter]; + [secondsFormatter release]; + + NSFormatter *indexFormatter = [[IndexFormatter alloc] init]; + [[[self tableColumnWithIdentifier:@"index"] dataCell] setFormatter:indexFormatter]; + [indexFormatter release]; [self setVerticalMotionCanBeginDrag:YES]; } diff --git a/TODO b/TODO index 569075b4e..30d921a5e 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,2 @@ Make playlist table header menu, (See Play _streamTableHeaderContextMenu). -Make PlaylistEntry numbers use NSNumber. -Instead of LengthString, use a formatter. -Add automatic header seperator without testing explicit types. Pull out binding? Perhaps the table column can do a objectAtIndex and then get a stringValue to get the width. \ No newline at end of file