Commit 3f2086d3 authored by David Fuhrmann's avatar David Fuhrmann

macosx: cleanup pl data source, do not show file size for directories

parent 813cc63a
...@@ -27,6 +27,20 @@ ...@@ -27,6 +27,20 @@
#define VLCPLItemPasteboadType @"VLCPlaylistItemPboardType" #define VLCPLItemPasteboadType @"VLCPlaylistItemPboardType"
/* playlist column definitions */
#define STATUS_COLUMN @"status"
#define TRACKNUM_COLUMN @"tracknumber"
#define TITLE_COLUMN @"name"
#define ARTIST_COLUMN @"artist"
#define DURATION_COLUMN @"duration"
#define GENRE_COLUMN @"genre"
#define ALBUM_COLUMN @"album"
#define DESCRIPTION_COLUMN @"description"
#define DATE_COLUMN @"date"
#define LANGUAGE_COLUMN @"language"
#define URI_COLUMN @"uri"
#define FILESIZE_COLUMN @"file-size"
@class VLCPlaylist; @class VLCPlaylist;
@interface PLModel : NSObject<NSOutlineViewDataSource> @interface PLModel : NSObject<NSOutlineViewDataSource>
......
...@@ -36,18 +36,6 @@ ...@@ -36,18 +36,6 @@
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_url.h> #include <vlc_url.h>
#define TRACKNUM_COLUMN @"tracknumber"
#define TITLE_COLUMN @"name"
#define ARTIST_COLUMN @"artist"
#define DURATION_COLUMN @"duration"
#define GENRE_COLUMN @"genre"
#define ALBUM_COLUMN @"album"
#define DESCRIPTION_COLUMN @"description"
#define DATE_COLUMN @"date"
#define LANGUAGE_COLUMN @"language"
#define URI_COLUMN @"uri"
#define FILESIZE_COLUMN @"file-size"
#pragma mark - #pragma mark -
@implementation PLModel @implementation PLModel
...@@ -288,7 +276,7 @@ ...@@ -288,7 +276,7 @@
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{ {
id o_value = nil; id o_value = nil;
char * psz_value; char *psz_value;
input_item_t *p_input = [item input]; input_item_t *p_input = [item input];
...@@ -296,88 +284,80 @@ ...@@ -296,88 +284,80 @@
if ([o_identifier isEqualToString:TRACKNUM_COLUMN]) { if ([o_identifier isEqualToString:TRACKNUM_COLUMN]) {
psz_value = input_item_GetTrackNumber(p_input); psz_value = input_item_GetTrackNumber(p_input);
if (psz_value) { o_value = toNSStr(psz_value);
o_value = [NSString stringWithUTF8String:psz_value]; free(psz_value);
free(psz_value);
}
} else if ([o_identifier isEqualToString:TITLE_COLUMN]) { } else if ([o_identifier isEqualToString:TITLE_COLUMN]) {
/* sanity check to prevent the NSString class from crashing */ psz_value = input_item_GetTitleFbName(p_input);
char *psz_title = input_item_GetTitleFbName(p_input); o_value = toNSStr(psz_value);
if (psz_title) { free(psz_value);
o_value = [NSString stringWithUTF8String:psz_title];
free(psz_title);
}
} else if ([o_identifier isEqualToString:ARTIST_COLUMN]) { } else if ([o_identifier isEqualToString:ARTIST_COLUMN]) {
psz_value = input_item_GetArtist(p_input); psz_value = input_item_GetArtist(p_input);
if (psz_value) { o_value = toNSStr(psz_value);
o_value = [NSString stringWithUTF8String:psz_value]; free(psz_value);
free(psz_value);
} } else if ([o_identifier isEqualToString:DURATION_COLUMN]) {
} else if ([o_identifier isEqualToString:@"duration"]) {
char psz_duration[MSTRTIME_MAX_SIZE]; char psz_duration[MSTRTIME_MAX_SIZE];
mtime_t dur = input_item_GetDuration(p_input); mtime_t dur = input_item_GetDuration(p_input);
if (dur != -1) { if (dur != -1) {
secstotimestr(psz_duration, dur/1000000); secstotimestr(psz_duration, dur/1000000);
o_value = [NSString stringWithUTF8String:psz_duration]; o_value = toNSStr(psz_duration);
} }
else else
o_value = @"--:--"; o_value = @"--:--";
} else if ([o_identifier isEqualToString:GENRE_COLUMN]) { } else if ([o_identifier isEqualToString:GENRE_COLUMN]) {
psz_value = input_item_GetGenre(p_input); psz_value = input_item_GetGenre(p_input);
if (psz_value) { o_value = toNSStr(psz_value);
o_value = [NSString stringWithUTF8String:psz_value]; free(psz_value);
free(psz_value);
}
} else if ([o_identifier isEqualToString:ALBUM_COLUMN]) { } else if ([o_identifier isEqualToString:ALBUM_COLUMN]) {
psz_value = input_item_GetAlbum(p_input); psz_value = input_item_GetAlbum(p_input);
if (psz_value) { o_value = toNSStr(psz_value);
o_value = [NSString stringWithUTF8String:psz_value]; free(psz_value);
free(psz_value);
}
} else if ([o_identifier isEqualToString:DESCRIPTION_COLUMN]) { } else if ([o_identifier isEqualToString:DESCRIPTION_COLUMN]) {
psz_value = input_item_GetDescription(p_input); psz_value = input_item_GetDescription(p_input);
if (psz_value) { o_value = toNSStr(psz_value);
o_value = [NSString stringWithUTF8String:psz_value]; free(psz_value);
free(psz_value);
}
} else if ([o_identifier isEqualToString:DATE_COLUMN]) { } else if ([o_identifier isEqualToString:DATE_COLUMN]) {
psz_value = input_item_GetDate(p_input); psz_value = input_item_GetDate(p_input);
if (psz_value) { o_value = toNSStr(psz_value);
o_value = [NSString stringWithUTF8String:psz_value]; free(psz_value);
free(psz_value);
}
} else if ([o_identifier isEqualToString:LANGUAGE_COLUMN]) { } else if ([o_identifier isEqualToString:LANGUAGE_COLUMN]) {
psz_value = input_item_GetLanguage(p_input); psz_value = input_item_GetLanguage(p_input);
if (psz_value) { o_value = toNSStr(psz_value);
o_value = [NSString stringWithUTF8String:psz_value]; free(psz_value);
free(psz_value);
} } else if ([o_identifier isEqualToString:URI_COLUMN]) {
}
else if ([o_identifier isEqualToString:URI_COLUMN]) {
psz_value = decode_URI(input_item_GetURI(p_input)); psz_value = decode_URI(input_item_GetURI(p_input));
if (psz_value) { o_value = toNSStr(psz_value);
o_value = [NSString stringWithUTF8String:psz_value]; free(psz_value);
free(psz_value);
} } else if ([o_identifier isEqualToString:FILESIZE_COLUMN]) {
}
else if ([o_identifier isEqualToString:FILESIZE_COLUMN]) {
psz_value = input_item_GetURI(p_input); psz_value = input_item_GetURI(p_input);
o_value = @""; if (!psz_value)
if (psz_value) { return @"";
NSURL *url = [NSURL URLWithString:[NSString stringWithUTF8String:psz_value]]; NSURL *url = [NSURL URLWithString:toNSStr(psz_value)];
if ([url isFileURL]) { free(psz_value);
NSFileManager *fileManager = [NSFileManager defaultManager]; if (![url isFileURL])
if ([fileManager fileExistsAtPath:[url path]]) { return @"";
NSError *error;
NSDictionary *attributes = [fileManager attributesOfItemAtPath:[url path] error:&error];
o_value = [VLCByteCountFormatter stringFromByteCount:[attributes fileSize] countStyle:NSByteCountFormatterCountStyleDecimal];
}
}
free(psz_value);
}
} NSFileManager *fileManager = [NSFileManager defaultManager];
else if ([o_identifier isEqualToString:@"status"]) { BOOL b_isDir;
if (![fileManager fileExistsAtPath:[url path] isDirectory:&b_isDir] || b_isDir)
return @"";
NSDictionary *attributes = [fileManager attributesOfItemAtPath:[url path] error:nil];
if (!attributes)
return @"";
o_value = [VLCByteCountFormatter stringFromByteCount:[attributes fileSize] countStyle:NSByteCountFormatterCountStyleDecimal];
} else if ([o_identifier isEqualToString:STATUS_COLUMN]) {
if (input_item_HasErrorWhenReading(p_input)) { if (input_item_HasErrorWhenReading(p_input)) {
o_value = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kAlertCautionIcon)]; o_value = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kAlertCautionIcon)];
[o_value setSize: NSMakeSize(16,16)]; [o_value setSize: NSMakeSize(16,16)];
......
...@@ -25,19 +25,6 @@ ...@@ -25,19 +25,6 @@
#import "PXSourceList.h" #import "PXSourceList.h"
/* playlist column definitions */
#define TRACKNUM_COLUMN @"tracknumber"
#define TITLE_COLUMN @"name"
#define ARTIST_COLUMN @"artist"
#define DURATION_COLUMN @"duration"
#define GENRE_COLUMN @"genre"
#define ALBUM_COLUMN @"album"
#define DESCRIPTION_COLUMN @"description"
#define DATE_COLUMN @"date"
#define LANGUAGE_COLUMN @"language"
#define URI_COLUMN @"uri"
#define FILESIZE_COLUMN @"file-size"
/***************************************************************************** /*****************************************************************************
* VLCPlaylistView interface * VLCPlaylistView interface
*****************************************************************************/ *****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment