Update to ARC and 10.9 deployment target.
This commit is contained in:
1 parent
e59092536b
commit
ac05736fed
67 files changed
+1240
-1694
No files matched your search
@@ -17,44 +17,39 @@
|
||||
{
|
||||
[super loadView];
|
||||
|
||||
NSMutableParagraphStyle *ps = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
|
||||
[ps setHeadIndent: -10.0];
|
||||
[ps setAlignment:NSRightTextAlignment];
|
||||
NSMutableParagraphStyle *ps = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
ps.headIndent = -10.0;
|
||||
ps.alignment = NSRightTextAlignment;
|
||||
|
||||
if ([[NSFont class] respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]) {
|
||||
detailBoldAttr = [@{ NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightBold],
|
||||
detailBoldAttr = @{ NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightBold],
|
||||
NSParagraphStyleAttributeName: ps,
|
||||
NSForegroundColorAttributeName: [NSColor grayColor] } retain];
|
||||
NSForegroundColorAttributeName: [NSColor grayColor] };
|
||||
}
|
||||
else {
|
||||
detailBoldAttr = [@{ NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]],
|
||||
detailBoldAttr = @{ NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]],
|
||||
NSParagraphStyleAttributeName: ps,
|
||||
NSForegroundColorAttributeName: [NSColor grayColor] } retain];
|
||||
NSForegroundColorAttributeName: [NSColor grayColor] };
|
||||
}
|
||||
|
||||
chapterTableView.defaultEditingColumn = 1;
|
||||
}
|
||||
|
||||
- (void)setTrack:(MP42ChapterTrack *)chapterTrack
|
||||
{
|
||||
track = [chapterTrack retain];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)boldString:(NSString *)string
|
||||
{
|
||||
return [[[NSAttributedString alloc] initWithString:string attributes:detailBoldAttr] autorelease];
|
||||
return [[NSAttributedString alloc] initWithString:string attributes:detailBoldAttr];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)t
|
||||
{
|
||||
return [track chapterCount];
|
||||
return [self.track chapterCount];
|
||||
}
|
||||
|
||||
- (id) tableView:(NSTableView *)tableView
|
||||
objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
row:(NSInteger)rowIndex
|
||||
{
|
||||
MP42TextSample *chapter = [track chapterAtIndex:rowIndex];
|
||||
MP42TextSample *chapter = [self.track chapterAtIndex:rowIndex];
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"time"]) {
|
||||
return [self boldString:StringFromTime(chapter.timestamp, 1000)];
|
||||
@@ -72,29 +67,29 @@
|
||||
forTableColumn:(NSTableColumn *)tableColumn
|
||||
row:(NSInteger)rowIndex
|
||||
{
|
||||
MP42TextSample * chapter = [track chapterAtIndex:rowIndex];
|
||||
MP42TextSample *chapter = [self.track chapterAtIndex:rowIndex];
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"title"]) {
|
||||
if (![chapter.title isEqualToString:anObject]) {
|
||||
[track setTitle:anObject forChapter:chapter];
|
||||
[self.track setTitle:anObject forChapter:chapter];
|
||||
|
||||
[[[[[self view]window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
}
|
||||
else if ([tableColumn.identifier isEqualToString:@"time"]) {
|
||||
MP42Duration timestamp = TimeFromString(anObject, 1000);
|
||||
if (!(chapter.timestamp == timestamp)) {
|
||||
[track setTimestamp:timestamp forChapter:chapter];
|
||||
[self.track setTimestamp:timestamp forChapter:chapter];
|
||||
[chapterTableView reloadData];
|
||||
|
||||
[[[[[self view]window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
|
||||
{
|
||||
if ([chapterTableView selectedRow] != -1) {
|
||||
if (chapterTableView.selectedRow != -1) {
|
||||
[removeChapter setEnabled:YES];
|
||||
}
|
||||
else {
|
||||
@@ -105,13 +100,12 @@
|
||||
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
|
||||
{
|
||||
if ([tableColumn.identifier isEqualToString:@"time"]) {
|
||||
if ([[tableView selectedRowIndexes] containsIndex:rowIndex]) {
|
||||
if ([tableView.selectedRowIndexes containsIndex:rowIndex]) {
|
||||
// Without this, the color won't change because
|
||||
// we are using a attributed string.
|
||||
NSMutableAttributedString *highlightedString = [[NSMutableAttributedString alloc] initWithAttributedString:[cell attributedStringValue]];
|
||||
[highlightedString addAttribute:NSForegroundColorAttributeName value:[NSColor blackColor] range:NSMakeRange(0, [highlightedString length])];
|
||||
[highlightedString addAttribute:NSForegroundColorAttributeName value:[NSColor blackColor] range:NSMakeRange(0, highlightedString.length)];
|
||||
[cell setAttributedStringValue:highlightedString];
|
||||
[highlightedString release];
|
||||
|
||||
[cell setTextColor:[NSColor blackColor]];
|
||||
}
|
||||
@@ -122,38 +116,31 @@
|
||||
}
|
||||
|
||||
- (IBAction)removeChapter:(id)sender {
|
||||
NSInteger current_index = [chapterTableView selectedRow];
|
||||
if (current_index < [track chapterCount]) {
|
||||
[track removeChapterAtIndex:current_index];
|
||||
NSInteger current_index = chapterTableView.selectedRow;
|
||||
if (current_index < [self.track chapterCount]) {
|
||||
[self.track removeChapterAtIndex:current_index];
|
||||
|
||||
[chapterTableView reloadData];
|
||||
[[[[[self view] window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)addChapter:(id)sender {
|
||||
[track addChapter:@"Chapter" duration:0];
|
||||
[self.track addChapter:@"Chapter" duration:0];
|
||||
|
||||
[chapterTableView reloadData];
|
||||
[[[[[self view] window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
- (IBAction)renameChapters:(id)sender {
|
||||
[track.chapters enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
[self.track.chapters enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
NSString *title = [NSString stringWithFormat:@"Chapter %lu", (unsigned long) idx + 1];
|
||||
[track setTitle:title forChapter:(MP42TextSample *)obj];
|
||||
[self.track setTitle:title forChapter:(MP42TextSample *)obj];
|
||||
}];
|
||||
|
||||
[chapterTableView reloadData];
|
||||
[[[[[self view] window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[self.view.window.windowController.document updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[track release];
|
||||
[detailBoldAttr release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user