[Play Counts] Add option to (mass) reset counts

Add option to reset counts for all selected tracks on the playlist.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
lastfm
Christopher Snowhill 2022-06-27 21:50:14 -07:00
parent de43192453
commit 8fc981cb92
3 changed files with 50 additions and 1 deletions

View File

@ -2166,6 +2166,15 @@ Gw
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="stopAfterSelection:" target="218" id="ZRy-Mw-4cY"/> <action selector="stopAfterSelection:" target="218" id="ZRy-Mw-4cY"/>
<binding destination="2020" name="enabled" keyPath="selection" id="lrh-gy-5Z3">
<dictionary key="options">
<integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<string key="NSValueTransformerName">NSIsNotNil</string>
</dictionary>
</binding>
</connections> </connections>
</menuItem> </menuItem>
<menuItem isSeparatorItem="YES" id="2047"/> <menuItem isSeparatorItem="YES" id="2047"/>
@ -2207,8 +2216,27 @@ Gw
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="reloadTags:" target="218" id="Ghx-F8-uF3"/> <action selector="reloadTags:" target="218" id="Ghx-F8-uF3"/>
<binding destination="2020" name="enabled" keyPath="selection" id="DmN-2M-3dY"> <binding destination="2020" name="enabled" keyPath="selection" id="s3T-C1-yR0">
<dictionary key="options"> <dictionary key="options">
<integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<string key="NSValueTransformerName">NSIsNotNil</string>
</dictionary>
</binding>
</connections>
</menuItem>
<menuItem title="Reset Play Count" id="5iV-dM-oX2">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="resetPlaycounts:" target="218" id="M3d-2T-ZRq"/>
<binding destination="2020" name="enabled" keyPath="selection" id="2FG-Dj-1XM">
<dictionary key="options">
<integer key="NSMultipleValuesPlaceholder" value="0"/>
<integer key="NSNoSelectionPlaceholder" value="0"/>
<integer key="NSNotApplicablePlaceholder" value="0"/>
<integer key="NSNullPlaceholder" value="0"/>
<string key="NSValueTransformerName">NSIsNotNil</string> <string key="NSValueTransformerName">NSIsNotNil</string>
</dictionary> </dictionary>
</binding> </binding>

View File

@ -141,6 +141,9 @@ typedef NS_ENUM(NSInteger, URLOrigin) {
// reload metadata of selection // reload metadata of selection
- (IBAction)reloadTags:(id _Nullable)sender; - (IBAction)reloadTags:(id _Nullable)sender;
// Reset playcount of selection
- (IBAction)resetPlaycounts:(id _Nullable)sender;
// Play statistics // Play statistics
- (void)updatePlayCountForTrack:(PlaylistEntry *_Nonnull)pe; - (void)updatePlayCountForTrack:(PlaylistEntry *_Nonnull)pe;
- (void)firstSawTrack:(PlaylistEntry *_Nonnull)pe; - (void)firstSawTrack:(PlaylistEntry *_Nonnull)pe;

View File

@ -282,6 +282,14 @@ static void *playlistControllerContext = &playlistControllerContext;
} }
} }
- (void)resetPlayCountForTrack:(PlaylistEntry *)pe {
PlayCount *pc = pe.playCountItem;
if(pc) {
pc.count = 0;
}
}
- (void)updatePlaylistIndexes { - (void)updatePlaylistIndexes {
NSArray *arranged = [self arrangedObjects]; NSArray *arranged = [self arrangedObjects];
NSUInteger n = [arranged count]; NSUInteger n = [arranged count];
@ -1719,4 +1727,14 @@ static void *playlistControllerContext = &playlistControllerContext;
} }
} }
- (IBAction)resetPlaycounts:(id)sender {
NSArray *selectedobjects = [self selectedObjects];
if([selectedobjects count]) {
for(PlaylistEntry *pe in selectedobjects) {
[self resetPlayCountForTrack:pe];
}
[self commitPersistentStore];
}
}
@end @end