Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WTrackMenu: add Remove From Disk action #3212

Merged
merged 29 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0e16a27
WTrackMenu: add capabilty RemoveFromDisk, add to Tracks, Hidden, Crates
ronso0 Oct 28, 2020
00b64fb
WTrackMenu > Remove from disk: add action, slot and TrackPointerOpera…
ronso0 Oct 28, 2020
836313c
Merge remote-tracking branch 'mixxx/main' into remove-from-disk
ronso0 Oct 30, 2020
7688b29
WTrackMenu: use QListWidget for track file deletion dialogs
ronso0 Nov 23, 2020
0511df7
Merge remote-tracking branch 'mixxx/main' into remove-from-disk
ronso0 Feb 17, 2021
a5b509d
WTrackMenu: allow Remove From Disk in Browse & Recording
ronso0 Feb 20, 2021
a4e9f71
WTrackMenu: improve format of Delete warning
ronso0 Feb 20, 2021
7300104
Remove from disk: rename variables
ronso0 Jun 14, 2021
4769018
widgethelper: add method to stretch QListWidget to show all content
ronso0 Jun 14, 2021
ac6c35f
Remove from disk: stretch dialog to show all files
ronso0 Jun 14, 2021
c739434
Merge remote-tracking branch 'mixxx/main' into remove-from-disk
ronso0 Jun 14, 2021
42952ad
Remove from disk: clean up comments
ronso0 Aug 31, 2021
d3c089d
Merge remote-tracking branch 'mixxx/main' into remove-from-disk
ronso0 Aug 31, 2021
7fb7783
WTrackMenu: move Delete Files into own submenu, rename Remove > Delete
ronso0 Aug 31, 2021
5227e9e
Hidden Tracks: add 'Delete & Purge' button
ronso0 Aug 31, 2021
c066ac7
Merge remote-tracking branch 'mixxx/main' into remove-from-disk
ronso0 Sep 20, 2021
8a59dbf
reword track delete dialogs
ronso0 Oct 1, 2021
2250522
move setMinimumSize() to widgethelper
ronso0 Oct 1, 2021
0f59bd8
make purged/keep list members of TrackPointerOperation
ronso0 Oct 1, 2021
394e338
explain why we must purge tracks AFTER the batch operation
ronso0 Oct 1, 2021
f92d287
Merge remote-tracking branch 'mixxx/main' into remove-from-disk
ronso0 Nov 14, 2021
d84c8a3
create QDialogs on the stack
ronso0 Nov 14, 2021
3a06d9c
refine comment in RemoveTrackFilesFromDiskTrackPointerOperation
ronso0 Nov 14, 2021
8a2130f
instantiate dialog ingredients just before they're needed
ronso0 Nov 14, 2021
9187e38
remove files from disk: de-duplicate file list
ronso0 Nov 23, 2021
f1b20af
remove files from disk: fix comment typo
ronso0 Nov 23, 2021
e9b70a6
remove files from disk: replace length() > 0 with isEmpty()
ronso0 Nov 23, 2021
ed79726
WTrackTableView: use QModelIndexList::isEmpty(), return early
ronso0 Nov 23, 2021
ab31361
const ref purge/keep track lists, more const
ronso0 Nov 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/library/browse/browsetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ TrackModel::Capabilities BrowseTableModel::getCapabilities() const {
Capability::AddToAutoDJ |
Capability::LoadToDeck |
Capability::LoadToPreviewDeck |
Capability::LoadToSampler;
Capability::LoadToSampler |
Capability::RemoveFromDisk;
}

