[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/amarok/src/playlist
From: Teo Mrnjavac <teo.mrnjavac () gmail ! com>
Date: 2009-07-14 9:59:51
Message-ID: 1247565591.308722.23228.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 996403 by mrnjavac:
Make Playlist::GroupingProxy::tracksInGroup() and lengthOfGroup() use GroupingProxy \
rows and Playlist::Model not talk to the GroupingProxy directly. The length of a \
group and the number of tracks is now added in GroupingProxy::data().
M +2 -3 PlaylistModel.cpp
M +23 -20 proxymodels/GroupingProxy.cpp
--- trunk/extragear/multimedia/amarok/src/playlist/PlaylistModel.cpp #996402:996403
@@ -37,7 +37,6 @@
#include "UndoCommands.h"
#include "playlistmanager/PlaylistManager.h"
#include "services/ServicePluginManager.h" // used in constructor
-#include "proxymodels/GroupingProxy.h"
#include <KGlobal>
#include <KUrl>
@@ -272,11 +271,11 @@
}
case GroupLength:
{
- return Meta::secToPrettyTime( \
GroupingProxy::instance()->lengthOfGroup( row ) ); + return \
Meta::secToPrettyTime( 0 ); }
case GroupTracks:
{
- return i18np ( "1 track", "%1 tracks", \
GroupingProxy::instance()->tracksInGroup( row ) ); + return QString();
}
case LastPlayed:
{
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/GroupingProxy.cpp \
#996402:996403 @@ -25,7 +25,7 @@
#include "GroupingProxy.h"
#include "Debug.h"
-#include "meta/Meta.h"
+#include "meta/MetaUtility.h"
#include <QVariant>
@@ -101,21 +101,37 @@
QVariant
Playlist::GroupingProxy::data( const QModelIndex& index, int role ) const
{
- if ( !index.isValid() )
+ if( !index.isValid() )
return QVariant();
int row = index.row();
- if ( role == Playlist::GroupRole )
+ if( role == Playlist::GroupRole )
return m_rowGroupMode.at( row );
- else if ( role == Playlist::GroupedTracksRole )
+ else if( role == Playlist::GroupedTracksRole )
return groupRowCount( row );
- else if ( role == Playlist::GroupedAlternateRole )
+ else if( role == Playlist::GroupedAlternateRole )
return ( row % 2 == 1 );
-
- return m_belowModel->data( index, role );
+ else if( role == Qt::DisplayRole || role == Qt::ToolTipRole )
+ {
+ switch( index.column() )
+ {
+ case GroupLength:
+ {
+ return Meta::secToPrettyTime( lengthOfGroup( row ) );
+ }
+ case GroupTracks:
+ {
+ return i18np ( "1 track", "%1 tracks", tracksInGroup( row ) );
+ }
+ default:
+ return m_belowModel->data( index, role );
+ }
+ }
+ else
+ return m_belowModel->data( index, role );
}
void
@@ -262,24 +278,11 @@
int Playlist::GroupingProxy::tracksInGroup( int row ) const
{
- //unfortunately we need to map this to row from source as it will
- //otherwise mess up ( and crash ) when a filter is applied
- //FIXME: this needs to talk to SortProxy only as currently is fails
- // with a sorted playlist. --Téo 17/6/2009
-
- row = SortProxy::instance()->rowFromSource( \
FilterProxy::instance()->rowFromSource( row ) );
-
return ( lastInGroup( row ) - firstInGroup( row ) ) + 1;
}
int Playlist::GroupingProxy::lengthOfGroup( int row ) const
{
- //unfortunately we need to map this to row from source as it will
- //otherwise mess up ( and crash ) when a filter is applied
- //FIXME: this needs to talk to SortProxy only as currently is fails
- // with a sorted playlist. --Téo 17/6/2009
- row = SortProxy::instance()->rowFromSource( \
FilterProxy::instance()->rowFromSource( row ) );
-
int totalLenght = 0;
for ( int i = firstInGroup( row ); i <= lastInGroup( row ); i++ )
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic