Skip to content
This repository
Browse code

Add methods for "Reset" menu action

  • Loading branch information...
commit 7077ebdce1db192441e3c8e2a7c084a8953cbfd1 1 parent 925a973
Oleksandr Tymoshenko authored
8 AudioBookBinderAppDelegate.m
@@ -383,6 +383,14 @@ - (IBAction) splitFiles: (id)sender
383 383 [fileList splitSelectedFiles:fileListView];
384 384 }
385 385
  386 +- (IBAction) resetToDefaults: (id)sender
  387 +{
  388 + [[form cellAtIndex:ABBAuthor] setStringValue:@""];
  389 + [[form cellAtIndex:ABBTitle] setStringValue:@""];
  390 + [fileList removeAllFiles:fileListView];
  391 + [coverImageView resetImage];
  392 +}
  393 +
386 394 - (void) bindingThreadIsDone:(id)sender
387 395 {
388 396 [bindButton setEnabled:TRUE];
4 AudioFileList.h
@@ -52,7 +52,7 @@ typedef struct
52 52
53 53 - (NSString*) commonAuthor;
54 54 - (NSString*) commonAlbum;
55   -
  55 +- (void) removeAllFiles:(NSOutlineView*)outlineView;
56 56 // NSOutlineView data source methods
57 57 - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
58 58 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
@@ -64,4 +64,6 @@ typedef struct
64 64 - (BOOL)deleteSelected:(NSOutlineView *)outlineView;
65 65 - (BOOL)joinSelectedFiles:(NSOutlineView *)outlineView;
66 66 - (BOOL)splitSelectedFiles: (NSOutlineView*)outlineView;
  67 +
  68 +
67 69 @end
22 AudioFileList.m
@@ -756,5 +756,27 @@ - (NSString *)commonAlbum
756 756 }
757 757 return album;
758 758 }
  759 +
  760 +- (void) removeAllFiles:(NSOutlineView*)outlineView;
  761 +{
  762 + Chapter *newChapter = nil;
  763 +
  764 + [self willChangeValueForKey:@"hasFiles"];
  765 + [_files removeAllObjects];
  766 + [_chapters removeAllObjects];
  767 + // this function is called before _chapterMode is changed by binding
  768 + if (_chapterMode) {
  769 + // put all files in one folder
  770 + newChapter = [[Chapter alloc] init];
  771 + newChapter.name = TEXT_CHAPTER;
  772 + [_chapters addObject:newChapter];
  773 + }
  774 + [outlineView deselectAll:self];
  775 + [outlineView reloadData];
  776 + if (_chapterMode)
  777 + [outlineView expandItem:newChapter];
  778 + [self didChangeValueForKey:@"hasFiles"];
  779 +
  780 +}
759 781
760 782 @end

0 comments on commit 7077ebd

Please sign in to comment.
Something went wrong with that request. Please try again.