[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/playlist/proxymodels
From:       Teo Mrnjavac <teo.mrnjavac () gmail ! com>
Date:       2009-06-30 12:36:49
Message-ID: 1246365409.601712.27416.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 989506 by mrnjavac:

Added rowExists() to Playlist::AbstractModel.
Moved forwarders rowCount(), rowExists(), setActiveRow(), supportedDropActions(), \
totalLength() and tractAt() from the proxies to Playlist::ProxyBase. This concludes \
the move of common forwarder methods.

 M  +9 -1      AbstractModel.h  
 M  +0 -26     FilterProxy.cpp  
 M  +2 -8      FilterProxy.h  
 M  +0 -29     GroupingProxy.cpp  
 M  +0 -14     GroupingProxy.h  
 M  +37 -0     ProxyBase.cpp  
 M  +44 -0     ProxyBase.h  
 M  +0 -37     SortProxy.cpp  
 M  +2 -44     SortProxy.h  


--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/AbstractModel.h \
#989505:989506 @@ -144,7 +144,15 @@
      * @return the number of rows.
      */
     virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const = 0;
-/**
+
+    /**
+     * Checks if a row exists in the current model or proxy.
+     * @param row the row in the model or proxy.
+     * @return true is the row exists, otherwise false.
+     */
+    virtual bool rowExists( int row ) const = 0;
+
+    /**
      * Sets the currently active (playing) row, translated for this proxy.
      * @param row the row to be set as active.
      */
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/FilterProxy.cpp \
#989505:989506 @@ -200,27 +200,6 @@
     return index.row();
 }
 
-bool FilterProxy::rowExists( int row ) const
-{
-    QModelIndex index = this->index( row, 0 );
-    return index.isValid();
-}
-
-void FilterProxy::setActiveRow( int row )
-{
-    m_belowModel->setActiveRow( rowToSource( row ) );
-}
-
-Meta::TrackPtr FilterProxy::trackAt(int row) const
-{
-    return m_belowModel->trackAt( rowToSource( row ) );
-}
-
-int FilterProxy::totalLength() const
-{
-    return m_belowModel->totalLength();
-}
-
 void FilterProxy::clearSearchTerm()
 {
     m_belowModel->clearSearchTerm();
@@ -232,11 +211,6 @@
     }
 }
 
-Qt::DropActions FilterProxy::supportedDropActions() const
-{
-    return m_belowModel->supportedDropActions();
-}
-
 void FilterProxy::setRowQueued( int row )
 {
     Model::instance()->setRowQueued( rowToSource( row ) );
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/FilterProxy.h \
#989505:989506 @@ -98,16 +98,10 @@
     void setRowQueued( int row );
     void setRowDequeued( int row );
 
-    bool rowExists( int row ) const;
-    void setActiveRow( int row );
-    Meta::TrackPtr trackAt( int row ) const;
-
-    Qt::DropActions supportedDropActions() const;
-
-    int totalLength() const;
-
     void clearSearchTerm();
 
+//FIXME: when the proxies are despaghettified, the following two methods need to be \
protected: +//protected:
     int rowToSource( int row ) const;
     int rowFromSource( int row ) const;
 
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/GroupingProxy.cpp \
#989505:989506 @@ -86,12 +86,6 @@
     return sourceModel()->parent( i );
 }
 
-int
-Playlist::GroupingProxy::rowCount( const QModelIndex& i ) const
-{
-    return m_belowModel->rowCount( i );
-}
-
 QModelIndex
 Playlist::GroupingProxy::mapToSource( const QModelIndex& i ) const
 {
@@ -125,24 +119,6 @@
 }
 
 void
-Playlist::GroupingProxy::setActiveRow( int row ) const
-{
-    m_belowModel->setActiveRow( row );
-}
-
-Meta::TrackPtr
-Playlist::GroupingProxy::trackAt( int row ) const
-{
-    return m_belowModel->trackAt( row );
-}
-
-Qt::DropActions
-Playlist::GroupingProxy::supportedDropActions() const
-{
-    return m_belowModel->supportedDropActions();
-}
-
-void
 Playlist::GroupingProxy::setCollapsed( int, bool ) const
 {
     AMAROK_DEPRECATED
@@ -284,11 +260,6 @@
     return false;
 }
 
