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:
@@ -44,6 +44,7 @@
|
||||
#include <QToolButton>
|
||||
#include <QShowEvent>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMimeData>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
@@ -110,6 +111,7 @@ PlaylistListContainer::PlaylistListContainer(QWidget *parent)
|
||||
|
||||
QObject::connect(ui_->tree, &PlaylistListView::ItemsSelectedChanged, this, &PlaylistListContainer::ItemsSelectedChanged);
|
||||
QObject::connect(ui_->tree, &PlaylistListView::doubleClicked, this, &PlaylistListContainer::ItemDoubleClicked);
|
||||
QObject::connect(ui_->tree, &PlaylistListView::ItemMimeDataDroppedSignal, this, &PlaylistListContainer::ItemMimeDataDropped);
|
||||
|
||||
model_->invisibleRootItem()->setData(PlaylistListModel::Type_Folder, PlaylistListModel::Role_Type);
|
||||
|
||||
@@ -348,6 +350,19 @@ void PlaylistListContainer::ItemDoubleClicked(const QModelIndex &proxy_idx) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistListContainer::ItemMimeDataDropped(const QModelIndex &proxy_idx, const QMimeData *q_mimedata) {
|
||||
|
||||
const QModelIndex idx = proxy_->mapToSource(proxy_idx);
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
// Drop playlist rows if type is playlist and it's not active, to prevent selfcopy
|
||||
int playlis_id = idx.data(PlaylistListModel::Role_PlaylistId).toInt();
|
||||
if (idx.data(PlaylistListModel::Role_Type).toInt() == PlaylistListModel::Type_Playlist && playlis_id != app_->playlist_manager()->active_id()) {
|
||||
app_->playlist_manager()->playlist(playlis_id)->dropMimeData(q_mimedata, Qt::CopyAction, -1, 0, QModelIndex());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PlaylistListContainer::CopyToDevice() {
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
|
||||
Reference in New Issue
Block a user