[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-15 13:00:21
Message-ID: 1247662821.210973.14998.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 997160 by mrnjavac:
Made the Playlist::Controller rely on the Playlist::AbstractModel interface to talk \
to the topmost proxy regardless of its implementation.
M +10 -10 PlaylistController.cpp
M +4 -2 PlaylistController.h
M +7 -0 proxymodels/AbstractModel.h
M +13 -0 proxymodels/ProxyBase.cpp
M +7 -0 proxymodels/ProxyBase.h
--- trunk/extragear/multimedia/amarok/src/playlist/PlaylistController.cpp \
#997159:997160 @@ -54,10 +54,10 @@
Playlist::Controller::Controller( QObject* parent )
: QObject( parent )
- , m_model( Model::instance() )
, m_undoStack( new QUndoStack( this ) )
{
s_instance = this;
+ m_topmostModel = Playlist::GroupingProxy::instance();
m_undoStack->setUndoLimit( 20 );
connect( m_undoStack, SIGNAL( canRedoChanged( bool ) ), this, SIGNAL( \
canRedoChanged( bool ) ) ); @@ -91,7 +91,7 @@
while ( i.hasNext() )
{
i.next();
- if ( m_model->containsTrack( i.value() ) )
+ if ( m_topmostModel->containsTrack( i.value() ) )
i.remove();
}
}
@@ -107,9 +107,9 @@
}
else if ( options & Queue )
{
- firstItemAdded = m_model->activeRow() + 1;
+ firstItemAdded = m_topmostModel->activeRow() + 1;
// We want to add the newly queued items after any items which are already \
queued
- while( m_model->stateOfRow( firstItemAdded ) & Item::Queued )
+ while( m_topmostModel->stateOfRow( firstItemAdded ) & Item::Queued )
firstItemAdded++;
insertionHelper( firstItemAdded, list );
@@ -122,7 +122,7 @@
}
else
{
- firstItemAdded = m_model->rowCount();
+ firstItemAdded = m_topmostModel->rowCount();
insertionHelper( firstItemAdded, list );
}
@@ -274,8 +274,8 @@
foreach( int r, rows )
{
debug() << "Removing row " << r;
- if (( r >= 0 ) && ( r < m_model->rowCount() ) )
- cmds.append( RemoveCmd( m_model->trackAt( r ), r ) );
+ if (( r >= 0 ) && ( r < m_topmostModel->rowCount() ) )
+ cmds.append( RemoveCmd( m_topmostModel->trackAt( r ), r ) );
else
warning() << "received command to remove non-existent row" << r;
}
@@ -346,7 +346,7 @@
if ( from.size() <= 0 )
return to;
- to = ( to == qBound( 0, to, m_model->rowCount() ) ) ? to : m_model->rowCount();
+ to = ( to == qBound( 0, to, m_topmostModel->rowCount() ) ) ? to : \
m_topmostModel->rowCount();
qSort( from.begin(), from.end() );
from.erase( std::unique( from.begin(), from.end() ), from.end() );
@@ -357,7 +357,7 @@
QList<int> target;
for ( int i = min; i <= max; i++ )
{
- if ( i >= m_model->rowCount() )
+ if ( i >= m_topmostModel->rowCount() )
break; // we are likely moving below the last element, to an index that \
really does not exist, and thus should not be moved up. source.append( i );
target.append( i );
@@ -410,7 +410,7 @@
for ( int i = 0; i < from.size(); i++ )
{
debug() << "moving rows:" << from.at( i ) << to.at( i );
- if ( ( from.at( i ) >= 0 ) && ( from.at( i ) < m_model->rowCount() ) )
+ if ( ( from.at( i ) >= 0 ) && ( from.at( i ) < m_topmostModel->rowCount() ) \
) if ( from.at( i ) != to.at( i ) )
cmds.append( MoveCmd( from.at( i ), to.at( i ) ) );
}
--- trunk/extragear/multimedia/amarok/src/playlist/PlaylistController.h \
#997159:997160 @@ -24,6 +24,8 @@
#include "meta/Meta.h"
#include "meta/Playlist.h"
#include "UndoCommands.h"
+#include "playlist/proxymodels/GroupingProxy.h" //FIXME: this needs to go away
+ // in favor of a The:: call.
#include <QObject>
@@ -32,7 +34,7 @@
namespace Playlist
{
class Controller;
-class Model;
+class AbstractModel;
}
namespace The
@@ -106,7 +108,7 @@
void insertionHelper( int row, Meta::TrackList& );
- Model* m_model;
+ AbstractModel* m_topmostModel;
QUndoStack* m_undoStack;
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/AbstractModel.h \
#997159:997160 @@ -47,6 +47,13 @@
virtual void clearSearchTerm() = 0;
/**
+ * Reports if the current model exposes a given track.
+ * @param track the track to check for.
+ * @return true if the track is present, otherwise false.
+ */
+ virtual bool containsTrack( const Meta::TrackPtr track ) const = 0;
+
+ /**
* Get the current search fields bitmask.
* @return The current search fields.
*/
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/ProxyBase.cpp \
#997159:997160 @@ -54,6 +54,19 @@
m_belowModel->clearSearchTerm();
}
+bool
+ProxyBase::containsTrack( const Meta::TrackPtr track ) const
+{
+ DEBUG_BLOCK
+ // The complexity of this isn't optimal
+ for( int i = 0; i < rowCount(); i++ ) //O(n^2) at worst
+ {
+ if( trackAt( i ) == track ) //O( n ) - uses .at()
+ return true;
+ }
+ return false;
+}
+
int
ProxyBase::currentSearchFields()
{
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/ProxyBase.h \
#997159:997160 @@ -69,6 +69,13 @@
virtual void clearSearchTerm();
/**
+ * Reports if the current model exposes a given track.
+ * @param track the track to check for.
+ * @return true if the track is present, otherwise false.
+ */
+ virtual bool containsTrack( const Meta::TrackPtr track ) const;
+
+ /**
* Get the current search fields bitmask.
* @return The current search fields.
*/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic