diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f51ac9ac..91a5f0e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,223 +1,311 @@ include_directories(${elisa_BINARY_DIR}) if (Qt5Quick_FOUND AND Qt5Widgets_FOUND) set(elisa_SOURCES main.cpp mediaplaylist.cpp musicstatistics.cpp musicalbum.cpp musicaudiotrack.cpp musicartist.cpp progressindicator.cpp albummodel.cpp allalbumsmodel.cpp allartistsmodel.cpp databaseinterface.cpp musiclistenersmanager.cpp managemediaplayercontrol.cpp manageheaderbar.cpp manageaudioplayer.cpp albumfilterproxymodel.cpp trackslistener.cpp elisaapplication.cpp audiowrapper.cpp alltracksmodel.cpp notificationitem.cpp topnotificationmanager.cpp elisautils.cpp abstractfile/abstractfilelistener.cpp abstractfile/abstractfilelisting.cpp file/filelistener.cpp file/localfilelisting.cpp qml/ElisaMainWindow.qml qml/Theme.qml qml/PlatformIntegration.qml qml/LabelWithToolTip.qml windows/WindowsTheme.qml windows/PlatformIntegration.qml android/ElisaMainWindow.qml android/AndroidTheme.qml android/PlatformIntegration.qml qml/RatingStar.qml qml/PlayListEntry.qml qml/MediaBrowser.qml qml/DraggableItem.qml qml/PassiveNotification.qml qml/TopNotification.qml qml/TopNotificationItem.qml qml/TrackImportNotification.qml qml/HeaderBar.qml qml/NavigationActionBar.qml qml/FilterBar.qml qml/MediaPlayerControl.qml qml/ContextView.qml qml/MediaPlayListView.qml qml/MediaAlbumView.qml qml/MediaAllTracksView.qml qml/MediaTrackDelegate.qml qml/MediaAlbumTrackDelegate.qml qml/MediaTrackMetadataView.qml qml/GridBrowserView.qml qml/GridBrowserDelegate.qml qml/ViewSelector.qml ) if (KF5Baloo_FOUND) if (Qt5DBus_FOUND) set(elisa_SOURCES ${elisa_SOURCES} baloo/localbaloofilelisting.cpp baloo/baloolistener.cpp ) qt5_add_dbus_interface(elisa_SOURCES ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.fileindexer.xml baloo/fileindexer) qt5_add_dbus_interface(elisa_SOURCES ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.scheduler.xml baloo/scheduler) endif() endif() if (Qt5DBus_FOUND) set(elisa_SOURCES ${elisa_SOURCES} mpris2/mpris2.cpp mpris2/mediaplayer2.cpp mpris2/mediaplayer2player.cpp ) endif() if (UPNPQT_FOUND) set(elisa_SOURCES ${elisa_SOURCES} upnp/upnpcontrolcontentdirectory.cpp upnp/upnpcontentdirectorymodel.cpp upnp/upnpcontrolconnectionmanager.cpp upnp/upnpcontrolmediaserver.cpp upnp/didlparser.cpp upnp/upnplistener.cpp upnp/upnpdiscoverallmusic.cpp ) endif() kconfig_add_kcfg_files(elisa_SOURCES elisa_settings.kcfgc) set(elisa_SOURCES ${elisa_SOURCES} elisa_core.kcfg ) qt5_add_resources(elisa_SOURCES resources.qrc) set(elisa_ICONS_PNG ../icons/128-apps-elisa.png ../icons/64-apps-elisa.png ../icons/48-apps-elisa.png ../icons/32-apps-elisa.png ../icons/22-apps-elisa.png ../icons/16-apps-elisa.png ) # add icons to application sources, to have them bundled ecm_add_app_icon(elisa_SOURCES ICONS ${elisa_ICONS_PNG}) add_executable(elisa ${elisa_SOURCES}) set_target_properties(elisa PROPERTIES LINK_FLAGS "-Wl,--no-undefined") target_include_directories(elisa PRIVATE ${KDSoap_INCLUDE_DIRS}) target_link_libraries(elisa LINK_PRIVATE Qt5::Core Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Multimedia Qt5::Svg Qt5::Sql KF5::I18n KF5::ConfigCore KF5::ConfigGui KF5::FileMetaData KF5::CoreAddons ) if (Qt5DBus_FOUND) target_link_libraries(elisa LINK_PRIVATE Qt5::DBus ) endif() if (KF5KCMUtils_FOUND) target_link_libraries(elisa LINK_PRIVATE KF5::KCMUtils ) endif() if (Qt5AndroidExtras_FOUND) target_link_libraries(elisa LINK_PRIVATE Qt5::AndroidExtras ) endif() if (KF5Baloo_FOUND) target_link_libraries(elisa LINK_PRIVATE KF5::Baloo ) endif() if (KF5Declarative_FOUND) target_link_libraries(elisa LINK_PRIVATE KF5::Declarative ) endif() if (KF5XmlGui_FOUND) target_link_libraries(elisa LINK_PRIVATE KF5::XmlGui ) endif() if (KF5Crash_FOUND) target_link_libraries(elisa LINK_PRIVATE KF5::Crash ) endif() if (UPNPQT_FOUND) target_link_libraries(elisa LINK_PRIVATE UPNP::upnpQt Qt5::Network ) endif() if (KF5DBusAddons_FOUND) target_link_libraries(elisa LINK_PRIVATE KF5::DBusAddons ) endif() endif() install(TARGETS elisa ${INSTALL_TARGETS_DEFAULT_ARGS}) if (KF5ConfigWidgets_FOUND) add_subdirectory(localFileConfiguration) endif() + +set(elisaImport_SOURCES + elisaimport.cpp + elisaimportapplication.cpp + elisaapplication.cpp + mediaplaylist.cpp + musicstatistics.cpp + musicalbum.cpp + musicaudiotrack.cpp + musicartist.cpp + progressindicator.cpp + albummodel.cpp + allalbumsmodel.cpp + allartistsmodel.cpp + databaseinterface.cpp + musiclistenersmanager.cpp + albumfilterproxymodel.cpp + trackslistener.cpp + alltracksmodel.cpp + notificationitem.cpp + topnotificationmanager.cpp + elisautils.cpp + abstractfile/abstractfilelistener.cpp + abstractfile/abstractfilelisting.cpp + file/filelistener.cpp + file/localfilelisting.cpp +) + +if (KF5Baloo_FOUND) + if (Qt5DBus_FOUND) + set(elisaImport_SOURCES + ${elisaImport_SOURCES} + baloo/localbaloofilelisting.cpp + baloo/baloolistener.cpp + ) + + qt5_add_dbus_interface(elisaImport_SOURCES + ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.fileindexer.xml + baloo/fileindexer) + + qt5_add_dbus_interface(elisaImport_SOURCES + ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.scheduler.xml + baloo/scheduler) + endif() +endif() + +kconfig_add_kcfg_files(elisaImport_SOURCES elisa_settings.kcfgc) +set(elisaImport_SOURCES + ${elisaImport_SOURCES} + elisa_core.kcfg +) + +add_executable(elisaImport ${elisaImport_SOURCES}) + +set_target_properties(elisaImport PROPERTIES LINK_FLAGS "-Wl,--no-undefined") + +target_link_libraries(elisaImport + LINK_PRIVATE + Qt5::Core + Qt5::Sql + Qt5::Multimedia + Qt5::Widgets + KF5::I18n + KF5::ConfigCore + KF5::ConfigGui + KF5::FileMetaData +) + +if (KF5XmlGui_FOUND) + target_link_libraries(elisaImport + LINK_PRIVATE + KF5::XmlGui + ) +endif() + +if (KF5KCMUtils_FOUND) + target_link_libraries(elisaImport + LINK_PRIVATE + KF5::KCMUtils + ) +endif() + +if (KF5Baloo_FOUND) + target_link_libraries(elisaImport + LINK_PRIVATE + KF5::Baloo + ) +endif() diff --git a/src/abstractfile/abstractfilelisting.cpp b/src/abstractfile/abstractfilelisting.cpp index d7a9b663..2074b945 100644 --- a/src/abstractfile/abstractfilelisting.cpp +++ b/src/abstractfile/abstractfilelisting.cpp @@ -1,397 +1,398 @@ /* * Copyright 2016-2017 Matthieu Gallien * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "abstractfilelisting.h" #include "musicaudiotrack.h" #include "notificationitem.h" #include "elisautils.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include - +#include #include #include #include class AbstractFileListingPrivate { public: explicit AbstractFileListingPrivate(QString sourceName) : mSourceName(std::move(sourceName)) { } QFileSystemWatcher mFileSystemWatcher; QHash mAllAlbumCover; QHash>> mDiscoveredFiles; QString mSourceName; bool mHandleNewFiles = true; KFileMetaData::ExtractorCollection mExtractors; QAtomicInt mStopRequest = 0; QMimeDatabase mMimeDb; int mImportedTracksCount = 0; }; AbstractFileListing::AbstractFileListing(const QString &sourceName, QObject *parent) : QObject(parent), d(std::make_unique(sourceName)) { connect(&d->mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &AbstractFileListing::directoryChanged); connect(&d->mFileSystemWatcher, &QFileSystemWatcher::fileChanged, this, &AbstractFileListing::fileChanged); } AbstractFileListing::~AbstractFileListing() = default; void AbstractFileListing::init() { executeInit(); } void AbstractFileListing::newTrackFile(const MusicAudioTrack &partialTrack) { const auto &newTrack = scanOneFile(partialTrack.resourceURI()); if (newTrack.isValid() && newTrack != partialTrack) { Q_EMIT modifyTracksList({newTrack}, d->mAllAlbumCover, d->mSourceName); } } void AbstractFileListing::resetImportedTracksCounter() { d->mImportedTracksCount = 0; } void AbstractFileListing::applicationAboutToQuit() { d->mStopRequest = 1; } void AbstractFileListing::scanDirectory(QList &newFiles, const QUrl &path) { if (d->mStopRequest == 1) { return; } QDir rootDirectory(path.toLocalFile()); rootDirectory.refresh(); if (rootDirectory.exists()) { watchPath(path.toLocalFile()); } auto ¤tDirectoryListingFiles = d->mDiscoveredFiles[path]; auto currentFilesList = QSet(); rootDirectory.refresh(); const auto entryList = rootDirectory.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs); for (const auto &oneEntry : entryList) { auto newFilePath = QUrl::fromLocalFile(oneEntry.canonicalFilePath()); if (oneEntry.isDir() || oneEntry.isFile()) { currentFilesList.insert(newFilePath); } } auto removedTracks = QVector>(); for (const auto &removedFilePath : currentDirectoryListingFiles) { auto itFilePath = std::find(currentFilesList.begin(), currentFilesList.end(), removedFilePath.first); if (itFilePath != currentFilesList.end()) { continue; } removedTracks.push_back(removedFilePath); } auto allRemovedTracks = QList(); for (const auto &oneRemovedTrack : removedTracks) { if (oneRemovedTrack.second) { allRemovedTracks.push_back(oneRemovedTrack.first); } else { removeFile(oneRemovedTrack.first, allRemovedTracks); } } for (const auto &oneRemovedTrack : removedTracks) { currentDirectoryListingFiles.remove(oneRemovedTrack); currentDirectoryListingFiles.remove(oneRemovedTrack); } if (!allRemovedTracks.isEmpty()) { Q_EMIT removedTracksList(allRemovedTracks); } if (!d->mHandleNewFiles) { return; } for (const auto &newFilePath : currentFilesList) { QFileInfo oneEntry(newFilePath.toLocalFile()); auto itFilePath = std::find(currentDirectoryListingFiles.begin(), currentDirectoryListingFiles.end(), QPair{newFilePath, oneEntry.isFile()}); if (itFilePath != currentDirectoryListingFiles.end()) { continue; } if (oneEntry.isDir()) { addFileInDirectory(newFilePath, path); scanDirectory(newFiles, newFilePath); if (d->mStopRequest == 1) { break; } continue; } if (!oneEntry.isFile()) { continue; } auto newTrack = scanOneFile(newFilePath); if (newTrack.isValid() && d->mStopRequest == 0) { addCover(newTrack); addFileInDirectory(newTrack.resourceURI(), path); newFiles.push_back(newTrack); ++d->mImportedTracksCount; if (d->mImportedTracksCount % 50 == 0) { Q_EMIT importedTracksCountChanged(); } if (newFiles.size() > 500 && d->mStopRequest == 0) { Q_EMIT importedTracksCountChanged(); emitNewFiles(newFiles); newFiles.clear(); } } if (d->mStopRequest == 1) { Q_EMIT importedTracksCountChanged(); break; } } } const QString &AbstractFileListing::sourceName() const { return d->mSourceName; } int AbstractFileListing::importedTracksCount() const { return d->mImportedTracksCount; } void AbstractFileListing::directoryChanged(const QString &path) { const auto directoryEntry = d->mDiscoveredFiles.find(QUrl::fromLocalFile(path)); if (directoryEntry == d->mDiscoveredFiles.end()) { return; } Q_EMIT indexingStarted(); scanDirectoryTree(path); Q_EMIT indexingFinished(); } void AbstractFileListing::fileChanged(const QString &modifiedFileName) { auto modifiedFile = QUrl::fromLocalFile(modifiedFileName); auto modifiedTrack = scanOneFile(modifiedFile); if (modifiedTrack.isValid()) { Q_EMIT modifyTracksList({modifiedTrack}, d->mAllAlbumCover, d->mSourceName); } } void AbstractFileListing::executeInit() { } void AbstractFileListing::triggerRefreshOfContent() { d->mImportedTracksCount = 0; } void AbstractFileListing::refreshContent() { triggerRefreshOfContent(); } MusicAudioTrack AbstractFileListing::scanOneFile(const QUrl &scanFile) { MusicAudioTrack newTrack; newTrack = ElisaUtils::scanOneFile(scanFile, d->mMimeDb, d->mExtractors); if (newTrack.isValid()) { QFileInfo scanFileInfo(scanFile.toLocalFile()); if (scanFileInfo.exists()) { watchPath(scanFile.toLocalFile()); } } return newTrack; } void AbstractFileListing::watchPath(const QString &pathName) { d->mFileSystemWatcher.addPath(pathName); } void AbstractFileListing::addFileInDirectory(const QUrl &newFile, const QUrl &directoryName) { const auto directoryEntry = d->mDiscoveredFiles.find(directoryName); if (directoryEntry == d->mDiscoveredFiles.end()) { watchPath(directoryName.toLocalFile()); QDir currentDirectory(directoryName.toLocalFile()); if (currentDirectory.cdUp()) { const auto parentDirectoryName = currentDirectory.absolutePath(); const auto parentDirectory = QUrl::fromLocalFile(parentDirectoryName); const auto parentDirectoryEntry = d->mDiscoveredFiles.find(parentDirectory); if (parentDirectoryEntry == d->mDiscoveredFiles.end()) { watchPath(parentDirectoryName); } auto &parentCurrentDirectoryListingFiles = d->mDiscoveredFiles[parentDirectory]; parentCurrentDirectoryListingFiles.insert({directoryName, false}); } } auto ¤tDirectoryListingFiles = d->mDiscoveredFiles[directoryName]; QFileInfo isAFile(newFile.toLocalFile()); currentDirectoryListingFiles.insert({newFile, isAFile.isFile()}); } void AbstractFileListing::scanDirectoryTree(const QString &path) { auto newFiles = QList(); scanDirectory(newFiles, QUrl::fromLocalFile(path)); if (!newFiles.isEmpty() && d->mStopRequest == 0) { Q_EMIT importedTracksCountChanged(); emitNewFiles(newFiles); } } void AbstractFileListing::setHandleNewFiles(bool handleThem) { d->mHandleNewFiles = handleThem; } void AbstractFileListing::emitNewFiles(const QList &tracks) { + qDebug() << "AbstractFileListing::emitNewFiles" << tracks.size(); Q_EMIT tracksList(tracks, d->mAllAlbumCover, d->mSourceName); } void AbstractFileListing::addCover(const MusicAudioTrack &newTrack) { auto itCover = d->mAllAlbumCover.find(newTrack.albumName()); if (itCover != d->mAllAlbumCover.end()) { return; } QFileInfo trackFilePath(newTrack.resourceURI().toLocalFile()); QFileInfo coverFilePath(trackFilePath.dir().filePath(QStringLiteral("cover.jpg"))); if (coverFilePath.exists()) { d->mAllAlbumCover[newTrack.resourceURI().toString()] = QUrl::fromLocalFile(coverFilePath.absoluteFilePath()); return; } coverFilePath.setFile(trackFilePath.dir().filePath(QStringLiteral("cover.png"))); if (coverFilePath.exists()) { d->mAllAlbumCover[newTrack.resourceURI().toString()] = QUrl::fromLocalFile(coverFilePath.absoluteFilePath()); } } void AbstractFileListing::removeDirectory(const QUrl &removedDirectory, QList &allRemovedFiles) { const auto itRemovedDirectory = d->mDiscoveredFiles.find(removedDirectory); if (itRemovedDirectory == d->mDiscoveredFiles.end()) { return; } const auto ¤tRemovedDirectory = *itRemovedDirectory; for (const auto &itFile : currentRemovedDirectory) { if (itFile.first.isValid() && !itFile.first.isEmpty()) { removeFile(itFile.first, allRemovedFiles); if (itFile.second) { allRemovedFiles.push_back(itFile.first); } } } d->mDiscoveredFiles.erase(itRemovedDirectory); } void AbstractFileListing::removeFile(const QUrl &oneRemovedTrack, QList &allRemovedFiles) { auto itRemovedDirectory = d->mDiscoveredFiles.find(oneRemovedTrack); if (itRemovedDirectory != d->mDiscoveredFiles.end()) { removeDirectory(oneRemovedTrack, allRemovedFiles); } } void AbstractFileListing::setSourceName(const QString &name) { d->mSourceName = name; } void AbstractFileListing::increaseImportedTracksCount() { ++d->mImportedTracksCount; } #include "moc_abstractfilelisting.cpp" diff --git a/src/elisaimport.cpp b/src/elisaimport.cpp new file mode 100644 index 00000000..8c454d62 --- /dev/null +++ b/src/elisaimport.cpp @@ -0,0 +1,65 @@ +/* + * Copyright 2015-2018 Matthieu Gallien + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config-upnp-qt.h" + +#include "musiclistenersmanager.h" +#include "elisaimportapplication.h" +#include "elisa_settings.h" + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + qRegisterMetaType>("QHash"); + qRegisterMetaType>("QList"); + qRegisterMetaType>("QVector"); + qRegisterMetaType>("QVector"); + qRegisterMetaType>("QHash"); + qRegisterMetaType("MusicAlbum"); + qRegisterMetaType("MusicArtist"); + qRegisterMetaType>(); + qRegisterMetaType("NotificationItem"); + qRegisterMetaType>("QMap"); + + QCommandLineParser parser; + parser.addHelpOption(); + parser.addVersionOption(); + parser.process(app); + + auto configurationFileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); + configurationFileName += QStringLiteral("/elisarc"); + Elisa::ElisaConfiguration::instance(configurationFileName); + Elisa::ElisaConfiguration::self()->load(); + Elisa::ElisaConfiguration::self()->save(); + + MusicListenersManager myMusicManager; + ElisaImportApplication myApplication; + + QObject::connect(&myMusicManager, &MusicListenersManager::indexingRunningChanged, + &myApplication, &ElisaImportApplication::indexingChanged); + + return app.exec(); +} + diff --git a/src/elisaimportapplication.cpp b/src/elisaimportapplication.cpp new file mode 100644 index 00000000..b6b9d56a --- /dev/null +++ b/src/elisaimportapplication.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2018 Matthieu Gallien + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "elisaimportapplication.h" + +#include + +ElisaImportApplication::ElisaImportApplication(QObject *parent) : QObject(parent) +{ +} + +void ElisaImportApplication::indexingChanged() +{ + static bool firstCall = true; + + if (firstCall) { + firstCall = false; + } else { + QCoreApplication::quit(); + } +} + + +#include "moc_elisaimportapplication.cpp" diff --git a/src/elisaimportapplication.h b/src/elisaimportapplication.h new file mode 100644 index 00000000..c4d432ef --- /dev/null +++ b/src/elisaimportapplication.h @@ -0,0 +1,39 @@ +/* + * Copyright 2018 Matthieu Gallien + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef ELISAIMPORTAPPLICATION_H +#define ELISAIMPORTAPPLICATION_H + +#include + +class ElisaImportApplication : public QObject +{ + Q_OBJECT +public: + explicit ElisaImportApplication(QObject *parent = nullptr); + +Q_SIGNALS: + +public Q_SLOTS: + + void indexingChanged(); + +}; + +#endif // ELISAIMPORTAPPLICATION_H diff --git a/src/musiclistenersmanager.h b/src/musiclistenersmanager.h index b82c3bc5..5eb58443 100644 --- a/src/musiclistenersmanager.h +++ b/src/musiclistenersmanager.h @@ -1,150 +1,149 @@ /* * Copyright 2016-2017 Matthieu Gallien * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MUSICLISTENERSMANAGER_H #define MUSICLISTENERSMANAGER_H #include "notificationitem.h" #include -#include #include #include "musicalbum.h" #include "musicartist.h" #include "musicaudiotrack.h" #include class MusicListenersManagerPrivate; class DatabaseInterface; class MediaPlayList; class NotificationItem; class ElisaApplication; class MusicListenersManager : public QObject { Q_OBJECT Q_PROPERTY(DatabaseInterface* viewDatabase READ viewDatabase NOTIFY viewDatabaseChanged) Q_PROPERTY(int importedTracksCount READ importedTracksCount NOTIFY importedTracksCountChanged) Q_PROPERTY(bool indexingRunning READ isIndexingRunning NOTIFY indexingRunningChanged) Q_PROPERTY(ElisaApplication* elisaApplication READ elisaApplication WRITE setElisaApplication NOTIFY elisaApplicationChanged) public: explicit MusicListenersManager(QObject *parent = nullptr); ~MusicListenersManager() override; DatabaseInterface* viewDatabase() const; void subscribeForTracks(MediaPlayList *client); int importedTracksCount() const; bool isIndexingRunning() const; ElisaApplication* elisaApplication() const; Q_SIGNALS: void viewDatabaseChanged(); void artistAdded(const MusicArtist &newArtist); void albumAdded(const MusicAlbum &newAlbum); void trackAdded(qulonglong id); void tracksAdded(const QList &allTracks); void artistRemoved(const MusicArtist &removedArtist); void albumRemoved(const MusicAlbum &removedAlbum, qulonglong removedAlbumId); void trackRemoved(qulonglong id); void artistModified(const MusicArtist &modifiedArtist); void albumModified(const MusicAlbum &modifiedAlbum, qulonglong modifiedAlbumId); void trackModified(const MusicAudioTrack &modifiedTrack); void applicationIsTerminating(); void importedTracksCountChanged(); void indexingRunningChanged(); void newNotification(NotificationItem notification); void closeNotification(QString notificationId); void elisaApplicationChanged(); void removeTracksInError(QList tracks); void displayTrackError(const QString &fileName); public Q_SLOTS: void databaseReady(); void applicationAboutToQuit(); void showConfiguration(); void resetImportedTracksCounter(); void setElisaApplication(ElisaApplication* elisaApplication); void playBackError(QUrl sourceInError, QMediaPlayer::Error playerError); private Q_SLOTS: void configChanged(); void computeImportedTracksCount(); void monitorStartingListeners(); void monitorEndingListeners(); private: std::unique_ptr d; }; #endif // MUSICLISTENERSMANAGER_H