1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-03 10:53:39 +02:00

Merge branch 'master' into qmlstation

This commit is contained in:
Christian Muehlhaeuser
2012-11-28 13:01:46 +01:00
6 changed files with 55 additions and 69 deletions

View File

@@ -58,9 +58,13 @@ Tomahawk::result_ptr
PlaylistInterface::siblingResult( int itemsAway ) const
{
qint64 idx = siblingIndex( itemsAway );
qint64 safetyCheck = 0;
while ( idx >= 0 )
// If safetyCheck equals idx, this means the interface keeps returning the same item and we won't discover anything new - abort
// This can happen in repeat / random mode e.g.
while ( idx >= 0 && safetyCheck != idx )
{
safetyCheck = idx;
Tomahawk::query_ptr query = queryAt( idx );
if ( query )
{

View File

@@ -121,7 +121,6 @@ ViewManager::ViewManager( QObject* parent )
ViewManager::~ViewManager()
{
saveCurrentPlaylistSettings();
delete m_whatsHotWidget;
delete m_newReleasesWidget;
delete m_welcomeWidget;
@@ -525,8 +524,6 @@ ViewManager::setPage( ViewPage* page, bool trackHistory )
if ( page == m_currentPage )
return;
// save the old playlist shuffle state in config before we change playlists
saveCurrentPlaylistSettings();
unlinkPlaylist();
if ( m_stack->indexOf( page->widget() ) < 0 )
@@ -606,29 +603,6 @@ ViewManager::unlinkPlaylist()
}
void
ViewManager::saveCurrentPlaylistSettings()
{
TomahawkSettings* s = TomahawkSettings::instance();
Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() );
if ( !pl.isNull() )
{
s->setShuffleState( pl->guid(), currentPlaylistInterface()->shuffled() );
s->setRepeatMode( pl->guid(), currentPlaylistInterface()->repeatMode() );
}
else
{
Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() );
if ( !dynPl.isNull() )
{
s->setShuffleState( dynPl->guid(), currentPlaylistInterface()->shuffled() );
s->setRepeatMode( dynPl->guid(), currentPlaylistInterface()->repeatMode() );
}
}
}
void
ViewManager::updateView()
{
@@ -672,31 +646,6 @@ ViewManager::updateView()
}
m_infobar->setLongDescription( currentPage()->longDescription() );
m_infobar->setPixmap( currentPage()->pixmap() );
// turn on shuffle/repeat mode for the new playlist view if specified in config
loadCurrentPlaylistSettings();
}
void
ViewManager::loadCurrentPlaylistSettings()
{
TomahawkSettings* s = TomahawkSettings::instance();
Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() );
if ( !pl.isNull() )
{
currentPlaylistInterface()->setShuffled( s->shuffleState( pl->guid() ));
currentPlaylistInterface()->setRepeatMode( s->repeatMode( pl->guid() ));
}
else
{
Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() );
if ( !dynPl.isNull() )
{
currentPlaylistInterface()->setShuffled( s->shuffleState( dynPl->guid() ));
}
}
}

View File

@@ -176,8 +176,6 @@ private:
void setPage( Tomahawk::ViewPage* page, bool trackHistory = true );
void updateView();
void unlinkPlaylist();
void saveCurrentPlaylistSettings();
void loadCurrentPlaylistSettings();
Tomahawk::playlist_ptr playlistForInterface( Tomahawk::playlistinterface_ptr plInterface ) const;
Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( Tomahawk::playlistinterface_ptr plInterface ) const;

View File