-int Playlist::GroupingProxy::totalLength()
-{
-    return m_belowModel->totalLength();
-}
-
 int Playlist::GroupingProxy::tracksInGroup( int row ) const
 {
     //unfortunately we need to map this to row from source as it will
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/GroupingProxy.h \
#989505:989506 @@ -69,16 +69,10 @@
     // functions from QAbstractProxyModel
     QModelIndex index( int, int c = 0, const QModelIndex& parent = QModelIndex() ) \
const;  QModelIndex parent( const QModelIndex& ) const;
-    int rowCount( const QModelIndex& idx = QModelIndex() ) const;
     QModelIndex mapToSource( const QModelIndex& ) const;
     QModelIndex mapFromSource( const QModelIndex& ) const;
     QVariant data( const QModelIndex &index, int role ) const;
 
-    // wrapped functions from PlaylistModel
-    void setActiveRow( int ) const;
-    Meta::TrackPtr trackAt( int ) const;
-    Qt::DropActions supportedDropActions() const;
-
     // grouping-related functions
     void setCollapsed( int, bool ) const;
     int firstInGroup( int ) const;
@@ -87,8 +81,6 @@
     int tracksInGroup( int row ) const;
     int lengthOfGroup( int row ) const;
 
-    int totalLength();
-
 signals:
     /**
      * This signal is emitted when tracks are added to the playlist.
@@ -112,12 +104,6 @@
      */
     void setActiveRow( int row );
 
-    /**
-     * Asks the model sitting below the total length of the playlist.
-     * @return the total length of the playlist.
-     */
-    int totalLength() const;
-
 private slots:
     void modelDataChanged( const QModelIndex&, const QModelIndex& );
     void modelRowsInserted( const QModelIndex&, int, int );
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/ProxyBase.cpp \
#989505:989506 @@ -132,6 +132,43 @@
     return m_belowModel->mimeTypes();
 }
 
+int
+ProxyBase::rowCount(const QModelIndex& parent) const
+{
+    return m_belowModel->rowCount( parent );
+}
+
+bool
+ProxyBase::rowExists( int row ) const
+{
+    QModelIndex index = this->index( row, 0 );
+    return index.isValid();
+}
+
+void
+ProxyBase::setActiveRow( int row )
+{
+    m_belowModel->setActiveRow( rowToSource( row ) );
+}
+
+Qt::DropActions
+ProxyBase::supportedDropActions() const
+{
+    return m_belowModel->supportedDropActions();
+}
+
+int
+ProxyBase::totalLength() const
+{
+    return m_belowModel->totalLength();
+}
+
+Meta::TrackPtr
+ProxyBase::trackAt(int row) const
+{
+    return m_belowModel->trackAt( rowToSource( row ) );
+}
+
 }   //namespace Playlist
 
 #include "ProxyBase.moc"
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/ProxyBase.h \
#989505:989506 @@ -169,7 +169,51 @@
      */
     virtual QStringList mimeTypes() const;
 
+    /**
+     * Returns the number of rows exposed by the current proxy.
+     * The default implementation forwards the row count of the model below it.
+     * @param parent the parent of the rows to count.
+     * @return the number of rows.
+     */
+    virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
 
