mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-02 12:26:48 +01:00
Add a menu item for copying songs to devices. Only filesystem devices supported so far
This commit is contained in:
parent
62616304d8
commit
9f2d610e9d
@ -21,6 +21,7 @@
|
||||
#include "filesystemdevice.h"
|
||||
#include "giolister.h"
|
||||
#include "gpoddevice.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/utilities.h"
|
||||
#include "ui/iconloader.h"
|
||||
@ -38,6 +39,7 @@ DeviceStateFilterModel::DeviceStateFilterModel(QObject *parent,
|
||||
: QSortFilterProxyModel(parent),
|
||||
state_(state)
|
||||
{
|
||||
setDynamicSortFilter(true);
|
||||
}
|
||||
|
||||
bool DeviceStateFilterModel::filterAcceptsRow(int row, const QModelIndex&) const {
|
||||
@ -235,6 +237,11 @@ QVariant DeviceManager::data(const QModelIndex& index, int role) const {
|
||||
return QVariant();
|
||||
return info.task_percentage_;
|
||||
|
||||
case MusicStorage::kStorageRole:
|
||||
if (info.device_)
|
||||
return QVariant::fromValue(info.device_->storage());
|
||||
return QVariant();
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -428,6 +435,7 @@ boost::shared_ptr<ConnectedDevice> DeviceManager::Connect(int row) {
|
||||
qWarning() << "Could not create device for" << url.toString();
|
||||
} else {
|
||||
info.device_ = ret;
|
||||
emit dataChanged(index(row), index(row));
|
||||
connect(info.device_.get(), SIGNAL(TaskStarted(int)), SLOT(DeviceTaskStarted(int)));
|
||||
connect(info.device_.get(), SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
}
|
||||
@ -453,6 +461,7 @@ void DeviceManager::Disconnect(int row) {
|
||||
return;
|
||||
|
||||
info.device_.reset();
|
||||
emit dataChanged(index(row), index(row));
|
||||
emit DeviceDisconnected(row);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "libraryview.h"
|
||||
#include "libraryitem.h"
|
||||
#include "librarybackend.h"
|
||||
#include "devices/devicemanager.h"
|
||||
#include "ui/iconloader.h"
|
||||
#include "ui/organisedialog.h"
|
||||
|
||||
@ -93,6 +94,8 @@ LibraryView::LibraryView(QWidget* parent)
|
||||
context_menu_->addSeparator();
|
||||
organise_ = context_menu_->addAction(IconLoader::Load("edit-copy"),
|
||||
tr("Organise files..."), this, SLOT(Organise()));
|
||||
copy_to_device_ = context_menu_->addAction(IconLoader::Load("multimedia-player-ipod-mini-blue"),
|
||||
tr("Copy to device..."), this, SLOT(CopyToDevice()));
|
||||
delete_ = context_menu_->addAction(IconLoader::Load("edit-delete"),
|
||||
tr("Delete from disk..."), this, SLOT(Delete()));
|
||||
context_menu_->addSeparator();
|
||||
@ -118,13 +121,16 @@ void LibraryView::ReloadSettings() {
|
||||
|
||||
void LibraryView::SetTaskManager(TaskManager *task_manager) {
|
||||
organise_dialog_.reset(new OrganiseDialog(task_manager));
|
||||
organise_dialog_->SetDestinationModel(library_->directory_model());
|
||||
}
|
||||
|
||||
void LibraryView::SetLibrary(LibraryModel *library) {
|
||||
library_ = library;
|
||||
}
|
||||
|
||||
void LibraryView::SetDeviceManager(DeviceManager *device_manager) {
|
||||
devices_ = device_manager;
|
||||
}
|
||||
|
||||
void LibraryView::TotalSongCountUpdated(int count) {
|
||||
bool old = total_song_count_;
|
||||
total_song_count_ = count;
|
||||
@ -240,22 +246,34 @@ void LibraryView::scrollTo(const QModelIndex &index, ScrollHint hint) {
|
||||
QTreeView::scrollTo(index, hint);
|
||||
}
|
||||
|
||||
void LibraryView::Organise() {
|
||||
QStringList LibraryView::GetSelectedFilenames() const {
|
||||
QModelIndexList selected_indexes =
|
||||
qobject_cast<QSortFilterProxyModel*>(model())->mapSelectionToSource(
|
||||
selectionModel()->selection()).indexes();
|
||||
SongList songs = library_->GetChildSongs(selected_indexes);
|
||||
QStringList filenames;
|
||||
QStringList ret;
|
||||
|
||||
foreach (const Song& song, songs) {
|
||||
filenames << song.filename();
|
||||
ret << song.filename();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void LibraryView::Organise() {
|
||||
organise_dialog_->SetDestinationModel(library_->directory_model());
|
||||
organise_dialog_->SetCopy(false);
|
||||
organise_dialog_->SetFilenames(filenames);
|
||||
organise_dialog_->SetFilenames(GetSelectedFilenames());
|
||||
organise_dialog_->show();
|
||||
}
|
||||
|
||||
void LibraryView::Delete() {
|
||||
|
||||
}
|
||||
|
||||
void LibraryView::CopyToDevice() {
|
||||
organise_dialog_->SetDestinationModel(devices_->connected_devices_model());
|
||||
organise_dialog_->SetCopy(true);
|
||||
organise_dialog_->SetFilenames(GetSelectedFilenames());
|
||||
organise_dialog_->show();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
class DeviceManager;
|
||||
class LibraryModel;
|
||||
class OrganiseDialog;
|
||||
class TaskManager;
|
||||
@ -44,6 +45,7 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
|
||||
void SetTaskManager(TaskManager* task_manager);
|
||||
void SetLibrary(LibraryModel* library);
|
||||
void SetDeviceManager(DeviceManager* device_manager);
|
||||
|
||||
// QTreeView
|
||||
void keyboardSearch(const QString &search);
|
||||
@ -68,6 +70,7 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
void Load();
|
||||
void AddToPlaylist();
|
||||
void Organise();
|
||||
void CopyToDevice();
|
||||
void Delete();
|
||||
void ShowInVarious();
|
||||
void NoShowInVarious();
|
||||
@ -75,9 +78,12 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
private:
|
||||
void RecheckIsEmpty();
|
||||
void ShowInVarious(bool on);
|
||||
QStringList GetSelectedFilenames() const;
|
||||
|
||||
private:
|
||||
LibraryModel* library_;
|
||||
DeviceManager* devices_;
|
||||
|
||||
int total_song_count_;
|
||||
|
||||
QPixmap nomusic_;
|
||||
@ -87,6 +93,7 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
QAction* load_;
|
||||
QAction* add_to_playlist_;
|
||||
QAction* organise_;
|
||||
QAction* copy_to_device_;
|
||||
QAction* delete_;
|
||||
QAction* show_in_various_;
|
||||
QAction* no_show_in_various_;
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr ""
|
||||
|
||||
|
@ -376,6 +376,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Zkopírovat do knihovny..."
|
||||
|
||||
|
@ -376,6 +376,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Kopiér til bibliotek..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "In die Musiksammlung kopieren..."
|
||||
|
||||
|
@ -383,6 +383,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Αντιγραφή στην βιβλιοθήκη..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Copy to library..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Copy to library..."
|
||||
|
||||
|
@ -377,6 +377,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Copiar a la colección..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Kopioi kirjastoon"
|
||||
|
||||
|
@ -376,6 +376,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Copier dans la bilbiothèque..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Copiar para a biblioteca"
|
||||
|
||||
|
@ -376,6 +376,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Copia nella raccolta..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr ""
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Kopier til bibliotek..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr ""
|
||||
|
||||
|
@ -376,6 +376,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Skopiuj do biblioteki..."
|
||||
|
||||
|
@ -380,6 +380,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Copiar para a biblioteca..."
|
||||
|
||||
|
@ -378,6 +378,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Copiar para biblioteca..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Copiază în bibliotecă..."
|
||||
|
||||
|
@ -374,6 +374,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Копировать в коллекцию..."
|
||||
|
||||
|
@ -380,6 +380,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Skopírovať do zbierky..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Kopiera till bibliotek..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr ""
|
||||
|
||||
|
@ -365,6 +365,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr ""
|
||||
|
||||
|
@ -379,6 +379,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr "Скопіювати до фонотеки..."
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr ""
|
||||
|
||||
|
@ -375,6 +375,9 @@ msgstr ""
|
||||
msgid "Connected"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to device..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to library..."
|
||||
msgstr ""
|
||||
|
||||
|
@ -196,6 +196,7 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
|
||||
ui_->library_view->setModel(library_sort_model_);
|
||||
ui_->library_view->SetLibrary(library_->model());
|
||||
ui_->library_view->SetTaskManager(task_manager_);
|
||||
ui_->library_view->SetDeviceManager(devices_);
|
||||
settings_dialog_->SetLibraryDirectoryModel(library_->model()->directory_model());
|
||||
|
||||
ui_->radio_view->SetModel(radio_model_);
|
||||
|
@ -149,12 +149,13 @@ void OrganiseDialog::InsertTag(const QString &tag) {
|
||||
void OrganiseDialog::UpdatePreviews() {
|
||||
const QModelIndex destination = ui_->destination->model()->index(
|
||||
ui_->destination->currentIndex(), 0);
|
||||
if (!destination.isValid())
|
||||
return;
|
||||
const MusicStorage* storage =
|
||||
destination.data(MusicStorage::kStorageRole).value<MusicStorage*>();
|
||||
MusicStorage* storage = NULL;
|
||||
bool has_local_destination = false;
|
||||
|
||||
const bool has_local_destination = !storage->LocalPath().isEmpty();
|
||||
if (destination.isValid()) {
|
||||
storage = destination.data(MusicStorage::kStorageRole).value<MusicStorage*>();
|
||||
has_local_destination = !storage->LocalPath().isEmpty();
|
||||
}
|
||||
|
||||
// Update the format object
|
||||
format_.set_format(ui_->naming->toPlainText());
|
||||
@ -163,13 +164,13 @@ void OrganiseDialog::UpdatePreviews() {
|
||||
format_.set_replace_the(ui_->replace_the->isChecked());
|
||||
|
||||
const bool format_valid = format_.IsValid();
|
||||
ui_->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(format_valid);
|
||||
ui_->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(format_valid && storage);
|
||||
if (!format_valid)
|
||||
return;
|
||||
|
||||
// Update the previews
|
||||
ui_->preview->clear();
|
||||
ui_->preview->setVisible(has_local_destination);
|
||||
ui_->preview_group->setVisible(has_local_destination);
|
||||
if (has_local_destination) {
|
||||
foreach (const Song& song, preview_songs_) {
|
||||
QString filename = storage->LocalPath() + "/" +
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>639</width>
|
||||
<height>436</height>
|
||||
<height>492</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -114,7 +114,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<widget class="QGroupBox" name="preview_group">
|
||||
<property name="title">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
@ -146,7 +146,9 @@
|
||||
<header>widgets/linetextedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../data/data.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
|
Loading…
x
Reference in New Issue
Block a user