Total time display is now a binding
This commit is contained in:
parent
53d9869e02
commit
5465ec09d9
8 changed files with 40 additions and 30 deletions
|
@ -32,8 +32,6 @@
|
|||
|
||||
- (IBAction)donate:(id)sender;
|
||||
|
||||
- (void)updateTotalTime;
|
||||
|
||||
- (IBAction)toggleInfoDrawer:(id)sender;
|
||||
- (void)drawerDidOpen:(NSNotification *)notification;
|
||||
- (void)drawerDidClose:(NSNotification *)notification;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
if ([p runModalForTypes:[playlistController acceptableFileTypes]] == NSOKButton)
|
||||
{
|
||||
[playlistController addPaths:[p filenames] sort:NO];
|
||||
[self updateTotalTime];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +34,6 @@
|
|||
- (IBAction)delEntries:(id)sender
|
||||
{
|
||||
[playlistController remove:self];
|
||||
[self updateTotalTime];
|
||||
}
|
||||
|
||||
- (PlaylistEntry *)currentEntry
|
||||
|
@ -65,8 +63,6 @@
|
|||
|
||||
NSString *filename = @"~/Library/Application Support/Cog/Default.playlist";
|
||||
[playlistController loadPlaylist:[filename stringByExpandingTildeInPath]];
|
||||
|
||||
[self updateTotalTime];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
||||
|
@ -124,8 +120,6 @@
|
|||
[playlistController setPlaylistFilename:[p filename]];
|
||||
|
||||
[playlistController loadPlaylist:[p filename]];
|
||||
|
||||
[self updateTotalTime];
|
||||
}
|
||||
|
||||
[mainWindow makeKeyAndOrderFront:self];
|
||||
|
@ -178,21 +172,4 @@
|
|||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://sourceforge.net/project/project_donations.php?group_id=140003"]];
|
||||
}
|
||||
|
||||
- (void)updateTotalTime
|
||||
{
|
||||
double tt=0;
|
||||
NSArray* entries = [playlistController arrangedObjects];
|
||||
|
||||
NSEnumerator *enumerator = [entries objectEnumerator];
|
||||
PlaylistEntry* pe;
|
||||
|
||||
while (pe = [enumerator nextObject]) {
|
||||
tt += [pe length];
|
||||
}
|
||||
|
||||
int sec = (int)(tt/1000.0);
|
||||
NSString* ttstring = [NSString stringWithFormat:@"Cog - %i:%02i",sec/60, sec%60];
|
||||
[mainWindow setTitle:ttstring];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
2
English.lproj/MainMenu.nib/info.nib
generated
2
English.lproj/MainMenu.nib/info.nib
generated
|
@ -29,9 +29,9 @@
|
|||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>29</integer>
|
||||
<integer>21</integer>
|
||||
<integer>513</integer>
|
||||
<integer>463</integer>
|
||||
<integer>21</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8I127</string>
|
||||
|
|
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -15,6 +15,7 @@
|
|||
NSArray *acceptablePlaylistTypes;
|
||||
|
||||
NSString *playlistFilename;
|
||||
NSString *totalTimeDisplay;
|
||||
|
||||
NSMutableArray *shuffleList;
|
||||
|
||||
|
@ -33,6 +34,8 @@
|
|||
- (int)insertFile:(NSString *)filename atIndex:(int)index;
|
||||
- (int)addFile:(NSString *)filename;
|
||||
- (void)updateIndexesFromRow:(int) row;
|
||||
- (void)updateTotalTime;
|
||||
|
||||
|
||||
//PUBLIC METHODS
|
||||
- (int)addPaths:(NSArray *)paths sort:(BOOL)sort;
|
||||
|
@ -48,6 +51,9 @@
|
|||
- (IBAction)takeShuffleFromObject:(id)sender;
|
||||
- (IBAction)takeRepeatFromObject:(id)sender;
|
||||
|
||||
- (void)setTotalTimeDisplay:(NSString *)ttd;
|
||||
- (NSString *)totalTimeDisplay;
|
||||
|
||||
//FUN PLAYLIST MANAGEMENT STUFF!
|
||||
- (id)currentEntry;
|
||||
- (void)setCurrentEntry:(PlaylistEntry *)pe;
|
||||
|
|
|
@ -134,6 +134,7 @@
|
|||
|
||||
|
||||
[self setSelectionIndex:index];
|
||||
[self updateTotalTime];
|
||||
|
||||
return count;
|
||||
}
|
||||
|
@ -193,6 +194,7 @@
|
|||
[self insertPaths:files atIndex:row sort:YES];
|
||||
|
||||
[self updateIndexesFromRow:row];
|
||||
[self updateTotalTime];
|
||||
|
||||
if (shuffle == YES)
|
||||
[self resetShuffleList];
|
||||
|
@ -200,6 +202,34 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (void)updateTotalTime
|
||||
{
|
||||
double tt=0;
|
||||
|
||||
NSEnumerator *enumerator = [[self arrangedObjects] objectEnumerator];
|
||||
PlaylistEntry* pe;
|
||||
|
||||
while (pe = [enumerator nextObject]) {
|
||||
tt += [pe length];
|
||||
}
|
||||
|
||||
int sec = (int)(tt/1000.0);
|
||||
[self setTotalTimeDisplay:[NSString stringWithFormat:@"%i:%02i",sec/60, sec%60]];
|
||||
}
|
||||
|
||||
- (void)setTotalTimeDisplay:(NSString *)ttd
|
||||
{
|
||||
[ttd retain];
|
||||
[totalTimeDisplay release];
|
||||
totalTimeDisplay = ttd;
|
||||
NSLog(@"Displaying: %@", ttd);
|
||||
}
|
||||
|
||||
- (NSString *)totalTimeDisplay;
|
||||
{
|
||||
return totalTimeDisplay;
|
||||
}
|
||||
|
||||
- (void)updateIndexesFromRow:(int) row
|
||||
{
|
||||
// DBLog(@"UPDATE INDEXES: %i", row);
|
||||
|
@ -236,6 +266,7 @@
|
|||
|
||||
[super removeObjectsAtArrangedObjectIndexes:indexes];
|
||||
[self updateIndexesFromRow:[indexes firstIndex]];
|
||||
[self updateTotalTime];
|
||||
|
||||
if (shuffle == YES)
|
||||
[self resetShuffleList];
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
@interface PlaylistView : NSTableView {
|
||||
|
||||
IBOutlet AppController *appController; //needed to update the total time in the main window title
|
||||
IBOutlet PlaybackController *playbackController;
|
||||
IBOutlet PlaylistController *playlistController;
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
if (c == NSDeleteCharacter)
|
||||
{
|
||||
[playlistController remove:self];
|
||||
[appController updateTotalTime];
|
||||
}
|
||||
else if (c == ' ')
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue