1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-15 18:58:55 +01:00

better names for 'new playlists' generated from the files' tab (Fixes issue #1463)

This commit is contained in:
Paweł Bara 2011-02-15 17:38:45 +00:00
parent b3839cf1d6
commit 88e0beeea9

View File

@ -19,9 +19,10 @@
#include "core/mimedata.h"
#include "ui/iconloader.h"
#include <QMenu>
#include <QContextMenuEvent>
#include <QFileSystemModel>
#include <QMenu>
#include <QSet>
#include <QtDebug>
FileViewList::FileViewList(QWidget* parent)
@ -90,7 +91,24 @@ void FileViewList::AddToPlaylistSlot() {
void FileViewList::OpenInNewPlaylistSlot() {
MimeData* data = MimeDataFromSelection();
data->name_for_new_playlist_ = static_cast<QFileSystemModel*>(model())->rootPath();
QSet<QString> filenames;
foreach(const QString& filename, FilenamesFromSelection()) {
filenames.insert(filename);
if(filenames.size() > 1) {
break;
}
}
// if just one file / folder selected - use it's path as the new playlist's name
if(filenames.size() == 1) {
data->name_for_new_playlist_ = filenames.toList()[0];
// otherwise, use the current root path
} else {
data->name_for_new_playlist_ = static_cast<QFileSystemModel*>(model())->rootPath();
}
emit AddToPlaylist(data);
}