Qt::ItemFlags BrowseTableModel::flags(const QModelIndex& index) const {
Expand Down
13 changes: 12 additions & 1 deletion src/library/dlghidden.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ DlgHidden::DlgHidden(
m_pHiddenTableModel = new HiddenTableModel(this, pLibrary->trackCollectionManager());
m_pTrackTableView->loadTrackModel(m_pHiddenTableModel);

// set up button connections
connect(btnUnhide,
&QPushButton::clicked,
m_pTrackTableView,
Expand All @@ -52,10 +53,19 @@ DlgHidden::DlgHidden(
&QPushButton::clicked,
this,
&DlgHidden::clicked);
connect(btnDelete,
&QPushButton::clicked,
m_pTrackTableView,
&WTrackTableView::slotDeleteTracksFromDisk);
connect(btnDelete,
&QPushButton::clicked,
this,
&DlgHidden::clicked);
connect(btnSelect,
&QPushButton::clicked,
this,
&DlgHidden::selectAll);
// set up common track table view connections
connect(m_pTrackTableView->selectionModel(),
&QItemSelectionModel::selectionChanged,
this,
Expand Down Expand Up @@ -110,8 +120,9 @@ void DlgHidden::selectAll() {
}

void DlgHidden::activateButtons(bool enable) {
btnPurge->setEnabled(enable);
btnUnhide->setEnabled(enable);
btnPurge->setEnabled(enable);
btnDelete->setEnabled(enable);
}

void DlgHidden::selectionChanged(const QItemSelection &selected,
Expand Down
16 changes: 16 additions & 0 deletions src/library/dlghidden.ui
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnDelete">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Purge selected tracks from the library and delete files from disk.</string>
</property>
<property name="text">
<string>Purge And Delete Files</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down
4 changes: 3 additions & 1 deletion src/library/hiddentablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,7 @@ Qt::ItemFlags HiddenTableModel::flags(const QModelIndex& index) const {
}

TrackModel::Capabilities HiddenTableModel::getCapabilities() const {
return Capability::Purge | Capability::Unhide;
return Capability::Purge |
Capability::Unhide |
Capability::RemoveFromDisk;
}
3 changes: 2 additions & 1 deletion src/library/librarytablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@ TrackModel::Capabilities LibraryTableModel::getCapabilities() const {
Capability::LoadToSampler |
Capability::LoadToPreviewDeck |
Capability::Hide |
Capability::ResetPlayed;
Capability::ResetPlayed |
Capability::RemoveFromDisk;
}
1 change: 1 addition & 0 deletions src/library/trackmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TrackModel {
Purge = 1u << 13u,
RemovePlaylist = 1u << 14u,
RemoveCrate = 1u << 15u,
RemoveFromDisk = 1u << 16u,
};
Q_DECLARE_FLAGS(Capabilities, Capability)

Expand Down
3 changes: 2 additions & 1 deletion src/library/trackset/crate/cratetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ TrackModel::Capabilities CrateTableModel::getCapabilities() const {
Capability::LoadToSampler |
Capability::LoadToPreviewDeck |
Capability::RemoveCrate |
Capability::ResetPlayed;
Capability::ResetPlayed |
Capability::RemoveFromDisk;

if (m_selectedCrate.isValid()) {
Crate crate;
Expand Down
28 changes: 28 additions & 0 deletions src/util/widgethelper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "util/widgethelper.h"

#include <QScreen>
#include <QStyle>

#include "util/math.h"

Expand Down Expand Up @@ -47,6 +48,33 @@ QWindow* getWindow(
return nullptr;
}

void growListWidget(QListWidget& listWidget, const QWidget& parent) {
// Try to display all files and the complete file locations to avoid
// horizontal scrolling.
// Get the screen dimensions
QScreen* const pScreen = getScreen(parent);
QSize screenSpace;
VERIFY_OR_DEBUG_ASSERT(pScreen) {
qWarning() << "Screen not detected. Assuming screen size of 800x600px.";
screenSpace = QSize(800, 600);
}
else {
screenSpace = pScreen->size();
}
// Calculate the dimensions of the file list to show all.
int margin = 2 * listWidget.frameWidth() +
listWidget.style()->pixelMetric(QStyle::PM_ScrollBarExtent);
int minW = listWidget.sizeHintForColumn(0) + margin;
int minH = listWidget.sizeHintForRow(0) * listWidget.count() + margin;
// The file list should fit into the window, but clamp to 90% of screen size.
int newW = std::min(minW, static_cast<int>(screenSpace.width() * 0.9));
int newH = std::min(minH, static_cast<int>(screenSpace.height() * 0.9));
// Apply new size
if (newW > 0 && newH > 0) {
listWidget.setMinimumSize(newW, newH);
}
}

} // namespace widgethelper

} // namespace mixxx
4 changes: 4 additions & 0 deletions src/util/widgethelper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <QListWidget>
#include <QPoint>
#include <QSize>
#include <QWidget>
Expand Down Expand Up @@ -49,6 +50,9 @@ inline QScreen* getScreen(
#endif
}

/// QSize for stretching a list widget attempting to show entire column
void growListWidget(QListWidget& listWidget, const QWidget& parent);

} // namespace widgethelper

} // namespace mixxx
Loading