[vlc-devel] [vlc-commits] Qt: PLModel: try to agregate inserts for efficiency

Ilkka Ollakka ileoo at videolan.org
Fri Jun 8 10:34:56 CEST 2012


On Thu, Jun 07, 2012 at 12:53:15PM +0200, Francois Cartegnie wrote:
> vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jun  6 19:05:58 2012 +0200| [bd0ae7ec66f9e94b877ec1b206fce52eb133b0ae] | committer: Francois Cartegnie

> Qt: PLModel: try to agregate inserts for efficiency

> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bd0ae7ec66f9e94b877ec1b206fce52eb133b0ae

>      /* We insert the newItem (children) inside the parent */
> -    beginInsertRows( index( nodeParentItem, 0 ), pos, pos );
> -    nodeParentItem->insertChild( newItem, pos );
> -    endInsertRows();
> -
> -    if( newItem->inputItem() == THEMIM->currentInputItem() )
> -        emit currentIndexChanged( index( newItem, 0 ) );
> +    bufferedRowInsert( newItem, nodeParentItem, pos );

Hi,

I think removing currentIndexChanged() broke the scrolling of current
item in playlistview. Atleast for me the tree-playlist views don't work
anymore when depth is over 2 levels (eg playlist->musicdirectory->albumdirectory->file)

Are you sure the flickering doesn't come forexample use of layoutChanged()
or dataChanged() signaling?

>      if( latestSearch.isEmpty() ) return;
>      search( latestSearch, index( rootItem, 0), false /*FIXME*/ );
> @@ -693,6 +752,7 @@ void PLModel::rebuild( playlist_item_t *p_root )

>  void PLModel::takeItem( PLItem *item )
>  {
> +    commitBufferedRowInserts();
>      assert( item );
>      PLItem *parent = item->parent();
>      assert( parent );
> @@ -705,6 +765,7 @@ void PLModel::takeItem( PLItem *item )

>  void PLModel::insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos )
>  {
> +    commitBufferedRowInserts();
>      assert( node );
>      int count = items.count();
>      if( !count ) return;
> @@ -720,6 +781,7 @@ void PLModel::insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos )
>  void PLModel::removeItem( PLItem *item )
>  {
>      if( !item ) return;
> +    commitBufferedRowInserts();

>      i_cached_id = -1;
>      i_cached_input_id = -1;
> @@ -822,6 +884,9 @@ void PLModel::sort( const int i_root_id, const int column, Qt::SortOrder order )

>      PLItem *item = findById( rootItem, i_root_id );
>      if( !item ) return;
> +
> +    commitBufferedRowInserts();
> +
>      QModelIndex qIndex = index( item, 0 );
>      int count = item->childCount();
>      if( count )
> @@ -868,6 +933,8 @@ void PLModel::search( const QString& search_text, const QModelIndex & idx, bool
>  {
>      latestSearch = search_text;

> +    commitBufferedRowInserts();
> +
>      /** \todo Fire the search with a small delay ? */
>      PL_LOCK;
>      {
> diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
> index 133928f..9eee44f 100644
> --- a/modules/gui/qt4/components/playlist/playlist_model.hpp
> +++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
> @@ -41,6 +41,8 @@
>  #include <QAbstractItemModel>
>  #include <QVariant>
>  #include <QModelIndex>
> +#include <QTimer>
> +#include <QMutex>

>  class PLItem;
>  class PLSelector;
> @@ -130,6 +132,15 @@ private:

>      static QIcon icons[ITEM_TYPE_NUMBER];

> +    /* single row linear inserts agregation */
> +    void bufferedRowInsert( PLItem *item, PLItem *parent, int pos );
> +    PLItem *insertBufferRoot;
> +    int insertbuffer_firstrow;
> +    int insertbuffer_lastrow;
> +    QTimer insertBufferCommitTimer;
> +    QList<PLItem *> insertBuffer;
> +    QMutex insertBufferMutex;
> +
>      /* Custom model private methods */
>      /* Lookups */
>      QStringList selectedURIs();
> @@ -192,6 +203,7 @@ private slots:
>      void processInputItemUpdate( input_thread_t* p_input );
>      void processItemRemoval( int i_id );
>      void processItemAppend( int item, int parent );
> +    void commitBufferedRowInserts();
>      void activateItem( playlist_item_t *p_item );
>      void increaseZoom();
>      void decreaseZoom();

> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> http://mailman.videolan.org/listinfo/vlc-commits


-- 
Ilkka Ollakka
"In defeat, unbeatable; in victory, unbearable."
		-- Winston Curchill, of Montgomery
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120608/4d7a3553/attachment.sig>


More information about the vlc-devel mailing list