@@ -195,6 +195,9 @@ PlayableProxyModelPlaylistInterface::siblingIndex( int itemsAway, qint64 rootInd
}
else
{
if ( !proxyModel->currentIndex().isValid() )
return -1;
// random mode is enabled
if ( m_shuffleCache.isValid() )
{
@@ -211,7 +214,7 @@ PlayableProxyModelPlaylistInterface::siblingIndex( int itemsAway, qint64 rootInd
item = proxyModel->itemFromIndex( proxyModel->mapToSource( idx ) );
}
while ( safetyCounter < proxyModel->rowCount() &&
( !item || !item->query()->playable() || m_shuffleHistory.contains( item->query() ) ) );
( !item || !item->query()->playable() || m_shuffleHistory.contains( item->query() ) ) );
if ( item && item->query()->playable() )
{
@@ -256,6 +259,9 @@ PlayableProxyModelPlaylistInterface::siblingIndex( int itemsAway, qint64 rootInd
if ( !idx.isValid() && m_repeatMode == PlaylistModes::RepeatAll )
{
if ( !proxyModel->currentIndex().isValid() )
return -1;
// repeat all tracks
if ( itemsAway > 0 )
{

View File

@@ -28,17 +28,18 @@
#include "PlayableModel.h"
#include "PlayableProxyModel.h"
#include "PlayableItem.h"
#include "audio/AudioEngine.h"
#include "context/ContextWidget.h"
#include "widgets/OverlayWidget.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
#include "utils/Closure.h"
#include "DropJob.h"
#include "Artist.h"
#include "Album.h"
#include "Source.h"
#include "TomahawkSettings.h"
#include "audio/AudioEngine.h"
#include "context/ContextWidget.h"
#include "widgets/OverlayWidget.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Closure.h"
#include "utils/AnimatedSpinner.h"
#include "utils/Logger.h"
#define SCROLL_TIMEOUT 280
@@ -95,19 +96,47 @@ TrackView::TrackView( QWidget* parent )
TrackView::~TrackView()
{
tDebug() << Q_FUNC_INFO;
tDebug() << Q_FUNC_INFO << ( m_guid.isEmpty() ? QString( "with empty guid" ) : QString( "with guid %1" ).arg( m_guid ) );
if ( !m_guid.isEmpty() && proxyModel()->playlistInterface() )
{
tDebug() << Q_FUNC_INFO << "Storing shuffle & random mode settings for guid" << m_guid;
TomahawkSettings* s = TomahawkSettings::instance();
s->setShuffleState( m_guid, proxyModel()->playlistInterface()->shuffled() );
s->setRepeatMode( m_guid, proxyModel()->playlistInterface()->repeatMode() );
}
}
QString
TrackView::guid() const
{
if ( m_guid.isEmpty() )
return QString();
return QString( "%1/%2" ).arg( m_guid ).arg( m_proxyModel->columnCount() );
}
void
TrackView::setGuid( const QString& guid )
TrackView::setGuid( const QString& newguid )
{
if ( !guid.isEmpty() )
if ( !newguid.isEmpty() )
{
tDebug() << Q_FUNC_INFO << "Setting guid on header" << guid << "for a view with" << m_proxyModel->columnCount() << "columns";
tDebug() << Q_FUNC_INFO << "Setting guid on header" << newguid << "for a view with" << m_proxyModel->columnCount() << "columns";
m_guid = QString( "%1/%2" ).arg( guid ).arg( m_proxyModel->columnCount() );
m_header->setGuid( m_guid );
m_guid = newguid;
m_header->setGuid( guid() );
if ( !m_guid.isEmpty() && proxyModel()->playlistInterface() )
{
tDebug() << Q_FUNC_INFO << "Restoring shuffle & random mode settings for guid" << m_guid;
TomahawkSettings* s = TomahawkSettings::instance();
proxyModel()->playlistInterface()->setShuffled( s->shuffleState( m_guid ) );
proxyModel()->playlistInterface()->setRepeatMode( s->repeatMode( m_guid ) );
}
}
}

View File

@@ -45,8 +45,8 @@ public:
explicit TrackView( QWidget* parent = 0 );
~TrackView();
virtual QString guid() const { return m_guid; }
virtual void setGuid( const QString& guid );
virtual QString guid() const;
virtual void setGuid( const QString& newguid );
virtual void setPlayableModel( PlayableModel* model );
virtual void setModel( QAbstractItemModel* model );