mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Merge remote branch 'origin/master' into proxyrefactor
This commit is contained in:
@@ -16,5 +16,5 @@ INCLUDE( ${QT_USE_FILE} )
|
|||||||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src ../../libtomahawk )
|
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src ../../libtomahawk )
|
||||||
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
|
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
|
||||||
|
|
||||||
ADD_EXECUTABLE( CrashReporter ${crashreporter_SOURCES} ${crashreporter_HEADERS_MOC} ${crashreporter_UI_HEADERS} ${crashreporter_RC_RCC} )
|
ADD_EXECUTABLE( CrashReporter WIN32 ${crashreporter_SOURCES} ${crashreporter_HEADERS_MOC} ${crashreporter_UI_HEADERS} ${crashreporter_RC_RCC} )
|
||||||
TARGET_LINK_LIBRARIES( CrashReporter ${QT_LIBRARIES} tomahawklib )
|
TARGET_LINK_LIBRARIES( CrashReporter ${QT_LIBRARIES} tomahawklib )
|
||||||
|
@@ -110,7 +110,7 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
|
|||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
QModelIndex idx = index( 0, 0 );
|
QModelIndex idx = index( 0, 0 );
|
||||||
if( rowCount() )
|
if ( rowCount() )
|
||||||
{
|
{
|
||||||
if ( m_shuffled )
|
if ( m_shuffled )
|
||||||
{
|
{
|
||||||
@@ -123,12 +123,7 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
|
|||||||
idx = currentIndex();
|
idx = currentIndex();
|
||||||
|
|
||||||
// random mode is disabled
|
// random mode is disabled
|
||||||
if ( m_repeatMode == PlaylistInterface::RepeatOne )
|
if ( m_repeatMode != PlaylistInterface::RepeatOne )
|
||||||
{
|
|
||||||
// repeat one track
|
|
||||||
idx = index( idx.row(), 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// keep progressing through the playlist normally
|
// keep progressing through the playlist normally
|
||||||
idx = index( idx.row() + itemsAway, 0 );
|
idx = index( idx.row() + itemsAway, 0 );
|
||||||
@@ -152,7 +147,7 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to find the next available PlaylistItem (with results)
|
// Try to find the next available PlaylistItem (with results)
|
||||||
if ( idx.isValid() ) do
|
while ( idx.isValid() )
|
||||||
{
|
{
|
||||||
TrackModelItem* item = itemFromIndex( mapToSource( idx ) );
|
TrackModelItem* item = itemFromIndex( mapToSource( idx ) );
|
||||||
if ( item && item->query()->playable() )
|
if ( item && item->query()->playable() )
|
||||||
@@ -165,7 +160,6 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
|
|||||||
|
|
||||||
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 );
|
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 );
|
||||||
}
|
}
|
||||||
while ( idx.isValid() );
|
|
||||||
|
|
||||||
if ( !readOnly )
|
if ( !readOnly )
|
||||||
setCurrentIndex( QModelIndex() );
|
setCurrentIndex( QModelIndex() );
|
||||||
|
@@ -300,10 +300,16 @@ TreeModel::data( const QModelIndex& index, int role ) const
|
|||||||
else if ( !entry->result().isNull() )
|
else if ( !entry->result().isNull() )
|
||||||
{
|
{
|
||||||
const result_ptr& result = entry->result();
|
const result_ptr& result = entry->result();
|
||||||
|
unsigned int albumpos = 0;
|
||||||
|
if ( !entry->query().isNull() )
|
||||||
|
albumpos = entry->query()->albumpos();
|
||||||
|
if ( albumpos == 0 )
|
||||||
|
albumpos = result->albumpos();
|
||||||
|
|
||||||
switch( index.column() )
|
switch( index.column() )
|
||||||
{
|
{
|
||||||
case Name:
|
case Name:
|
||||||
return QString( "%1%2" ).arg( result->albumpos() > 0 ? QString( "%1. ").arg( result->albumpos() ) : QString() )
|
return QString( "%1%2" ).arg( albumpos > 0 ? QString( "%1. ").arg( albumpos ) : QString() )
|
||||||
.arg( result->track() );
|
.arg( result->track() );
|
||||||
|
|
||||||
case Duration:
|
case Duration:
|
||||||
@@ -331,9 +337,21 @@ TreeModel::data( const QModelIndex& index, int role ) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !entry->query().isNull() && index.column() == Name )
|
else if ( !entry->query().isNull() )
|
||||||
{
|
{
|
||||||
return entry->query()->track();
|
const query_ptr& query = entry->query();
|
||||||
|
switch( index.column() )
|
||||||
|
{
|
||||||
|
case Name:
|
||||||
|
return QString( "%1%2" ).arg( query->albumpos() > 0 ? QString( "%1. ").arg( query->albumpos() ) : QString() )
|
||||||
|
.arg( query->track() );
|
||||||
|
|
||||||
|
case AlbumPosition:
|
||||||
|
return entry->query()->albumpos();
|
||||||
|
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@@ -889,16 +907,17 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV
|
|||||||
|
|
||||||
m_receivedInfoData.insert( requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >() );
|
m_receivedInfoData.insert( requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >() );
|
||||||
|
|
||||||
|
|
||||||
QStringList tracks = returnedData[ "tracks" ].toStringList();
|
QStringList tracks = returnedData[ "tracks" ].toStringList();
|
||||||
QList<query_ptr> ql;
|
QList<query_ptr> ql;
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash inputInfo;
|
Tomahawk::InfoSystem::InfoStringHash inputInfo;
|
||||||
inputInfo = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
inputInfo = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||||
|
|
||||||
|
unsigned int trackNo = 1;
|
||||||
foreach ( const QString& trackName, tracks )
|
foreach ( const QString& trackName, tracks )
|
||||||
{
|
{
|
||||||
query_ptr query = Query::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ], uuid() );
|
query_ptr query = Query::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ], uuid() );
|
||||||
|
query->setAlbumPos( trackNo++ );
|
||||||
ql << query;
|
ql << query;
|
||||||
}
|
}
|
||||||
onTracksAdded( ql, requestData.customData[ "rows" ] );
|
onTracksAdded( ql, requestData.customData[ "rows" ] );
|
||||||
|
@@ -192,18 +192,18 @@ TreeProxyModel::filterFinished()
|
|||||||
bool
|
bool
|
||||||
TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
TreeModelItem* pi = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
TreeModelItem* item = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
||||||
Q_ASSERT( pi );
|
Q_ASSERT( item );
|
||||||
|
|
||||||
if ( m_model->mode() == Tomahawk::DatabaseMode && !pi->result().isNull() )
|
if ( m_model->mode() == Tomahawk::DatabaseMode && !item->result().isNull() )
|
||||||
{
|
{
|
||||||
QList< Tomahawk::result_ptr > rl = m_cache.values( sourceParent );
|
QList< Tomahawk::result_ptr > rl = m_cache.values( sourceParent );
|
||||||
foreach ( const Tomahawk::result_ptr& result, rl )
|
foreach ( const Tomahawk::result_ptr& cachedResult, rl )
|
||||||
{
|
{
|
||||||
if ( result->track() == pi->result()->track() &&
|
if ( cachedResult->track() == item->result()->track() &&
|
||||||
( result->albumpos() == pi->result()->albumpos() || result->albumpos() == 0 ) )
|
( cachedResult->albumpos() == item->result()->albumpos() || cachedResult->albumpos() == 0 ) )
|
||||||
{
|
{
|
||||||
return ( result.data() == pi->result().data() );
|
return ( cachedResult.data() == item->result().data() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,13 +214,13 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
|
|||||||
|
|
||||||
TreeModelItem* ti = sourceModel()->itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
|
TreeModelItem* ti = sourceModel()->itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
|
||||||
|
|
||||||
if ( ti->name() == pi->name() &&
|
if ( ti->name() == item->name() &&
|
||||||
( ti->result()->albumpos() == pi->result()->albumpos() || ti->result()->albumpos() == 0 ) )
|
( ti->result()->albumpos() == item->result()->albumpos() || ti->result()->albumpos() == 0 || item->result()->albumpos() == 0 ) )
|
||||||
{
|
{
|
||||||
if ( !pi->result()->isOnline() && ti->result()->isOnline() )
|
if ( !item->result()->isOnline() && ti->result()->isOnline() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( !pi->result()->collection()->source()->isLocal() && ti->result()->collection()->source()->isLocal() )
|
if ( !item->result()->collection()->source()->isLocal() && ti->result()->collection()->source()->isLocal() )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,26 +229,26 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
|
|||||||
bool accepted = false;
|
bool accepted = false;
|
||||||
if ( m_filter.isEmpty() )
|
if ( m_filter.isEmpty() )
|
||||||
accepted = true;
|
accepted = true;
|
||||||
else if ( !pi->artist().isNull() )
|
else if ( !item->artist().isNull() )
|
||||||
accepted = m_artistsFilter.contains( pi->artist() );
|
accepted = m_artistsFilter.contains( item->artist() );
|
||||||
else if ( !pi->album().isNull() )
|
else if ( !item->album().isNull() )
|
||||||
accepted = m_albumsFilter.contains( pi->album()->id() );
|
accepted = m_albumsFilter.contains( item->album()->id() );
|
||||||
|
|
||||||
if ( !accepted )
|
if ( !accepted )
|
||||||
{
|
{
|
||||||
QStringList sl = m_filter.split( " ", QString::SkipEmptyParts );
|
QStringList sl = m_filter.split( " ", QString::SkipEmptyParts );
|
||||||
foreach( const QString& s, sl )
|
foreach( const QString& s, sl )
|
||||||
{
|
{
|
||||||
if ( !pi->name().contains( s, Qt::CaseInsensitive ) &&
|
if ( !item->name().contains( s, Qt::CaseInsensitive ) &&
|
||||||
!pi->albumName().contains( s, Qt::CaseInsensitive ) &&
|
!item->albumName().contains( s, Qt::CaseInsensitive ) &&
|
||||||
!pi->artistName().contains( s, Qt::CaseInsensitive ) )
|
!item->artistName().contains( s, Qt::CaseInsensitive ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cache.insertMulti( sourceParent, pi->result() );
|
m_cache.insertMulti( sourceParent, item->result() );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,22 +264,30 @@ TreeProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) co
|
|||||||
if ( !p2 )
|
if ( !p2 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( !p1->result().isNull() && p2->result().isNull() )
|
/* if ( !p1->result().isNull() && p2->result().isNull() )
|
||||||
return true;
|
return true;
|
||||||
if ( p1->result().isNull() && !p2->result().isNull() )
|
if ( p1->result().isNull() && !p2->result().isNull() )
|
||||||
return false;
|
return false;*/
|
||||||
|
|
||||||
|
unsigned int albumpos1 = 0;
|
||||||
|
unsigned int albumpos2 = 0;
|
||||||
|
if ( !p1->query().isNull() )
|
||||||
|
albumpos1 = p1->query()->albumpos();
|
||||||
|
if ( !p2->query().isNull() )
|
||||||
|
albumpos2 = p2->query()->albumpos();
|
||||||
|
if ( albumpos1 == 0 && !p1->result().isNull() )
|
||||||
|
albumpos1 = p1->result()->albumpos();
|
||||||
|
if ( albumpos2 == 0 && !p2->result().isNull() )
|
||||||
|
albumpos2 = p2->result()->albumpos();
|
||||||
|
|
||||||
const QString& lefts = textForItem( p1 );
|
const QString& lefts = textForItem( p1 );
|
||||||
const QString& rights = textForItem( p2 );
|
const QString& rights = textForItem( p2 );
|
||||||
|
|
||||||
if ( !p1->result().isNull() )
|
if ( albumpos1 != albumpos2 )
|
||||||
{
|
return albumpos1 < albumpos2;
|
||||||
if ( p1->result()->albumpos() != p2->result()->albumpos() )
|
|
||||||
return p1->result()->albumpos() < p2->result()->albumpos();
|
|
||||||
|
|
||||||
if ( lefts == rights )
|
if ( lefts == rights )
|
||||||
return (qint64)&p1 < (qint64)&p2;
|
return (qint64)&p1 < (qint64)&p2;
|
||||||
}
|
|
||||||
|
|
||||||
return QString::localeAwareCompare( lefts, rights ) < 0;
|
return QString::localeAwareCompare( lefts, rights ) < 0;
|
||||||
}
|
}
|
||||||
@@ -334,11 +342,14 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
|
|||||||
return Tomahawk::result_ptr();
|
return Tomahawk::result_ptr();
|
||||||
|
|
||||||
if ( m_shuffled )
|
if ( m_shuffled )
|
||||||
|
{
|
||||||
idx = index( qrand() % rowCount( idx.parent() ), 0, idx.parent() );
|
idx = index( qrand() % rowCount( idx.parent() ), 0, idx.parent() );
|
||||||
else if ( m_repeatMode == PlaylistInterface::RepeatOne )
|
}
|
||||||
idx = index( idx.row(), 0, idx.parent() );
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if ( m_repeatMode != PlaylistInterface::RepeatOne )
|
||||||
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll )
|
if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll )
|
||||||
{
|
{
|
||||||
@@ -355,11 +366,8 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to find the next available PlaylistItem (with results)
|
// Try to find the next available PlaylistItem (with results)
|
||||||
if ( idx.isValid() ) do
|
while ( idx.isValid() )
|
||||||
{
|
{
|
||||||
if ( !idx.isValid() )
|
|
||||||
break;
|
|
||||||
|
|
||||||
TreeModelItem* item = itemFromIndex( mapToSource( idx ) );
|
TreeModelItem* item = itemFromIndex( mapToSource( idx ) );
|
||||||
if ( item && !item->result().isNull() && item->result()->isOnline() )
|
if ( item && !item->result().isNull() && item->result()->isOnline() )
|
||||||
{
|
{
|
||||||
@@ -368,8 +376,9 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
|
|||||||
setCurrentIndex( idx );
|
setCurrentIndex( idx );
|
||||||
return item->result();
|
return item->result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
||||||
}
|
}
|
||||||
while ( idx.isValid() );
|
|
||||||
|
|
||||||
if ( !readOnly )
|
if ( !readOnly )
|
||||||
setCurrentIndex( QModelIndex() );
|
setCurrentIndex( QModelIndex() );
|
||||||
|
@@ -122,6 +122,7 @@ Query::init()
|
|||||||
m_solved = false;
|
m_solved = false;
|
||||||
m_playable = false;
|
m_playable = false;
|
||||||
m_duration = -1;
|
m_duration = -1;
|
||||||
|
m_albumpos = 0;
|
||||||
|
|
||||||
updateSortNames();
|
updateSortNames();
|
||||||
}
|
}
|
||||||
|
@@ -86,6 +86,7 @@ public:
|
|||||||
void setTrack( const QString& track ) { m_track = track; updateSortNames(); }
|
void setTrack( const QString& track ) { m_track = track; updateSortNames(); }
|
||||||
void setResultHint( const QString& resultHint ) { m_resultHint = resultHint; }
|
void setResultHint( const QString& resultHint ) { m_resultHint = resultHint; }
|
||||||
void setDuration( int duration ) { m_duration = duration; }
|
void setDuration( int duration ) { m_duration = duration; }
|
||||||
|
void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; }
|
||||||
|
|
||||||
QVariant toVariant() const;
|
QVariant toVariant() const;
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
@@ -97,7 +98,9 @@ public:
|
|||||||
QString artist() const { return m_artist; }
|
QString artist() const { return m_artist; }
|
||||||
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; }
|
||||||
|
|
||||||
void setResolveFinished( bool resolved ) { m_resolveFinished = resolved; }
|
void setResolveFinished( bool resolved ) { m_resolveFinished = resolved; }
|
||||||
void setPlayedBy( const Tomahawk::source_ptr& source, unsigned int playtime );
|
void setPlayedBy( const Tomahawk::source_ptr& source, unsigned int playtime );
|
||||||
@@ -154,6 +157,7 @@ private:
|
|||||||
QString m_fullTextQuery;
|
QString m_fullTextQuery;
|
||||||
|
|
||||||
int m_duration;
|
int m_duration;
|
||||||
|
unsigned int m_albumpos;
|
||||||
QString m_resultHint;
|
QString m_resultHint;
|
||||||
|
|
||||||
QPair< Tomahawk::source_ptr, unsigned int > m_playedBy;
|
QPair< Tomahawk::source_ptr, unsigned int > m_playedBy;
|
||||||
|
Reference in New Issue
Block a user