Commit 757dff82 authored by Alexander Stippich's avatar Alexander Stippich
Browse files

remove special handling of radios and use generic functions, remove unused functions

parent 6b2b9b03
......@@ -3674,7 +3674,7 @@ void MediaPlayListTest::testReplaceAndPlayArtist()
QCOMPARE(newTrackByNameInListSpy.count(), 0);
QCOMPARE(newEntryInListSpy.count(), 0);
myPlayList.replaceAndPlay({{}, QStringLiteral("artist3"), {}}, ElisaUtils::Artist);
myPlayList.enqueue(ElisaUtils::EntryData{{}, QStringLiteral("artist3"), {}}, ElisaUtils::Artist, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -3715,7 +3715,7 @@ void MediaPlayListTest::testReplaceAndPlayArtist()
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsPlayingRole).toBool(), false);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ColumnsRoles::IsSingleDiscAlbumRole).toBool(), false);
myPlayList.replaceAndPlay({{}, QStringLiteral("artist4"), {}}, ElisaUtils::Artist);
myPlayList.enqueue(ElisaUtils::EntryData{{}, QStringLiteral("artist4"), {}}, ElisaUtils::Artist, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 1);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -3825,7 +3825,7 @@ void MediaPlayListTest::testReplaceAndPlayTrackId()
QCOMPARE(firstTrackId != 0, true);
myPlayList.replaceAndPlay(ElisaUtils::EntryData{{{DataTypes::DatabaseIdRole, firstTrackId}}, {}, {}}, ElisaUtils::Track);
myPlayList.enqueue(ElisaUtils::EntryData{{{DataTypes::DatabaseIdRole, firstTrackId}}, {}, {}}, ElisaUtils::Track, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -3871,7 +3871,7 @@ void MediaPlayListTest::testReplaceAndPlayTrackId()
QCOMPARE(secondTrackId != 0, true);
myPlayList.replaceAndPlay(ElisaUtils::EntryData{{{DataTypes::DatabaseIdRole, secondTrackId}}, {}, {}}, ElisaUtils::Track);
myPlayList.enqueue(ElisaUtils::EntryData{{{DataTypes::DatabaseIdRole, secondTrackId}}, {}, {}}, ElisaUtils::Track, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 1);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -4189,7 +4189,7 @@ void MediaPlayListTest::testRemoveSelection()
QCOMPARE(newTrackByNameInListSpy.count(), 0);
QCOMPARE(newEntryInListSpy.count(), 0);
myPlayList.replaceAndPlay({{}, QStringLiteral("artist1"), {}}, ElisaUtils::Artist);
myPlayList.enqueue(ElisaUtils::EntryData{{}, QStringLiteral("artist1"), {}}, ElisaUtils::Artist, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -4361,7 +4361,7 @@ void MediaPlayListTest::testTrackBeenRemoved()
QCOMPARE(newTrackByNameInListSpy.count(), 0);
QCOMPARE(newEntryInListSpy.count(), 0);
myPlayList.replaceAndPlay({{}, QStringLiteral("artist1"), {}}, ElisaUtils::Artist);
myPlayList.enqueue(ElisaUtils::EntryData{{}, QStringLiteral("artist1"), {}}, ElisaUtils::Artist, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......
......@@ -96,7 +96,7 @@ private Q_SLOTS:
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
QCOMPARE(tracksListAddedSpy.count(), 0);
myPlayList.replaceAndPlay({{}, QStringLiteral("artist1"), {}}, ElisaUtils::Artist);
myPlayList.enqueue(ElisaUtils::EntryData{{}, QStringLiteral("artist1"), {}}, ElisaUtils::Artist, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
QCOMPARE(trackHasChangedSpy.count(), 0);
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
......@@ -223,7 +223,7 @@ private Q_SLOTS:
QCOMPARE(trackId != 0, true);
myPlayList.replaceAndPlay(ElisaUtils::EntryData{{{DataTypes::DatabaseIdRole, trackId}}, {}, {}}, ElisaUtils::Track);
myPlayList.enqueue(ElisaUtils::EntryData{{{DataTypes::DatabaseIdRole, trackId}}, {}, {}}, ElisaUtils::Track, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
QCOMPARE(trackHasChangedSpy.count(), 1);
QCOMPARE(trackHasBeenRemovedSpy.count(), 0);
......
......@@ -402,7 +402,7 @@ void ElisaApplication::initializePlayer()
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::currentPlayingForRadiosChanged, d->mMediaPlayList.get(), &MediaPlayList::updateRadioData);
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);
......
......@@ -416,8 +416,8 @@ void ManageAudioPlayer::setPlayerPosition(qint64 playerPosition)
void ManageAudioPlayer::setCurrentPlayingForRadios(const QString &title, const QString &nowPlaying)
{
if (mPlayListModel && mCurrentTrack.isValid()) {
Q_EMIT currentPlayingForRadiosChanged(title, MediaPlayList::TitleRole);
Q_EMIT currentPlayingForRadiosChanged(nowPlaying, MediaPlayList::ArtistRole);
Q_EMIT updateData(mCurrentTrack, title, MediaPlayList::TitleRole);
Q_EMIT updateData(mCurrentTrack, nowPlaying, MediaPlayList::ArtistRole);
}
}
......
......@@ -203,7 +203,7 @@ Q_SIGNALS:
void startedPlayingTrack(const QUrl &fileName, const QDateTime &time);
void currentPlayingForRadiosChanged(const QVariant &value, int role);
void updateData(const QPersistentModelIndex &index, const QVariant &value, int role);
public Q_SLOTS:
......
......@@ -578,13 +578,6 @@ void MediaPlayList::enqueueMultipleEntries(const ElisaUtils::EntryDataList &entr
Q_EMIT persistentStateChanged();
}
void MediaPlayList::replaceAndPlay(const ElisaUtils::EntryData &newEntry,
ElisaUtils::PlayListEntryType databaseIdType)
{
qCDebug(orgKdeElisaPlayList()) << "MediaPlayList::replaceAndPlay" << std::get<0>(newEntry) << std::get<1>(newEntry) << databaseIdType;
enqueue(newEntry, databaseIdType, ElisaUtils::PlayListEnqueueMode::ReplacePlayList, ElisaUtils::PlayListEnqueueTriggerPlay::TriggerPlay);
}
void MediaPlayList::clearPlayList(bool prepareUndo)
{
if (d->mData.isEmpty()) {
......@@ -665,14 +658,6 @@ void MediaPlayList::undoClearPlayList()
Q_EMIT undoClearPlayListPlayer();
}
void MediaPlayList::updateRadioData(const QVariant &value, int role)
{
auto convertedRole = static_cast<ColumnsRoles>(role);
if (d->mCurrentTrack.data(convertedRole) != value) {
this->setData(d->mCurrentTrack, value, role);
}
}
void MediaPlayList::enqueueCommon()
{
displayOrHideUndoInline(false);
......
......@@ -280,14 +280,10 @@ public Q_SLOTS:
ElisaUtils::PlayListEnqueueMode enqueueMode,
ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay);
void replaceAndPlay(const ElisaUtils::EntryData &newEntry, ElisaUtils::PlayListEntryType databaseIdType);
void trackInError(const QUrl &sourceInError, QMediaPlayer::Error playerError);
void undoClearPlayList();
void updateRadioData(const QVariant &value, int role);
private Q_SLOTS:
void loadPlayListLoaded();
......
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