1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 17:43:59 +02:00

Initial work on latch functionality

This commit is contained in:
Jeff Mitchell
2011-06-16 17:19:19 -04:00
parent 00252e4e53
commit 64cd6e584f
7 changed files with 167 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ set( libSources
query.cpp
result.cpp
source.cpp
sourceplaylistinterface.cpp
viewpage.cpp
viewmanager.cpp
globalactionmanager.cpp
@@ -189,6 +190,7 @@ set( libHeaders
resolver.h
result.h
source.h
sourceplaylistinterface.h
viewpage.h
viewmanager.h
globalactionmanager.h

View File

@@ -146,7 +146,9 @@ void
AudioEngine::previous()
{
qDebug() << Q_FUNC_INFO;
loadPreviousTrack();
if ( !m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkip &&
!m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkipSeek )
loadPreviousTrack();
}
@@ -154,13 +156,19 @@ void
AudioEngine::next()
{
qDebug() << Q_FUNC_INFO;
loadNextTrack();
if ( !m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkip &&
!m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkipSeek )
loadNextTrack();
}
void
AudioEngine::seek( int ms )
{
if ( m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSeek ||
m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkipSeek )
return;
if ( isPlaying() || isPaused() )
{
qDebug() << Q_FUNC_INFO << ms;

View File

@@ -35,6 +35,7 @@ class DLLEXPORT PlaylistInterface
public:
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
enum ViewMode { Unknown, Tree, Flat, Album };
enum SkipSeekRestrictions { NoRestrictions, NoSkip, NoSeek, NoSkipSeek };
PlaylistInterface( QObject* parent = 0 ) : m_object( parent ) {}
virtual ~PlaylistInterface() {}
@@ -51,6 +52,7 @@ public:
virtual PlaylistInterface::RepeatMode repeatMode() const = 0;
virtual bool shuffled() const = 0;
virtual PlaylistInterface::ViewMode viewMode() const { return Unknown; }
virtual PlaylistInterface::SkipSeekRestrictions skipSeekRestrictions() const { return NoRestrictions; }
virtual QString filter() const { return m_filter; }
virtual void setFilter( const QString& pattern ) { m_filter = pattern; }

View File

@@ -20,6 +20,7 @@
#include "collection.h"
#include "sourcelist.h"
#include "sourceplaylistinterface.h"
#include "network/controlconnection.h"
#include "database/databasecommand_addsource.h"
@@ -267,6 +268,18 @@ Source::trackCount() const
}
Tomahawk::playlistinterface_ptr
Source::getPlaylistInterface()
{
if ( m_playlistInterface.isNull() )
{
Tomahawk::source_ptr source = SourceList::instance()->get( id() );
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::SourcePlaylistInterface( source ) );
}
return m_playlistInterface;
}
void
Source::onPlaybackStarted( const Tomahawk::query_ptr& query )
{

View File

@@ -77,6 +77,8 @@ public:
Tomahawk::query_ptr currentTrack() const { return m_currentTrack; }
QString textStatus() const { return m_textStatus; }
Tomahawk::playlistinterface_ptr getPlaylistInterface();
signals:
void syncedWithDatabase();
void online();
@@ -124,6 +126,8 @@ private:
ControlConnection* m_cc;
QPixmap* m_avatar;
Tomahawk::playlistinterface_ptr m_playlistInterface;
};
};

View File

@@ -0,0 +1,62 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sourceplaylistinterface.h"
#include <QDebug>
#include "source.h"
#include "pipeline.h"
using namespace Tomahawk;
SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source )
: PlaylistInterface( this )
, m_source( source )
{
connect( source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
}
Tomahawk::result_ptr
SourcePlaylistInterface::siblingItem( int itemsAway )
{
Q_UNUSED( itemsAway );
return m_source->currentTrack()->results().first();
}
Tomahawk::result_ptr
SourcePlaylistInterface::nextItem()
{
return m_source->currentTrack()->results().first();
}
QList<Tomahawk::query_ptr>
SourcePlaylistInterface::tracks()
{
return m_source->collection()->tracks();
}
void
SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& query ) const
{
Pipeline::instance()->resolve( query, true );
}

View File

@@ -0,0 +1,74 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOMAHAWKSOURCEPLAYLISTINTERFACE_H
#define TOMAHAWKSOURCEPLAYLISTINTERFACE_H
#include <QObject>
#include <QSharedPointer>
#include "typedefs.h"
#include "collection.h"
#include "playlistinterface.h"
#include "dllmacro.h"
namespace Tomahawk
{
class DLLEXPORT SourcePlaylistInterface : public QObject, public PlaylistInterface
{
Q_OBJECT
public:
SourcePlaylistInterface( Tomahawk::source_ptr& source );
QList<Tomahawk::query_ptr> tracks();
virtual int trackCount() const { return 1; }
virtual int unfilteredTrackCount() const { return 1; }
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
virtual Tomahawk::result_ptr nextItem();
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
virtual PlaylistInterface::SkipSeekRestrictions skipSeekRestrictions() const { return PlaylistInterface::NoSkipSeek; }
virtual bool shuffled() const { return false; }
virtual void setFilter( const QString& /*pattern*/ ) {}
public slots:
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
virtual void setShuffled( bool ) {}
signals:
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
void shuffleModeChanged( bool enabled );
void trackCountChanged( unsigned int tracks );
void sourceTrackCountChanged( unsigned int tracks );
private slots:
void onSourcePlaybackStarted( const Tomahawk::query_ptr& query ) const;
private:
Tomahawk::source_ptr m_source;
};
}; // ns
#endif