Implemented censored names preference
Added case sensitivity preference Integer tags are not clearable anymore
This commit is contained in:
committed by
Kim Wittenburg
parent
e2bdcd21e5
commit
257a7811d6
@@ -28,21 +28,20 @@ public class Track: iTunesType {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public var clearable: Bool {
|
||||
switch self {
|
||||
case .Year, .TrackNumber, .TrackCount, .DiscNumber, .DiscCount:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a string identifying the respective tag that can be displayed
|
||||
/// to the user.
|
||||
public var localizedName: String {
|
||||
return NSLocalizedString(self.rawValue, comment: "")
|
||||
}
|
||||
|
||||
/// Returns the object that should be saved to *clear* the tag.
|
||||
public var clearedValue: AnyObject? {
|
||||
switch self {
|
||||
case .Year, .TrackNumber, .TrackCount, .DiscNumber, .DiscCount:
|
||||
return ""
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
return NSLocalizedString("Tag: \(self.rawValue)", comment: "")
|
||||
}
|
||||
|
||||
/// Returns an array of all tags.
|
||||
@@ -153,11 +152,10 @@ public class Track: iTunesType {
|
||||
case .Save:
|
||||
track.setValue(value, forKey: tag.rawValue)
|
||||
case .Clear:
|
||||
track.setValue(tag.clearedValue, forKey: tag.rawValue)
|
||||
track.setValue("", forKey: tag.rawValue)
|
||||
case .Ignore:
|
||||
break
|
||||
}
|
||||
track.setValue(value, forKey: tag.rawValue)
|
||||
}
|
||||
|
||||
/// Returns `true` if all `associatedTrack`s contain the same values as the
|
||||
@@ -165,13 +163,22 @@ public class Track: iTunesType {
|
||||
public var saved: Bool {
|
||||
let components = NSCalendar.currentCalendar().components(.Year, fromDate: releaseDate)
|
||||
for track in associatedTracks {
|
||||
guard track.name == name && track.artist == artistName && track.year == components.year && track.trackNumber == trackNumber && track.trackCount == trackCount && track.discNumber == discNumber && track.discCount == discCount && track.genre == genre && track.album == album.name && track.albumArtist == album.artistName && track.composer == "" else {
|
||||
let trackName = Preferences.sharedPreferences.useCensoredNames ? censoredName : name
|
||||
let albumName = Preferences.sharedPreferences.useCensoredNames ? album.censoredName : album.name
|
||||
let options = Preferences.sharedPreferences.caseSensitive ? [] : NSStringCompareOptions.CaseInsensitiveSearch
|
||||
guard track.name.compare(trackName, options: options, range: nil, locale: nil) == .OrderedSame else {
|
||||
return false
|
||||
}
|
||||
guard track.album.compare(albumName, options: options, range: nil, locale: nil) == .OrderedSame else {
|
||||
return false
|
||||
}
|
||||
guard track.artist == artistName && track.year == components.year && track.trackNumber == trackNumber && track.trackCount == trackCount && track.discNumber == discNumber && track.discCount == discCount && track.genre == genre && track.albumArtist == album.artistName && track.composer == "" else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
extension Track: Hashable {
|
||||
|
||||
Reference in New Issue
Block a user