1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-02-01 20:06:53 +01:00

Add support for deleting files from the filesystem, devices, and ipods.

This commit is contained in:
David Sansome 2010-07-31 16:12:16 +00:00
parent 5a1fe772ac
commit 1f2b69c6bc
48 changed files with 799 additions and 12 deletions

View File

@ -35,6 +35,7 @@ set(SOURCES
core/backgroundthread.cpp
core/commandlineoptions.cpp
core/database.cpp
core/deletefiles.cpp
core/filesystemmusicstorage.cpp
core/fht.cpp
core/globalshortcutbackend.cpp
@ -171,6 +172,7 @@ set(HEADERS
core/albumcoverloader.h
core/backgroundthread.h
core/database.h
core/deletefiles.h
core/globalshortcuts.h
core/gnomeglobalshortcutbackend.h
core/mergedproxymodel.h

99
src/core/deletefiles.cpp Normal file
View File

@ -0,0 +1,99 @@
/* This file is part of Clementine.
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "deletefiles.h"
#include "musicstorage.h"
#include "taskmanager.h"
#include <QStringList>
#include <QTimer>
#include <QThread>
const int DeleteFiles::kBatchSize = 50;
DeleteFiles::DeleteFiles(TaskManager* task_manager, MusicStorage* storage)
: thread_(NULL),
task_manager_(task_manager),
storage_(storage),
started_(false),
task_id_(0),
progress_(0)
{
original_thread_ = thread();
}
void DeleteFiles::Start(const SongList& songs) {
if (thread_)
return;
songs_ = songs;
task_id_ = task_manager_->StartTask(tr("Deleting files"));
task_manager_->SetTaskBlocksLibraryScans(true);
thread_ = new QThread;
connect(thread_, SIGNAL(started()), SLOT(ProcessSomeFiles()));
moveToThread(thread_);
thread_->start();
}
void DeleteFiles::Start(const QStringList& filenames) {
SongList songs;
foreach (const QString& filename, filenames) {
Song song;
song.set_filename(filename);
songs << song;
}
Start(songs);
}
void DeleteFiles::ProcessSomeFiles() {
if (!started_) {
storage_->StartDelete();
started_ = true;
}
// None left?
if (progress_ >= songs_.count()) {
task_manager_->SetTaskProgress(task_id_, progress_, songs_.count());
storage_->FinishCopy();
task_manager_->SetTaskFinished(task_id_);
// Move back to the original thread so deleteLater() can get called in
// the main thread's event loop
moveToThread(original_thread_);
deleteLater();
// Stop this thread
thread_->quit();
return;
}
// We process files in batches so we can be cancelled part-way through.
const int n = qMin(songs_.count(), progress_ + kBatchSize);
for ( ; progress_<n ; ++progress_) {
task_manager_->SetTaskProgress(task_id_, progress_, songs_.count());
storage_->DeleteFromStorage(songs_.at(progress_));
}
QTimer::singleShot(0, this, SLOT(ProcessSomeFiles()));
}

55
src/core/deletefiles.h Normal file
View File

@ -0,0 +1,55 @@
/* This file is part of Clementine.
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DELETEFILES_H
#define DELETEFILES_H
#include <QObject>
#include "song.h"
class MusicStorage;
class TaskManager;
class DeleteFiles : public QObject {
Q_OBJECT
public:
DeleteFiles(TaskManager* task_manager, MusicStorage* storage);
static const int kBatchSize;
void Start(const SongList& songs);
void Start(const QStringList& filenames);
private slots:
void ProcessSomeFiles();
private:
QThread* thread_;
QThread* original_thread_;
TaskManager* task_manager_;
MusicStorage* storage_;
SongList songs_;
bool started_;
int task_id_;
int progress_;
};
#endif // DELETEFILES_H

View File

@ -47,3 +47,7 @@ bool FilesystemMusicStorage::CopyToStorage(
else
return QFile::copy(source, dest_filename);
}
bool FilesystemMusicStorage::DeleteFromStorage(const Song& metadata) {
return QFile::remove(metadata.filename());
}

View File

@ -28,6 +28,7 @@ public:
bool CopyToStorage(const QString &source, const QString &destination,
const Song &metadata, bool overwrite, bool remove_original);
bool DeleteFromStorage(const Song& metadata);
private:
QString root_;

View File

@ -39,6 +39,11 @@ public:
const Song& metadata, bool overwrite,
bool remove_original) = 0;
virtual void FinishCopy() {}
virtual void StartDelete() {}
virtual bool DeleteFromStorage(const Song& metadata) = 0;
virtual void FinishDelete() {}
virtual void Eject() {}
};

View File

@ -18,6 +18,7 @@
#include "devicemanager.h"
#include "deviceproperties.h"
#include "deviceview.h"
#include "core/deletefiles.h"
#include "core/mergedproxymodel.h"
#include "library/librarydirectorymodel.h"
#include "library/librarymodel.h"
@ -206,6 +207,14 @@ QModelIndex DeviceView::MapToDevice(const QModelIndex& merged_model_index) const
return sort_model_->mapToSource(sort_model_index);
}
QModelIndex DeviceView::FindParentDevice(const QModelIndex& merged_model_index) const {
QModelIndex index = merged_model_->FindSourceParent(merged_model_index);
if (index.model() != sort_model_)
return QModelIndex();
return sort_model_->mapToSource(index);
}
QModelIndex DeviceView::MapToLibrary(const QModelIndex& merged_model_index) const {
QModelIndex sort_model_index = merged_model_->mapToSource(merged_model_index);
if (const QSortFilterProxyModel* sort_model =
@ -323,7 +332,23 @@ void DeviceView::AddToPlaylist() {
}
void DeviceView::Delete() {
if (selectedIndexes().isEmpty())
return;
// Take the device of the first selected item
QModelIndex device_index = FindParentDevice(selectedIndexes()[0]);
if (!device_index.isValid())
return;
if (QMessageBox::question(this, tr("Delete files"),
tr("These files will be deleted from the device, are you sure you want to continue?"),
QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes)
return;
MusicStorage* storage = device_index.data(MusicStorage::Role_Storage).value<MusicStorage*>();
DeleteFiles* delete_files = new DeleteFiles(manager_->task_manager(), storage);
delete_files->Start(GetSelectedSongs());
}
void DeviceView::Organise() {

View File

@ -78,6 +78,7 @@ private slots:
private:
QModelIndex MapToDevice(const QModelIndex& merged_model_index) const;
QModelIndex MapToLibrary(const QModelIndex& merged_model_index) const;
QModelIndex FindParentDevice(const QModelIndex& merged_model_index) const;
SongList GetSelectedSongs() const;
private:

View File

@ -67,7 +67,7 @@ void GPodDevice::StartCopy() {
}
// Ensure only one "organise files" can be active at any one time
copy_in_progress_.lock();
db_busy_.lock();
}
bool GPodDevice::CopyToStorage(
@ -128,6 +128,55 @@ void GPodDevice::FinishCopy() {
}
songs_to_add_.clear();
copy_in_progress_.unlock();
db_busy_.unlock();
}
void GPodDevice::StartDelete() {
StartCopy();
}
bool GPodDevice::DeleteFromStorage(const Song& metadata) {
Q_ASSERT(db_);
// Find the track in the itdb, identify it by its filename
Itdb_Track* track = NULL;
for (GList* tracks = db_->tracks ; tracks != NULL ; tracks = tracks->next) {
Itdb_Track* t = static_cast<Itdb_Track*>(tracks->data);
itdb_filename_ipod2fs(t->ipod_path);
if (url_.path() + t->ipod_path == metadata.filename()) {
track = t;
break;
}
}
if (track == NULL) {
qWarning() << "Couldn't find song" << metadata.filename() << "in iTunesDB";
return false;
}
// Remove the track from all playlists
for (GList* playlists = db_->playlists ; playlists != NULL ; playlists = playlists->next) {
Itdb_Playlist* playlist = static_cast<Itdb_Playlist*>(playlists->data);
if (itdb_playlist_contains_track(playlist, track)) {
itdb_playlist_remove_track(playlist, track);
}
}
// Remove the track from the database, this frees the struct too
itdb_track_remove(track);
// Remove the file
QFile::remove(metadata.filename());
// Remove it from our library model
backend_->DeleteSongs(SongList() << metadata);
return true;
}
void GPodDevice::FinishDelete() {
FinishCopy();
}

View File

@ -44,6 +44,10 @@ public:
const Song &metadata, bool overwrite, bool remove_original);
void FinishCopy();
void StartDelete();
bool DeleteFromStorage(const Song& metadata);
void FinishDelete();
private slots:
void LoadFinished(Itdb_iTunesDB* db);
@ -55,7 +59,7 @@ private:
QMutex db_mutex_;
Itdb_iTunesDB* db_;
QMutex copy_in_progress_;
QMutex db_busy_;
SongList songs_to_add_;
};

View File

@ -19,6 +19,8 @@
#include "libraryview.h"
#include "libraryitem.h"
#include "librarybackend.h"
#include "core/deletefiles.h"
#include "core/musicstorage.h"
#include "devices/devicemanager.h"
#include "devices/devicestatefiltermodel.h"
#include "ui/iconloader.h"
@ -27,6 +29,7 @@
#include <QPainter>
#include <QContextMenuEvent>
#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
#include <QSettings>
@ -105,8 +108,6 @@ LibraryView::LibraryView(QWidget* parent)
no_show_in_various_ = context_menu_->addAction(
tr("Don't show in various artists"), this, SLOT(NoShowInVarious()));
delete_->setVisible(false); // TODO
ReloadSettings();
}
@ -121,6 +122,7 @@ void LibraryView::ReloadSettings() {
}
void LibraryView::SetTaskManager(TaskManager *task_manager) {
task_manager_ = task_manager;
organise_dialog_.reset(new OrganiseDialog(task_manager));
}
@ -251,19 +253,25 @@ void LibraryView::scrollTo(const QModelIndex &index, ScrollHint hint) {
}
void LibraryView::GetSelectedFileInfo(
QStringList *filenames, quint64 *size) const {
QStringList *filenames, quint64 *size, SongList* songs_out) const {
QModelIndexList selected_indexes =
qobject_cast<QSortFilterProxyModel*>(model())->mapSelectionToSource(
selectionModel()->selection()).indexes();
SongList songs = library_->GetChildSongs(selected_indexes);
*size = 0;
foreach (const Song& song, songs) {
*filenames << song.filename();
if (size)
*size = 0;
if (song.filesize() >= 0)
foreach (const Song& song, songs) {
if (filenames)
*filenames << song.filename();
if (size && song.filesize() >= 0)
*size += song.filesize();
}
if (songs_out)
*songs_out = songs;
}
void LibraryView::Organise() {
@ -278,7 +286,24 @@ void LibraryView::Organise() {
}
void LibraryView::Delete() {
SongList songs;
GetSelectedFileInfo(NULL, NULL, &songs);
if (songs.isEmpty())
return;
if (QMessageBox::question(this, tr("Delete files"),
tr("These files will be deleted from disk, are you sure you want to continue?"),
QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes)
return;
// We can cheat and always take the storage of the first directory, since
// they'll all be FilesystemMusicStorage in a library and deleting doesn't
// check the actual directory.
MusicStorage* storage = library_->directory_model()->index(0, 0).data(
MusicStorage::Role_Storage).value<MusicStorage*>();
DeleteFiles* delete_files = new DeleteFiles(task_manager_, storage);
delete_files->Start(songs);
}
void LibraryView::CopyToDevice() {

View File

@ -17,6 +17,7 @@
#ifndef LIBRARYVIEW_H
#define LIBRARYVIEW_H
#include "core/song.h"
#include "widgets/autoexpandingtreeview.h"
#include <QStyledItemDelegate>
@ -78,11 +79,12 @@ class LibraryView : public AutoExpandingTreeView {
private:
void RecheckIsEmpty();
void ShowInVarious(bool on);
void GetSelectedFileInfo(QStringList* filenames, quint64* size) const;
void GetSelectedFileInfo(QStringList* filenames, quint64* size, SongList* songs = NULL) const;
private:
LibraryModel* library_;
DeviceManager* devices_;
TaskManager* task_manager_;
int total_song_count_;

View File

@ -473,6 +473,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr ""
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1534,6 +1540,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "سيتم فحص الملفات الصوتية الموجودة في هذه الملفات لإضافتها لمكتبتك"

View File

@ -473,6 +473,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr ""
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1534,6 +1540,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -474,6 +474,9 @@ msgstr "Snížit hlasitost"
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -489,6 +492,9 @@ msgstr "Smazat předvolbu"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1538,6 +1544,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "Tyto složky budou prohledány a nalezená hudba bude přidána do knihovny"

View File

@ -474,6 +474,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -489,6 +492,9 @@ msgstr "Slet forudindstilling"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1541,6 +1547,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "Disse mapper vil blive scannet for musik til at opbygget dit bibliotek"

View File

@ -482,6 +482,9 @@ msgstr "Lautstärke verringern"
msgid "Delay between visualizations"
msgstr "Verzögerung zwischen Visualisierungen"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Dateien löschen..."
@ -497,6 +500,9 @@ msgstr "Voreinstellung löschen"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Stücke aus der Warteschlange nehmen"
@ -1553,6 +1559,15 @@ msgstr "Die Wiedergabeliste \"%1\" ist leer oder konnte nicht geladen werden."
msgid "There was a problem fetching the metadata from Magnatune"
msgstr "Beim Holen der Metadaten von Magnatune ist ein Fehler aufgetreten"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "Diese Ordner werden für Ihre Musiksammlung durchsucht"

View File

@ -485,6 +485,9 @@ msgstr "Μείωση έντασης"
msgid "Delay between visualizations"
msgstr "Καθυστέρηση μεταξύ οπτικών εφέ"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Διαγραφή αρχείων..."
@ -500,6 +503,9 @@ msgstr "Διαγραφή ρύθμισης"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Αφαίρεση των επιλεγμένων κομματιών από την λίστα αναμονής"
@ -1556,6 +1562,15 @@ msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
"Υπήρξε κάποιο σφάλμα κατά την μεταφορά των μετα-δεδομένων από το Magnatune"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "Οι φάκελοι αυτοί θα σαρωθούν για μουσικά αρχεία για την βιβλιοθήκη σας"

View File

@ -475,6 +475,9 @@ msgstr "Decrease volume"
msgid "Delay between visualizations"
msgstr "Delay between visualisations"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -490,6 +493,9 @@ msgstr "Delete preset"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1539,6 +1545,15 @@ msgstr "The playlist '%1' was empty or could not be loaded."
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "These folders will be scanned for music to make up your library"

View File

@ -473,6 +473,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr "Delay between visualisations"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr "Delete preset"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1536,6 +1542,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "These folders will be scanned for music to make up your library"

View File

@ -485,6 +485,9 @@ msgstr "Disminuir volumen"
msgid "Delay between visualizations"
msgstr "Retardo entre visualizaciones"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Eliminar archivos..."
@ -500,6 +503,9 @@ msgstr "Eliminar predefinición"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1559,6 +1565,15 @@ msgstr "La lista de reproducción '%1' estaba vacía o no pudo ser cargada."
msgid "There was a problem fetching the metadata from Magnatune"
msgstr "Hubo un problema obteniendo los metadatos desde Magnatune"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""
"Estas carpetas serán analizadas en busca de música para crear su colección"

View File

@ -473,6 +473,9 @@ msgstr "Vähennä äänenvoimakkuutta"
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Poista tiedostot..."
@ -488,6 +491,9 @@ msgstr ""
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1536,6 +1542,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -478,6 +478,9 @@ msgstr "Diminuer le volume"
msgid "Delay between visualizations"
msgstr "Délai entre les visualisations"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Supprimer les fichiers…"
@ -493,6 +496,9 @@ msgstr "Effacer le pré-réglage"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Enlever les pistes sélectionnées de la file d'attente"
@ -1546,6 +1552,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""
"Ces dossiers seront analysés pour trouver les fichiers qui constitueront "

View File

@ -473,6 +473,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr "Eliminar predefinido"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1536,6 +1542,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -484,6 +484,9 @@ msgstr "Riduci il volume"
msgid "Delay between visualizations"
msgstr "Ritardo tra le visualizzazioni"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Elimina file..."
@ -499,6 +502,9 @@ msgstr "Elimina la preimpostazione"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Rimuovi le tracce selezionate dalla coda"
@ -1560,6 +1566,15 @@ msgstr ""
"Si è verificato un problema durante il recupero dei dati aggiuntivi da "
"Magnatune"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""
"Queste cartelle saranno analizzate alla ricerca di musica per creare la tua "

View File

@ -473,6 +473,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr ""
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1536,6 +1542,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -473,6 +473,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr ""
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1534,6 +1540,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -473,6 +473,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr "Slett forhåndsinnstilling"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1537,6 +1543,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""
"Disse katalogene vil skannes for musikk som kan legges til biblioteket ditt"

View File

@ -481,6 +481,9 @@ msgstr "Volume verlagen"
msgid "Delay between visualizations"
msgstr "Vertraging tussen visualisaties"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Bestanden wissen..."
@ -496,6 +499,9 @@ msgstr "Voorinstelling verwijderen"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Geselecteerde tracks uit wachtrij verwijderen"
@ -1554,6 +1560,15 @@ msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
"Er is een probleem opgetreden bij het ophalen van de metadata van Magnatune"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""
"Deze mappen zullen worden doorzocht op muziek dat uw bibliotheek zal vormen"

View File

@ -473,6 +473,9 @@ msgstr "Reduire lo volum"
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr "Escafar un prereglatge"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1534,6 +1540,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -479,6 +479,9 @@ msgstr "Zmniejsz głośność"
msgid "Delay between visualizations"
msgstr "Opóźnienie pomiędzy wizualizacjami"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Usuń pliki..."
@ -494,6 +497,9 @@ msgstr "Usuń ustawienia korektora"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1545,6 +1551,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "Te katalogi będą skanowane w poszukiwaniu muzyki"

View File

@ -482,6 +482,9 @@ msgstr "Diminuir volume"
msgid "Delay between visualizations"
msgstr "Atraso entre visualizações"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Apagar ficheiros..."
@ -497,6 +500,9 @@ msgstr "Apagar pré-ajustes"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Retiras da fila as faixas seleccionadas"
@ -1550,6 +1556,15 @@ msgstr "A lista de reprodução '%1' está vazia ou não pôde ser carregada."
msgid "There was a problem fetching the metadata from Magnatune"
msgstr "Ocorreu um problema ao obter os meta-dados Magnatune"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "Estas pastas irão ser analisadas para criar a sua biblioteca"

View File

@ -478,6 +478,9 @@ msgstr "Diminuir volume"
msgid "Delay between visualizations"
msgstr "Atraso entre as visualizações"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Remover arquivos..."
@ -493,6 +496,9 @@ msgstr "Apagar pré-regulagem"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1546,6 +1552,15 @@ msgstr "A lista de reprodução '%1' está vazia ou não pode ser carregada."
msgid "There was a problem fetching the metadata from Magnatune"
msgstr "Há um problema ao buscar o arquivo multimídia no Magnatune"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""
"As pastas serão escaneadas em busca de músicas para montar sua biblioteca"

View File

@ -473,6 +473,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr "Şterge presetări"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1535,6 +1541,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -480,6 +480,9 @@ msgstr "Уменьшить громкость"
msgid "Delay between visualizations"
msgstr "Задержка между визуализациями"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Удалить файлы..."
@ -495,6 +498,9 @@ msgstr "Удалить настройку"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Убрать из очереди выбранные композиции"
@ -1548,6 +1554,15 @@ msgstr "Список воспроизведения '%1' пуст или не м
msgid "There was a problem fetching the metadata from Magnatune"
msgstr "Проблема получения метаданных с Magnatune"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""
"В этих каталогах будет выполнен поиск музыки для создания вашей коллекции"

View File

@ -482,6 +482,9 @@ msgstr "Znížiť hlasitosť"
msgid "Delay between visualizations"
msgstr "Oneskorenie medzi vizualizáciami"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Vymazať súbory..."
@ -497,6 +500,9 @@ msgstr "Vymazať predvoľbu"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Vybrať z radu vybrané skladby"
@ -1549,6 +1555,15 @@ msgstr "Playlist '%1' je prázdny alebo nemôže byť načítaný."
msgid "There was a problem fetching the metadata from Magnatune"
msgstr "Nastal problém so získavaním metadát z Magnatune"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "Tieto priečinky budú prehľadané pre vytvorenie vyšej zbierky"

View File

@ -475,6 +475,9 @@ msgstr "Утишај звук"
msgid "Delay between visualizations"
msgstr "Застој између визуелизација"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Обриши фајлове...."
@ -490,6 +493,9 @@ msgstr "Обриши претподешавање"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Избаци означене нумере из реда"
@ -1539,6 +1545,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -475,6 +475,9 @@ msgstr "Sänk volymen"
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -490,6 +493,9 @@ msgstr "Ta bort förinställning"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1539,6 +1545,15 @@ msgstr "Spellistan '%1' var tom eller kunde inte läsas in."
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""
"De här mapparna kommer genomsökas efter musik som skall vara med i ditt "

View File

@ -473,6 +473,9 @@ msgstr "Sesi azalt"
msgid "Delay between visualizations"
msgstr "Görselleştirmeler arasındaki gecikme"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Dosyaları sil..."
@ -488,6 +491,9 @@ msgstr "Ayarı sil"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1540,6 +1546,15 @@ msgstr "Çalma listesi '%1' boş veya yüklenemiyor."
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "Bu dosyalar kütüphaneni oluşturacak parçalar için taranacak"

View File

@ -463,6 +463,9 @@ msgstr ""
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -478,6 +481,9 @@ msgstr ""
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1524,6 +1530,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -481,6 +481,9 @@ msgstr "Зменшити гучність"
msgid "Delay between visualizations"
msgstr "Затримка між візуалізаціями"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "Вилучити файли..."
@ -496,6 +499,9 @@ msgstr "Стерти установки"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr "Вилучити з черги вибрані доріжки"
@ -1549,6 +1555,15 @@ msgstr "Список відтворення '%1' порожній або нем
msgid "There was a problem fetching the metadata from Magnatune"
msgstr "Проблема отримання метаданих з Magnatune"
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "В цих теках виконуватиметься пошук музики для створення фонотеки"

View File

@ -473,6 +473,9 @@ msgstr "降低音量"
msgid "Delay between visualizations"
msgstr ""
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr ""
@ -488,6 +491,9 @@ msgstr ""
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1534,6 +1540,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr ""

View File

@ -477,6 +477,9 @@ msgstr "減低音量"
msgid "Delay between visualizations"
msgstr "在兩個視覺化效果間延遲切換"
msgid "Delete files"
msgstr ""
msgid "Delete files..."
msgstr "刪除檔案"
@ -492,6 +495,9 @@ msgstr "刪除預置"
msgid "Delete the original files"
msgstr ""
msgid "Deleting files"
msgstr ""
msgid "Dequeue selected tracks"
msgstr ""
@ -1539,6 +1545,15 @@ msgstr ""
msgid "There was a problem fetching the metadata from Magnatune"
msgstr ""
msgid ""
"These files will be deleted from disk, are you sure you want to continue?"
msgstr ""
msgid ""
"These files will be deleted from the device, are you sure you want to "
"continue?"
msgstr ""
msgid "These folders will be scanned for music to make up your library"
msgstr "這些檔案夾將被掃描是否有音樂檔,以建構你的音樂庫."

View File

@ -243,6 +243,7 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
connect(ui_->file_view, SIGNAL(PathChanged(QString)), SLOT(FilePathChanged(QString)));
connect(ui_->file_view, SIGNAL(CopyToLibrary(QList<QUrl>)), SLOT(CopyFilesToLibrary(QList<QUrl>)));
connect(ui_->file_view, SIGNAL(MoveToLibrary(QList<QUrl>)), SLOT(MoveFilesToLibrary(QList<QUrl>)));
ui_->file_view->SetTaskManager(task_manager_);
// Cover manager connections
connect(cover_manager_.get(), SIGNAL(AddSongsToPlaylist(SongList)), SLOT(AddLibrarySongsToPlaylist(SongList)));

View File

@ -16,16 +16,21 @@
#include "fileview.h"
#include "ui_fileview.h"
#include "core/deletefiles.h"
#include "core/filesystemmusicstorage.h"
#include "ui/iconloader.h"
#include <QFileSystemModel>
#include <QMessageBox>
#include <QScrollBar>
FileView::FileView(QWidget* parent)
: QWidget(parent),
ui_(new Ui_FileView),
model_(new QFileSystemModel(this)),
undo_stack_(new QUndoStack(this))
undo_stack_(new QUndoStack(this)),
task_manager_(NULL),
storage_(new FilesystemMusicStorage("/"))
{
ui_->setupUi(this);
@ -53,16 +58,22 @@ FileView::FileView(QWidget* parent)
connect(ui_->list, SIGNAL(AddToPlaylist(QList<QUrl>)), SIGNAL(AddToPlaylist(QList<QUrl>)));
connect(ui_->list, SIGNAL(CopyToLibrary(QList<QUrl>)), SIGNAL(CopyToLibrary(QList<QUrl>)));
connect(ui_->list, SIGNAL(MoveToLibrary(QList<QUrl>)), SIGNAL(MoveToLibrary(QList<QUrl>)));
connect(ui_->list, SIGNAL(Delete(QStringList)), SLOT(Delete(QStringList)));
}
FileView::~FileView() {
delete ui_;
delete storage_;
}
void FileView::SetPath(const QString& path) {
ChangeFilePathWithoutUndo(path);
}
void FileView::SetTaskManager(TaskManager* task_manager) {
task_manager_ = task_manager;
}
void FileView::FileUp() {
QDir dir(model_->rootDirectory());
dir.cdUp();
@ -146,3 +157,16 @@ void FileView::UndoCommand::undo() {
view_->ui_->list->setCurrentIndex(old_state_.index);
view_->ui_->list->verticalScrollBar()->setValue(old_state_.scroll_pos);
}
void FileView::Delete(const QStringList& filenames) {
if (filenames.isEmpty())
return;
if (QMessageBox::question(this, tr("Delete files"),
tr("These files will be deleted from disk, are you sure you want to continue?"),
QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes)
return;
DeleteFiles* delete_files = new DeleteFiles(task_manager_, storage_);
delete_files->Start(filenames);
}

View File

@ -22,6 +22,8 @@
#include <QUrl>
#include <QModelIndex>
class FilesystemMusicStorage;
class TaskManager;
class Ui_FileView;
class QFileSystemModel;
@ -35,6 +37,7 @@ class FileView : public QWidget {
~FileView();
void SetPath(const QString& path);
void SetTaskManager(TaskManager* task_manager);
signals:
void PathChanged(const QString& path);
@ -51,6 +54,7 @@ class FileView : public QWidget {
void ChangeFilePath(const QString& new_path);
void ItemActivated(const QModelIndex& index);
void ItemDoubleClick(const QModelIndex& index);
void Delete(const QStringList& filenames);
private:
void ChangeFilePathWithoutUndo(const QString& new_path);
@ -83,6 +87,9 @@ class FileView : public QWidget {
QFileSystemModel* model_;
QUndoStack* undo_stack_;
TaskManager* task_manager_;
FilesystemMusicStorage* storage_;
};
#endif // FILEVIEW_H

View File

@ -35,6 +35,8 @@ FileViewList::FileViewList(QWidget* parent)
this, SLOT(CopyToLibrarySlot()));
menu_->addAction(IconLoader::Load("go-jump"), tr("Move to library..."),
this, SLOT(MoveToLibrarySlot()));
menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."),
this, SLOT(DeleteSlot()));
}
void FileViewList::contextMenuEvent(QContextMenuEvent* e) {
@ -54,6 +56,15 @@ QList<QUrl> FileViewList::UrlListFromSelection() const {
return urls;
}
QStringList FileViewList::FilenamesFromSelection() const {
QStringList filenames;
foreach (const QModelIndex& index, menu_selection_.indexes()) {
if (index.column() == 0)
filenames << static_cast<QFileSystemModel*>(model())->filePath(index);
}
return filenames;
}
void FileViewList::LoadSlot() {
emit Load(UrlListFromSelection());
}
@ -69,3 +80,7 @@ void FileViewList::CopyToLibrarySlot() {
void FileViewList::MoveToLibrarySlot() {
emit MoveToLibrary(UrlListFromSelection());
}
void FileViewList::DeleteSlot() {
emit Delete(FilenamesFromSelection());
}

View File

@ -31,6 +31,7 @@ class FileViewList : public QListView {
void AddToPlaylist(const QList<QUrl>& urls);
void CopyToLibrary(const QList<QUrl>& urls);
void MoveToLibrary(const QList<QUrl>& urls);
void Delete(const QStringList& filenames);
protected:
void contextMenuEvent(QContextMenuEvent* e);
@ -40,8 +41,10 @@ class FileViewList : public QListView {
void AddToPlaylistSlot();
void CopyToLibrarySlot();
void MoveToLibrarySlot();
void DeleteSlot();
QList<QUrl> UrlListFromSelection() const;
QStringList FilenamesFromSelection() const;
private:
QMenu* menu_;