mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Introduced Query::displayQuery(). Returns (if available) the first result as a query_ptr, otherwise returns the Query's own query_ptr. Use this whenever you wanna display Query stuff in the GUI. Also, reduce numResults() usage.
This commit is contained in:
@@ -88,6 +88,7 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr&
|
|||||||
, m_cover( 0 )
|
, m_cover( 0 )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
m_sortname = DatabaseImpl::sortname( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -50,6 +50,8 @@ public:
|
|||||||
|
|
||||||
unsigned int id() const { return m_id; }
|
unsigned int id() const { return m_id; }
|
||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
|
QString sortname() const { return m_sortname; }
|
||||||
|
|
||||||
artist_ptr artist() const;
|
artist_ptr artist() const;
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
QPixmap cover( const QSize& size, bool forceLoad = true ) const;
|
QPixmap cover( const QSize& size, bool forceLoad = true ) const;
|
||||||
@@ -78,6 +80,8 @@ private:
|
|||||||
|
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
QString m_sortname;
|
||||||
|
|
||||||
artist_ptr m_artist;
|
artist_ptr m_artist;
|
||||||
QByteArray m_coverBuffer;
|
QByteArray m_coverBuffer;
|
||||||
|
|
||||||
|
@@ -87,20 +87,9 @@ GlobalActionManager::~GlobalActionManager()
|
|||||||
QUrl
|
QUrl
|
||||||
GlobalActionManager::openLinkFromQuery( const query_ptr& query ) const
|
GlobalActionManager::openLinkFromQuery( const query_ptr& query ) const
|
||||||
{
|
{
|
||||||
QString title, artist, album;
|
QString title = query->displayQuery()->track();
|
||||||
|
QString artist = query->displayQuery()->artist();
|
||||||
if ( !query->results().isEmpty() && !query->results().first().isNull() )
|
QString album = query->displayQuery()->album();
|
||||||
{
|
|
||||||
title = query->results().first()->track();
|
|
||||||
artist = query->results().first()->artist().isNull() ? QString() : query->results().first()->artist()->name();
|
|
||||||
album = query->results().first()->album().isNull() ? QString() : query->results().first()->album()->name();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
title = query->track();
|
|
||||||
artist = query->artist();
|
|
||||||
album = query->album();
|
|
||||||
}
|
|
||||||
|
|
||||||
return openLink( title, artist, album );
|
return openLink( title, artist, album );
|
||||||
}
|
}
|
||||||
@@ -1166,11 +1155,7 @@ GlobalActionManager::doBookmark( const playlist_ptr& pl, const query_ptr& q )
|
|||||||
plentry_ptr e( new PlaylistEntry );
|
plentry_ptr e( new PlaylistEntry );
|
||||||
e->setGuid( uuid() );
|
e->setGuid( uuid() );
|
||||||
|
|
||||||
if ( q->results().count() )
|
e->setDuration( q->displayQuery()->duration() );
|
||||||
e->setDuration( q->results().at( 0 )->duration() );
|
|
||||||
else
|
|
||||||
e->setDuration( 0 );
|
|
||||||
|
|
||||||
e->setLastmodified( 0 );
|
e->setLastmodified( 0 );
|
||||||
QString annotation = "";
|
QString annotation = "";
|
||||||
if ( !q->property( "annotation" ).toString().isEmpty() )
|
if ( !q->property( "annotation" ).toString().isEmpty() )
|
||||||
|
@@ -622,11 +622,7 @@ Playlist::entriesFromQueries( const QList<Tomahawk::query_ptr>& queries, bool cl
|
|||||||
plentry_ptr e( new PlaylistEntry() );
|
plentry_ptr e( new PlaylistEntry() );
|
||||||
e->setGuid( uuid() );
|
e->setGuid( uuid() );
|
||||||
|
|
||||||
if ( query->results().count() )
|
e->setDuration( query->displayQuery()->duration() );
|
||||||
e->setDuration( query->results().at( 0 )->duration() );
|
|
||||||
else
|
|
||||||
e->setDuration( 0 );
|
|
||||||
|
|
||||||
e->setLastmodified( 0 );
|
e->setLastmodified( 0 );
|
||||||
QString annotation = "";
|
QString annotation = "";
|
||||||
if ( !query->property( "annotation" ).toString().isEmpty() )
|
if ( !query->property( "annotation" ).toString().isEmpty() )
|
||||||
|
@@ -182,6 +182,16 @@ Query::updateSortNames()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
query_ptr
|
||||||
|
Query::displayQuery() const
|
||||||
|
{
|
||||||
|
if ( !results().isEmpty() )
|
||||||
|
return results().first()->toQuery();
|
||||||
|
|
||||||
|
return m_ownRef.toStrongRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
|
Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
|
||||||
{
|
{
|
||||||
|
@@ -131,14 +131,16 @@ public:
|
|||||||
QString artistSortname() const { return m_artistSortname; }
|
QString artistSortname() const { return m_artistSortname; }
|
||||||
QString albumSortname() const { return m_albumSortname; }
|
QString albumSortname() const { return m_albumSortname; }
|
||||||
QString trackSortname() const { return m_trackSortname; }
|
QString trackSortname() const { return m_trackSortname; }
|
||||||
|
|
||||||
QString artist() const { return m_artist; }
|
QString artist() const { return m_artist; }
|
||||||
QString composer() const { return m_composer; }
|
QString composer() const { return m_composer; }
|
||||||
QString album() const { return m_album; }
|
QString album() const { return m_album; }
|
||||||
QString track() const { return m_track; }
|
QString track() const { return m_track; }
|
||||||
|
|
||||||
int duration() const { return m_duration; }
|
int duration() const { return m_duration; }
|
||||||
unsigned int albumpos() const { return m_albumpos; }
|
unsigned int albumpos() const { return m_albumpos; }
|
||||||
unsigned int discnumber() const { return m_discnumber; }
|
unsigned int discnumber() const { return m_discnumber; }
|
||||||
|
|
||||||
|
query_ptr displayQuery() const;
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
QPixmap cover( const QSize& size, bool forceLoad = true ) const;
|
QPixmap cover( const QSize& size, bool forceLoad = true ) const;
|
||||||
|
@@ -163,12 +163,7 @@ Result::toVariant() const
|
|||||||
m.insert( "artist", artist()->name() );
|
m.insert( "artist", artist()->name() );
|
||||||
m.insert( "album", album()->name() );
|
m.insert( "album", album()->name() );
|
||||||
m.insert( "track", track() );
|
m.insert( "track", track() );
|
||||||
|
m.insert( "source", friendlySource() );
|
||||||
if ( !collection().isNull() )
|
|
||||||
m.insert( "source", collection()->source()->friendlyName() );
|
|
||||||
else
|
|
||||||
m.insert( "source", friendlySource() );
|
|
||||||
|
|
||||||
m.insert( "mimetype", mimetype() );
|
m.insert( "mimetype", mimetype() );
|
||||||
m.insert( "size", size() );
|
m.insert( "size", size() );
|
||||||
m.insert( "bitrate", bitrate() );
|
m.insert( "bitrate", bitrate() );
|
||||||
@@ -176,6 +171,7 @@ Result::toVariant() const
|
|||||||
m.insert( "score", score() );
|
m.insert( "score", score() );
|
||||||
m.insert( "sid", id() );
|
m.insert( "sid", id() );
|
||||||
m.insert( "discnumber", discnumber() );
|
m.insert( "discnumber", discnumber() );
|
||||||
|
m.insert( "albumpos", albumpos() );
|
||||||
|
|
||||||
if ( !composer().isNull() )
|
if ( !composer().isNull() )
|
||||||
m.insert( "composer", composer()->name() );
|
m.insert( "composer", composer()->name() );
|
||||||
@@ -197,6 +193,12 @@ Result::toQuery()
|
|||||||
if ( m_query.isNull() )
|
if ( m_query.isNull() )
|
||||||
{
|
{
|
||||||
m_query = Tomahawk::Query::get( artist()->name(), track(), album()->name() );
|
m_query = Tomahawk::Query::get( artist()->name(), track(), album()->name() );
|
||||||
|
m_query->setAlbumPos( albumpos() );
|
||||||
|
m_query->setDiscNumber( discnumber() );
|
||||||
|
m_query->setDuration( duration() );
|
||||||
|
if ( !composer().isNull() )
|
||||||
|
m_query->setComposer( composer()->name() );
|
||||||
|
|
||||||
QList<Tomahawk::result_ptr> rl;
|
QList<Tomahawk::result_ptr> rl;
|
||||||
rl << Result::get( m_url );
|
rl << Result::get( m_url );
|
||||||
|
|
||||||
|
@@ -151,8 +151,8 @@ AlbumView::onItemActivated( const QModelIndex& index )
|
|||||||
ViewManager::instance()->show( item->album() );
|
ViewManager::instance()->show( item->album() );
|
||||||
else if ( !item->artist().isNull() )
|
else if ( !item->artist().isNull() )
|
||||||
ViewManager::instance()->show( item->artist() );
|
ViewManager::instance()->show( item->artist() );
|
||||||
else if ( item->query()->numResults() )
|
else if ( !item->query().isNull() )
|
||||||
AudioEngine::instance()->playItem( playlistinterface_ptr(), item->query()->results().first() );
|
AudioEngine::instance()->playItem( playlistinterface_ptr(), item->query() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -135,21 +135,12 @@ PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const query_ptr q = item->query()->displayQuery();
|
||||||
|
unsigned int duration = q->duration();
|
||||||
|
QString artist = q->artist();
|
||||||
|
QString track = q->track();
|
||||||
QPixmap avatar;
|
QPixmap avatar;
|
||||||
QString artist, track, upperText, lowerText;
|
QString upperText, lowerText;
|
||||||
unsigned int duration = 0;
|
|
||||||
|
|
||||||
if ( item->query()->results().count() )
|
|
||||||
{
|
|
||||||
artist = item->query()->results().first()->artist()->name();
|
|
||||||
track = item->query()->results().first()->track();
|
|
||||||
duration = item->query()->results().first()->duration();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
artist = item->query()->artist();
|
|
||||||
track = item->query()->track();
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
{
|
{
|
||||||
|
@@ -133,21 +133,13 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const query_ptr q = item->query()->displayQuery();
|
||||||
|
QString artist = q->artist();
|
||||||
|
QString track = q->track();
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
QString artist, track, upperText, lowerText;
|
QString upperText, lowerText;
|
||||||
source_ptr source = item->query()->playedBy().first;
|
source_ptr source = item->query()->playedBy().first;
|
||||||
|
|
||||||
if ( item->query()->results().count() )
|
|
||||||
{
|
|
||||||
artist = item->query()->results().first()->artist()->name();
|
|
||||||
track = item->query()->results().first()->track();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
artist = item->query()->artist();
|
|
||||||
track = item->query()->track();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( source.isNull() )
|
if ( source.isNull() )
|
||||||
{
|
{
|
||||||
upperText = track;
|
upperText = track;
|
||||||
|
@@ -136,21 +136,12 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const query_ptr q = item->query()->displayQuery();
|
||||||
|
QString artist = q->artist();
|
||||||
|
QString track = q->track();
|
||||||
|
unsigned int duration = q->duration();
|
||||||
QPixmap avatar;
|
QPixmap avatar;
|
||||||
QString artist, track, lowerText;
|
QString lowerText;
|
||||||
unsigned int duration = 0;
|
|
||||||
|
|
||||||
if ( item->query()->results().count() )
|
|
||||||
{
|
|
||||||
artist = item->query()->results().first()->artist()->name();
|
|
||||||
track = item->query()->results().first()->track();
|
|
||||||
duration = item->query()->results().first()->duration();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
artist = item->query()->artist();
|
|
||||||
track = item->query()->track();
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize avatarSize( 32, 32 );
|
QSize avatarSize( 32, 32 );
|
||||||
source_ptr source = item->query()->playedBy().first;
|
source_ptr source = item->query()->playedBy().first;
|
||||||
|
@@ -187,11 +187,7 @@ PlaylistModel::insert( const QList< Tomahawk::query_ptr >& queries, int row )
|
|||||||
{
|
{
|
||||||
plentry_ptr entry = plentry_ptr( new PlaylistEntry() );
|
plentry_ptr entry = plentry_ptr( new PlaylistEntry() );
|
||||||
|
|
||||||
if ( query->results().count() )
|
entry->setDuration( query->displayQuery()->duration() );
|
||||||
entry->setDuration( query->results().at( 0 )->duration() );
|
|
||||||
else
|
|
||||||
entry->setDuration( 0 );
|
|
||||||
|
|
||||||
entry->setLastmodified( 0 );
|
entry->setLastmodified( 0 );
|
||||||
QString annotation = "";
|
QString annotation = "";
|
||||||
if ( !query->property( "annotation" ).toString().isEmpty() )
|
if ( !query->property( "annotation" ).toString().isEmpty() )
|
||||||
|
@@ -152,49 +152,46 @@ TrackModel::data( const QModelIndex& index, int role ) const
|
|||||||
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
|
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
const query_ptr& query = entry->query();
|
const query_ptr& query = entry->query()->displayQuery();
|
||||||
if ( !query->numResults() )
|
switch( index.column() )
|
||||||
{
|
{
|
||||||
switch( index.column() )
|
case Artist:
|
||||||
{
|
return query->artist();
|
||||||
case Artist:
|
break;
|
||||||
return query->artist();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Track:
|
case Track:
|
||||||
return query->track();
|
return query->track();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Album:
|
case Album:
|
||||||
return query->album();
|
return query->album();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case Composer:
|
||||||
|
return query->composer();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Duration:
|
||||||
|
return TomahawkUtils::timeToString( query->duration() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AlbumPos:
|
||||||
|
QString tPos;
|
||||||
|
if ( query->albumpos() != 0 )
|
||||||
|
{
|
||||||
|
tPos = QString::number( query->albumpos() );
|
||||||
|
if( query->discnumber() == 0 )
|
||||||
|
return tPos;
|
||||||
|
else
|
||||||
|
return QString( "%1.%2" ).arg( QString::number( query->discnumber() ) )
|
||||||
|
.arg( tPos );
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
if ( query->numResults() )
|
||||||
{
|
{
|
||||||
switch( index.column() )
|
switch( index.column() )
|
||||||
{
|
{
|
||||||
case Artist:
|
|
||||||
return query->results().first()->artist()->name();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Track:
|
|
||||||
return query->results().first()->track();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Album:
|
|
||||||
return query->results().first()->album()->name();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Composer:
|
|
||||||
if ( !query->results().first()->composer().isNull() )
|
|
||||||
return query->results().first()->composer()->name();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Duration:
|
|
||||||
return TomahawkUtils::timeToString( query->results().first()->duration() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Bitrate:
|
case Bitrate:
|
||||||
if ( query->results().first()->bitrate() > 0 )
|
if ( query->results().first()->bitrate() > 0 )
|
||||||
return query->results().first()->bitrate();
|
return query->results().first()->bitrate();
|
||||||
@@ -220,19 +217,6 @@ TrackModel::data( const QModelIndex& index, int role ) const
|
|||||||
case Score:
|
case Score:
|
||||||
return query->results().first()->score();
|
return query->results().first()->score();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AlbumPos:
|
|
||||||
QString tPos;
|
|
||||||
if ( query->results().first()->albumpos() != 0 )
|
|
||||||
{
|
|
||||||
tPos = QString::number( query->results().first()->albumpos() );
|
|
||||||
if( query->results().first()->discnumber() == 0 )
|
|
||||||
return tPos;
|
|
||||||
else
|
|
||||||
return QString( "%1.%2" ).arg( QString::number( query->results().first()->discnumber() ) )
|
|
||||||
.arg( tPos );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParen
|
|||||||
if ( !pi )
|
if ( !pi )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Tomahawk::query_ptr& q = pi->query();
|
const Tomahawk::query_ptr& q = pi->query()->displayQuery();
|
||||||
if ( q.isNull() ) // uh oh? filter out invalid queries i guess
|
if ( q.isNull() ) // uh oh? filter out invalid queries i guess
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -88,23 +88,11 @@ TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParen
|
|||||||
foreach( QString s, sl )
|
foreach( QString s, sl )
|
||||||
{
|
{
|
||||||
s = s.toLower();
|
s = s.toLower();
|
||||||
if ( !r.isNull() )
|
if ( !q->artist().toLower().contains( s ) &&
|
||||||
|
!q->album().toLower().contains( s ) &&
|
||||||
|
!q->track().toLower().contains( s ) )
|
||||||
{
|
{
|
||||||
if ( !r->artist()->name().toLower().contains( s ) &&
|
return false;
|
||||||
!r->album()->name().toLower().contains( s ) &&
|
|
||||||
!r->track().toLower().contains( s ) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( !q->artist().toLower().contains( s ) &&
|
|
||||||
!q->album().toLower().contains( s ) &&
|
|
||||||
!q->track().toLower().contains( s ) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,17 +157,19 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
|
|||||||
if ( !p2 )
|
if ( !p2 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Tomahawk::query_ptr& q1 = p1->query();
|
const Tomahawk::query_ptr& q1 = p1->query()->displayQuery();
|
||||||
const Tomahawk::query_ptr& q2 = p2->query();
|
const Tomahawk::query_ptr& q2 = p2->query()->displayQuery();
|
||||||
|
|
||||||
QString artist1 = q1->artistSortname();
|
QString artist1 = q1->artistSortname();
|
||||||
QString artist2 = q2->artistSortname();
|
QString artist2 = q2->artistSortname();
|
||||||
QString album1 = q1->album();
|
QString album1 = q1->albumSortname();
|
||||||
QString album2 = q2->album();
|
QString album2 = q2->albumSortname();
|
||||||
QString track1 = q1->track();
|
QString track1 = q1->trackSortname();
|
||||||
QString track2 = q2->track();
|
QString track2 = q2->trackSortname();
|
||||||
unsigned int albumpos1 = 0, albumpos2 = 0;
|
unsigned int albumpos1 = q1->albumpos();
|
||||||
unsigned int discnumber1 = 0, discnumber2 = 0;
|
unsigned int albumpos2 = q2->albumpos();
|
||||||
|
unsigned int discnumber1 = q1->discnumber();
|
||||||
|
unsigned int discnumber2 = q2->discnumber();
|
||||||
unsigned int bitrate1 = 0, bitrate2 = 0;
|
unsigned int bitrate1 = 0, bitrate2 = 0;
|
||||||
unsigned int mtime1 = 0, mtime2 = 0;
|
unsigned int mtime1 = 0, mtime2 = 0;
|
||||||
unsigned int size1 = 0, size2 = 0;
|
unsigned int size1 = 0, size2 = 0;
|
||||||
@@ -188,11 +178,6 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
|
|||||||
if ( q1->numResults() )
|
if ( q1->numResults() )
|
||||||
{
|
{
|
||||||
const Tomahawk::result_ptr& r = q1->results().at( 0 );
|
const Tomahawk::result_ptr& r = q1->results().at( 0 );
|
||||||
artist1 = r->artist()->sortname();
|
|
||||||
album1 = r->album()->name();
|
|
||||||
track1 = r->track();
|
|
||||||
albumpos1 = r->albumpos();
|
|
||||||
discnumber1 = qMax( 1, (int)r->discnumber() );
|
|
||||||
bitrate1 = r->bitrate();
|
bitrate1 = r->bitrate();
|
||||||
mtime1 = r->modificationTime();
|
mtime1 = r->modificationTime();
|
||||||
id1 = r->trackId();
|
id1 = r->trackId();
|
||||||
@@ -201,11 +186,6 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
|
|||||||
if ( q2->numResults() )
|
if ( q2->numResults() )
|
||||||
{
|
{
|
||||||
const Tomahawk::result_ptr& r = q2->results().at( 0 );
|
const Tomahawk::result_ptr& r = q2->results().at( 0 );
|
||||||
artist2 = r->artist()->sortname();
|
|
||||||
album2 = r->album()->name();
|
|
||||||
track2 = r->track();
|
|
||||||
albumpos2 = r->albumpos();
|
|
||||||
discnumber2 = qMax( 1, (int)r->discnumber() );
|
|
||||||
bitrate2 = r->bitrate();
|
bitrate2 = r->bitrate();
|
||||||
mtime2 = r->modificationTime();
|
mtime2 = r->modificationTime();
|
||||||
id2 = r->trackId();
|
id2 = r->trackId();
|
||||||
|
@@ -295,11 +295,10 @@ bool
|
|||||||
TrackView::tryToPlayItem( const QModelIndex& index )
|
TrackView::tryToPlayItem( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
TrackModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
TrackModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
||||||
if ( item && !item->query().isNull() && item->query()->numResults() )
|
if ( item && !item->query().isNull() )
|
||||||
{
|
{
|
||||||
tDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
|
||||||
m_proxyModel->setCurrentIndex( index );
|
m_proxyModel->setCurrentIndex( index );
|
||||||
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->query()->results().first() );
|
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->query() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -661,7 +660,7 @@ TrackView::mousePressEvent( QMouseEvent* event )
|
|||||||
{
|
{
|
||||||
case TrackModel::Artist:
|
case TrackModel::Artist:
|
||||||
{
|
{
|
||||||
if ( item->query()->results().count() )
|
if ( item->query()->numResults() )
|
||||||
{
|
{
|
||||||
ViewManager::instance()->show( item->query()->results().first()->artist() );
|
ViewManager::instance()->show( item->query()->results().first()->artist() );
|
||||||
}
|
}
|
||||||
@@ -674,7 +673,7 @@ TrackView::mousePressEvent( QMouseEvent* event )
|
|||||||
|
|
||||||
case TrackModel::Album:
|
case TrackModel::Album:
|
||||||
{
|
{
|
||||||
if ( item->query()->results().count() )
|
if ( item->query()->numResults() )
|
||||||
{
|
{
|
||||||
ViewManager::instance()->show( item->query()->results().first()->album() );
|
ViewManager::instance()->show( item->query()->results().first()->album() );
|
||||||
}
|
}
|
||||||
|
@@ -798,11 +798,7 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModel
|
|||||||
TreeModelItem* item = 0;
|
TreeModelItem* item = 0;
|
||||||
foreach( const query_ptr& query, tracks )
|
foreach( const query_ptr& query, tracks )
|
||||||
{
|
{
|
||||||
if ( query->numResults() )
|
item = new TreeModelItem( query, parentItem );
|
||||||
item = new TreeModelItem( query->results().first(), parentItem );
|
|
||||||
else
|
|
||||||
item = new TreeModelItem( query, parentItem );
|
|
||||||
|
|
||||||
item->index = createIndex( parentItem->children.count() - 1, 0, item );
|
item->index = createIndex( parentItem->children.count() - 1, 0, item );
|
||||||
|
|
||||||
connect( item, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
connect( item, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||||
|
@@ -168,6 +168,7 @@ TreeModelItem::TreeModelItem( const Tomahawk::query_ptr& query, TreeModelItem* p
|
|||||||
}
|
}
|
||||||
|
|
||||||
toberemoved = false;
|
toberemoved = false;
|
||||||
|
onResultsChanged();
|
||||||
|
|
||||||
connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
|
connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
|
||||||
SLOT( onResultsChanged() ) );
|
SLOT( onResultsChanged() ) );
|
||||||
@@ -254,7 +255,7 @@ TreeModelItem::result() const
|
|||||||
{
|
{
|
||||||
if ( m_result.isNull() && !m_query.isNull() )
|
if ( m_result.isNull() && !m_query.isNull() )
|
||||||
{
|
{
|
||||||
if ( m_query->results().count() )
|
if ( m_query->numResults() )
|
||||||
return m_query->results().first();
|
return m_query->results().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -410,7 +410,7 @@ prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, Tr
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
float opacity = 0.0;
|
float opacity = 0.0;
|
||||||
if ( item->query()->results().count() )
|
if ( !item->query()->results().isEmpty() )
|
||||||
opacity = item->query()->results().first()->score();
|
opacity = item->query()->results().first()->score();
|
||||||
|
|
||||||
opacity = qMax( (float)0.3, opacity );
|
opacity = qMax( (float)0.3, opacity );
|
||||||
|
Reference in New Issue
Block a user