Added AMRemoveableTableColumns to aid with hiding/showing playlist columns.
This commit is contained in:
parent
ff98fd44f0
commit
838dd31a64
10 changed files with 522 additions and 106 deletions
|
@ -94,6 +94,10 @@
|
||||||
8E757B5709F326710080F1EE /* OggFLAC.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E75773809F31F1F0080F1EE /* OggFLAC.framework */; };
|
8E757B5709F326710080F1EE /* OggFLAC.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E75773809F31F1F0080F1EE /* OggFLAC.framework */; };
|
||||||
8E757C7C09F32F070080F1EE /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E757C7A09F32F070080F1EE /* AudioToolbox.framework */; };
|
8E757C7C09F32F070080F1EE /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E757C7A09F32F070080F1EE /* AudioToolbox.framework */; };
|
||||||
8E757C7D09F32F070080F1EE /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E757C7B09F32F070080F1EE /* AudioUnit.framework */; };
|
8E757C7D09F32F070080F1EE /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E757C7B09F32F070080F1EE /* AudioUnit.framework */; };
|
||||||
|
8E76ED760B877C0700494D51 /* AMRemovableColumnsTableView.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E76ED720B877C0700494D51 /* AMRemovableColumnsTableView.h */; };
|
||||||
|
8E76ED770B877C0700494D51 /* AMRemovableColumnsTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E76ED730B877C0700494D51 /* AMRemovableColumnsTableView.m */; };
|
||||||
|
8E76ED780B877C0700494D51 /* AMRemovableTableColumn.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E76ED740B877C0700494D51 /* AMRemovableTableColumn.h */; };
|
||||||
|
8E76ED790B877C0700494D51 /* AMRemovableTableColumn.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E76ED750B877C0700494D51 /* AMRemovableTableColumn.m */; };
|
||||||
8E7A0F1A0A8FEB4A00F27EE8 /* add_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E7A0F060A8FEB4A00F27EE8 /* add_blue.png */; };
|
8E7A0F1A0A8FEB4A00F27EE8 /* add_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E7A0F060A8FEB4A00F27EE8 /* add_blue.png */; };
|
||||||
8E7A0F1B0A8FEB4A00F27EE8 /* add_gray.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E7A0F070A8FEB4A00F27EE8 /* add_gray.png */; };
|
8E7A0F1B0A8FEB4A00F27EE8 /* add_gray.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E7A0F070A8FEB4A00F27EE8 /* add_gray.png */; };
|
||||||
8E7A0F1C0A8FEB4A00F27EE8 /* info_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E7A0F080A8FEB4A00F27EE8 /* info_blue.png */; };
|
8E7A0F1C0A8FEB4A00F27EE8 /* info_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E7A0F080A8FEB4A00F27EE8 /* info_blue.png */; };
|
||||||
|
@ -186,6 +190,8 @@
|
||||||
8E07AB780AAC930B00A4B32F /* PreferencesController.h in CopyFiles */,
|
8E07AB780AAC930B00A4B32F /* PreferencesController.h in CopyFiles */,
|
||||||
8E7C2B160AACE0F2009B4EAD /* NDHotKeyEvent.h in CopyFiles */,
|
8E7C2B160AACE0F2009B4EAD /* NDHotKeyEvent.h in CopyFiles */,
|
||||||
171678BF0AC8C39E00C28CF3 /* SmartFolderNode.h in CopyFiles */,
|
171678BF0AC8C39E00C28CF3 /* SmartFolderNode.h in CopyFiles */,
|
||||||
|
8E76ED760B877C0700494D51 /* AMRemovableColumnsTableView.h in CopyFiles */,
|
||||||
|
8E76ED780B877C0700494D51 /* AMRemovableTableColumn.h in CopyFiles */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -319,6 +325,10 @@
|
||||||
8E75775309F31F750080F1EE /* WavPack.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WavPack.framework; path = Libraries/WavPack/build/Release/WavPack.framework; sourceTree = "<group>"; };
|
8E75775309F31F750080F1EE /* WavPack.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WavPack.framework; path = Libraries/WavPack/build/Release/WavPack.framework; sourceTree = "<group>"; };
|
||||||
8E757C7A09F32F070080F1EE /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
|
8E757C7A09F32F070080F1EE /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
|
||||||
8E757C7B09F32F070080F1EE /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = /System/Library/Frameworks/AudioUnit.framework; sourceTree = "<absolute>"; };
|
8E757C7B09F32F070080F1EE /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = /System/Library/Frameworks/AudioUnit.framework; sourceTree = "<absolute>"; };
|
||||||
|
8E76ED720B877C0700494D51 /* AMRemovableColumnsTableView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AMRemovableColumnsTableView.h; sourceTree = "<group>"; };
|
||||||
|
8E76ED730B877C0700494D51 /* AMRemovableColumnsTableView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = AMRemovableColumnsTableView.m; sourceTree = "<group>"; };
|
||||||
|
8E76ED740B877C0700494D51 /* AMRemovableTableColumn.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AMRemovableTableColumn.h; sourceTree = "<group>"; };
|
||||||
|
8E76ED750B877C0700494D51 /* AMRemovableTableColumn.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = AMRemovableTableColumn.m; sourceTree = "<group>"; };
|
||||||
8E7A0F060A8FEB4A00F27EE8 /* add_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add_blue.png; sourceTree = "<group>"; };
|
8E7A0F060A8FEB4A00F27EE8 /* add_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add_blue.png; sourceTree = "<group>"; };
|
||||||
8E7A0F070A8FEB4A00F27EE8 /* add_gray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add_gray.png; sourceTree = "<group>"; };
|
8E7A0F070A8FEB4A00F27EE8 /* add_gray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add_gray.png; sourceTree = "<group>"; };
|
||||||
8E7A0F080A8FEB4A00F27EE8 /* info_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = info_blue.png; sourceTree = "<group>"; };
|
8E7A0F080A8FEB4A00F27EE8 /* info_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = info_blue.png; sourceTree = "<group>"; };
|
||||||
|
@ -522,6 +532,10 @@
|
||||||
8E75751A09F31D5A0080F1EE /* Custom */ = {
|
8E75751A09F31D5A0080F1EE /* Custom */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
8E76ED720B877C0700494D51 /* AMRemovableColumnsTableView.h */,
|
||||||
|
8E76ED730B877C0700494D51 /* AMRemovableColumnsTableView.m */,
|
||||||
|
8E76ED740B877C0700494D51 /* AMRemovableTableColumn.h */,
|
||||||
|
8E76ED750B877C0700494D51 /* AMRemovableTableColumn.m */,
|
||||||
8E75751B09F31D5A0080F1EE /* ClickField.h */,
|
8E75751B09F31D5A0080F1EE /* ClickField.h */,
|
||||||
8E75751C09F31D5A0080F1EE /* ClickField.m */,
|
8E75751C09F31D5A0080F1EE /* ClickField.m */,
|
||||||
8E75751D09F31D5A0080F1EE /* InfoView.h */,
|
8E75751D09F31D5A0080F1EE /* InfoView.h */,
|
||||||
|
@ -886,6 +900,8 @@
|
||||||
8E07AB790AAC930B00A4B32F /* PreferencesController.m in Sources */,
|
8E07AB790AAC930B00A4B32F /* PreferencesController.m in Sources */,
|
||||||
8E7C2B170AACE0F2009B4EAD /* NDHotKeyEvent.m in Sources */,
|
8E7C2B170AACE0F2009B4EAD /* NDHotKeyEvent.m in Sources */,
|
||||||
171678C00AC8C39E00C28CF3 /* SmartFolderNode.m in Sources */,
|
171678C00AC8C39E00C28CF3 /* SmartFolderNode.m in Sources */,
|
||||||
|
8E76ED770B877C0700494D51 /* AMRemovableColumnsTableView.m in Sources */,
|
||||||
|
8E76ED790B877C0700494D51 /* AMRemovableTableColumn.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
39
Custom/AMRemovableColumnsTableView.h
Normal file
39
Custom/AMRemovableColumnsTableView.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// AMRemovableColumnsTableView.h
|
||||||
|
// HebX
|
||||||
|
//
|
||||||
|
// Created by Andreas on 26.08.05.
|
||||||
|
// Copyright 2005 Andreas Mayer. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
|
||||||
|
@interface AMRemovableColumnsTableView : NSTableView {
|
||||||
|
IBOutlet id obligatoryColumnIdentifiers; // NSArray
|
||||||
|
NSSet *allTableColumns;
|
||||||
|
NSSet *obligatoryTableColumns;
|
||||||
|
BOOL am_respondsToControlDidBecomeFirstResponder;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSSet *)allTableColumns;
|
||||||
|
|
||||||
|
- (NSSet *)visibleTableColumns;
|
||||||
|
|
||||||
|
- (NSSet *)hiddenTableColumns;
|
||||||
|
|
||||||
|
// obligatory columns are automatically retrieved from obligatoryColumnIdentifiers if not nil;
|
||||||
|
// use setter otherwise
|
||||||
|
- (NSSet *)obligatoryTableColumns;
|
||||||
|
- (void)setObligatoryTableColumns:(NSSet *)newObligatoryTableColumns;
|
||||||
|
|
||||||
|
- (BOOL)isObligatoryColumn:(NSTableColumn *)column;
|
||||||
|
|
||||||
|
// use these to show and hide columns:
|
||||||
|
|
||||||
|
- (BOOL)hideTableColumn:(NSTableColumn *)column;
|
||||||
|
|
||||||
|
- (BOOL)showTableColumn:(NSTableColumn *)column;
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
299
Custom/AMRemovableColumnsTableView.m
Normal file
299
Custom/AMRemovableColumnsTableView.m
Normal file
|
@ -0,0 +1,299 @@
|
||||||
|
//
|
||||||
|
// AMRemovableColumnsTableView.m
|
||||||
|
// HebX
|
||||||
|
//
|
||||||
|
// Created by Andreas on 26.08.05.
|
||||||
|
// Copyright 2005 Andreas Mayer. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AMRemovableColumnsTableView.h"
|
||||||
|
#import "AMRemovableTableColumn.h"
|
||||||
|
|
||||||
|
|
||||||
|
@interface NSTableView (ApplePrivate)
|
||||||
|
- (void)_readPersistentTableColumns;
|
||||||
|
- (void)_writePersistentTableColumns;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@interface AMRemovableColumnsTableView (Private)
|
||||||
|
- (NSString *)columnVisibilitySaveName;
|
||||||
|
- (void)setAllTableColumns:(NSSet *)newAllTableColumns;
|
||||||
|
- (void)am_hideTableColumn:(NSTableColumn *)column;
|
||||||
|
- (void)am_showTableColumn:(NSTableColumn *)column;
|
||||||
|
- (void)readPersistentTableColumns;
|
||||||
|
- (void)writePersistentTableColumns;
|
||||||
|
- (void)am_readPersistentTableColumns;
|
||||||
|
- (void)am_writePersistentTableColumns;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation AMRemovableColumnsTableView
|
||||||
|
|
||||||
|
static BOOL AMRemovableColumnsTableView_readPersistentTableColumnsIsPublic = NO;
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
// should the framework support readPersistentTableColumns/writePersistentTableColumns, use the public methods
|
||||||
|
AMRemovableColumnsTableView_readPersistentTableColumnsIsPublic = [NSTableColumn instancesRespondToSelector:@selector(readPersistentTableColumns)];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)awakeFromNib
|
||||||
|
{
|
||||||
|
am_respondsToControlDidBecomeFirstResponder = [[self delegate] respondsToSelector:@selector(controlDidBecomeFirstResponder:)];
|
||||||
|
|
||||||
|
// set main table view for columns
|
||||||
|
NSEnumerator *enumerator = [[self tableColumns] objectEnumerator];
|
||||||
|
AMRemovableTableColumn *column;
|
||||||
|
while (column = [enumerator nextObject]) {
|
||||||
|
[column setMainTableView:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
// if there's an array of the names of obligatory columns, update the obligatoryTableColumns set
|
||||||
|
if (obligatoryColumnIdentifiers) {
|
||||||
|
NSMutableSet *columns = (NSMutableSet *)[NSMutableSet setWithSet:[self allTableColumns]];
|
||||||
|
NSEnumerator *enumerator = [columns objectEnumerator];
|
||||||
|
NSTableColumn *column;
|
||||||
|
while (column = [enumerator nextObject]) {
|
||||||
|
if (![(NSArray *)obligatoryColumnIdentifiers containsObject:[column identifier]]) {
|
||||||
|
[columns removeObject:column];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[self setObligatoryTableColumns:columns];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[obligatoryColumnIdentifiers release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (NSSet *)allTableColumns
|
||||||
|
{
|
||||||
|
return allTableColumns;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setAllTableColumns:(NSSet *)newAllTableColumns
|
||||||
|
{
|
||||||
|
if (allTableColumns != newAllTableColumns) {
|
||||||
|
[newAllTableColumns retain];
|
||||||
|
[allTableColumns release];
|
||||||
|
allTableColumns = newAllTableColumns;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSSet *)visibleTableColumns
|
||||||
|
{
|
||||||
|
NSMutableSet *result = [NSMutableSet set];
|
||||||
|
[result addObjectsFromArray:[self tableColumns]];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSSet *)hiddenTableColumns
|
||||||
|
{
|
||||||
|
NSMutableSet *result = [NSMutableSet setWithSet:[self allTableColumns]];
|
||||||
|
[result minusSet:[self visibleTableColumns]];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSSet *)obligatoryTableColumns
|
||||||
|
{
|
||||||
|
return obligatoryTableColumns;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setObligatoryTableColumns:(NSSet *)newObligatoryTableColumns
|
||||||
|
{
|
||||||
|
if (obligatoryTableColumns != newObligatoryTableColumns) {
|
||||||
|
[newObligatoryTableColumns retain];
|
||||||
|
[obligatoryTableColumns release];
|
||||||
|
obligatoryTableColumns = newObligatoryTableColumns;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)hideTableColumn:(NSTableColumn *)column
|
||||||
|
{
|
||||||
|
BOOL result = NO;
|
||||||
|
if (![(AMRemovableTableColumn *)column isHidden] && ![self isObligatoryColumn:column]) {
|
||||||
|
[(AMRemovableTableColumn *)column setHidden:YES];
|
||||||
|
result = YES;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)showTableColumn:(NSTableColumn *)column
|
||||||
|
{
|
||||||
|
BOOL result = NO;
|
||||||
|
if ([(AMRemovableTableColumn *)column isHidden]) {
|
||||||
|
[(AMRemovableTableColumn *)column setHidden:NO];
|
||||||
|
result = YES;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isObligatoryColumn:(NSTableColumn *)column
|
||||||
|
{
|
||||||
|
return [(NSArray *)obligatoryColumnIdentifiers containsObject:[column identifier]] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark ━ table view methods ━
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
- (NSTableColumn *)tableColumnWithIdentifier:(id)identifier
|
||||||
|
{
|
||||||
|
NSTableColumn *result = nil;
|
||||||
|
NSEnumerator *enumerator = [[self allTableColumns] objectEnumerator];
|
||||||
|
NSTableColumn *column;
|
||||||
|
while (column = [enumerator nextObject]) {
|
||||||
|
if ([[column identifier] isEqualToString:identifier]) {
|
||||||
|
result = column;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setDelegate:(id)anObject
|
||||||
|
{
|
||||||
|
am_respondsToControlDidBecomeFirstResponder = [anObject respondsToSelector:@selector(controlDidBecomeFirstResponder:)];
|
||||||
|
[super setDelegate:anObject];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark ━ view methods ━
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
- (void)viewWillMoveToWindow:(NSWindow *)newWindow
|
||||||
|
{
|
||||||
|
//NSLog(@"AMRemovableColumnsTableView - viewWillMoveToWindow:%@", newWindow);
|
||||||
|
[self am_readPersistentTableColumns];
|
||||||
|
[super viewWillMoveToWindow:newWindow];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark ━ responder methods ━
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
- (BOOL)becomeFirstResponder
|
||||||
|
{
|
||||||
|
BOOL result = [super becomeFirstResponder];
|
||||||
|
if (result && am_respondsToControlDidBecomeFirstResponder) {
|
||||||
|
[[self delegate] performSelector:@selector(controlDidBecomeFirstResponder:) withObject:self];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark ━ private table view methods ━
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
- (void)_readPersistentTableColumns
|
||||||
|
{
|
||||||
|
//NSLog(@"_readPersistentTableColumns");
|
||||||
|
if (!AMRemovableColumnsTableView_readPersistentTableColumnsIsPublic) {
|
||||||
|
[self setAllTableColumns:[NSSet setWithArray:[self tableColumns]]];
|
||||||
|
// restore visible columns
|
||||||
|
[self am_readPersistentTableColumns];
|
||||||
|
} // else readPersistentTableColumns will be used
|
||||||
|
[super _readPersistentTableColumns];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_writePersistentTableColumns
|
||||||
|
{
|
||||||
|
//NSLog(@"_writePersistentTableColumns");
|
||||||
|
[super _writePersistentTableColumns];
|
||||||
|
// save visible columns
|
||||||
|
if (!AMRemovableColumnsTableView_readPersistentTableColumnsIsPublic) {
|
||||||
|
[self am_writePersistentTableColumns];
|
||||||
|
} // else writePersistentTableColumns will be used
|
||||||
|
}
|
||||||
|
|
||||||
|
// just in case these methods should become public:
|
||||||
|
- (void)readPersistentTableColumns
|
||||||
|
{
|
||||||
|
//NSLog(@"_readPersistentTableColumns");
|
||||||
|
[self setAllTableColumns:[NSSet setWithArray:[self tableColumns]]];
|
||||||
|
// restore visible columns
|
||||||
|
[self am_readPersistentTableColumns];
|
||||||
|
[(id)super readPersistentTableColumns]; // cast to avoid compiler warning
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)writePersistentTableColumns
|
||||||
|
{
|
||||||
|
//NSLog(@"_writePersistentTableColumns");
|
||||||
|
[(id)super writePersistentTableColumns]; // cast to avoid compiler warning
|
||||||
|
// save visible columns
|
||||||
|
[self am_writePersistentTableColumns];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark ━ private methods ━
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
- (NSString *)columnVisibilitySaveName
|
||||||
|
{
|
||||||
|
NSString *autosaveName = [self autosaveName];
|
||||||
|
if (!autosaveName) {
|
||||||
|
NSLog(@"AMRemovableColumnsTableView: autosave name missing for table view: %@", self);
|
||||||
|
autosaveName = @"no-autosave-name-set";
|
||||||
|
}
|
||||||
|
return [@"AMRemovableColumnsTableView VisibleColumns " stringByAppendingString:autosaveName];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)am_readPersistentTableColumns
|
||||||
|
{
|
||||||
|
// restore visible columns
|
||||||
|
NSArray *visibleColumnIdentifiers = [[NSUserDefaults standardUserDefaults] objectForKey:[self columnVisibilitySaveName]];
|
||||||
|
if (visibleColumnIdentifiers) {
|
||||||
|
NSSet *allColumns = [self allTableColumns];
|
||||||
|
NSEnumerator *enumerator = [allColumns objectEnumerator];
|
||||||
|
NSTableColumn *column;
|
||||||
|
while (column = [enumerator nextObject]) {
|
||||||
|
if (![visibleColumnIdentifiers containsObject:[column identifier]]) {
|
||||||
|
[(AMRemovableTableColumn *)column setMainTableView:self];
|
||||||
|
[self removeTableColumn:column];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)am_writePersistentTableColumns
|
||||||
|
{
|
||||||
|
NSMutableArray *visibleColumnIdentifiers = [NSMutableArray array];
|
||||||
|
NSEnumerator *enumerator = [[self visibleTableColumns] objectEnumerator];
|
||||||
|
NSTableColumn *column;
|
||||||
|
while (column = [enumerator nextObject]) {
|
||||||
|
[visibleColumnIdentifiers addObject:[column identifier]];
|
||||||
|
}
|
||||||
|
[[NSUserDefaults standardUserDefaults] setObject:visibleColumnIdentifiers forKey:[self columnVisibilitySaveName]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)am_hideTableColumn:(NSTableColumn *)column
|
||||||
|
{
|
||||||
|
[(AMRemovableTableColumn *)column setMainTableView:self];
|
||||||
|
[self removeTableColumn:column];
|
||||||
|
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(am_writePersistentTableColumns) object:nil];
|
||||||
|
[self performSelector:@selector(am_writePersistentTableColumns) withObject:nil afterDelay:0.0];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)am_showTableColumn:(NSTableColumn *)column
|
||||||
|
{
|
||||||
|
[self addTableColumn:column];
|
||||||
|
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(am_writePersistentTableColumns) object:nil];
|
||||||
|
[self performSelector:@selector(am_writePersistentTableColumns) withObject:nil afterDelay:0.0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
24
Custom/AMRemovableTableColumn.h
Normal file
24
Custom/AMRemovableTableColumn.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// AMRemovableTableColumn.h
|
||||||
|
// HebX
|
||||||
|
//
|
||||||
|
// Created by Andreas on 28.08.05.
|
||||||
|
// Copyright 2005 Andreas Mayer. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import "AMRemovableColumnsTableView.h"
|
||||||
|
|
||||||
|
|
||||||
|
@interface AMRemovableTableColumn : NSTableColumn {
|
||||||
|
IBOutlet AMRemovableColumnsTableView *mainTableView;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (AMRemovableColumnsTableView *)mainTableView;
|
||||||
|
- (void)setMainTableView:(AMRemovableColumnsTableView *)newMainTableView;
|
||||||
|
|
||||||
|
- (BOOL)isHidden;
|
||||||
|
- (void)setHidden:(BOOL)flag;
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
63
Custom/AMRemovableTableColumn.m
Normal file
63
Custom/AMRemovableTableColumn.m
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
//
|
||||||
|
// AMRemovableTableColumn.m
|
||||||
|
// HebX
|
||||||
|
//
|
||||||
|
// Created by Andreas on 28.08.05.
|
||||||
|
// Copyright 2005 Andreas Mayer. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AMRemovableTableColumn.h"
|
||||||
|
|
||||||
|
@interface AMRemovableColumnsTableView (Private)
|
||||||
|
- (void)am_hideTableColumn:(NSTableColumn *)column;
|
||||||
|
- (void)am_showTableColumn:(NSTableColumn *)column;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation AMRemovableTableColumn
|
||||||
|
|
||||||
|
static BOOL AMRemovableTableColumn_frameworkDoesSupportHiddenColumns = NO;
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
// should the framework support isHidden/setHidden:, use the build-in methods
|
||||||
|
AMRemovableTableColumn_frameworkDoesSupportHiddenColumns = [NSTableColumn instancesRespondToSelector:@selector(setHidden:)];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (AMRemovableColumnsTableView *)mainTableView
|
||||||
|
{
|
||||||
|
return mainTableView;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setMainTableView:(AMRemovableColumnsTableView *)newMainTableView
|
||||||
|
{
|
||||||
|
// do not retain
|
||||||
|
mainTableView = newMainTableView;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (BOOL)isHidden
|
||||||
|
{
|
||||||
|
if (AMRemovableTableColumn_frameworkDoesSupportHiddenColumns) {
|
||||||
|
return [(id)super isHidden]; // cast to id to avoid compiler warning
|
||||||
|
} else {
|
||||||
|
return ([self tableView] != mainTableView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setHidden:(BOOL)flag
|
||||||
|
{
|
||||||
|
if (AMRemovableTableColumn_frameworkDoesSupportHiddenColumns) {
|
||||||
|
[(id)super setHidden:flag]; // cast to id to avoid compiler warning
|
||||||
|
} else {
|
||||||
|
if (flag) {
|
||||||
|
[(AMRemovableColumnsTableView *)[self tableView] am_hideTableColumn:self];
|
||||||
|
} else {
|
||||||
|
[mainTableView am_showTableColumn:self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
29
English.lproj/MainMenu.nib/classes.nib
generated
29
English.lproj/MainMenu.nib/classes.nib
generated
|
@ -1,5 +1,17 @@
|
||||||
{
|
{
|
||||||
IBClasses = (
|
IBClasses = (
|
||||||
|
{
|
||||||
|
CLASS = AMRemovableColumnsTableView;
|
||||||
|
LANGUAGE = ObjC;
|
||||||
|
OUTLETS = {obligatoryColumnIdentifiers = id; };
|
||||||
|
SUPERCLASS = NSTableView;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
CLASS = AMRemovableTableColumn;
|
||||||
|
LANGUAGE = ObjC;
|
||||||
|
OUTLETS = {mainTableView = AMRemovableColumnsTableView; };
|
||||||
|
SUPERCLASS = NSTableColumn;
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ACTIONS = {
|
ACTIONS = {
|
||||||
addFiles = id;
|
addFiles = id;
|
||||||
|
@ -109,13 +121,14 @@
|
||||||
ACTIONS = {
|
ACTIONS = {
|
||||||
shufflePlaylist = id;
|
shufflePlaylist = id;
|
||||||
sortByPath = id;
|
sortByPath = id;
|
||||||
takeBoolForAlbum = id;
|
toggleColumnForAlbum = id;
|
||||||
takeBoolForArtist = id;
|
toggleColumnForArtist = id;
|
||||||
takeBoolForGenre = id;
|
toggleColumnForGenre = id;
|
||||||
takeBoolForLength = id;
|
toggleColumnForIndex = id;
|
||||||
takeBoolForTitle = id;
|
toggleColumnForLength = id;
|
||||||
takeBoolForTrack = id;
|
toggleColumnForTitle = id;
|
||||||
takeBoolForYear = id;
|
toggleColumnForTrack = id;
|
||||||
|
toggleColumnForYear = id;
|
||||||
};
|
};
|
||||||
CLASS = PlaylistView;
|
CLASS = PlaylistView;
|
||||||
LANGUAGE = ObjC;
|
LANGUAGE = ObjC;
|
||||||
|
@ -123,7 +136,7 @@
|
||||||
playbackController = PlaybackController;
|
playbackController = PlaybackController;
|
||||||
playlistController = PlaylistController;
|
playlistController = PlaylistController;
|
||||||
};
|
};
|
||||||
SUPERCLASS = NSTableView;
|
SUPERCLASS = AMRemovableColumnsTableView;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ACTIONS = {showPrefs = id; };
|
ACTIONS = {showPrefs = id; };
|
||||||
|
|
7
English.lproj/MainMenu.nib/info.nib
generated
7
English.lproj/MainMenu.nib/info.nib
generated
|
@ -3,7 +3,7 @@
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>IBDocumentLocation</key>
|
<key>IBDocumentLocation</key>
|
||||||
<string>33 358 639 388 0 0 1024 746 </string>
|
<string>38 327 639 388 0 0 1024 746 </string>
|
||||||
<key>IBEditorPositions</key>
|
<key>IBEditorPositions</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>1063</key>
|
<key>1063</key>
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
<key>1156</key>
|
<key>1156</key>
|
||||||
<string>233 341 241 366 0 0 1024 746 </string>
|
<string>233 341 241 366 0 0 1024 746 </string>
|
||||||
<key>29</key>
|
<key>29</key>
|
||||||
<string>65 680 383 44 0 0 1024 746 </string>
|
<string>73 702 383 44 0 0 1024 746 </string>
|
||||||
<key>463</key>
|
<key>463</key>
|
||||||
<string>358 380 308 279 0 0 1024 746 </string>
|
<string>358 380 308 279 0 0 1024 746 </string>
|
||||||
<key>513</key>
|
<key>513</key>
|
||||||
|
@ -32,11 +32,12 @@
|
||||||
<integer>4</integer>
|
<integer>4</integer>
|
||||||
<key>IBOpenObjects</key>
|
<key>IBOpenObjects</key>
|
||||||
<array>
|
<array>
|
||||||
|
<integer>513</integer>
|
||||||
<integer>29</integer>
|
<integer>29</integer>
|
||||||
<integer>21</integer>
|
<integer>21</integer>
|
||||||
<integer>463</integer>
|
<integer>463</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>8J135</string>
|
<string>8L127</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -12,25 +12,25 @@
|
||||||
#import "PlaybackController.h"
|
#import "PlaybackController.h"
|
||||||
#import "PlaylistController.h"
|
#import "PlaylistController.h"
|
||||||
|
|
||||||
@interface PlaylistView : NSTableView {
|
#import "AMRemovableColumnsTableView.h"
|
||||||
|
|
||||||
|
@interface PlaylistView : AMRemovableColumnsTableView {
|
||||||
|
|
||||||
IBOutlet PlaybackController *playbackController;
|
IBOutlet PlaybackController *playbackController;
|
||||||
IBOutlet PlaylistController *playlistController;
|
IBOutlet PlaylistController *playlistController;
|
||||||
|
|
||||||
NSArray *_tableColumnsCache;
|
|
||||||
NSMutableArray *_removedColumns;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)sortByPath:(id)sender;
|
- (IBAction)sortByPath:(id)sender;
|
||||||
- (IBAction)shufflePlaylist:(id)sender;
|
- (IBAction)shufflePlaylist:(id)sender;
|
||||||
|
|
||||||
- (IBAction)takeBoolForTitle:(id)sender;
|
- (IBAction)toggleColumnForIndex:(id)sender;
|
||||||
- (IBAction)takeBoolForArtist:(id)sender;
|
- (IBAction)toggleColumnForTitle:(id)sender;
|
||||||
- (IBAction)takeBoolForAlbum:(id)sender;
|
- (IBAction)toggleColumnForArtist:(id)sender;
|
||||||
- (IBAction)takeBoolForLength:(id)sender;
|
- (IBAction)toggleColumnForAlbum:(id)sender;
|
||||||
- (IBAction)takeBoolForYear:(id)sender;
|
- (IBAction)toggleColumnForLength:(id)sender;
|
||||||
- (IBAction)takeBoolForGenre:(id)sender;
|
- (IBAction)toggleColumnForYear:(id)sender;
|
||||||
- (IBAction)takeBoolForTrack:(id)sender;
|
- (IBAction)toggleColumnForGenre:(id)sender;
|
||||||
|
- (IBAction)toggleColumnForTrack:(id)sender;
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -16,14 +16,16 @@
|
||||||
|
|
||||||
- (void)awakeFromNib
|
- (void)awakeFromNib
|
||||||
{
|
{
|
||||||
id c;
|
[super awakeFromNib];
|
||||||
|
|
||||||
NSControlSize s = NSSmallControlSize;
|
NSControlSize s = NSSmallControlSize;
|
||||||
NSEnumerator *oe = [[self tableColumns] objectEnumerator];
|
NSEnumerator *oe = [[self allTableColumns] objectEnumerator];
|
||||||
NSFont *f = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:s]];
|
NSFont *f = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:s]];
|
||||||
|
|
||||||
[self setRowHeight:[f defaultLineHeightForFont]];
|
[self setRowHeight:[f defaultLineHeightForFont]];
|
||||||
|
|
||||||
//Resize the fonts
|
//Resize the fonts
|
||||||
|
id c;
|
||||||
while (c = [oe nextObject])
|
while (c = [oe nextObject])
|
||||||
{
|
{
|
||||||
[[c dataCell] setControlSize:s];
|
[[c dataCell] setControlSize:s];
|
||||||
|
@ -40,108 +42,67 @@
|
||||||
[self setHeaderView:customTableHeaderView];
|
[self setHeaderView:customTableHeaderView];
|
||||||
|
|
||||||
[self setVerticalMotionCanBeginDrag:YES];
|
[self setVerticalMotionCanBeginDrag:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)toggleColumn:(id)sender withIdentifier:(NSString *)identifier
|
||||||
|
{
|
||||||
|
NSTableColumn *tc = [super tableColumnWithIdentifier:identifier];
|
||||||
|
|
||||||
//Hack for bindings and columns
|
|
||||||
_tableColumnsCache = [[NSArray alloc] initWithArray:[self tableColumns] copyItems:NO];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IBAction)takeBoolForTitle:(id)sender
|
|
||||||
{
|
|
||||||
[self showColumn:sender withIdentifier:@"title"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IBAction)takeBoolForArtist:(id)sender
|
|
||||||
{
|
|
||||||
[self showColumn:sender withIdentifier:@"artist"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IBAction)takeBoolForAlbum:(id)sender
|
|
||||||
{
|
|
||||||
[self showColumn:sender withIdentifier:@"album"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IBAction)takeBoolForLength:(id)sender
|
|
||||||
{
|
|
||||||
[self showColumn:sender withIdentifier:@"length"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IBAction)takeBoolForYear:(id)sender
|
|
||||||
{
|
|
||||||
[self showColumn:sender withIdentifier:@"year"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IBAction)takeBoolForGenre:(id)sender
|
|
||||||
{
|
|
||||||
[self showColumn:sender withIdentifier:@"genre"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IBAction)takeBoolForTrack:(id)sender
|
|
||||||
{
|
|
||||||
[self showColumn:sender withIdentifier:@"track"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)showColumn:(id)sender withIdentifier:(NSString *)identifier
|
|
||||||
{
|
|
||||||
if ([sender state] == NSOffState)
|
if ([sender state] == NSOffState)
|
||||||
{
|
{
|
||||||
[sender setState:NSOnState];
|
[sender setState:NSOnState];
|
||||||
[self showColumnWithIdentifier:identifier];
|
|
||||||
|
[self showTableColumn:tc];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[sender setState:NSOffState];
|
[sender setState:NSOffState];
|
||||||
[self hideColumnWithIdentifier:identifier];
|
[self hideTableColumn:tc];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)hideColumnWithIdentifier:(NSString *)identifier
|
- (IBAction)toggleColumnForIndex:(id)sender
|
||||||
{
|
{
|
||||||
NSTableColumn *tc = [super tableColumnWithIdentifier:identifier];
|
[self toggleColumn:sender withIdentifier:@"index"];
|
||||||
if (!tc)
|
|
||||||
return;
|
|
||||||
|
|
||||||
[self removeTableColumn:tc];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)showColumnWithIdentifier:(NSString *)identifier
|
- (IBAction)toggleColumnForTitle:(id)sender
|
||||||
{
|
{
|
||||||
if ([super tableColumnWithIdentifier:identifier])
|
[self toggleColumn:sender withIdentifier:@"title"];
|
||||||
return;
|
|
||||||
|
|
||||||
NSEnumerator *e = [_tableColumnsCache objectEnumerator];
|
|
||||||
NSTableColumn *t = nil;
|
|
||||||
|
|
||||||
while (t = [e nextObject])
|
|
||||||
{
|
|
||||||
// Locate cached version if there is one.
|
|
||||||
if ([[t identifier] isEqualToString:identifier])
|
|
||||||
// Remove it from the array and release the array if it isn't needed any more.
|
|
||||||
[self addTableColumn:t];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//FUN HACKS SO COLUMNS DONT DISAPPEAR WHEN THE TABLE IS AUTOSAVED
|
- (IBAction)toggleColumnForArtist:(id)sender
|
||||||
- (NSTableColumn *)tableColumnWithIdentifier:(id)anObject
|
|
||||||
{
|
{
|
||||||
NSTableColumn *tc = [super tableColumnWithIdentifier:anObject];
|
[self toggleColumn:sender withIdentifier:@"artist"];
|
||||||
|
|
||||||
if (!tc)
|
|
||||||
{
|
|
||||||
NSEnumerator *e = [_tableColumnsCache objectEnumerator];
|
|
||||||
NSTableColumn *t = nil;
|
|
||||||
|
|
||||||
while (t = [e nextObject])
|
|
||||||
{
|
|
||||||
// Locate cached version if there is one.
|
|
||||||
if ([[t identifier] isEqual:anObject])
|
|
||||||
// Remove it from the array and release the array if it isn't needed any more.
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction)toggleColumnForAlbum:(id)sender
|
||||||
|
{
|
||||||
|
[self toggleColumn:sender withIdentifier:@"album"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)toggleColumnForLength:(id)sender
|
||||||
|
{
|
||||||
|
[self toggleColumn:sender withIdentifier:@"length"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)toggleColumnForYear:(id)sender
|
||||||
|
{
|
||||||
|
[self toggleColumn:sender withIdentifier:@"year"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)toggleColumnForGenre:(id)sender
|
||||||
|
{
|
||||||
|
[self toggleColumn:sender withIdentifier:@"genre"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)toggleColumnForTrack:(id)sender
|
||||||
|
{
|
||||||
|
[self toggleColumn:sender withIdentifier:@"track"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (BOOL)acceptsFirstResponder
|
- (BOOL)acceptsFirstResponder
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
|
|
Loading…
Reference in a new issue