Try to detect if we are connected to Mopidy, and act accordingly

This commit is contained in:
craig.p.drummond
2014-01-22 19:23:26 +00:00
parent 6982526293
commit 238019a2f3
18 changed files with 88 additions and 41 deletions

View File

@@ -33,6 +33,7 @@
#include "devicepropertieswidget.h"
#include "utils.h"
#include "mpdparseutils.h"
#include "mpdconnection.h"
#include "encoders.h"
#include "transcodingjob.h"
#include "actiondialog.h"
@@ -443,7 +444,7 @@ void FsDevice::addSong(const Song &s, bool overwrite, bool copyCover)
}
}
void FsDevice::copySongTo(const Song &s, const QString &baseDir, const QString &musicPath, bool overwrite, bool copyCover)
void FsDevice::copySongTo(const Song &s, const QString &musicPath, bool overwrite, bool copyCover)
{
jobAbortRequested=false;
if (!isConnected()) {
@@ -472,14 +473,13 @@ void FsDevice::copySongTo(const Song &s, const QString &baseDir, const QString &
return;
}
QString baseDir=MPDConnection::self()->getDetails().dir;
if (!overwrite && QFile::exists(baseDir+musicPath)) {
emit actionStatus(FileExists);
return;
}
currentMpdDir=baseDir;
currentDestFile=baseDir+musicPath;
QDir dir(Utils::getDir(currentDestFile));
if (!dir.exists() && !Utils::createWorldReadableDir(dir.absolutePath(), baseDir)) {
emit actionStatus(DirCreationFaild);
@@ -596,13 +596,19 @@ void FsDevice::copySongToResult(int status)
if (Ok!=status) {
emit actionStatus(status);
} else {
currentSong.file=currentDestFile.mid(currentMpdDir.length());
currentSong.file=currentDestFile.mid(MPDConnection::self()->getDetails().dir.length());
QString origPath;
if (MPDConnection::self()->isMopdidy()) {
origPath=currentSong.file;
currentSong.file=Song::encodePath(currentSong.file);
}
if (needToFixVa) {
currentSong.revertVariousArtists();
}
Utils::setFilePerms(currentDestFile);
MusicLibraryModel::self()->addSongToList(currentSong);
DirViewModel::self()->addFileToList(currentSong.file);
DirViewModel::self()->addFileToList(origPath.isEmpty() ? currentSong.file : origPath,
origPath.isEmpty() ? QString() : currentSong.file);
emit actionStatus(Ok, job && job->coverCopied());
}
}