[vlc-commits] Qt: PLTreeView: Show details as tooltip
Francois Cartegnie
git at videolan.org
Thu Jun 14 17:05:50 CEST 2012
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jun 14 15:16:07 2012 +0200| [1621978090b2d183b9f881c2e15f86c981dcaf3e] | committer: Francois Cartegnie
Qt: PLTreeView: Show details as tooltip
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1621978090b2d183b9f881c2e15f86c981dcaf3e
---
.../gui/qt4/components/playlist/playlist_model.cpp | 27 ++++++++++++++
modules/gui/qt4/components/playlist/views.cpp | 38 ++++++++++++++++++++
modules/gui/qt4/components/playlist/views.hpp | 3 ++
3 files changed, 68 insertions(+)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index b7c0b66..e46a439 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -389,6 +389,33 @@ QVariant PLModel::data( const QModelIndex &index, const int role ) const
f.setBold( true );
return QVariant( f );
}
+ else if( role == Qt::ToolTipRole )
+ {
+ QString artUrl = getArtUrl( index );
+ if ( artUrl.isEmpty() ) artUrl = ":/noart";
+ QString duration = qtr( "unknown" );
+ QString name;
+ PL_LOCK;
+ input_item_t *p_item = item->inputItem();
+ if ( !p_item )
+ {
+ PL_UNLOCK;
+ return QVariant();
+ }
+ if ( p_item->i_duration > 0 )
+ {
+ char *psz = psz_column_meta( item->inputItem(), COLUMN_DURATION );
+ duration = qfu( psz );
+ free( psz );
+ }
+ name = QString( p_item->psz_name );
+ PL_UNLOCK;
+ return QVariant( QString("<img width=\"128\" height=\"128\" align=\"left\" src=\"%1\"/><div><b>%2</b><br/>%3</div>")
+ .arg( artUrl )
+ .arg( name )
+ .arg( qtr("Duration") + ": " + duration )
+ );
+ }
else if( role == Qt::BackgroundRole && isCurrent( index ) )
{
return QVariant( QBrush( Qt::gray ) );
diff --git a/modules/gui/qt4/components/playlist/views.cpp b/modules/gui/qt4/components/playlist/views.cpp
index c66cd71..76f41a6 100644
--- a/modules/gui/qt4/components/playlist/views.cpp
+++ b/modules/gui/qt4/components/playlist/views.cpp
@@ -313,6 +313,19 @@ void PlIconView::dragMoveEvent ( QDragMoveEvent * event )
QAbstractItemView::dragMoveEvent( event );
}
+bool PlIconView::viewportEvent ( QEvent * event )
+{
+ if ( event->type() == QEvent::ToolTip )
+ {
+ event->ignore();
+ return true;
+ }
+ else
+ {
+ return QAbstractItemView::viewportEvent( event );
+ }
+}
+
PlListView::PlListView( PLModel *, QWidget *parent ) : QListView( parent )
{
setViewMode( QListView::ListMode );
@@ -350,6 +363,19 @@ void PlListView::keyPressEvent( QKeyEvent *event )
QListView::keyPressEvent( event );
}
+bool PlListView::viewportEvent ( QEvent * event )
+{
+ if ( event->type() == QEvent::ToolTip )
+ {
+ event->ignore();
+ return true;
+ }
+ else
+ {
+ return QAbstractItemView::viewportEvent( event );
+ }
+}
+
void PlTreeView::setModel( QAbstractItemModel * model )
{
QTreeView::setModel( model );
@@ -477,3 +503,15 @@ void PicFlowView::playItem( int i_item )
emit activated( model()->index(i_item, 0) );
}
+bool PicFlowView::viewportEvent ( QEvent * event )
+{
+ if ( event->type() == QEvent::ToolTip )
+ {
+ event->ignore();
+ return true;
+ }
+ else
+ {
+ return QAbstractItemView::viewportEvent( event );
+ }
+}
diff --git a/modules/gui/qt4/components/playlist/views.hpp b/modules/gui/qt4/components/playlist/views.hpp
index 38285d8..0cc15c0 100644
--- a/modules/gui/qt4/components/playlist/views.hpp
+++ b/modules/gui/qt4/components/playlist/views.hpp
@@ -71,6 +71,7 @@ public:
protected:
virtual void startDrag ( Qt::DropActions supportedActions );
virtual void dragMoveEvent ( QDragMoveEvent * event );
+ virtual bool viewportEvent ( QEvent * );
};
class PlListView : public QListView
@@ -83,6 +84,7 @@ protected:
virtual void startDrag ( Qt::DropActions supportedActions );
virtual void dragMoveEvent ( QDragMoveEvent * event );
virtual void keyPressEvent( QKeyEvent *event );
+ virtual bool viewportEvent ( QEvent * );
};
class PlTreeView : public QTreeView
@@ -114,6 +116,7 @@ protected:
virtual bool isIndexHidden(const QModelIndex&) const;
virtual QRegion visualRegionForSelection(const QItemSelection&) const;
virtual void setSelection(const QRect&, QFlags<QItemSelectionModel::SelectionFlag>);
+ virtual bool viewportEvent ( QEvent * );
private:
PictureFlow *picFlow;
More information about the vlc-commits
mailing list