1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-02 04:10:20 +02:00

* Made sure lists resolve top-to-bottom.

This commit is contained in:
Christian Muehlhaeuser
2011-12-02 10:00:07 +01:00
parent eec1e56dda
commit f46d0803be
12 changed files with 74 additions and 66 deletions

View File

@@ -45,6 +45,7 @@ AudioControls::AudioControls( QWidget* parent )
, ui( new Ui::AudioControls ) , ui( new Ui::AudioControls )
, m_repeatMode( PlaylistInterface::NoRepeat ) , m_repeatMode( PlaylistInterface::NoRepeat )
, m_shuffled( false ) , m_shuffled( false )
, m_lastSliderCheck( 0 )
{ {
ui->setupUi( this ); ui->setupUi( this );
setAcceptDrops( true ); setAcceptDrops( true );
@@ -212,6 +213,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
ui->seekSlider->setVisible( true ); ui->seekSlider->setVisible( true );
m_noTimeChange = false; m_noTimeChange = false;
m_lastSliderCheck = 0;
Tomahawk::InfoSystem::InfoStringHash trackInfo; Tomahawk::InfoSystem::InfoStringHash trackInfo;
trackInfo["artist"] = result->artist()->name(); trackInfo["artist"] = result->artist()->name();
@@ -371,7 +373,11 @@ AudioControls::onPlaybackStopped()
void void
AudioControls::onPlaybackTimer( qint64 msElapsed ) AudioControls::onPlaybackTimer( qint64 msElapsed )
{ {
//tDebug( LOGEXTRA ) << Q_FUNC_INFO << " msElapsed = " << msElapsed << " and timer current time = " << m_sliderTimeLine.currentTime() << " and m_seekMsecs = " << m_seekMsecs; // tDebug( LOGEXTRA ) << Q_FUNC_INFO << "msElapsed =" << msElapsed << "and timer current time =" << m_sliderTimeLine.currentTime() << "and m_seekMsecs =" << m_seekMsecs;
if ( msElapsed > 0 && msElapsed - 500 < m_lastSliderCheck )
return;
m_lastSliderCheck = msElapsed;
if ( m_currentTrack.isNull() ) if ( m_currentTrack.isNull() )
return; return;
@@ -405,7 +411,7 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
else if ( m_sliderTimeLine.duration() > msElapsed && m_sliderTimeLine.state() == QTimeLine::NotRunning ) else if ( m_sliderTimeLine.duration() > msElapsed && m_sliderTimeLine.state() == QTimeLine::NotRunning )
{ {
ui->seekSlider->setEnabled( AudioEngine::instance()->canSeek() ); ui->seekSlider->setEnabled( AudioEngine::instance()->canSeek() );
m_sliderTimeLine.resume(); m_sliderTimeLine.start();
} }
else if ( m_sliderTimeLine.state() == QTimeLine::Paused && AudioEngine::instance()->state() != AudioEngine::Paused ) else if ( m_sliderTimeLine.state() == QTimeLine::Paused && AudioEngine::instance()->state() != AudioEngine::Paused )
{ {

View File

@@ -95,6 +95,7 @@ private:
QTimeLine m_sliderTimeLine; QTimeLine m_sliderTimeLine;
qint64 m_seekMsecs; qint64 m_seekMsecs;
qint64 m_lastSliderCheck;
bool m_noTimeChange; bool m_noTimeChange;
}; };

View File

@@ -185,7 +185,7 @@ AudioEngine::stop()
else if ( TomahawkSettings::instance()->verboseNotifications() ) else if ( TomahawkSettings::instance()->verboseNotifications() )
{ {
QVariantMap stopInfo; QVariantMap stopInfo;
stopInfo["message"] = QString( "Tomahawk is stopped." ); stopInfo["message"] = tr( "Tomahawk is stopped." );
map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< QVariantMap >( stopInfo ); map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< QVariantMap >( stopInfo );
} }
@@ -452,7 +452,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
if ( furl.startsWith( "file://" ) ) if ( furl.startsWith( "file://" ) )
furl = furl.right( furl.length() - 7 ); furl = furl.right( furl.length() - 7 );
#endif #endif
tLog() << "Passing to Phonon:" << furl << furl.toLatin1(); tLog( LOGVERBOSE ) << "Passing to Phonon:" << furl << furl.toLatin1();
m_mediaObject->setCurrentSource( furl ); m_mediaObject->setCurrentSource( furl );
} }

View File

@@ -19,10 +19,11 @@
#include "databasecommand_genericselect.h" #include "databasecommand_genericselect.h"
#include "databaseimpl.h" #include "databaseimpl.h"
#include "sourcelist.h"
#include "artist.h"
#include "album.h"
#include "pipeline.h"
#include "utils/logger.h" #include "utils/logger.h"
#include <sourcelist.h>
#include <artist.h>
#include <album.h>
using namespace Tomahawk; using namespace Tomahawk;
@@ -63,7 +64,6 @@ DatabaseCommand_GenericSelect::exec( DatabaseImpl* dbi )
while( query.next() ) while( query.next() )
{ {
QStringList rawRow; QStringList rawRow;
int count = 0; int count = 0;
while ( query.value( count ).isValid() ) while ( query.value( count ).isValid() )
@@ -90,15 +90,16 @@ DatabaseCommand_GenericSelect::exec( DatabaseImpl* dbi )
track = query.value( 0 ).toString(); track = query.value( 0 ).toString();
artist = query.value( 1 ).toString(); artist = query.value( 1 ).toString();
qry = Tomahawk::Query::get( artist, track, QString() );
qry = Tomahawk::Query::get( artist, track, QString(), uuid(), true ); // Only auto-resolve non-local results }
} else if ( m_queryType == Artist ) else if ( m_queryType == Artist )
{ {
int artistId = query.value( 0 ).toInt(); int artistId = query.value( 0 ).toInt();
QString artistName = query.value( 1 ).toString(); QString artistName = query.value( 1 ).toString();
artist = Tomahawk::Artist::get( artistId, artistName ); artist = Tomahawk::Artist::get( artistId, artistName );
} else if ( m_queryType == Album ) }
else if ( m_queryType == Album )
{ {
int albumId = query.value( 0 ).toInt(); int albumId = query.value( 0 ).toInt();
QString albumName = query.value( 1 ).toString(); QString albumName = query.value( 1 ).toString();
@@ -122,12 +123,14 @@ DatabaseCommand_GenericSelect::exec( DatabaseImpl* dbi )
if ( !extraData.isEmpty() ) if ( !extraData.isEmpty() )
qry->setProperty( "data", extraData ); qry->setProperty( "data", extraData );
queries << qry; queries << qry;
} else if ( m_queryType == Artist ) }
else if ( m_queryType == Artist )
{ {
if ( !extraData.isEmpty() ) if ( !extraData.isEmpty() )
artist->setProperty( "data", extraData ); artist->setProperty( "data", extraData );
arts << artist; arts << artist;
} else if ( m_queryType == Album ) }
else if ( m_queryType == Album )
{ {
if ( !extraData.isEmpty() ) if ( !extraData.isEmpty() )
album->setProperty( "data", extraData ); album->setProperty( "data", extraData );

View File

@@ -31,7 +31,6 @@ using namespace Tomahawk;
void void
DatabaseCommand_LoadPlaylistEntries::exec( DatabaseImpl* dbi ) DatabaseCommand_LoadPlaylistEntries::exec( DatabaseImpl* dbi )
{ {
// qDebug() << "Loading playlist entries for revision" << m_revguid;
generateEntries( dbi ); generateEntries( dbi );
emit done( m_revguid, m_guids, m_oldentries, m_islatest, m_entrymap, true ); emit done( m_revguid, m_guids, m_oldentries, m_islatest, m_entrymap, true );
@@ -42,40 +41,38 @@ void
DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi ) DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
{ {
TomahawkSqlQuery query_entries = dbi->newquery(); TomahawkSqlQuery query_entries = dbi->newquery();
query_entries.prepare("SELECT entries, playlist, author, timestamp, previous_revision " query_entries.prepare( "SELECT entries, playlist, author, timestamp, previous_revision "
"FROM playlist_revision " "FROM playlist_revision "
"WHERE guid = :guid"); "WHERE guid = :guid" );
query_entries.bindValue( ":guid", m_revguid ); query_entries.bindValue( ":guid", m_revguid );
query_entries.exec(); query_entries.exec();
// qDebug() << "trying to load entries:" << m_revguid; tLog( LOGVERBOSE ) << "trying to load playlist entries for guid:" << m_revguid;
QString prevrev; QString prevrev;
QJson::Parser parser; bool ok; QJson::Parser parser; bool ok;
if( query_entries.next() ) if ( query_entries.next() )
{ {
// entries should be a list of strings: // entries should be a list of strings:
QVariant v = parser.parse( query_entries.value(0).toByteArray(), &ok ); QVariant v = parser.parse( query_entries.value( 0 ).toByteArray(), &ok );
Q_ASSERT( ok && v.type() == QVariant::List ); //TODO Q_ASSERT( ok && v.type() == QVariant::List ); //TODO
m_guids = v.toStringList(); m_guids = v.toStringList();
QString inclause = QString( "('%1')" ).arg( m_guids.join( "', '" ) );
QString inclause = QString("('%1')").arg(m_guids.join("', '"));
TomahawkSqlQuery query = dbi->newquery(); TomahawkSqlQuery query = dbi->newquery();
QString sql = QString("SELECT guid, trackname, artistname, albumname, annotation, " QString sql = QString( "SELECT guid, trackname, artistname, albumname, annotation, "
"duration, addedon, addedby, result_hint " "duration, addedon, addedby, result_hint "
"FROM playlist_item " "FROM playlist_item "
"WHERE guid IN %1").arg( inclause ); "WHERE guid IN %1" ).arg( inclause );
//qDebug() << sql;
query.exec( sql ); query.exec( sql );
while( query.next() ) while ( query.next() )
{ {
plentry_ptr e( new PlaylistEntry ); plentry_ptr e( new PlaylistEntry );
e->setGuid( query.value( 0 ).toString() ); e->setGuid( query.value( 0 ).toString() );
e->setAnnotation( query.value( 4 ).toString() ); e->setAnnotation( query.value( 4 ).toString() );
e->setDuration( query.value( 5 ).toUInt() ); e->setDuration( query.value( 5 ).toUInt() );
e->setLastmodified( 0 ); // TODO e->lastmodified = query.value(6).toInt(); e->setLastmodified( 0 ); // TODO e->lastmodified = query.value( 6 ).toInt();
e->setResultHint( query.value( 8 ).toString() ); e->setResultHint( query.value( 8 ).toString() );
Tomahawk::query_ptr q = Tomahawk::Query::get( query.value( 2 ).toString(), query.value( 1 ).toString(), query.value( 3 ).toString() ); Tomahawk::query_ptr q = Tomahawk::Query::get( query.value( 2 ).toString(), query.value( 1 ).toString(), query.value( 3 ).toString() );
@@ -86,14 +83,13 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
} }
prevrev = query_entries.value( 4 ).toString(); prevrev = query_entries.value( 4 ).toString();
} }
else else
{ {
// qDebug() << "Playlist has no current revision data"; // qDebug() << "Playlist has no current revision data";
} }
if( prevrev.length() ) if ( prevrev.length() )
{ {
TomahawkSqlQuery query_entries_old = dbi->newquery(); TomahawkSqlQuery query_entries_old = dbi->newquery();
query_entries_old.prepare( "SELECT entries, " query_entries_old.prepare( "SELECT entries, "
@@ -105,7 +101,7 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
query_entries_old.addBindValue( prevrev ); query_entries_old.addBindValue( prevrev );
query_entries_old.exec(); query_entries_old.exec();
if( !query_entries_old.next() ) if ( !query_entries_old.next() )
{ {
return; return;
Q_ASSERT( false ); Q_ASSERT( false );

View File

@@ -65,7 +65,7 @@ DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
if ( query_track.next() ) if ( query_track.next() )
{ {
Tomahawk::query_ptr q = Tomahawk::Query::get( query_track.value( 1 ).toString(), query_track.value( 0 ).toString(), QString(), uuid() ); Tomahawk::query_ptr q = Tomahawk::Query::get( query_track.value( 1 ).toString(), query_track.value( 0 ).toString(), QString() );
if ( query.value( 3 ).toUInt() == 0 ) if ( query.value( 3 ).toUInt() == 0 )
{ {
@@ -80,8 +80,6 @@ DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
} }
} }
qDebug() << Q_FUNC_INFO << ql.length();
if ( ql.count() ) if ( ql.count() )
emit tracks( ql ); emit tracks( ql );
} }

View File

@@ -126,11 +126,10 @@ Pipeline::addScriptResolver( const QString& path, bool start )
{ {
ExternalResolver* res = 0; ExternalResolver* res = 0;
foreach( ResolverFactoryFunc factory, m_resolverFactories) foreach ( ResolverFactoryFunc factory, m_resolverFactories )
{ {
res = factory( path ); res = factory( path );
if ( !res )
if( !res )
continue; continue;
m_scriptResolvers << res; m_scriptResolvers << res;

View File

@@ -157,7 +157,9 @@ Playlist::init()
} }
Playlist::~Playlist() {} Playlist::~Playlist()
{
}
playlist_ptr playlist_ptr
@@ -363,7 +365,6 @@ Playlist::setRevision( const QString& rev,
{ {
connect( entry->query().data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ), connect( entry->query().data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
SLOT( onResultsFound( QList<Tomahawk::result_ptr> ) ), Qt::UniqueConnection ); SLOT( onResultsFound( QList<Tomahawk::result_ptr> ) ), Qt::UniqueConnection );
} }
setBusy( false ); setBusy( false );

View File

@@ -104,8 +104,7 @@ CustomPlaylistView::generateTracks()
void void
CustomPlaylistView::tracksGenerated( QList< query_ptr > tracks ) CustomPlaylistView::tracksGenerated( QList< query_ptr > tracks )
{ {
foreach ( const query_ptr& q, tracks ) m_model->append( tracks );
m_model->append( q );
} }

View File

@@ -132,13 +132,7 @@ PlaylistModel::append( const QList< query_ptr >& queries )
void void
PlaylistModel::append( const Tomahawk::query_ptr& query ) PlaylistModel::append( const Tomahawk::query_ptr& query )
{ {
if ( query.isNull() ) insert( query, rowCount( QModelIndex() ) );
return;
if ( !query->resolvingFinished() )
Pipeline::instance()->resolve( query );
TrackModel::append( query );
} }
@@ -230,6 +224,7 @@ PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row )
emit beginInsertRows( QModelIndex(), crows.first, crows.second ); emit beginInsertRows( QModelIndex(), crows.first, crows.second );
QList< Tomahawk::query_ptr > queries;
int i = 0; int i = 0;
TrackModelItem* plitem; TrackModelItem* plitem;
foreach( const plentry_ptr& entry, entries ) foreach( const plentry_ptr& entry, entries )
@@ -243,6 +238,7 @@ PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row )
if ( !entry->query()->resolvingFinished() && !entry->query()->playable() ) if ( !entry->query()->resolvingFinished() && !entry->query()->playable() )
{ {
queries << entry->query();
m_waitingForResolved.append( entry->query().data() ); m_waitingForResolved.append( entry->query().data() );
connect( entry->query().data(), SIGNAL( resolvingFinished( bool ) ), SLOT( trackResolved( bool ) ) ); connect( entry->query().data(), SIGNAL( resolvingFinished( bool ) ), SLOT( trackResolved( bool ) ) );
} }
@@ -251,7 +247,10 @@ PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row )
} }
if ( !m_waitingForResolved.isEmpty() ) if ( !m_waitingForResolved.isEmpty() )
{
Pipeline::instance()->resolve( queries );
emit loadingStarted(); emit loadingStarted();
}
emit endInsertRows(); emit endInsertRows();
emit trackCountChanged( rowCount( QModelIndex() ) ); emit trackCountChanged( rowCount( QModelIndex() ) );

View File

@@ -47,24 +47,28 @@ TemporaryPageItem::text() const
return m_page->title(); return m_page->title();
} }
void void
TemporaryPageItem::activate() TemporaryPageItem::activate()
{ {
ViewManager::instance()->show( m_page ); ViewManager::instance()->show( m_page );
} }
QIcon QIcon
TemporaryPageItem::icon() const TemporaryPageItem::icon() const
{ {
return m_icon; return m_icon;
} }
int int
TemporaryPageItem::peerSortValue() const TemporaryPageItem::peerSortValue() const
{ {
return m_sortValue; return m_sortValue;
} }
int int
TemporaryPageItem::IDValue() const TemporaryPageItem::IDValue() const
{ {

View File

@@ -1,19 +1,21 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
/* *
This program is free software; you can redistribute it and/or modify * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
it under the terms of the GNU General Public License as published by * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
the Free Software Foundation; either version 2 of the License, or *
(at your option) any later version. * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
This program is distributed in the hope that it will be useful, * the Free Software Foundation, either version 3 of the License, or
but WITHOUT ANY WARRANTY; without even the implied warranty of * (at your option) any later version.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
GNU General Public License for more details. * Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
You should have received a copy of the GNU General Public License along * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
with this program; if not, write to the Free Software Foundation, Inc., * GNU General Public License for more details.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
*/ * You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sourcetree/sourcesmodel.h" #include "sourcetree/sourcesmodel.h"