+    /**
+     * Checks if a row exists in the current proxy.
+     * @param row the row in the proxy.
+     * @return true is the row exists, otherwise false.
+     */
+    virtual bool rowExists( int row ) const;
+
+    /**
+     * Sets the currently active (playing) row, translated for the current proxy.
+     * @param row the row to be set as active.
+     */
+    virtual void setActiveRow( int row );
+
+    /**
+     * 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.
+     * @return the drop actions.
+     */
+    virtual Qt::DropActions supportedDropActions() const;
+
+    /**
+     * Returns the total length of the playlist.
+     * The default implementation forwards the total time from the proxy or model \
below the +     * current proxy.
+     * @return the total length of the playlist.
+     */
+    virtual int totalLength() const;
+
+    /**
+     * Returns a pointer to the track at a given row in the current proxy.
+     * @param row the row to return the track pointer for.
+     * @return a pointer to the track at the given row.
+     */
+    virtual Meta::TrackPtr trackAt( int row ) const;
+
+
 //FIXME: When every proxy talks only to the proxy below it, these should be made \
protected  //       here and and in subclasses that reimplement them. For now, they \
have to be public  //       otherwise it won't compile.    -- Téo 21/6/2009
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/SortProxy.cpp \
#989505:989506 @@ -81,19 +81,6 @@
 // Please keep them sorted alphabetically.  -- Téo
 
 int
-SortProxy::rowCount(const QModelIndex& parent) const
-{
-    return m_belowModel->rowCount( parent );
-}
-
-bool
-SortProxy::rowExists( int row ) const
-{
-    QModelIndex index = this->index( row, 0 );
-    return index.isValid();
-}
-
-int
 SortProxy::rowFromSource( int row ) const
 {
     QModelIndex sourceIndex = sourceModel()->index( row, 0 );
@@ -115,28 +102,4 @@
     return sourceIndex.row();
 }
 
-void
-SortProxy::setActiveRow( int row )
-{
-    m_belowModel->setActiveRow( rowToSource( row ) );
-}
-
-Qt::DropActions
-SortProxy::supportedDropActions() const
-{
-    return m_belowModel->supportedDropActions();
-}
-
-int
-SortProxy::totalLength() const
-{
-    return m_belowModel->totalLength();
-}
-
-Meta::TrackPtr
-SortProxy::trackAt(int row) const
-{
-    return m_belowModel->trackAt( rowToSource( row ) );
-}
-
 }   //namespace Playlist
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/SortProxy.h \
#989505:989506 @@ -50,26 +50,9 @@
      */
     bool lessThan( const QModelIndex & left, const QModelIndex & right ) const;
 
-// Pass-through public methods, basically identical to those in \
                Playlist::FilterProxy, that
-// pretty much just forward stuff through the stack of proxies start here.
-// Please keep them sorted alphabetically.  -- To
-
+//FIXME: when the proxies are despaghettified, the following two methods need to be \
protected: +//protected:
     /**
-     * Forwards the number of rows from the FilterProxy as SortProxy by definition \
                shouldn't
-     * change the row count.
-     * @param parent the parent of the rows to count.
-     * @return the number of rows.
-     */
-    int rowCount( const QModelIndex &parent = QModelIndex() ) const;
-
-    /**
-     * Checks if a row exists in the ProxyModel.
-     * @param row the row in the Proxy.
-     * @return true is the row exists, otherwise false.
-     */
-    bool rowExists( int row ) const;
-
-    /**
      * Converts a row index that's valid in the proxy below this one to a row index \
                valid
      * in this proxy, with sanity checks.
      * @param row the row index to be converted.
@@ -85,31 +68,6 @@
      */
     int rowToSource( int row ) const;
 
-    /**
-     * Sets the currently active (playing) row, translated for this proxy.
-     * @param row the row to be set as active.
-     */
-    void setActiveRow( int row );
-
-    /**
-     * Returns the drop actions supported by this model.
-     * @return the drop actions.
-     */
-    Qt::DropActions supportedDropActions() const;
-
-    /**
-     * Asks the model sitting below the total length of the playlist.
-     * @return the total length of the playlist.
-     */
-    int totalLength() const;
-
-    /**
-     * Returns a pointer to the track at a given row.
-     * @param row the row to return the track pointer for.
-     * @return a pointer to the track at the given row.
-     */
-    Meta::TrackPtr trackAt( int row ) const;
-
 public slots:
     /**
      * Applies a sorting scheme to the playlist.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic