Using library item's name instead of generic text 'Playlist' when creating new playlist by DnD from the library, or when using 'Open in new playlist'

This commit is contained in:
Arnaud Bienner 2011-02-14 23:06:36 +00:00
parent 7221d93888
commit 4d58e75e0a
2 changed files with 10 additions and 1 deletions

View File

@ -918,6 +918,11 @@ QMimeData* LibraryModel::mimeData(const QModelIndexList& indexes) const {
QSet<int> song_ids;
data->backend = backend_;
if(!indexes.isEmpty()) {
// Give a "name" to the mime data. Will be used for naming playlist, if needed
data->setText(IndexToItem(indexes.first())->DisplayText());
}
foreach (const QModelIndex& index, indexes) {
GetChildSongs(IndexToItem(index), &urls, &data->songs, &song_ids);

View File

@ -208,7 +208,11 @@ void PlaylistTabBar::timerEvent(QTimerEvent* e) {
void PlaylistTabBar::dropEvent(QDropEvent* e) {
if (drag_hover_tab_ == -1) {
manager_->New(tr("Playlist"));
if(e->mimeData()->text().isEmpty()) {
manager_->New(tr("Playlist"));
} else {
manager_->New(e->mimeData()->text());
}
setCurrentIndex(count() - 1);
} else {
setCurrentIndex(drag_hover_tab_);