Skip to content

Commit

Permalink
Fix repairing a selection of a playlist
Browse files Browse the repository at this point in the history
Resolves: #196
  • Loading branch information
Borewit committed Sep 18, 2023
1 parent 395652e commit f7a4630
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
20 changes: 11 additions & 9 deletions src/main/java/listfix/model/playlists/Playlist.java
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,14 @@ public List<BatchMatchItem> findClosestMatchesForSelectedEntries(List<Integer> r
return findClosestMatches(entrySelection, libraryFiles, observer);
}

public List<Integer> applyClosestMatchSelections(List<BatchMatchItem> items)
public List<PlaylistEntry> applyClosestMatchSelections(List<BatchMatchItem> items)
{
List<Integer> fixed = new ArrayList<>();
List<PlaylistEntry> fixed = new ArrayList<>();
for (BatchMatchItem item : items)
{
if (item.getSelectedIx() >= 0)
{
int ix = item.getEntryIx();
PlaylistEntry playlistEntry = _entries.get(ix);
final PlaylistEntry playlistEntry = item.getEntry();
if (playlistEntry instanceof FilePlaylistEntry)
{
((FilePlaylistEntry) playlistEntry).update(item.getSelectedMatch().getTrack());
Expand All @@ -736,12 +735,11 @@ public List<Integer> applyClosestMatchSelections(List<BatchMatchItem> items)
{
throw new UnsupportedOperationException("ToDo");
}
PlaylistEntry tempEntry = _entries.get(ix);
tempEntry.recheckFoundStatus();
tempEntry.markFixedIfFound();
if (tempEntry.isFixed())
playlistEntry.recheckFoundStatus();
playlistEntry.markFixedIfFound();
if (playlistEntry.isFixed())
{
fixed.add(ix);
fixed.add(playlistEntry);
}
}
}
Expand Down Expand Up @@ -1035,4 +1033,8 @@ public static synchronized Path getNewPlaylistFilename()
return path;
}

public int indexOf(PlaylistEntry playlistEntry) {
return this._entries.indexOf(playlistEntry);
}

}
5 changes: 3 additions & 2 deletions src/main/java/listfix/view/controls/PlaylistEditCtrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,10 @@ private void findClosestMatches(ProgressWorker<List<BatchMatchItem>, String> wor
if (dlg.isAccepted())
{
_uiTable.clearSelection();
List<Integer> fixed = _playlist.applyClosestMatchSelections(items);
for (Integer fixIx : fixed)
List<PlaylistEntry> fixed = _playlist.applyClosestMatchSelections(items);
for (PlaylistEntry fixEntry : fixed)
{
int fixIx = _playlist.indexOf(fixEntry);
int viewIx = _uiTable.convertRowIndexToView(fixIx);
_uiTable.addRowSelectionInterval(viewIx, viewIx);
}
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/listfix/view/controls/PlaylistsList.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@


/*
* PlaylistsList.java
*
* Created on Apr 2, 2011, 12:11:40 PM
*/

package listfix.view.controls;

import listfix.model.BatchRepair;
Expand All @@ -26,7 +18,6 @@
import java.util.ArrayList;
import java.util.List;


public class PlaylistsList extends JPanel
{
private BatchRepair _batch;
Expand All @@ -41,7 +32,6 @@ public PlaylistsList()
initComponents();
}


public PlaylistsList(BatchRepair batch)
{
_batch = batch;
Expand Down

0 comments on commit f7a4630

Please sign in to comment.