1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01: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 )
, m_repeatMode( PlaylistInterface::NoRepeat )
, m_shuffled( false )
, m_lastSliderCheck( 0 )
{
ui->setupUi( this );
setAcceptDrops( true );
@ -212,6 +213,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
ui->seekSlider->setVisible( true );
m_noTimeChange = false;
m_lastSliderCheck = 0;
Tomahawk::InfoSystem::InfoStringHash trackInfo;
trackInfo["artist"] = result->artist()->name();
@ -371,7 +373,11 @@ AudioControls::onPlaybackStopped()
void
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() )
return;
@ -405,7 +411,7 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
else if ( m_sliderTimeLine.duration() > msElapsed && m_sliderTimeLine.state() == QTimeLine::NotRunning )
{
ui->seekSlider->setEnabled( AudioEngine::instance()->canSeek() );
m_sliderTimeLine.resume();
m_sliderTimeLine.start();
}
else if ( m_sliderTimeLine.state() == QTimeLine::Paused && AudioEngine::instance()->state() != AudioEngine::Paused )
{

View File

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

View File

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

View File

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

View File

@ -31,7 +31,6 @@ using namespace Tomahawk;
void
DatabaseCommand_LoadPlaylistEntries::exec( DatabaseImpl* dbi )
{
// qDebug() << "Loading playlist entries for revision" << m_revguid;
generateEntries( dbi );
emit done( m_revguid, m_guids, m_oldentries, m_islatest, m_entrymap, true );
@ -42,40 +41,38 @@ void
DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
{
TomahawkSqlQuery query_entries = dbi->newquery();
query_entries.prepare("SELECT entries, playlist, author, timestamp, previous_revision "
"FROM playlist_revision "
"WHERE guid = :guid");
query_entries.prepare( "SELECT entries, playlist, author, timestamp, previous_revision "
"FROM playlist_revision "
"WHERE guid = :guid" );
query_entries.bindValue( ":guid", m_revguid );
query_entries.exec();
// qDebug() << "trying to load entries:" << m_revguid;
tLog( LOGVERBOSE ) << "trying to load playlist entries for guid:" << m_revguid;
QString prevrev;
QJson::Parser parser; bool ok;
if( query_entries.next() )
if ( query_entries.next() )
{
// 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
m_guids = v.toStringList();
QString inclause = QString("('%1')").arg(m_guids.join("', '"));
QString inclause = QString( "('%1')" ).arg( m_guids.join( "', '" ) );
TomahawkSqlQuery query = dbi->newquery();
QString sql = QString("SELECT guid, trackname, artistname, albumname, annotation, "
"duration, addedon, addedby, result_hint "
"FROM playlist_item "
"WHERE guid IN %1").arg( inclause );
//qDebug() << sql;
QString sql = QString( "SELECT guid, trackname, artistname, albumname, annotation, "
"duration, addedon, addedby, result_hint "
"FROM playlist_item "
"WHERE guid IN %1" ).arg( inclause );
query.exec( sql );
while( query.next() )
while ( query.next() )
{
plentry_ptr e( new PlaylistEntry );
e->setGuid( query.value( 0 ).toString() );
e->setAnnotation( query.value( 4 ).toString() );
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() );
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();
}
else
{
// qDebug() << "Playlist has no current revision data";
}
if( prevrev.length() )
if ( prevrev.length() )
{
TomahawkSqlQuery query_entries_old = dbi->newquery();
query_entries_old.prepare( "SELECT entries, "
@ -105,7 +101,7 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
query_entries_old.addBindValue( prevrev );
query_entries_old.exec();
if( !query_entries_old.next() )
if ( !query_entries_old.next() )
{
return;
Q_ASSERT( false );

View File

@ -65,7 +65,7 @@ DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
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 )
{
@ -80,8 +80,6 @@ DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
}
}
qDebug() << Q_FUNC_INFO << ql.length();
if ( ql.count() )
emit tracks( ql );
}

View File

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

View File

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

View File

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

View File

@ -132,13 +132,7 @@ PlaylistModel::append( const QList< query_ptr >& queries )
void
PlaylistModel::append( const Tomahawk::query_ptr& query )
{
if ( query.isNull() )
return;
if ( !query->resolvingFinished() )
Pipeline::instance()->resolve( query );
TrackModel::append( query );
insert( query, rowCount( QModelIndex() ) );
}
@ -230,6 +224,7 @@ PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row )
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
QList< Tomahawk::query_ptr > queries;
int i = 0;
TrackModelItem* plitem;
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() )
{
queries << entry->query();
m_waitingForResolved.append( entry->query().data() );
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() )
{
Pipeline::instance()->resolve( queries );
emit loadingStarted();
}
emit endInsertRows();
emit trackCountChanged( rowCount( QModelIndex() ) );

View File

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

View File

@ -1,19 +1,21 @@
/*
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.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 "sourcetree/sourcesmodel.h"