#include "playlist_model.hpp" /* plMimeData */
#include "input_manager.hpp" /* MainInputManager, for podcast */
+#include <QApplication>
#include <QInputDialog>
#include <QMessageBox>
#include <QMimeData>
#include <QTreeWidgetItem>
#include <QHBoxLayout>
#include <QPainter>
+#include <QPalette>
+#include <QScrollBar>
#include <vlc_playlist.h>
#include <vlc_services_discovery.h>
int frame = style()->pixelMetric( QStyle::PM_DefaultFrameWidth, 0, this );
p.drawLine( rect().topLeft() + QPoint( 0, frame ),
rect().bottomLeft() - QPoint( 0, frame ) );
- QVLCFramelessButton::paintEvent( event );
+ QFramelessButton::paintEvent( event );
}
PLSelItem::PLSelItem ( QTreeWidgetItem *i, const QString& text )
layout->setContentsMargins(0,0,0,0);
layout->addSpacing( 3 );
- lbl = new QVLCElidingLabel( text );
+ lbl = new QElidingLabel( text );
layout->addWidget(lbl, 1);
int height = qMax( 22, fontMetrics().height() + 8 );
icon = QIcon( ":/buttons/playlist/playlist_add" ); break;
case RM_ACTION:
icon = QIcon( ":/buttons/playlist/playlist_remove" ); break;
+ default:
+ return;
}
lblAction = new SelectorActionButton();
{
/* Properties */
setFrameStyle( QFrame::NoFrame );
+ setAttribute( Qt::WA_MacShowFocusRect, false );
viewport()->setAutoFillBackground( false );
setIconSize( QSize( 24,24 ) );
setIndentation( 12 );
setDropIndicatorShown(true);
invisibleRootItem()->setFlags( invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled );
+#ifdef Q_WS_MAC
+ setAutoFillBackground( true );
+ QPalette palette;
+ palette.setColor( QPalette::Window, QColor(209,215,226) );
+ setPalette( palette );
+#endif
+ setMinimumHeight( 120 );
+
/* Podcasts */
podcastsParent = NULL;
podcastsParentId = -1;
this, inputItemUpdate( input_item_t * ) );
createItems();
+
+ /* Expand at least to show level 2 */
+ for ( int i = 0; i < topLevelItemCount(); i++ )
+ expandItem( topLevelItem( i ) );
+
+ /***
+ * We need to react to both clicks and activation (enter-key) here.
+ * We use curItem to avoid rebuilding twice.
+ * See QStyle::SH_ItemView_ActivateItemOnSingleClick
+ ***/
+ curItem = NULL;
CONNECT( this, itemActivated( QTreeWidgetItem *, int ),
this, setSource( QTreeWidgetItem *) );
CONNECT( this, itemClicked( QTreeWidgetItem *, int ),
this, setSource( QTreeWidgetItem *) );
-
- /* I believe this is unnecessary, seeing
- QStyle::SH_ItemView_ActivateItemOnSingleClick
- CONNECT( view, itemClicked( QTreeWidgetItem *, int ),
- this, setSource( QTreeWidgetItem *) ); */
-
- /* select the first item */
-// view->setCurrentIndex( model->index( 0, 0, QModelIndex() ) );
}
PLSelector::~PLSelector()
void PLSelector::createItems()
{
/* PL */
- PLSelItem *pl = putPLData( addItem( PL_ITEM_TYPE, "Playlist", true ),
+ PLSelItem *pl = putPLData( addItem( PL_ITEM_TYPE, N_("Playlist"), true ),
THEPL->p_playing );
pl->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PL ) );
+ setCurrentItem( pl->treeItem() );
/* ML */
- PLSelItem *ml = putPLData( addItem( PL_ITEM_TYPE, "Media Library", true ),
+ PLSelItem *ml = putPLData( addItem( PL_ITEM_TYPE, N_("Media Library"), true ),
THEPL->p_media_library );
ml->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_ML ) );
+#ifdef MEDIA_LIBRARY
+ /* SQL ML */
+ addItem( SQL_ML_TYPE, "SQL Media Library" )->treeItem();
+#endif
+
/* SD nodes */
- QTreeWidgetItem *mycomp = addItem( CATEGORY_TYPE, "My Computer" )->treeItem();
- QTreeWidgetItem *devices = addItem( CATEGORY_TYPE, "Devices" )->treeItem();
- QTreeWidgetItem *lan = addItem( CATEGORY_TYPE, "Local Network" )->treeItem();
- QTreeWidgetItem *internet = addItem( CATEGORY_TYPE, "Internet" )->treeItem();
+ QTreeWidgetItem *mycomp = addItem( CATEGORY_TYPE, N_("My Computer") )->treeItem();
+ QTreeWidgetItem *devices = addItem( CATEGORY_TYPE, N_("Devices") )->treeItem();
+ QTreeWidgetItem *lan = addItem( CATEGORY_TYPE, N_("Local Network") )->treeItem();
+ QTreeWidgetItem *internet = addItem( CATEGORY_TYPE, N_("Internet") )->treeItem();
+
+#define NOT_SELECTABLE(w) w->setFlags( w->flags() ^ Qt::ItemIsSelectable );
+ NOT_SELECTABLE( mycomp );
+ NOT_SELECTABLE( devices );
+ NOT_SELECTABLE( lan );
+ NOT_SELECTABLE( internet );
+#undef NOT_SELECTABLE
/* SD subnodes */
char **ppsz_longnames;
void PLSelector::setSource( QTreeWidgetItem *item )
{
- if( !item )
+ if( !item || item == curItem )
return;
bool b_ok;
QString qs = item->data( 0, NAME_ROLE ).toString();
sd_loaded = playlist_IsServicesDiscoveryLoaded( THEPL, qtu( qs ) );
if( !sd_loaded )
- playlist_ServicesDiscoveryAdd( THEPL, qtu( qs ) );
+ {
+ if ( playlist_ServicesDiscoveryAdd( THEPL, qtu( qs ) ) != VLC_SUCCESS )
+ return ;
+
+ services_discovery_descriptor_t *p_test = new services_discovery_descriptor_t;
+ int i_ret = playlist_ServicesDiscoveryControl( THEPL, qtu( qs ), SD_CMD_DESCRIPTOR, p_test );
+ if( i_ret == VLC_SUCCESS && p_test->i_capabilities & SD_CAP_SEARCH )
+ item->setData( 0, CAP_SEARCH_ROLE, true );
+ }
}
+#ifdef MEDIA_LIBRARY
+ else if( i_type == SQL_ML_TYPE )
+ {
+ emit categoryActivated( NULL, true );
+ return;
+ }
+#endif
+
+ curItem = item;
/* */
playlist_Lock( THEPL );
playlist_item_t *pl_item = NULL;
+ /* Special case for podcast */
+ // FIXME: simplify
if( i_type == SD_TYPE )
{
/* Find the right item for the SD */
/* */
if( pl_item )
- emit activated( pl_item );
+ emit categoryActivated( pl_item, false );
}
PLSelItem * PLSelector::addItem (
return types;
}
-bool PLSelector::dropMimeData ( QTreeWidgetItem * parent, int index,
- const QMimeData * data, Qt::DropAction action )
+bool PLSelector::dropMimeData ( QTreeWidgetItem * parent, int,
+ const QMimeData * data, Qt::DropAction )
{
if( !parent ) return false;
}
}
-void PLSelector::podcastAdd( PLSelItem* item )
+void PLSelector::podcastAdd( PLSelItem * )
{
bool ok;
QString url = QInputDialog::getText( this, qtr( "Subscribe" ),
setSource( podcastsParent ); //to load the SD in case it's not loaded
- vlc_object_t *p_obj = (vlc_object_t*) vlc_object_find_name(
- p_intf->p_libvlc, "podcast", FIND_CHILD );
+ vlc_object_t *p_obj = (vlc_object_t*) vlc_object_find_name( p_intf->p_libvlc, "podcast" );
if( !p_obj ) return;
QString request("ADD:");
if( !input ) return;
vlc_object_t *p_obj = (vlc_object_t*) vlc_object_find_name(
- p_intf->p_libvlc, "podcast", FIND_CHILD );
+ p_intf->p_libvlc, "podcast" );
if( !p_obj ) return;
QString request("RM:");
QStyle::PE_IndicatorArrowRight, &option, painter );
}
-void PLSelector::getCurrentSelectedItem( int* type, QString *string)
+void PLSelector::getCurrentItemInfos( int* type, bool* can_delay_search, QString *string)
{
*type = currentItem()->data( 0, TYPE_ROLE ).toInt();
*string = currentItem()->data( 0, NAME_ROLE ).toString();
+ *can_delay_search = currentItem()->data( 0, CAP_SEARCH_ROLE ).toBool();
+}
+
+int PLSelector::getCurrentItemCategory()
+{
+ return currentItem()->data( 0, SPECIAL_ROLE ).toInt();
+}
+
+void PLSelector::wheelEvent( QWheelEvent *e )
+{
+ if( verticalScrollBar()->isVisible() && (
+ (verticalScrollBar()->value() != verticalScrollBar()->minimum() && e->delta() >= 0 ) ||
+ (verticalScrollBar()->value() != verticalScrollBar()->maximum() && e->delta() < 0 )
+ ) )
+ QApplication::sendEvent(verticalScrollBar(), e);
+
+ // Accept this event in order to prevent unwanted volume up/down changes
+ e->accept();
}