[vlc-devel] commit: Qt: replace playlist view title with interactive location bar ( Jakob Leben )
git version control
git at videolan.org
Thu Jan 28 06:54:18 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Thu Jan 28 06:52:04 2010 +0100| [84249d56364b2da8f2d197f4074f7fed0b0a230b] | committer: Jakob Leben
Qt: replace playlist view title with interactive location bar
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=84249d56364b2da8f2d197f4074f7fed0b0a230b
---
.../gui/qt4/components/playlist/standardpanel.cpp | 61 ++++++++++++++++++--
.../gui/qt4/components/playlist/standardpanel.hpp | 18 ++++++
2 files changed, 73 insertions(+), 6 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 9f9c20a..c6662bf 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -43,6 +43,8 @@
#include <QMenu>
#include <QSignalMapper>
#include <QWheelEvent>
+#include <QToolButton>
+#include <QFontMetrics>
#include <assert.h>
@@ -68,12 +70,15 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
currentRootId = -1;
/* Title label */
- title = new QLabel;
+ /*title = new QLabel;
QFont titleFont;
titleFont.setPointSize( titleFont.pointSize() + 6 );
titleFont.setFamily( "Verdana" );
title->setFont( titleFont );
- layout->addWidget( title, 0, 0 );
+ layout->addWidget( title, 0, 0 );*/
+
+ locationBar = new LocationBar( model );
+ layout->addWidget( locationBar, 0, 0 );
/* A Spacer and the search possibilities */
layout->setColumnStretch( 1, 10 );
@@ -117,6 +122,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
last_activated_id = -1;
CONNECT( THEMIM, inputChanged( input_thread_t * ),
this, handleInputChange( input_thread_t * ) );
+ CONNECT( locationBar, invoked( const QModelIndex & ),
+ iconView, setRootIndex( const QModelIndex & ) );
}
StandardPLPanel::~StandardPLPanel()
@@ -219,15 +226,17 @@ void StandardPLPanel::setRoot( playlist_item_t *p_item )
currentRootId = p_item->i_id;
/* cosmetics, ..still need playlist locking.. */
- char *psz_title = input_item_GetName( p_item->p_input );
+ /*char *psz_title = input_item_GetName( p_item->p_input );
title->setText( qfu(psz_title) );
- free( psz_title );
+ free( psz_title );*/
QPL_UNLOCK;
/* do THE job */
model->rebuild( p_item );
+ locationBar->setIndex( QModelIndex() );
+
/* enable/disable adding */
if( p_item == THEPL->p_local_category ||
p_item == THEPL->p_local_onelevel )
@@ -372,7 +381,8 @@ void StandardPLPanel::activate( const QModelIndex &index )
{
if( currentView == iconView ) {
iconView->setRootIndex( index );
- title->setText( index.data().toString() );
+ //title->setText( index.data().toString() );
+ locationBar->setIndex( index );
}
}
else
@@ -395,9 +405,48 @@ void StandardPLPanel::handleInputChange( input_thread_t *p_input_thread )
{
QModelIndex index = model->index( p_item->p_parent->i_id, 0 );
iconView->setRootIndex( index );
- title->setText( index.data().toString() );
+ //title->setText( index.data().toString() );
+ locationBar->setIndex( index );
last_activated_id = p_item->i_id;
}
playlist_Unlock( THEPL );
}
+
+LocationBar::LocationBar( PLModel *m )
+{
+ model = m;
+ mapper = new QSignalMapper;
+ CONNECT( mapper, mapped( int ), this, invoke( int ) );
+}
+
+void LocationBar::setIndex( const QModelIndex &index )
+{
+ clear();
+ QAction *prev = NULL;
+ QModelIndex i = index;
+ QFont font;
+ QFontMetrics metrics( font );
+ while( true )
+ {
+ QToolButton *btn = new QToolButton;
+ PLItem *item = model->getItem( i );
+ QString text = input_item_GetTitleFbName( item->inputItem() );
+ text = QString("/ ") + metrics.elidedText( text, Qt::ElideRight, 150 );
+ btn->setText( text );
+ btn->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
+ prev = insertWidget( prev, btn );
+
+ mapper->setMapping( btn, item->id() );
+ CONNECT( btn, clicked( ), mapper, map( ) );
+
+ if( i.isValid() ) i = i.parent();
+ else break;
+ }
+}
+
+void LocationBar::invoke( int i_id )
+{
+ QModelIndex index = model->index( i_id, 0 );
+ emit invoked ( index );
+}
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index 3a841b1..3cb5621 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -34,6 +34,7 @@
#include <QModelIndex>
#include <QWidget>
#include <QString>
+#include <QToolBar>
#include <vlc_playlist.h>
@@ -45,6 +46,7 @@ class QPushButton;
class QKeyEvent;
class QWheelEvent;
class PlIconView;
+class LocationBar;
class StandardPLPanel: public QWidget
{
@@ -68,6 +70,7 @@ private:
QLabel *title;
QPushButton *addButton;
QGridLayout *layout;
+ LocationBar *locationBar;
QTreeView *treeView;
PlIconView *iconView;
@@ -104,4 +107,19 @@ private slots:
void handleInputChange( input_thread_t * );
};
+class LocationBar : public QToolBar
+{
+ Q_OBJECT;
+public:
+ LocationBar( PLModel * );
+ void setIndex( const QModelIndex & );
+signals:
+ void invoked( const QModelIndex & );
+private slots:
+ void invoke( int i_item_id );
+private:
+ PLModel *model;
+ QSignalMapper *mapper;
+};
+
#endif
More information about the vlc-devel
mailing list