[Spotlight Panel] Fixed to work with new Core Data
Fixed the implementation to work correctly with the new Core Data storage system. Tracks will be garbage collected later. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
c71021fc9b
commit
333c6c7e8b
|
@ -130,7 +130,7 @@ DQ
|
|||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<connections>
|
||||
<binding destination="16" name="value" keyPath="arrangedObjects.lengthText" id="K4A-L7-jOn">
|
||||
<binding destination="16" name="value" keyPath="arrangedObjects.spotlightLength" id="gWF-nL-fqJ">
|
||||
<dictionary key="options">
|
||||
<bool key="NSConditionallySetsEditable" value="YES"/>
|
||||
</dictionary>
|
||||
|
@ -285,9 +285,8 @@ DQ
|
|||
<string>artist</string>
|
||||
<string>album</string>
|
||||
<string>genre</string>
|
||||
<string>lengthText</string>
|
||||
<string>track</string>
|
||||
<string>trackText</string>
|
||||
<string>spotlightLength</string>
|
||||
<string>spotlightTrack</string>
|
||||
</declaredKeys>
|
||||
<classReference key="objectClass" className="PlaylistEntry"/>
|
||||
<connections>
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
<attribute name="sampleRate" optional="YES" attributeType="Float" defaultValueString="0.0" usesScalarValueType="YES"/>
|
||||
<attribute name="seekable" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
|
||||
<attribute name="shuffleIndex" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="spotlightLength" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
|
||||
<attribute name="spotlightTrack" optional="YES" attributeType="String"/>
|
||||
<attribute name="stopAfter" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
|
||||
<attribute name="totalFrames" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="track" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
|
@ -50,7 +52,7 @@
|
|||
<attribute name="year" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
</entity>
|
||||
<elements>
|
||||
<element name="PlaylistEntry" positionX="-36" positionY="9" width="128" height="674"/>
|
||||
<element name="AlbumArtwork" positionX="0" positionY="207" width="128" height="59"/>
|
||||
<element name="PlaylistEntry" positionX="-36" positionY="9" width="128" height="704"/>
|
||||
</elements>
|
||||
</model>
|
|
@ -26,11 +26,16 @@ extern NSPersistentContainer *__persistentContainer;
|
|||
NSArray *artistTransform =
|
||||
@[@"artist", @"AuthorToArtistTransformer"];
|
||||
|
||||
// Track numbers must sometimes be converted from NSNumber to NSString
|
||||
NSArray *trackTransform =
|
||||
@[@"spotlightTrack", @"NumberToStringTransformer"];
|
||||
|
||||
importKeys = @{ @"kMDItemTitle": @"title",
|
||||
@"kMDItemAlbum": @"album",
|
||||
@"kMDItemAudioTrackNumber": @"track",
|
||||
@"kMDItemAudioTrackNumber": trackTransform,
|
||||
@"kMDItemRecordingYear": @"year",
|
||||
@"kMDItemMusicalGenre": @"genre",
|
||||
@"kMDItemDurationSeconds": @"spotlightLength",
|
||||
@"kMDItemPath": URLTransform,
|
||||
@"kMDItemAuthors": artistTransform };
|
||||
}
|
||||
|
@ -38,6 +43,8 @@ extern NSPersistentContainer *__persistentContainer;
|
|||
+ (PlaylistEntry *)playlistEntryWithMetadataItem:(NSMetadataItem *)metadataItem {
|
||||
PlaylistEntry *entry = [NSEntityDescription insertNewObjectForEntityForName:@"PlaylistEntry" inManagedObjectContext:__persistentContainer.viewContext];
|
||||
|
||||
entry.deLeted = YES;
|
||||
|
||||
// loop through the keys we want to extract
|
||||
for(NSString *mdKey in importKeys) {
|
||||
id importTarget = [importKeys objectForKey:mdKey];
|
||||
|
|
|
@ -244,8 +244,8 @@ static NSPredicate *musicOnlyPredicate = nil;
|
|||
if([tracks count] == 0)
|
||||
tracks = playlistController.arrangedObjects;
|
||||
|
||||
[playlistLoader willInsertURLs:[tracks valueForKey:@"URL"] origin:URLOriginExternal];
|
||||
[playlistLoader didInsertURLs:[playlistLoader addURLs:[tracks valueForKey:@"URL"] sort:NO] origin:URLOriginExternal];
|
||||
[playlistLoader willInsertURLs:[tracks valueForKey:@"url"] origin:URLOriginExternal];
|
||||
[playlistLoader didInsertURLs:[playlistLoader addURLs:[tracks valueForKey:@"url"] sort:NO] origin:URLOriginExternal];
|
||||
[self.query enableUpdates];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue