Browse files

Add methods for "Reset" menu action

  • Loading branch information...
1 parent 925a973 commit 7077ebdce1db192441e3c8e2a7c084a8953cbfd1 @gonzoua committed Aug 2, 2011
Showing with 33 additions and 1 deletion.
  1. +8 −0 AudioBookBinderAppDelegate.m
  2. +3 −1 AudioFileList.h
  3. +22 −0 AudioFileList.m
View
8 AudioBookBinderAppDelegate.m
@@ -383,6 +383,14 @@ - (IBAction) splitFiles: (id)sender
[fileList splitSelectedFiles:fileListView];
}
+- (IBAction) resetToDefaults: (id)sender
+{
+ [[form cellAtIndex:ABBAuthor] setStringValue:@""];
+ [[form cellAtIndex:ABBTitle] setStringValue:@""];
+ [fileList removeAllFiles:fileListView];
+ [coverImageView resetImage];
+}
+
- (void) bindingThreadIsDone:(id)sender
{
[bindButton setEnabled:TRUE];
View
4 AudioFileList.h
@@ -52,7 +52,7 @@ typedef struct
- (NSString*) commonAuthor;
- (NSString*) commonAlbum;
-
+- (void) removeAllFiles:(NSOutlineView*)outlineView;
// NSOutlineView data source methods
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
@@ -64,4 +64,6 @@ typedef struct
- (BOOL)deleteSelected:(NSOutlineView *)outlineView;
- (BOOL)joinSelectedFiles:(NSOutlineView *)outlineView;
- (BOOL)splitSelectedFiles: (NSOutlineView*)outlineView;
+
+
@end
View
22 AudioFileList.m
@@ -756,5 +756,27 @@ - (NSString *)commonAlbum
}
return album;
}
+
+- (void) removeAllFiles:(NSOutlineView*)outlineView;
+{
+ Chapter *newChapter = nil;
+
+ [self willChangeValueForKey:@"hasFiles"];
+ [_files removeAllObjects];
+ [_chapters removeAllObjects];
+ // this function is called before _chapterMode is changed by binding
+ if (_chapterMode) {
+ // put all files in one folder
+ newChapter = [[Chapter alloc] init];
+ newChapter.name = TEXT_CHAPTER;
+ [_chapters addObject:newChapter];
+ }
+ [outlineView deselectAll:self];
+ [outlineView reloadData];
+ if (_chapterMode)
+ [outlineView expandItem:newChapter];
+ [self didChangeValueForKey:@"hasFiles"];
+
+}
@end

0 comments on commit 7077ebd

Please sign in to comment.