Allow drag and drop of songs to favorite playlists

- allows adding songs from active playlist
to any favorite by drag & drop
- after 500msec hovering with the songs over
desired playlist it becomes current
- drag & drop multiple songs is supported
This commit is contained in:
Sergei B
2023-11-03 18:34:30 +01:00
committed by Jonas Kvinge
parent c52fc90306
commit 661615e546
4 changed files with 105 additions and 0 deletions

View File

@@ -24,6 +24,7 @@
#include "config.h"
#include <QBasicTimer>
#include <QObject>
#include <QWidget>
#include <QString>
@@ -31,6 +32,11 @@
#include "widgets/autoexpandingtreeview.h"
class QPaintEvent;
class QDragEnterEvent;
class QDragLeaveEvent;
class QDragMoveEvent;
class QDropEvent;
class QTimerEvent;
class PlaylistListView : public AutoExpandingTreeView {
Q_OBJECT
@@ -42,11 +48,23 @@ class PlaylistListView : public AutoExpandingTreeView {
signals:
void ItemsSelectedChanged(const bool);
void ItemMimeDataDroppedSignal(const QModelIndex &proxy_idx, const QMimeData *q_mimedata);
protected:
// QWidget
void paintEvent(QPaintEvent *event) override;
void selectionChanged(const QItemSelection&, const QItemSelection&) override;
void dragEnterEvent(QDragEnterEvent *e) override;
void dragMoveEvent(QDragMoveEvent *e) override;
void dragLeaveEvent(QDragLeaveEvent *e) override;
void dropEvent(QDropEvent *e) override;
void timerEvent(QTimerEvent *e) override;
private:
static const int kDragHoverTimeout = 500;
QBasicTimer drag_hover_timer_;
};
#endif // PLAYLISTVIEW_H