Commit 0eacedb2 authored by Matthieu Gallien's avatar Matthieu Gallien

almost working switch from baloo to files indexing on config changes

parent 68753ca5
......@@ -66,6 +66,8 @@ public:
bool mErrorWatchingFileSystemChanges = false;
bool mIsActive = false;
};
AbstractFileListing::AbstractFileListing(QObject *parent) : QObject(parent), d(std::make_unique<AbstractFileListingPrivate>())
......@@ -82,9 +84,19 @@ AbstractFileListing::~AbstractFileListing()
void AbstractFileListing::init()
{
qCDebug(orgKdeElisaIndexer()) << "AbstractFileListing::init";
d->mIsActive = true;
Q_EMIT askRestoredTracks();
}
void AbstractFileListing::stop()
{
d->mIsActive = false;
triggerStop();
}
void AbstractFileListing::newTrackFile(const DataTypes::TrackDataType &partialTrack)
{
auto scanFileInfo = QFileInfo(partialTrack.resourceURI().toLocalFile());
......@@ -272,6 +284,10 @@ void AbstractFileListing::executeInit(QHash<QUrl, QDateTime> allFiles)
d->mAllFiles = std::move(allFiles);
}
void AbstractFileListing::triggerStop()
{
}
void AbstractFileListing::triggerRefreshOfContent()
{
d->mImportedTracksCount = 0;
......@@ -462,5 +478,10 @@ void AbstractFileListing::setWaitEndTrackRemoval(bool wait)
d->mWaitEndTrackRemoval = wait;
}
bool AbstractFileListing::isActive() const
{
return d->mIsActive;
}
#include "moc_abstractfilelisting.cpp"
......@@ -73,6 +73,8 @@ public Q_SLOTS:
void init();
void stop();
void newTrackFile(const DataTypes::TrackDataType &partialTrack);
void restoredTracks(QHash<QUrl, QDateTime> allFiles);
......@@ -95,6 +97,8 @@ protected:
virtual void triggerRefreshOfContent();
virtual void triggerStop();
void scanDirectory(DataTypes::ListTrackDataType &newFiles, const QUrl &path);
virtual DataTypes::TrackDataType scanOneFile(const QUrl &scanFile, const QFileInfo &scanFileInfo);
......@@ -127,6 +131,8 @@ protected:
void setWaitEndTrackRemoval(bool wait);
bool isActive() const;
private:
std::unique_ptr<AbstractFileListingPrivate> d;
......
......@@ -153,6 +153,11 @@ void LocalBalooFileListing::newBalooFile(const QString &fileName)
{
qCDebug(orgKdeElisaBaloo()) << "LocalBalooFileListing::newBalooFile" << fileName;
if (!isActive()) {
qCDebug(orgKdeElisaBaloo()) << "LocalBalooFileListing::newBalooFile is inactive";
return;
}
auto scanFileInfo = QFileInfo(fileName);
if (!scanFileInfo.exists()) {
......@@ -325,19 +330,26 @@ void LocalBalooFileListing::serviceUnregistered(const QString &serviceName)
}
}
void LocalBalooFileListing::stop()
{
qCInfo(orgKdeElisaBaloo()) << "LocalBalooFileListing::stop";
}
void LocalBalooFileListing::executeInit(QHash<QUrl, QDateTime> allFiles)
{
if (!isActive()) {
qCDebug(orgKdeElisaBaloo()) << "LocalBalooFileListing::executeInit is inactive";
return;
}
qCDebug(orgKdeElisaBaloo()) << "LocalBalooFileListing::executeInit" << "with" << allFiles.size() << "files";
AbstractFileListing::executeInit(std::move(allFiles));
}
void LocalBalooFileListing::triggerRefreshOfContent()
{
qCDebug(orgKdeElisaBaloo()) << "LocalBalooFileListing::triggerRefreshOfContent";
if (!isActive()) {
qCDebug(orgKdeElisaBaloo()) << "LocalBalooFileListing::triggerRefreshOfContent is inactive";
return;
}
Q_EMIT indexingStarted();
AbstractFileListing::triggerRefreshOfContent();
......@@ -421,6 +433,12 @@ void LocalBalooFileListing::triggerRefreshOfContent()
}
}
void LocalBalooFileListing::triggerStop()
{
qCDebug(orgKdeElisaBaloo()) << "LocalBalooFileListing::triggerStop";
AbstractFileListing::triggerStop();
}
DataTypes::TrackDataType LocalBalooFileListing::scanOneFile(const QUrl &scanFile, const QFileInfo &scanFileInfo)
{
DataTypes::TrackDataType trackData;
......
......@@ -58,8 +58,6 @@ public Q_SLOTS:
void serviceUnregistered(const QString &serviceName);
void stop();
private Q_SLOTS:
void newBalooFile(const QString &fileName);
......@@ -76,6 +74,8 @@ private:
void triggerRefreshOfContent() override;
void triggerStop() override;
DataTypes::TrackDataType scanOneFile(const QUrl &scanFile, const QFileInfo &scanFileInfo) override;
std::unique_ptr<LocalBalooFileListingPrivate> d;
......
......@@ -45,12 +45,24 @@ LocalFileListing::~LocalFileListing()
void LocalFileListing::executeInit(QHash<QUrl, QDateTime> allFiles)
{
if (!isActive()) {
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::executeInit is inactive";
return;
}
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::executeInit" << "with" << allFiles.size() << "files";
AbstractFileListing::executeInit(std::move(allFiles));
}
void LocalFileListing::triggerRefreshOfContent()
{
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerRefreshOfContent";
if (!isActive()) {
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerRefreshOfContent is inactive";
return;
}
Q_EMIT indexingStarted();
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerRefreshOfContent" << allRootPaths();
......@@ -71,5 +83,11 @@ void LocalFileListing::triggerRefreshOfContent()
}
}
void LocalFileListing::triggerStop()
{
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerStop";
AbstractFileListing::triggerStop();
}
#include "moc_localfilelisting.cpp"
......@@ -45,6 +45,8 @@ private:
void triggerRefreshOfContent() override;
void triggerStop() override;
std::unique_ptr<LocalFileListingPrivate> d;
};
......
......@@ -361,16 +361,26 @@ void MusicListenersManager::configChanged()
if (!d->mBalooIndexerActive && !d->mFileSystemIndexerActive) {
testBalooIndexerAvailability();
}
if (d->mBalooIndexerAvailable && !d->mBalooIndexerActive && d->mBalooListener.canHandleRootPaths())
{
qCDebug(orgKdeElisaIndexersManager()) << "trigger start of baloo file indexer";
QMetaObject::invokeMethod(d->mFileListener.fileListing(), "stop", Qt::BlockingQueuedConnection);
d->mFileSystemIndexerActive = true;
startBalooIndexing();
} else if (!d->mFileSystemIndexerActive && d->mBalooIndexerActive && !d->mBalooListener.canHandleRootPaths())
{
qCDebug(orgKdeElisaIndexersManager()) << "trigger stop of baloo file indexer";
QMetaObject::invokeMethod(d->mBalooListener.fileListing(), "stop", Qt::BlockingQueuedConnection);
d->mBalooIndexerActive = false;
startLocalFileSystemIndexing();
}
if (d->mBalooIndexerActive) {
qCInfo(orgKdeElisaIndexersManager()) << "trigger init of baloo file indexer";
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
QMetaObject::invokeMethod(d->mBalooListener.fileListing(), "init", Qt::QueuedConnection);
#endif
} else if (d->mFileSystemIndexerActive) {
if (d->mBalooIndexerActive) {
qCInfo(orgKdeElisaIndexersManager()) << "trigger stop of baloo file indexer";
QMetaObject::invokeMethod(d->mBalooListener.fileListing(), "stop", Qt::QueuedConnection);
}
qCInfo(orgKdeElisaIndexersManager()) << "trigger init of local file indexer";
QMetaObject::invokeMethod(d->mFileListener.fileListing(), "init", Qt::QueuedConnection);
}
......
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