]> git.sesse.net Git - vlc/commitdiff
Qt: iconView delegate: encode PLModel::IsCurrent(QModelIndex) into cache key
authorJakob Leben <jleben@videolan.org>
Thu, 28 Jan 2010 19:08:50 +0000 (20:08 +0100)
committerJakob Leben <jleben@videolan.org>
Thu, 28 Jan 2010 19:10:22 +0000 (20:10 +0100)
This way item is redrawn when current item changes.

modules/gui/qt4/components/playlist/icon_view.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.hpp

index 856cbd65d318665d2a4e4c8b1d61f4c24a8ccb59..7e63ebe33e1aeeb57c21a714424153dba55fb5f9 100644 (file)
@@ -82,7 +82,8 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
     // picture where all the rendering happens and which will be cached
     QPixmap pix;
 
-    QString key = title + artist + artUrl;
+    QString key = title + artist + artUrl
+                  + QString( index.data( PLModel::IsCurrentRole ).toInt() );
     if(QPixmapCache::find( key, pix ))
     {
         // cool, we found it in the cache
index 455291888b78f5dc2079784380d2c7efcac67e91..f9c87628ffa6b7b900929cdec87b7bbeb38d5b61 100644 (file)
@@ -346,6 +346,7 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
             QFont f; f.setBold( true ); return QVariant( f );
         }
     }
+    else if( role == IsCurrentRole ) return QVariant( isCurrent( index ) );
     return QVariant();
 }
 
index cd5b1ecd6116d42a07c5a97778b659a28fd14601..e1d87b403fb9003cc6461b10c8dba48c853bd9d3 100644 (file)
@@ -54,6 +54,10 @@ class PLModel : public QAbstractItemModel
 friend class PLItem;
 
 public:
+    enum {
+      IsCurrentRole = Qt::UserRole
+    };
+
     PLModel( playlist_t *, intf_thread_t *,
              playlist_item_t *, QObject *parent = 0 );
     ~PLModel();