Commit 65078186 authored by Matthieu Gallien's avatar Matthieu Gallien

Merge branch '0.4'

parents 5301e529 e535ef7e
......@@ -23,6 +23,8 @@
#include "musicaudiotrack.h"
#include "trackslistener.h"
#include "config-upnp-qt.h"
#include <QtTest>
#include <QStandardItemModel>
#include <QStandardItem>
......@@ -6915,6 +6917,7 @@ void MediaPlayListTest::testEnqueueSampleFiles()
QCOMPARE(newTrackByNameInListSpy.count(), 0);
QCOMPARE(newEntryInListSpy.count(), 2);
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::TitleRole).toString(), QStringLiteral("Title"));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::AlbumRole).toString(), QStringLiteral("Test"));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ArtistRole).toString(), QStringLiteral("Artist"));
......@@ -6927,6 +6930,20 @@ void MediaPlayListTest::testEnqueueSampleFiles()
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::TrackNumberRole).toInt(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::DiscNumberRole).toInt(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::MilliSecondsDurationRole).toInt(), 1000);
#else
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::TitleRole).toString(), QStringLiteral("test.ogg"));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::AlbumRole).toString(), QStringLiteral(""));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ArtistRole).toString(), QStringLiteral(""));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::TrackNumberRole).toInt(), -1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::DiscNumberRole).toInt(), -1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::MilliSecondsDurationRole).toInt(), 0);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::TitleRole).toString(), QStringLiteral("test2.ogg"));
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::AlbumRole).toString(), QStringLiteral(""));
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::ArtistRole).toString(), QStringLiteral(""));
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::TrackNumberRole).toInt(), -1);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::DiscNumberRole).toInt(), -1);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::MilliSecondsDurationRole).toInt(), 0);
#endif
}
void MediaPlayListTest::testEmptyEnqueue()
......
......@@ -34,7 +34,6 @@
#include <QSet>
#include <QPair>
#include <QAtomicInt>
#include <QDebug>
#include <QtGlobal>
......@@ -241,6 +240,8 @@ void AbstractFileListing::scanDirectory(QList<MusicAudioTrack> &newFiles, const
emitNewFiles(newFiles);
newFiles.clear();
}
} else {
qCDebug(orgKdeElisaIndexer()) << "AbstractFileListing::scanDirectory" << newFilePath << "is not a valid track";
}
if (d->mStopRequest == 1) {
......@@ -369,6 +370,8 @@ void AbstractFileListing::scanDirectoryTree(const QString &path)
{
auto newFiles = QList<MusicAudioTrack>();
qCDebug(orgKdeElisaIndexer()) << "AbstractFileListing::scanDirectoryTree" << path;
scanDirectory(newFiles, QUrl::fromLocalFile(path));
if (!newFiles.isEmpty() && d->mStopRequest == 0) {
......@@ -441,6 +444,8 @@ void AbstractFileListing::checkFilesToRemove()
allRemovedFiles.push_back(itFile.key());
}
qCDebug(orgKdeElisaIndexer()) << "AbstractFileListing::checkFilesToRemove" << allRemovedFiles.size();
if (!allRemovedFiles.isEmpty()) {
setWaitEndTrackRemoval(true);
Q_EMIT removedTracksList(allRemovedFiles);
......
......@@ -348,7 +348,7 @@ void LocalBalooFileListing::triggerRefreshOfContent()
if (!scanFileInfo.exists()) {
qCDebug(orgKdeElisaBaloo()) << "LocalBalooFileListing::triggerRefreshOfContent" << fileName << "file does not exists";
return;
continue;
}
auto itExistingFile = allFiles().find(newFileUrl);
......
......@@ -6031,9 +6031,12 @@ void DatabaseInterface::updateTrackOrigin(const QUrl &fileName, const QDateTime
qulonglong DatabaseInterface::internalInsertTrack(const MusicAudioTrack &oneTrack,
const QHash<QString, QUrl> &covers, bool &isInserted)
{
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack trying to insert" << oneTrack;
qulonglong resultId = 0;
if (oneTrack.title().isEmpty()) {
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << oneTrack << "is not inserted";
return resultId;
}
......@@ -6207,6 +6210,7 @@ qulonglong DatabaseInterface::internalInsertTrack(const MusicAudioTrack &oneTrac
d->mInsertTrackQuery.bindValue(QStringLiteral(":hasEmbeddedCover"), oneTrack.hasEmbeddedCover());
auto result = execQuery(d->mInsertTrackQuery);
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << oneTrack << "is inserted";
if (result && d->mInsertTrackQuery.isActive()) {
d->mInsertTrackQuery.finish();
......
......@@ -19,6 +19,8 @@
#include "musicaudiotrack.h"
#include "abstractfile/indexercommon.h"
#include <QThread>
#include <QHash>
#include <QFileInfo>
......@@ -46,6 +48,7 @@ LocalFileListing::~LocalFileListing()
void LocalFileListing::executeInit(QHash<QUrl, QDateTime> allFiles)
{
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::executeInit" << "with" << allFiles.size() << "files";
AbstractFileListing::executeInit(std::move(allFiles));
}
......@@ -53,6 +56,8 @@ void LocalFileListing::triggerRefreshOfContent()
{
Q_EMIT indexingStarted();
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerRefreshOfContent" << allRootPaths();
AbstractFileListing::triggerRefreshOfContent();
const auto &rootPaths = allRootPaths();
......
......@@ -19,6 +19,8 @@
#include "config-upnp-qt.h"
#include "abstractfile/indexercommon.h"
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
#include <KFileMetaData/ExtractorCollection>
......@@ -36,6 +38,7 @@
#endif
#include <QLoggingCategory>
#include <QFileInfo>
#include <QLocale>
#include <QDir>
......@@ -71,7 +74,6 @@ FileScanner::~FileScanner() = default;
MusicAudioTrack FileScanner::scanOneFile(const QUrl &scanFile, const QMimeDatabase &mimeDatabase)
{
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
MusicAudioTrack newTrack;
auto localFileName = scanFile.toLocalFile();
......@@ -79,7 +81,9 @@ MusicAudioTrack FileScanner::scanOneFile(const QUrl &scanFile, const QMimeDataba
QFileInfo scanFileInfo(localFileName);
newTrack.setFileModificationTime(scanFileInfo.fileTime(QFile::FileModificationTime));
newTrack.setResourceURI(scanFile);
newTrack.setRating(0);
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
const auto &fileMimeType = mimeDatabase.mimeTypeForFile(localFileName);
if (!fileMimeType.name().startsWith(QLatin1String("audio/"))) {
return newTrack;
......@@ -103,13 +107,17 @@ MusicAudioTrack FileScanner::scanOneFile(const QUrl &scanFile, const QMimeDataba
scanProperties(localFileName, newTrack);
return newTrack;
qCDebug(orgKdeElisaIndexer()) << "scanOneFile" << scanFile << "using KFileMetaData" << newTrack;
#else
Q_UNUSED(scanFile)
Q_UNUSED(mimeDatabase)
return {};
newTrack.setTitle(scanFileInfo.fileName());
newTrack.setValid(true);
qCDebug(orgKdeElisaIndexer()) << "scanOneFile" << scanFile << "no metadata provider" << newTrack;
#endif
return newTrack;
}
void FileScanner::scanProperties(const Baloo::File &match, MusicAudioTrack &trackData)
......@@ -117,9 +125,13 @@ void FileScanner::scanProperties(const Baloo::File &match, MusicAudioTrack &trac
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
d->mAllProperties = match.properties();
scanProperties(match.path(), trackData);
qCDebug(orgKdeElisaIndexer()) << "scanProperties" << match.path() << "using Baloo" << trackData;
#else
Q_UNUSED(match)
Q_UNUSED(trackData)
qCDebug(orgKdeElisaIndexer()) << "scanProperties" << "no metadata provider" << trackData;
#endif
}
......@@ -270,6 +282,8 @@ bool FileScanner::checkEmbeddedCoverImage(const QString &localFileName)
return true;
}
}
#else
Q_UNUSED(localFileName)
#endif
return false;
......
......@@ -123,6 +123,15 @@ MusicListenersManager::MusicListenersManager(QObject *parent)
connect(&d->mDatabaseInterface, &DatabaseInterface::cleanedDatabase,
this, &MusicListenersManager::cleanedDatabase);
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
connect(&d->mBalooDetector, &BalooDetector::balooAvailabilityChanged,
this, &MusicListenersManager::balooAvailabilityChanged);
#endif
qCInfo(orgKdeElisaIndexersManager) << "Local file system indexer is inactive";
qCInfo(orgKdeElisaIndexersManager) << "Baloo indexer is unavailable";
qCInfo(orgKdeElisaIndexersManager) << "Baloo indexer is inactive";
const auto &localDataPaths = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
auto databaseFileName = QString();
if (!localDataPaths.isEmpty()) {
......@@ -158,15 +167,6 @@ MusicListenersManager::MusicListenersManager(QObject *parent)
connect(&d->mDatabaseInterface, &DatabaseInterface::tracksAdded,
this, &MusicListenersManager::increaseImportedTracksCount);
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
connect(&d->mBalooDetector, &BalooDetector::balooAvailabilityChanged,
this, &MusicListenersManager::balooAvailabilityChanged);
#endif
qCInfo(orgKdeElisaIndexersManager) << "Local file system indexer is inactive";
qCInfo(orgKdeElisaIndexersManager) << "Baloo indexer is unavailable";
qCInfo(orgKdeElisaIndexersManager) << "Baloo indexer is inactive";
}
MusicListenersManager::~MusicListenersManager()
......@@ -325,14 +325,6 @@ void MusicListenersManager::configChanged()
if (!d->mBalooIndexerActive && !d->mFileSystemIndexerActive) {
testBalooIndexerAvailability();
} else {
if (d->mBalooIndexerActive) {
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
QMetaObject::invokeMethod(d->mBalooListener.fileListing(), "init", Qt::QueuedConnection);
#endif
} else if (d->mFileSystemIndexerActive) {
QMetaObject::invokeMethod(d->mFileListener.fileListing(), "init", Qt::QueuedConnection);
}
}
#if defined UPNPQT_FOUND && UPNPQT_FOUND
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment