/* Copyright (c) 2004, Noah Sorscher
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 	¥ 	Redistributions of source code must retain the above copyright
 * 	notice, this list of conditions and the following disclaimer.
 * 	¥ 	Redistributions in binary form must reproduce the above copyright
 * 	notice, this list of conditions and the following disclaimer in the
 * 	documentation and/or other materials provided with the distribution.
 * 	¥ 	Neither the name of the Noah Sorscher nor the names of its
 * 	contributors may be used to endorse or promote products derived from
 * 	this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */
/* tModel */

#import <Cocoa/Cocoa.h>
#include "Movies.h"
#import "IconFamily.h"
#import "MHMovie.h"
#import "tInit.h"
//#include "tController.h"
//#import "tChapters.h"

@interface tPlaylist : NSDocument
{

IBOutlet id smartCat, smartCon, smartVal, window;

NSMutableArray *theMovies, *theShuffledMovies, *theSortedMovies;
NSString *sortedString;
int lastSelectedRow, lastClickedColumn, shouldEditVariable;
int NumberOfFiles, currentPlayingIndex;
double totalLength;
double totalSize;

id controller;
NSString *name;
BOOL wontChange, colMoveRecurse, recursion;

MHMovie *editingMovie;
NSString *editingType, *uneditedString;

NSArray *myOptions;

// (animated) sorting stuff:
    id sortingDelegate;
}

//+ (void)backSpace;
- (void)textDidChange:(NSNotification *)aNotification;

- (tPlaylist *)initWithController:(id)aController;
- (NSString *)stringValue;
- (NSString *)name; // same as stringValue
- (NSString *)description; // same as stringValue
- (NSString *)sortedString;
- (int)count;
- (int)currentPlayingIndex;
- (void)setCurrentPlayingIndex:(int)index;
- (MHMovie *)currentPlayingMovie;
- (void)setCurrentPlayingMovie:(MHMovie *)movie;
- (void)setName:(NSString *)aName;
- (NSDictionary *)defsEntry;
- (NSArray *)addFromDefsEntry:(NSArray *)entries;
- (void)replaceMovie:(MHMovie *)oldMovie withMovie:(MHMovie *)newMovie;

- (void) updateToOptions;
- (NSArray *) options;
- (void)setOptions:(NSArray *) options;
- (void)showOptions;
- (void)multiEdit:(NSNotification *)note;

- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
- (void) tableView: (NSTableView *) tableView didClickTableColumn: (NSTableColumn *) tableColumn;
- (void) sortByIdentifier:(NSString *)identifier;
- (BOOL) tableView: (NSTableView *) tableView shouldEditTableColumn: (NSTableColumn *) tableColumn row: (int) rowIndex;
- (BOOL) shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
- (BOOL) tableView: (NSTableView *) tableView shouldSelectRow: (int) rowIndex;
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification;
- (void)tableViewSelectionWontChange:(NSNotification *)aNotification;
- (void)tableViewSelectionWillChangeAgain:(NSNotification *)aNotification;
- (void)doSingleClick:(id)sender;
- (IBAction)doSingleClickWithDelay:(id)sender;
- (IBAction)doDoubleClick:(id)sender;
- (BOOL) commandDeleteForTableView:(NSTableView *) tableView;


- (BOOL)tableView:(NSTableView *)tableView writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pboard;
- (NSDragOperation)tableView:(NSTableView*)tableView validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)operation;
- (BOOL)tableView:(NSTableView*)tableView acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)operation;

- (BOOL) isSelectedFileWritable;
- (BOOL) learn:(NSString *)newString;
- (BOOL) addMovie:(MHMovie *)theMovie;
//- (void)savePrefs;
//- (void)savePrefsIndex:(int)index;
- (NSArray *)search:(NSString *)searchString;
- (BOOL)addMovies: (NSArray *)someMovies;
- (BOOL)removeMovie: (int)index;
- (BOOL)removeAll;
- (MHMovie *)movieWithPath:(NSString *)path;
- (MHMovie *)movieForIndex: (int)index;
- (int)indexForMovie:(MHMovie *)movie;
- (NSArray *)movieArray;
- (double)getTotalMB; //was an (NSString *)
- (double)getTotalTime;
- (int)getNumberOfFiles;
- (NSString *)summaryForIndex:(int)index;
- (BOOL)updateCategoriesForTable: (NSTableView *)tableView upTo: (int)maxColumns;
- (void)shuffle;
- (void)unshuffle;


@end
