Skip to content

Add an auto remove duplicates for the playlists. - #2046

Open
Vinzzzze wants to merge 1 commit into
strawberrymusicplayer:masterfrom
Vinzzzze:auto_remove_duplicates
Open

Add an auto remove duplicates for the playlists.#2046
Vinzzzze wants to merge 1 commit into
strawberrymusicplayer:masterfrom
Vinzzzze:auto_remove_duplicates

Conversation

@Vinzzzze

@Vinzzzze Vinzzzze commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

When adding tracks to a playlist, you may have tracks in flac format for quality and mp3 format for portable devices, so when you select an album from the library to add to the playlist the flac and the mp3 will be added.
You can use the remove duplicates menu on the playlist, but if you want to have some tracks more than one time in your playlist, it will also delete theses tracks...
So I add the opportunity to automatically delete the duplicates in the added track list.

In the parameters, playlist tab, I add a checkbox to remove the added duplicates.
The data is then forwarded to the playlist object, when tracks are inserted in the playlist (Playlist::InsertSongItems), if the functionality is on, the duplicates are removed (call Playlist::RemoveDuplicateSongs)
Playlist::RemoveDuplicateSongs had been change to work on any track list, not only the playlist's tracklist.

Summary by CodeRabbit

  • New Features
    • Added a configurable “Remove duplicates when adding tracks to the playlist” option in playlist settings.
    • When enabled, duplicate songs are filtered out automatically during track insertion, including batch additions.
    • The preference is persisted and applied to both regular and smart playlist previews.
    • Player settings reload now recognizes the option immediately, without needing a restart.
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 3 times, most recently from e149529 to 59ef7c8 Compare March 29, 2026 21:49
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 4 times, most recently from f6bb3bd to e526c1e Compare April 10, 2026 19:28
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 5 times, most recently from 27886fc to 0861938 Compare April 23, 2026 22:54
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch from 0861938 to b3dee7a Compare April 26, 2026 09:38
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 3 times, most recently from 24086c2 to 2458318 Compare May 10, 2026 21:40
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch from 2458318 to 2ce7e41 Compare May 17, 2026 14:14
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 4 times, most recently from bf4009f to 783eb57 Compare May 31, 2026 14:46
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 2 times, most recently from e30716f to 493735e Compare June 5, 2026 19:18
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 3 times, most recently from 30568cd to 3539075 Compare June 15, 2026 07:18
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a persistent remove-duplicates playlist setting and wires it through the settings UI, playlist construction and insertion, playlist manager state, and runtime settings reload.

Changes

Remove Duplicates Playlist Feature

Layer / File(s) Summary
Settings constant and UI checkbox
src/constants/playlistsettings.h, src/settings/playlistsettingspage.ui, src/settings/playlistsettingspage.cpp
Adds kRemoveDuplicates, adds checkbox_remove_duplicates to the playlist settings page, and loads/saves the checkbox state.
Playlist API structure and declarations
src/playlist/playlist.h
Adds the default constant, constructor parameter, setting updater, helper declarations, duplicate-removal overloads, row-removal overloads, and remove_duplicates_.
Playlist implementation and duplicate removal flow
src/playlist/playlist.cpp
Stores the flag, deduplicates insertion batches when enabled, and applies row removal to the analyzed item list.
PlaylistManager state and propagation
src/playlist/playlistmanager.h, src/playlist/playlistmanager.cpp
Adds the manager flag and getter, propagates updates to loaded playlists, and passes the flag to new playlists.
Player settings reload and smart playlist wiring
src/core/player.cpp, src/smartplaylists/smartplaylistsearchpreview.cpp
Reloads the setting into PlaylistManager and passes the current flag into smart playlist preview construction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Hoppity-hop, a checkbox now gleams,
No duplicate tracks in playlist dreams.
One flag to set, one path to share,
Songs land once, with bunny care.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding automatic duplicate removal for playlists.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/core/player.cpp (1)

154-154: ⚡ Quick win

Use a single source of truth for the remove-duplicates default.

Line [154] uses a literal false; prefer REMOVE_DUPLICATES_DEFAULT to prevent default drift across layers.

Suggested change
-  playlist_manager_->update_setting(s.value(PlaylistSettings::kRemoveDuplicates, false).toBool());
+  playlist_manager_->update_setting(s.value(PlaylistSettings::kRemoveDuplicates, REMOVE_DUPLICATES_DEFAULT).toBool());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/player.cpp` at line 154, The hardcoded literal `false` in the
`playlist_manager_->update_setting()` call at line 154 should be replaced with
the constant `REMOVE_DUPLICATES_DEFAULT` to maintain a single source of truth
for the remove-duplicates default value across all layers of the codebase. This
prevents default drift if the constant is updated in the future.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/core/player.cpp`:
- Line 154: The hardcoded literal `false` in the
`playlist_manager_->update_setting()` call at line 154 should be replaced with
the constant `REMOVE_DUPLICATES_DEFAULT` to maintain a single source of truth
for the remove-duplicates default value across all layers of the codebase. This
prevents default drift if the constant is updated in the future.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e48fa2bd-ae4f-4f54-8324-b76af366da01

📥 Commits

Reviewing files that changed from the base of the PR and between de3ad29 and 3539075.

📒 Files selected for processing (9)
  • src/constants/playlistsettings.h
  • src/core/player.cpp
  • src/playlist/playlist.cpp
  • src/playlist/playlist.h
  • src/playlist/playlistmanager.cpp
  • src/playlist/playlistmanager.h
  • src/settings/playlistsettingspage.cpp
  • src/settings/playlistsettingspage.ui
  • src/smartplaylists/smartplaylistsearchpreview.cpp
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 2 times, most recently from 0cfbecb to 94adbbb Compare June 21, 2026 14:01
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 5 times, most recently from 5125321 to c3b13e8 Compare June 29, 2026 21:13
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 2 times, most recently from e704c5c to f973049 Compare July 5, 2026 15:44
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 4 times, most recently from 2ce5e0b to 7f35b4b Compare July 15, 2026 18:32
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 4 times, most recently from ca766c8 to 35fafa4 Compare July 26, 2026 15:31
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 3 times, most recently from 5f033b2 to e31a931 Compare August 2, 2026 12:12
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 3 times, most recently from 2677525 to 2afdff9 Compare August 12, 2026 18:04
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch 4 times, most recently from 61b3302 to 1936bf4 Compare August 26, 2026 19:16
@Vinzzzze
Vinzzzze force-pushed the auto_remove_duplicates branch from 1936bf4 to b88ec4c Compare August 29, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant