Commit 3c925162 authored by Alexander Stippich's avatar Alexander Stippich
Browse files

New shuffle mode for playlist

This implements a new shuffle mode for the playlist with a proxy model that shuffles the available data.
he following features are implemented:

each track is selected exactly once in shuffle mode
the shuffle mode and order are fully visible to the user
full history with going back and forth

Interfacing with the QML code is now done with the proxy model.

BUG: 394333
parent 8368d876
......@@ -81,6 +81,21 @@ ecm_add_test(${mediaplaylistTest_SOURCES}
target_include_directories(mediaplaylistTest PRIVATE ${CMAKE_SOURCE_DIR}/src)
ecm_qt_declare_logging_category(mediaplaylistproxymodelTest_SOURCES HEADER elisa_debug.h IDENTIFIER lcModelTest CATEGORY_NAME qt.modeltest)
set(mediaplaylistproxymodelTest_SOURCES
mediaplaylistproxymodeltest.cpp
../src/elisautils.cpp
)
ecm_add_test(${mediaplaylistproxymodelTest_SOURCES}
TEST_NAME "mediaplaylistproxymodelTest"
LINK_LIBRARIES
Qt5::Test elisaLib Qt5::CorePrivate
)
target_include_directories(mediaplaylistproxymodelTest PRIVATE ${CMAKE_SOURCE_DIR}/src)
set(trackslistenertest_SOURCES
trackslistenertest.cpp
../src/elisautils.cpp
......
This diff is collapsed.
/*
* Copyright 2016-2017 Matthieu Gallien <matthieu_gallien@yahoo.fr>
* Copyright 2020 Alexander Stippich <a.stippich@gmx.net>
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MEDIAPLAYLISTPROXYMODELTEST_H
#define MEDIAPLAYLISTPROXYMODELTEST_H
#include "databasetestdata.h"
#include <QObject>
#include <QHash>
class MediaPlayListProxyModelTest : public QObject, public DatabaseTestData
{
Q_OBJECT
public:
explicit MediaPlayListProxyModelTest(QObject *parent = nullptr);
Q_SIGNALS:
private Q_SLOTS:
void initTestCase();
void simpleInitialCase();
void enqueueAlbumCase();
void enqueueArtistCase();
void enqueueMultipleAlbumsCase();
void enqueueTrackByUrl();
void enqueueTracksByUrl();
void enqueueReplaceAndPlay();
void enqueueFiles();
void enqueueSampleFiles();
void enqueueEmpty();
void removeFirstTrackOfAlbum();
void testSaveLoadPlayList();
void testSavePersistentState();
void testRestoreSettings();
void testSaveAndRestoreSettings();
void testBringUpAndSkipPreviousAndContinueCase();
void testBringUpAndRemoveMultipleNotBeginCase();
void testBringUpAndPlayCase();
void testBringUpAndSkipNextCase();
void testBringUpAndSkipPreviousCase();
void testBringUpAndRemoveCase();
void testBringUpAndRemoveLastCase();
void testBringUpAndRemoveMultipleCase();
void testBringUpAndDownCase();
void testBringUpCase();
void testBringUpCaseFromNewAlbum();
void testSetData();
void testRemoveSelection();
void testReplaceAndPlayArtist();
void testReplaceAndPlayTrackId();
void testTrackBeenRemoved();
void randomPlayList();
void testShuffleMode();
void randomAndContinuePlayList();
void continuePlayList();
void previousAndNextTracksTest();
void remainingTracksTest();
void clearPlayListCase();
void undoClearPlayListCase();
void undoReplacePlayListCase();
void finishPlayList();
void removeBeforeCurrentTrack();
void switchToTrackTest();
void singleTrack();
void testHasHeader();
void testHasHeaderWithRemove();
void testHasHeaderMoveFirst();
void testHasHeaderMoveAnother();
void testHasHeaderAlbumWithSameTitle();
void testHasHeaderMoveFirstLikeQml();
void testHasHeaderMoveAnotherLikeQml();
void testHasHeaderYetAnotherMoveLikeQml();
};
#endif // MEDIAPLAYLISTPROXYMODELTEST_H
This diff is collapsed.
......@@ -44,109 +44,45 @@ private Q_SLOTS:
void enqueueArtistCase();
void removeFirstTrackOfAlbum();
void testHasHeader();
void testHasHeaderWithRestore();
void testHasHeaderWithRemove();
void testHasHeaderMoveFirst();
void testHasHeaderMoveAnother();
void testHasHeaderMoveFirstLikeQml();
void testHasHeaderMoveAnotherLikeQml();
void testHasHeaderYetAnotherMoveLikeQml();
void enqueueReplaceAndPlay();
void crashOnEnqueue();
void restoreMultipleIdenticalTracks();
void restoreTrackWithoutAlbum();
void testHasHeaderAlbumWithSameTitle();
void enqueueTrackByUrl();
void testSavePersistentState();
void enqueueTracksByUrl();
void testReplaceAndPlayArtist();
void enqueueFiles();
void testReplaceAndPlayTrackId();
void enqueueSampleFiles();
void testSetData();
void enqueueEmpty();
void testRemoveSelection();
void removeFirstTrackOfAlbum();
void testTrackBeenRemoved();
void testBringUpCase();
void testBringUpCaseFromNewAlbum();
void testBringUpAndDownCase();
void testBringUpAndRemoveCase();
void testBringUpAndRemoveMultipleCase();
void testBringUpAndRemoveMultipleNotBeginCase();
void testBringUpAndPlayCase();
void testBringUpAndSkipNextCase();
void testBringUpAndSkipPreviousCase();
void testBringUpAndSkipPreviousAndContinueCase();
void finishPlayList();
void randomPlayList();
void randomAndContinuePlayList();
void continuePlayList();
void testRestoreSettings();
void removeBeforeCurrentTrack();
void switchToTrackTest();
void previousAndNextTracksTest();
void singleTrack();
void remainingTracksTest();
void testSetData();
void testBringUpAndRemoveLastCase();
void testHasHeader();
void testSaveAndRestoreSettings();
void testHasHeaderWithRemove();
void testSaveLoadPlayList();
void testHasHeaderWithRestore();
void testEnqueueFiles();
void testHasHeaderMoveFirst();
void testEnqueueSampleFiles();
void testHasHeaderMoveAnother();
void testEmptyEnqueue();
void restoreMultipleIdenticalTracks();
void clearPlayListCase();
void restoreTrackWithoutAlbum();
void undoClearPlayListCase();
void testHasHeaderAlbumWithSameTitle();
void undoReplacePlayListCase();
void testHasHeaderMoveFirstLikeQml();
void enqueueMultipleAlbumsCase();
void testHasHeaderMoveAnotherLikeQml();
void enqueueTrackByUrl();
void testHasHeaderYetAnotherMoveLikeQml();
void enqueueTracksByUrl();
void crashOnEnqueue();
};
......
......@@ -96,13 +96,13 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 0);
myPlayList.enqueue(ElisaUtils::EntryData{{}, QStringLiteral("artist1"), {}}, ElisaUtils::Artist, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
myPlayList.enqueueOneEntry(ElisaUtils::EntryData{{}, QStringLiteral("artist1"), {}}, ElisaUtils::Artist);
QCOMPARE(trackHasChangedSpy.count(), 0);
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 1);
QCOMPARE(myPlayList.tracksCount(), 6);
QCOMPARE(myPlayList.rowCount(), 6);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), true);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -147,7 +147,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 1);
QCOMPARE(tracksListAddedSpy.count(), 1);
QCOMPARE(myPlayList.tracksCount(), 6);
QCOMPARE(myPlayList.rowCount(), 6);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), false);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -223,13 +223,13 @@ private Q_SLOTS:
QCOMPARE(trackId != 0, true);
myPlayList.enqueue(ElisaUtils::EntryData{{{DataTypes::DatabaseIdRole, trackId}}, {}, {}}, ElisaUtils::Track, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
myPlayList.enqueueOneEntry(ElisaUtils::EntryData{{{DataTypes::DatabaseIdRole, trackId}}, {}, {}}, ElisaUtils::Track);
QCOMPARE(trackHasChangedSpy.count(), 1);
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 0);
QCOMPARE(myPlayList.tracksCount(), 1);
QCOMPARE(myPlayList.rowCount(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), true);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -244,7 +244,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 1);
QCOMPARE(tracksListAddedSpy.count(), 0);
QCOMPARE(myPlayList.tracksCount(), 1);
QCOMPARE(myPlayList.rowCount(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), false);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -285,7 +285,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 0);
myPlayList.enqueue({{{DataTypes::DatabaseIdRole, myDatabaseContent.trackIdFromTitleAlbumTrackDiscNumber(QStringLiteral("track1"), QStringLiteral("artist1"), QStringLiteral("album1"), 1, 1)}},
myPlayList.enqueueOneEntry({{{DataTypes::DatabaseIdRole, myDatabaseContent.trackIdFromTitleAlbumTrackDiscNumber(QStringLiteral("track1"), QStringLiteral("artist1"), QStringLiteral("album1"), 1, 1)}},
QStringLiteral("track1"), {}},
ElisaUtils::Track);
......@@ -293,7 +293,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 0);
QCOMPARE(myPlayList.tracksCount(), 1);
QCOMPARE(myPlayList.rowCount(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), true);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -308,7 +308,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 1);
QCOMPARE(tracksListAddedSpy.count(), 0);
QCOMPARE(myPlayList.tracksCount(), 1);
QCOMPARE(myPlayList.rowCount(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), false);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -349,7 +349,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 0);
QCOMPARE(myPlayList.tracksCount(), 1);
QCOMPARE(myPlayList.rowCount(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), false);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -377,7 +377,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 1);
QCOMPARE(tracksListAddedSpy.count(), 0);
QCOMPARE(myPlayList.tracksCount(), 1);
QCOMPARE(myPlayList.rowCount(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), false);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -418,7 +418,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 0);
myPlayList.enqueue({{{DataTypes::DatabaseIdRole, myDatabaseContent.trackIdFromTitleAlbumTrackDiscNumber(QStringLiteral("track1"), QStringLiteral("artist1"), QStringLiteral("album1"), 1, 1)}},
myPlayList.enqueueOneEntry({{{DataTypes::DatabaseIdRole, myDatabaseContent.trackIdFromTitleAlbumTrackDiscNumber(QStringLiteral("track1"), QStringLiteral("artist1"), QStringLiteral("album1"), 1, 1)}},
QStringLiteral("track1"), {}},
ElisaUtils::Track);
......@@ -426,7 +426,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 0);
QCOMPARE(myPlayList.tracksCount(), 1);
QCOMPARE(myPlayList.rowCount(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), true);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -448,7 +448,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 0);
QCOMPARE(myPlayList.tracksCount(), 1);
QCOMPARE(myPlayList.rowCount(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), true);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......@@ -463,7 +463,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 1);
QCOMPARE(tracksListAddedSpy.count(), 0);
QCOMPARE(myPlayList.tracksCount(), 1);
QCOMPARE(myPlayList.rowCount(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsValidRole).toBool(), false);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::TitleRole).toString(), QStringLiteral("track1"));
......
......@@ -2,6 +2,7 @@ include_directories(${elisa_BINARY_DIR})
set(elisaLib_SOURCES
mediaplaylist.cpp
mediaplaylistproxymodel.cpp
progressindicator.cpp
databaseinterface.cpp
datatypes.cpp
......@@ -30,7 +31,7 @@ set(elisaLib_SOURCES
models/trackcontextmetadatamodel.cpp
models/viewsmodel.cpp
localFileConfiguration/elisaconfigurationdialog.cpp
)
)
ecm_qt_declare_logging_category(elisaLib_SOURCES
HEADER "indexersManager.h"
......
......@@ -21,6 +21,7 @@
#include "musiclistenersmanager.h"
#include "mediaplaylist.h"
#include "mediaplaylistproxymodel.h"
#include "audiowrapper.h"
#include "manageaudioplayer.h"
#include "managemediaplayercontrol.h"
......@@ -94,6 +95,8 @@ public:
std::unique_ptr<MediaPlayList> mMediaPlayList;
std::unique_ptr<MediaPlayListProxyModel> mMediaPlayListProxyModel;
std::unique_ptr<AudioWrapper> mAudioWrapper;
std::unique_ptr<ManageAudioPlayer> mAudioControl;
......@@ -363,13 +366,17 @@ void ElisaApplication::initializeModels()
d->mMusicManager->subscribeForTracks(d->mMediaPlayList.get());
Q_EMIT mediaPlayListChanged();
d->mMediaPlayListProxyModel = std::make_unique<MediaPlayListProxyModel>();
d->mMediaPlayListProxyModel->setPlayListModel(d->mMediaPlayList.get());
Q_EMIT mediaPlayListProxyModelChanged();
d->mMusicManager->setElisaApplication(this);
QObject::connect(this, &ElisaApplication::enqueue,
d->mMediaPlayList.get(), static_cast<void (MediaPlayList::*)(const ElisaUtils::EntryDataList&,
d->mMediaPlayListProxyModel.get(), static_cast<void (MediaPlayListProxyModel::*)(const ElisaUtils::EntryDataList&,
ElisaUtils::PlayListEntryType,
ElisaUtils::PlayListEnqueueMode,
ElisaUtils::PlayListEnqueueTriggerPlay)>(&MediaPlayList::enqueue));
ElisaUtils::PlayListEnqueueTriggerPlay)>(&MediaPlayListProxyModel::enqueue));
}
void ElisaApplication::initializePlayer()
......@@ -388,7 +395,7 @@ void ElisaApplication::initializePlayer()
d->mAudioControl->setTitleRole(MediaPlayList::TitleRole);
d->mAudioControl->setUrlRole(MediaPlayList::ResourceRole);
d->mAudioControl->setIsPlayingRole(MediaPlayList::IsPlayingRole);
d->mAudioControl->setPlayListModel(d->mMediaPlayList.get());
d->mAudioControl->setPlayListModel(d->mMediaPlayListProxyModel.get());
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::playerPlay, d->mAudioWrapper.get(), &AudioWrapper::play);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::playerPause, d->mAudioWrapper.get(), &AudioWrapper::pause);
......@@ -396,19 +403,22 @@ void ElisaApplication::initializePlayer()
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::seek, d->mAudioWrapper.get(), &AudioWrapper::seek);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::saveUndoPositionInAudioWrapper, d->mAudioWrapper.get(), &AudioWrapper::saveUndoPosition);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::restoreUndoPositionInAudioWrapper, d->mAudioWrapper.get(), &AudioWrapper::restoreUndoPosition);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::skipNextTrack, d->mMediaPlayList.get(), &MediaPlayList::skipNextTrack);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::sourceInError, d->mMediaPlayList.get(), &MediaPlayList::trackInError);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::skipNextTrack, d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::skipNextTrack);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::sourceInError, d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::trackInError);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::sourceInError, d->mMusicManager.get(), &MusicListenersManager::playBackError);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::playerSourceChanged, d->mAudioWrapper.get(), &AudioWrapper::setSource);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::startedPlayingTrack,
d->mMusicManager->viewDatabase(), &DatabaseInterface::trackHasStartedPlaying);
QObject::connect(d->mAudioControl.get(), &ManageAudioPlayer::updateData, d->mMediaPlayList.get(), &MediaPlayList::setData);
QObject::connect(d->mMediaPlayList.get(), &MediaPlayList::ensurePlay, d->mAudioControl.get(), &ManageAudioPlayer::ensurePlay);
QObject::connect(d->mMediaPlayList.get(), &MediaPlayList::playListFinished, d->mAudioControl.get(), &ManageAudioPlayer::playListFinished);
QObject::connect(d->mMediaPlayList.get(), &MediaPlayList::currentTrackChanged, d->mAudioControl.get(), &ManageAudioPlayer::setCurrentTrack);
QObject::connect(d->mMediaPlayList.get(), &MediaPlayList::clearPlayListPlayer, d->mAudioControl.get(), &ManageAudioPlayer::saveForUndoClearPlaylist);
QObject::connect(d->mMediaPlayList.get(), &MediaPlayList::undoClearPlayListPlayer, d->mAudioControl.get(), &ManageAudioPlayer::restoreForUndoClearPlaylist);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::ensurePlay, d->mAudioControl.get(), &ManageAudioPlayer::ensurePlay);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::playListFinished, d->mAudioControl.get(), &ManageAudioPlayer::playListFinished);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::currentTrackChanged, d->mAudioControl.get(), &ManageAudioPlayer::setCurrentTrack);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::clearPlayListPlayer, d->mAudioControl.get(), &ManageAudioPlayer::saveForUndoClearPlaylist);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::undoClearPlayListPlayer, d->mAudioControl.get(), &ManageAudioPlayer::restoreForUndoClearPlaylist);
QObject::connect(d->mAudioWrapper.get(), &AudioWrapper::playbackStateChanged,
d->mAudioControl.get(), &ManageAudioPlayer::setPlayerPlaybackState);
......@@ -419,9 +429,9 @@ void ElisaApplication::initializePlayer()
QObject::connect(d->mAudioWrapper.get(), &AudioWrapper::positionChanged, d->mAudioControl.get(), &ManageAudioPlayer::setPlayerPosition);
QObject::connect(d->mAudioWrapper.get(), &AudioWrapper::currentPlayingForRadiosChanged, d->mAudioControl.get(), &ManageAudioPlayer::setCurrentPlayingForRadios);
QObject::connect(d->mMediaPlayList.get(), &MediaPlayList::currentTrackChanged, d->mPlayerControl.get(), &ManageMediaPlayerControl::setCurrentTrack);
QObject::connect(d->mMediaPlayList.get(), &MediaPlayList::previousTrackChanged, d->mPlayerControl.get(), &ManageMediaPlayerControl::setPreviousTrack);
QObject::connect(d->mMediaPlayList.get(), &MediaPlayList::nextTrackChanged, d->mPlayerControl.get(), &ManageMediaPlayerControl::setNextTrack);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::currentTrackChanged, d->mPlayerControl.get(), &ManageMediaPlayerControl::setCurrentTrack);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::previousTrackChanged, d->mPlayerControl.get(), &ManageMediaPlayerControl::setPreviousTrack);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::nextTrackChanged, d->mPlayerControl.get(), &ManageMediaPlayerControl::setNextTrack);
QObject::connect(d->mAudioWrapper.get(), &AudioWrapper::playing, d->mPlayerControl.get(), &ManageMediaPlayerControl::playerPlaying);
QObject::connect(d->mAudioWrapper.get(), &AudioWrapper::paused, d->mPlayerControl.get(), &ManageMediaPlayerControl::playerPausedOrStopped);
......@@ -437,7 +447,8 @@ void ElisaApplication::initializePlayer()
d->mManageHeaderBar->setTrackTypeRole(MediaPlayList::ElementTypeRole);
d->mManageHeaderBar->setAlbumIdRole(MediaPlayList::AlbumIdRole);
d->mManageHeaderBar->setIsValidRole(MediaPlayList::IsValidRole);
QObject::connect(d->mMediaPlayList.get(), &MediaPlayList::currentTrackChanged, d->mManageHeaderBar.get(), &ManageHeaderBar::setCurrentTrack);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::currentTrackChanged, d->mManageHeaderBar.get(), &ManageHeaderBar::setCurrentTrack);
QObject::connect(d->mMediaPlayListProxyModel.get(), &MediaPlayListProxyModel::currentTrackDataChanged, d->mManageHeaderBar.get(), &ManageHeaderBar::updateCurrentTrackData);
if (!d->mArguments.isEmpty()) {
Q_EMIT enqueue(d->mArguments, ElisaUtils::FileName,
......@@ -506,6 +517,12 @@ MediaPlayList *ElisaApplication::mediaPlayList() const
return d->mMediaPlayList.get();
}
MediaPlayListProxyModel *ElisaApplication::mediaPlayListProxyModel() const
{
return d->mMediaPlayListProxyModel.get();
}
AudioWrapper *ElisaApplication::audioPlayer() const
{
return d->mAudioWrapper.get();
......
......@@ -33,6 +33,7 @@ class QIcon;
class QAction;
class MusicListenersManager;
class MediaPlayList;
class MediaPlayListProxyModel;
class AudioWrapper;
class ManageAudioPlayer;
class ManageMediaPlayerControl;
......@@ -58,6 +59,12 @@ class ELISALIB_EXPORT ElisaApplication : public QObject
READ mediaPlayList
NOTIFY mediaPlayListChanged)
Q_PROPERTY(MediaPlayListProxyModel *mediaPlayListProxyModel
READ mediaPlayListProxyModel
NOTIFY mediaPlayListProxyModelChanged)
Q_PROPERTY(AudioWrapper *audioPlayer
READ audioPlayer
NOTIFY audioPlayerChanged)
......@@ -97,6 +104,8 @@ public:
MediaPlayList *mediaPlayList() const;
MediaPlayListProxyModel *mediaPlayListProxyModel() const;
AudioWrapper *audioPlayer() const;
ManageAudioPlayer *audioControl() const;
......@@ -115,6 +124,8 @@ Q_SIGNALS:
void mediaPlayListChanged();
void mediaPlayListProxyModelChanged();
void audioPlayerChanged();
void audioControlChanged();
......
......@@ -37,6 +37,7 @@
#include "elisaapplication.h"
#include "progressindicator.h"
#include "mediaplaylist.h"
#include "mediaplaylistproxymodel.h"
#include "managemediaplayercontrol.h"