Git commit 693789e1301b6a970a0d41830e6bda4f67b60f6b by Urs Fleisch. Committed on 29/09/2024 at 13:13. Pushed by ufleisch into branch 'master'.
Superfluous imported tracks can be deleted before import This makes it easier to import just a part of the imported tracks, e.g. a single disc from a multi disc album. BUG 493591 M +9 -0 doc/en/index.docbook M +48 -0 src/gui/dialogs/importdialog.cpp M +5 -0 src/gui/dialogs/importdialog.h https://invent.kde.org/multimedia/kid3/-/commit/693789e1301b6a970a0d41830e6bda4f67b60f6b diff --git a/doc/en/index.docbook b/doc/en/index.docbook index 3cbce9fed..9ceee7ad4 100644 --- a/doc/en/index.docbook +++ b/doc/en/index.docbook @@ -1312,6 +1312,15 @@ manually, a track can be dragged with the <mousebutton>left</mousebutton> mouse and then dropped at the new location. </para> <para> +If there are more imported tracks than files, for example if the current folder +contains only the second disc of a two disc album but the tracks of both discs +are imported, it is possible to delete the tracks of the first disc by selecting +them by clicking on the row label of the first track, then clicking on the row +label of the last track of the first disc while holding down the +<keycap>Shift</keycap> key, and finally removing the tracks by pressing the +<keycap>Delete</keycap> key. +</para> +<para> When the import dialog is opened, it contains the actual contents of the tags. The tag type (Tag 1, Tag 2, Tag 1 and Tag 2) can be selected using the <guilabel>Destination</guilabel> combo box. The button on the right of this diff --git a/src/gui/dialogs/importdialog.cpp b/src/gui/dialogs/importdialog.cpp index 0d933584a..6b72aac0f 100644 --- a/src/gui/dialogs/importdialog.cpp +++ b/src/gui/dialogs/importdialog.cpp @@ -259,6 +259,12 @@ ImportDialog::ImportDialog(IPlatformTools* platformTools, connect(okButton, &QAbstractButton::clicked, this, &QDialog::accept); connect(cancelButton, &QAbstractButton::clicked, this, &QDialog::reject); vlayout->addLayout(hlayout); + + auto deleteAction = new QAction(this); + deleteAction->setShortcut(QKeySequence::Delete); + connect(deleteAction, &QAction::triggered, + this, &ImportDialog::deleteSelectedTableRows); + addAction(deleteAction); } /** @@ -588,6 +594,48 @@ void ImportDialog::moveTableRow(int, int fromIndex, int toIndex) { } } +/** + * Delete the selected table rows. + */ +void ImportDialog::deleteSelectedTableRows() +{ + QSet<int> rows; + const QModelIndexList selectedRows = + m_trackDataTable->selectionModel()->selectedRows(); + for (const QModelIndex& index : selectedRows) { + rows.insert(index.row()); + } + if (rows.isEmpty()) { + if (auto index = m_trackDataTable->currentIndex(); index.isValid()) { + rows.insert(index.row()); + } + } + if (!rows.isEmpty()) { + ImportTrackDataVector trackDataVector(m_trackDataModel->getTrackData()); + int numTracks = trackDataVector.size(); + int fromIndex = 0; + for (auto toIt = trackDataVector.begin(), fromIt = trackDataVector.begin(); + toIt != trackDataVector.end();) { + if (fromIndex >= numTracks) { + trackDataVector.erase(toIt, trackDataVector.end()); + break; + } + if (!rows.contains(fromIndex)) { + if (toIt != fromIt) { + toIt->setFrameCollection(fromIt->getFrameCollection()); + toIt->setImportDuration(fromIt->getImportDuration()); + } + ++toIt; + } + ++fromIt; + ++fromIndex; + } + m_trackDataModel->setTrackData(trackDataVector); + // redisplay the table + showPreview(); + } +} + /** * Called when the destination combo box value is changed. */ diff --git a/src/gui/dialogs/importdialog.h b/src/gui/dialogs/importdialog.h index 0a904b7c5..b7f92c0c7 100644 --- a/src/gui/dialogs/importdialog.h +++ b/src/gui/dialogs/importdialog.h @@ -125,6 +125,11 @@ private slots: */ void moveTableRow(int, int fromIndex, int toIndex); + /** + * Delete the selected table rows. + */ + void deleteSelectedTableRows(); + /** * Import from server and preview in table. */