From 6ec8f127c0c5a5c735f6542e196fd7786939c5cc Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 8 Nov 2011 10:41:30 +0100 Subject: [PATCH 1/5] * Fixed freezing when filtering out the current item in a tree-view and trying to advance to the next track. --- src/libtomahawk/playlist/trackproxymodel.cpp | 12 +++--------- src/libtomahawk/playlist/treeproxymodel.cpp | 17 +++++++++-------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/libtomahawk/playlist/trackproxymodel.cpp b/src/libtomahawk/playlist/trackproxymodel.cpp index cfbea42a7..3c92699e9 100644 --- a/src/libtomahawk/playlist/trackproxymodel.cpp +++ b/src/libtomahawk/playlist/trackproxymodel.cpp @@ -110,7 +110,7 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly ) qDebug() << Q_FUNC_INFO; QModelIndex idx = index( 0, 0 ); - if( rowCount() ) + if ( rowCount() ) { if ( m_shuffled ) { @@ -123,12 +123,7 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly ) idx = currentIndex(); // random mode is disabled - if ( m_repeatMode == PlaylistInterface::RepeatOne ) - { - // repeat one track - idx = index( idx.row(), 0 ); - } - else + if ( m_repeatMode != PlaylistInterface::RepeatOne ) { // keep progressing through the playlist normally 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) - if ( idx.isValid() ) do + while ( idx.isValid() ) { TrackModelItem* item = itemFromIndex( mapToSource( idx ) ); if ( item && item->query()->playable() ) @@ -165,7 +160,6 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly ) idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 ); } - while ( idx.isValid() ); if ( !readOnly ) setCurrentIndex( QModelIndex() ); diff --git a/src/libtomahawk/playlist/treeproxymodel.cpp b/src/libtomahawk/playlist/treeproxymodel.cpp index 206bbd1b7..64f4741eb 100644 --- a/src/libtomahawk/playlist/treeproxymodel.cpp +++ b/src/libtomahawk/playlist/treeproxymodel.cpp @@ -334,11 +334,14 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly ) return Tomahawk::result_ptr(); if ( m_shuffled ) + { idx = index( qrand() % rowCount( idx.parent() ), 0, idx.parent() ); - else if ( m_repeatMode == PlaylistInterface::RepeatOne ) - idx = index( idx.row(), 0, idx.parent() ); + } else - idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() ); + { + if ( m_repeatMode != PlaylistInterface::RepeatOne ) + idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() ); + } if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll ) { @@ -355,11 +358,8 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly ) } // 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 ) ); if ( item && !item->result().isNull() && item->result()->isOnline() ) { @@ -368,8 +368,9 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly ) setCurrentIndex( idx ); return item->result(); } + + idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() ); } - while ( idx.isValid() ); if ( !readOnly ) setCurrentIndex( QModelIndex() ); From 0c136e6815856e74f33e3ecab4756fbadc734c31 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Tue, 8 Nov 2011 14:16:13 +0100 Subject: [PATCH 2/5] Don't show CMD window for CrashReporter --- src/breakpad/CrashReporter/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/breakpad/CrashReporter/CMakeLists.txt b/src/breakpad/CrashReporter/CMakeLists.txt index 8b019947b..e178e7ebf 100644 --- a/src/breakpad/CrashReporter/CMakeLists.txt +++ b/src/breakpad/CrashReporter/CMakeLists.txt @@ -16,5 +16,5 @@ INCLUDE( ${QT_USE_FILE} ) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src ../../libtomahawk ) 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 ) From 14639337d4e606c0825820bbf96c627ca914e7d6 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 8 Nov 2011 15:30:13 +0100 Subject: [PATCH 3/5] * Fixed album position & ordering for InfoSystem views. --- src/libtomahawk/playlist/treemodel.cpp | 27 ++++++++++++++++--- src/libtomahawk/playlist/treeproxymodel.cpp | 29 ++++++++++++++------- src/libtomahawk/query.cpp | 1 + src/libtomahawk/query.h | 4 +++ 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/libtomahawk/playlist/treemodel.cpp b/src/libtomahawk/playlist/treemodel.cpp index 68b7937a2..3c9a445b0 100644 --- a/src/libtomahawk/playlist/treemodel.cpp +++ b/src/libtomahawk/playlist/treemodel.cpp @@ -300,10 +300,16 @@ TreeModel::data( const QModelIndex& index, int role ) const else if ( !entry->result().isNull() ) { 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() ) { 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() ); case Duration: @@ -331,9 +337,21 @@ TreeModel::data( const QModelIndex& index, int role ) const 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(); @@ -889,16 +907,17 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV m_receivedInfoData.insert( requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >() ); - QStringList tracks = returnedData[ "tracks" ].toStringList(); QList ql; Tomahawk::InfoSystem::InfoStringHash inputInfo; inputInfo = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >(); + unsigned int trackNo = 1; foreach ( const QString& trackName, tracks ) { query_ptr query = Query::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ], uuid() ); + query->setAlbumPos( trackNo++ ); ql << query; } onTracksAdded( ql, requestData.customData[ "rows" ] ); diff --git a/src/libtomahawk/playlist/treeproxymodel.cpp b/src/libtomahawk/playlist/treeproxymodel.cpp index 64f4741eb..e147bfc29 100644 --- a/src/libtomahawk/playlist/treeproxymodel.cpp +++ b/src/libtomahawk/playlist/treeproxymodel.cpp @@ -264,22 +264,33 @@ TreeProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) co if ( !p2 ) return false; - if ( !p1->result().isNull() && p2->result().isNull() ) +/* if ( !p1->result().isNull() && p2->result().isNull() ) return true; 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& rights = textForItem( p2 ); - if ( !p1->result().isNull() ) - { - if ( p1->result()->albumpos() != p2->result()->albumpos() ) - return p1->result()->albumpos() < p2->result()->albumpos(); + tDebug() << lefts << albumpos1; + tDebug() << rights << albumpos2; - if ( lefts == rights ) - return (qint64)&p1 < (qint64)&p2; - } + if ( albumpos1 != albumpos2 ) + return albumpos1 < albumpos2; + + if ( lefts == rights ) + return (qint64)&p1 < (qint64)&p2; return QString::localeAwareCompare( lefts, rights ) < 0; } diff --git a/src/libtomahawk/query.cpp b/src/libtomahawk/query.cpp index 6ae6f03fd..bdfc5536b 100644 --- a/src/libtomahawk/query.cpp +++ b/src/libtomahawk/query.cpp @@ -122,6 +122,7 @@ Query::init() m_solved = false; m_playable = false; m_duration = -1; + m_albumpos = 0; updateSortNames(); } diff --git a/src/libtomahawk/query.h b/src/libtomahawk/query.h index ebba460b6..9939cb4f0 100644 --- a/src/libtomahawk/query.h +++ b/src/libtomahawk/query.h @@ -86,6 +86,7 @@ public: void setTrack( const QString& track ) { m_track = track; updateSortNames(); } void setResultHint( const QString& resultHint ) { m_resultHint = resultHint; } void setDuration( int duration ) { m_duration = duration; } + void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; } QVariant toVariant() const; QString toString() const; @@ -97,7 +98,9 @@ public: QString artist() const { return m_artist; } QString album() const { return m_album; } QString track() const { return m_track; } + int duration() const { return m_duration; } + unsigned int albumpos() const { return m_albumpos; } void setResolveFinished( bool resolved ) { m_resolveFinished = resolved; } void setPlayedBy( const Tomahawk::source_ptr& source, unsigned int playtime ); @@ -154,6 +157,7 @@ private: QString m_fullTextQuery; int m_duration; + unsigned int m_albumpos; QString m_resultHint; QPair< Tomahawk::source_ptr, unsigned int > m_playedBy; From 7f9fc557a979e61804b262cb1da12af945f936f0 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 8 Nov 2011 15:30:53 +0100 Subject: [PATCH 4/5] * Remove debugging output. --- src/libtomahawk/playlist/treeproxymodel.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libtomahawk/playlist/treeproxymodel.cpp b/src/libtomahawk/playlist/treeproxymodel.cpp index e147bfc29..a3a7acec3 100644 --- a/src/libtomahawk/playlist/treeproxymodel.cpp +++ b/src/libtomahawk/playlist/treeproxymodel.cpp @@ -283,9 +283,6 @@ TreeProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) co const QString& lefts = textForItem( p1 ); const QString& rights = textForItem( p2 ); - tDebug() << lefts << albumpos1; - tDebug() << rights << albumpos2; - if ( albumpos1 != albumpos2 ) return albumpos1 < albumpos2; From b80f3717b89c5b140346d065ee8ae233336d7e6e Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 8 Nov 2011 15:49:09 +0100 Subject: [PATCH 5/5] * Properly exclude queries without album position. --- src/libtomahawk/playlist/treeproxymodel.cpp | 38 ++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libtomahawk/playlist/treeproxymodel.cpp b/src/libtomahawk/playlist/treeproxymodel.cpp index a3a7acec3..dc2e59ef3 100644 --- a/src/libtomahawk/playlist/treeproxymodel.cpp +++ b/src/libtomahawk/playlist/treeproxymodel.cpp @@ -192,18 +192,18 @@ TreeProxyModel::filterFinished() bool TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const { - TreeModelItem* pi = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) ); - Q_ASSERT( pi ); + TreeModelItem* item = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) ); + 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 ); - foreach ( const Tomahawk::result_ptr& result, rl ) + foreach ( const Tomahawk::result_ptr& cachedResult, rl ) { - if ( result->track() == pi->result()->track() && - ( result->albumpos() == pi->result()->albumpos() || result->albumpos() == 0 ) ) + if ( cachedResult->track() == item->result()->track() && + ( 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 ) ); - if ( ti->name() == pi->name() && - ( ti->result()->albumpos() == pi->result()->albumpos() || ti->result()->albumpos() == 0 ) ) + if ( ti->name() == item->name() && + ( 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; - if ( !pi->result()->collection()->source()->isLocal() && ti->result()->collection()->source()->isLocal() ) + if ( !item->result()->collection()->source()->isLocal() && ti->result()->collection()->source()->isLocal() ) return false; } } @@ -229,26 +229,26 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent bool accepted = false; if ( m_filter.isEmpty() ) accepted = true; - else if ( !pi->artist().isNull() ) - accepted = m_artistsFilter.contains( pi->artist() ); - else if ( !pi->album().isNull() ) - accepted = m_albumsFilter.contains( pi->album()->id() ); + else if ( !item->artist().isNull() ) + accepted = m_artistsFilter.contains( item->artist() ); + else if ( !item->album().isNull() ) + accepted = m_albumsFilter.contains( item->album()->id() ); if ( !accepted ) { QStringList sl = m_filter.split( " ", QString::SkipEmptyParts ); foreach( const QString& s, sl ) { - if ( !pi->name().contains( s, Qt::CaseInsensitive ) && - !pi->albumName().contains( s, Qt::CaseInsensitive ) && - !pi->artistName().contains( s, Qt::CaseInsensitive ) ) + if ( !item->name().contains( s, Qt::CaseInsensitive ) && + !item->albumName().contains( s, Qt::CaseInsensitive ) && + !item->artistName().contains( s, Qt::CaseInsensitive ) ) { return false; } } } - m_cache.insertMulti( sourceParent, pi->result() ); + m_cache.insertMulti( sourceParent, item->result() ); return true; }