summaryrefslogtreecommitdiff
path: root/nephilim/plugins
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-09-12 20:15:06 +0200
committerAnton Khirnov <wyskas@gmail.com>2009-09-12 20:15:06 +0200
commit530265c9aeb58f8b0120675a90d8ee94638e775c (patch)
tree4c955692a5288abf8128e108f41b0b096fde88d2 /nephilim/plugins
parentbe7260ad246f033479b0a5e4a84bc94ac2dba604 (diff)
Playlist: allow dropping items from library.
Diffstat (limited to 'nephilim/plugins')
-rw-r--r--nephilim/plugins/Playlist.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/nephilim/plugins/Playlist.py b/nephilim/plugins/Playlist.py
index 1e1bedb..b6266cc 100644
--- a/nephilim/plugins/Playlist.py
+++ b/nephilim/plugins/Playlist.py
@@ -19,6 +19,7 @@ from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import QVariant
from ..plugin import Plugin
+from ..common import MIMETYPES
class Playlist(Plugin):
# public, const
@@ -77,13 +78,19 @@ class PlaylistWidget(QtGui.QWidget):
self.setSelectionMode(QtGui.QTreeWidget.ExtendedSelection)
self.setAlternatingRowColors(True)
self.setRootIsDecorated(False)
+
+ # drag&drop
+ self.viewport().setAcceptDrops(True)
+ self.setDropIndicatorShown(True)
+ self.setDragDropMode(QtGui.QAbstractItemView.DropOnly)
+
columns = self.plugin.settings.value(self.plugin.name + '/columns').toStringList()
self.setColumnCount(len(columns))
self.setHeaderLabels(columns)
self.header().restoreState(self.plugin.settings.value(self.plugin.name + '/header_state').toByteArray())
+
self.itemActivated.connect(self._song_activated)
self.header().geometriesChanged.connect(self._save_state)
-
self.plugin.mpclient.playlist_changed.connect(self.fill)
def _save_state(self):
@@ -111,5 +118,19 @@ class PlaylistWidget(QtGui.QWidget):
else:
QtGui.QTreeWidget.keyPressEvent(self, event)
+ def dropMimeData(self, parent, index, data, action):
+ if data.hasFormat(MIMETYPES['songs']):
+ if parent:
+ index = self.indexOfTopLevelItem(parent)
+ self.plugin.mpclient.add(data.songs(), index)
+ return True
+ return False
+
+ def supportedDropActions(self):
+ return QtCore.Qt.CopyAction | QtCore.Qt.MoveAction
+
+ def mimeTypes(self):
+ return [MIMETYPES['songs'], MIMETYPES['plistsongs']]
+
def fill_playlist(self):
self.playlist.fill()