Commit 3311ba3a authored by Alexander Volkov's avatar Alexander Volkov

Use lambdas instead of QSignalMapper

Reviewers: #okular, aacid

Reviewed By: #okular, aacid

Subscribers: okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D17481
parent 2c39981b
......@@ -90,7 +90,6 @@ public:
AudioPlayerPrivate::AudioPlayerPrivate( AudioPlayer * qq )
: q( qq ), m_state( AudioPlayer::StoppedState )
{
QObject::connect( &m_mapper, SIGNAL(mapped(int)), q, SLOT(finished(int)) );
}
AudioPlayerPrivate::~AudioPlayerPrivate()
......@@ -131,7 +130,9 @@ bool AudioPlayerPrivate::play( const SoundInfo& si )
if ( !url.isEmpty() )
{
int newid = newId();
m_mapper.setMapping( data->m_mediaobject, newid );
QObject::connect( data->m_mediaobject, &Phonon::MediaObject::finished, q, [this, newid]() {
finished(newid);
});
QUrl newurl;
if ( QUrl::fromUserInput(url).isRelative() )
{
......@@ -156,7 +157,9 @@ bool AudioPlayerPrivate::play( const SoundInfo& si )
{
qCDebug(OkularCoreDebug) << "Mediaobject:" << data->m_mediaobject;
int newid = newId();
m_mapper.setMapping( data->m_mediaobject, newid );
QObject::connect( data->m_mediaobject, &Phonon::MediaObject::finished, q, [this, newid]() {
finished(newid);
});
data->m_buffer = new QBuffer();
data->m_buffer->setData( filedata );
data->m_mediaobject->setCurrentSource( Phonon::MediaSource( data->m_buffer ) );
......@@ -173,7 +176,6 @@ bool AudioPlayerPrivate::play( const SoundInfo& si )
}
if ( data )
{
QObject::connect( data->m_mediaobject, SIGNAL(finished()), &m_mapper, SLOT(map()) );
qCDebug(OkularCoreDebug) << "PLAY";
data->play();
m_state = AudioPlayer::PlayingState;
......@@ -203,7 +205,6 @@ void AudioPlayerPrivate::finished( int id )
}
else
{
m_mapper.removeMappings( it.value()->m_mediaobject );
delete it.value();
m_playing.erase( it );
m_state = AudioPlayer::StoppedState;
......
......@@ -81,7 +81,6 @@ class OKULARCORE_EXPORT AudioPlayer : public QObject
friend class Document;
Q_DISABLE_COPY( AudioPlayer )
Q_PRIVATE_SLOT( d, void finished( int ) )
};
}
......
......@@ -12,7 +12,6 @@
// qt/kde includes
#include <qhash.h>
#include <qsignalmapper.h>
#include <QUrl>
class PlayData;
......@@ -33,13 +32,11 @@ public:
bool play( const SoundInfo& si );
void stopPlayings();
// private slots
void finished( int );
AudioPlayer * q;
QHash< int, PlayData * > m_playing;
QSignalMapper m_mapper;
QUrl m_currentDocument;
AudioPlayer::State m_state;
};
......
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