[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 16:22:26
Message-ID: 1247588546.937350.5247.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 996666 by mrnjavac:
Made Playlist::FilterProxy talk to the model/proxy below it without relying on the \
specific interface of Playlist::Model. To achieve this, moved several methods to \
Playlist::AbstractModel and implemented the corresponding forwarders in \
Playlist::ProxyBase.
M +0 -1 PlaylistModel.h
M +29 -0 proxymodels/AbstractModel.h
M +2 -19 proxymodels/FilterProxy.cpp
M +0 -21 proxymodels/FilterProxy.h
M +26 -0 proxymodels/ProxyBase.cpp
M +28 -0 proxymodels/ProxyBase.h
--- trunk/extragear/multimedia/amarok/src/playlist/PlaylistModel.h #996665:996666
@@ -24,7 +24,6 @@
#include "proxymodels/AbstractModel.h"
#include "Amarok.h"
-#include "PlaylistItem.h"
#include "UndoCommands.h"
#include "meta/Meta.h"
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/AbstractModel.h \
#996665:996666 @@ -19,6 +19,7 @@
#include "meta/Meta.h"
#include "playlist/PlaylistDefines.h"
+#include "playlist/PlaylistItem.h"
#include <QAbstractItemModel>
@@ -103,6 +104,13 @@
virtual Qt::ItemFlags flags( const QModelIndex& index ) const = 0;
/**
+ * Returns the unique 64-bit id for the given row in the current model.
+ * @param row the row.
+ * @return the unique id.
+ */
+ virtual quint64 idAt( const int row ) const = 0;
+
+ /**
* Returns an object that contains serialized items of data corresponding to the \
list of indexes specified.
* @param indexes a list of indexes.
* @return the MIME data corresponding to the indexes.
@@ -131,12 +139,33 @@
virtual bool rowExists( int row ) const = 0;
/**
+ * Returns the row in the current model for a given unique 64-bit id.
+ * @param id the id.
+ * @return the row, -1 if the id is invalid.
+ */
+ virtual int rowForId( const quint64 id ) const = 0;
+
+ /**
* Sets the currently active (playing) row, translated for this proxy.
* @param row the row to be set as active.
*/
virtual void setActiveRow( int row ) = 0;
/**
+ * Get the state of a track by its id.
+ * @param id The id of the track.
+ * @return The state of the track.
+ */
+ virtual Item::State stateOfId( quint64 id ) const = 0;
+
+ /**
+ * Get the sate of the track at given row in the proxy model.
+ * @param row The row in proxy terms.
+ * @return The state of the track at the row.
+ */
+ virtual Item::State stateOfRow( int row ) const = 0;
+
+ /**
* Returns the drop actions supported by this model.
* @return the drop actions.
*/
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/FilterProxy.cpp \
#996665:996666 @@ -61,13 +61,6 @@
return match;
}
-quint64 FilterProxy::idAt( const int row ) const
-{
- QModelIndex index = this->index( row, 0 );
- QModelIndex sourceIndex = mapToSource( index );
- return Model::instance()->idAt( sourceIndex.row() );
-}
-
int
FilterProxy::rowCount(const QModelIndex& parent) const
{
@@ -151,7 +144,7 @@
QList< quint64 > proxyIds;
foreach( quint64 id, ids )
{
- if ( matchesCurrentSearchTerm( Model::instance()->rowForId( id ) ) )
+ if ( matchesCurrentSearchTerm( m_belowModel->rowForId( id ) ) )
proxyIds << id;
}
@@ -163,7 +156,7 @@
{
QList<quint64> proxyIds;
foreach( quint64 id, ids ) {
- const int row = Model::instance()->rowForId( id );
+ const int row = m_belowModel->rowForId( id );
if ( row == -1 || matchesCurrentSearchTerm( row ) ) {
proxyIds << id;
}
@@ -173,16 +166,6 @@
emit removedIds( proxyIds );
}
-Item::State FilterProxy::stateOfRow( int row ) const
-{
- return Model::instance()->stateOfRow( rowToSource( row ) );
-}
-
-Item::State FilterProxy::stateOfId( quint64 id ) const
-{
- return Model::instance()->stateOfId( id );
-}
-
void
FilterProxy::showOnlyMatches( bool onlyMatches )
{
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/FilterProxy.h \
#996665:996666 @@ -43,30 +43,9 @@
*/
static FilterProxy* instance();
- /**
- * Find the id of the track at a given row in the proxy model.
- * @param row The row in proxy terms.
- * @return The id of the row.
- */
- quint64 idAt( const int row ) const;
-
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
/**
- * Get the sate of the track at given row in the proxy model.
- * @param row The row in proxy terms.
- * @return The state of the track at the row.
- */
- Item::State stateOfRow( int row ) const;
-
- /**
- * Get the state of a track by its id.
- * @param id The id of the track.
- * @return The state of the track.
- */
- Item::State stateOfId( quint64 id ) const;
-
- /**
* Find the first track in the playlist that matches the search term in one of \
the
* specified search fields. This function emits found() or notFound() depending \
on
* whether a match is found.
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/ProxyBase.cpp \
#996665:996666 @@ -118,6 +118,14 @@
return m_belowModel->flags( index );
}
+quint64
+ProxyBase::idAt( const int row ) const
+{
+ if( rowExists( row ) )
+ return m_belowModel->idAt( rowToSource( row ) );
+ return 0;
+}
+
QMimeData *
ProxyBase::mimeData( const QModelIndexList &indexes ) const
{
@@ -143,6 +151,12 @@
return index.isValid();
}
+int
+ProxyBase::rowForId( const quint64 id ) const
+{
+ return rowFromSource( m_belowModel->rowForId( id ) );
+}
+
void
ProxyBase::setActiveRow( int row )
{
@@ -155,6 +169,18 @@
( dynamic_cast< ProxyBase * >( m_belowModel) )->showOnlyMatches( onlyMatches );
}
+Item::State
+ProxyBase::stateOfId( quint64 id ) const
+{
+ return m_belowModel->stateOfId( id );
+}
+
+Item::State
+ProxyBase::stateOfRow( int row ) const
+{
+ return m_belowModel->stateOfRow( rowToSource( row ) );
+}
+
Qt::DropActions
ProxyBase::supportedDropActions() const
{
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/ProxyBase.h \
#996665:996666 @@ -153,6 +153,13 @@
virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
/**
+ * Returns the unique 64-bit id for the given row in the current model.
+ * @param row the row.
+ * @return the unique id, or 0 if the row does not exist.
+ */
+ virtual quint64 idAt( const int row ) const;
+
+ /**
* Returns an object that contains serialized items of data corresponding to the \
list
* of indexes specified.
* @param indexes a list of indexes.
@@ -182,6 +189,13 @@
virtual bool rowExists( int row ) const;
/**
+ * Returns the row in the current model for a given unique 64-bit id.
+ * @param id the id.
+ * @return the row, -1 if the id is invalid.
+ */
+ virtual int rowForId( const quint64 id ) const;
+
+ /**
* Sets the currently active (playing) row, translated for the current proxy.
* @param row the row to be set as active.
*/
@@ -194,6 +208,20 @@
virtual void showOnlyMatches( bool onlyMatches );
/**
+ * Get the state of a track by its id.
+ * @param id The id of the track.
+ * @return The state of the track.
+ */
+ virtual Item::State stateOfId( quint64 id ) const;
+
+ /**
+ * Get the sate of the track at given row in the proxy model.
+ * @param row The row in proxy terms.
+ * @return The state of the track at the row.
+ */
+ virtual Item::State stateOfRow( int row ) const;
+
+ /**
* Returns the drop actions supported by this proxy.
* The default implementation returns the drop actions supported by the proxy or \
model
* below the current proxy.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic