Commit 16219780 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: PLTreeView: Show details as tooltip

parent bd733d23
...@@ -389,6 +389,33 @@ QVariant PLModel::data( const QModelIndex &index, const int role ) const ...@@ -389,6 +389,33 @@ QVariant PLModel::data( const QModelIndex &index, const int role ) const
f.setBold( true ); f.setBold( true );
return QVariant( f ); 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 ) ) else if( role == Qt::BackgroundRole && isCurrent( index ) )
{ {
return QVariant( QBrush( Qt::gray ) ); return QVariant( QBrush( Qt::gray ) );
......
...@@ -313,6 +313,19 @@ void PlIconView::dragMoveEvent ( QDragMoveEvent * event ) ...@@ -313,6 +313,19 @@ void PlIconView::dragMoveEvent ( QDragMoveEvent * event )
QAbstractItemView::dragMoveEvent( 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 ) PlListView::PlListView( PLModel *, QWidget *parent ) : QListView( parent )
{ {
setViewMode( QListView::ListMode ); setViewMode( QListView::ListMode );
...@@ -350,6 +363,19 @@ void PlListView::keyPressEvent( QKeyEvent *event ) ...@@ -350,6 +363,19 @@ void PlListView::keyPressEvent( QKeyEvent *event )
QListView::keyPressEvent( 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 ) void PlTreeView::setModel( QAbstractItemModel * model )
{ {
QTreeView::setModel( model ); QTreeView::setModel( model );
...@@ -477,3 +503,15 @@ void PicFlowView::playItem( int i_item ) ...@@ -477,3 +503,15 @@ void PicFlowView::playItem( int i_item )
emit activated( model()->index(i_item, 0) ); 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 );
}
}
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
protected: protected:
virtual void startDrag ( Qt::DropActions supportedActions ); virtual void startDrag ( Qt::DropActions supportedActions );
virtual void dragMoveEvent ( QDragMoveEvent * event ); virtual void dragMoveEvent ( QDragMoveEvent * event );
virtual bool viewportEvent ( QEvent * );
}; };
class PlListView : public QListView class PlListView : public QListView
...@@ -83,6 +84,7 @@ protected: ...@@ -83,6 +84,7 @@ protected:
virtual void startDrag ( Qt::DropActions supportedActions ); virtual void startDrag ( Qt::DropActions supportedActions );
virtual void dragMoveEvent ( QDragMoveEvent * event ); virtual void dragMoveEvent ( QDragMoveEvent * event );
virtual void keyPressEvent( QKeyEvent *event ); virtual void keyPressEvent( QKeyEvent *event );
virtual bool viewportEvent ( QEvent * );
}; };
class PlTreeView : public QTreeView class PlTreeView : public QTreeView
...@@ -114,6 +116,7 @@ protected: ...@@ -114,6 +116,7 @@ protected:
virtual bool isIndexHidden(const QModelIndex&) const; virtual bool isIndexHidden(const QModelIndex&) const;
virtual QRegion visualRegionForSelection(const QItemSelection&) const; virtual QRegion visualRegionForSelection(const QItemSelection&) const;
virtual void setSelection(const QRect&, QFlags<QItemSelectionModel::SelectionFlag>); virtual void setSelection(const QRect&, QFlags<QItemSelectionModel::SelectionFlag>);
virtual bool viewportEvent ( QEvent * );
private: private:
PictureFlow *picFlow; PictureFlow *picFlow;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment