From d1902eb8d655d269f342d0562d0e63c1b0ab136d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf <jb@videolan.org> Date: Wed, 11 Jan 2012 18:42:09 +0100 Subject: [PATCH] Qt4: restore search in SD Close #5545 --- modules/gui/qt4/components/playlist/selector.cpp | 10 +++++++++- modules/gui/qt4/components/playlist/selector.hpp | 5 +++-- .../gui/qt4/components/playlist/standardpanel.cpp | 12 ++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/modules/gui/qt4/components/playlist/selector.cpp b/modules/gui/qt4/components/playlist/selector.cpp index 820c69f928a3..bef865ad43d2 100644 --- a/modules/gui/qt4/components/playlist/selector.cpp +++ b/modules/gui/qt4/components/playlist/selector.cpp @@ -278,7 +278,14 @@ void PLSelector::setSource( QTreeWidgetItem *item ) QString qs = item->data( 0, NAME_ROLE ).toString(); sd_loaded = playlist_IsServicesDiscoveryLoaded( THEPL, qtu( qs ) ); if( !sd_loaded ) + { playlist_ServicesDiscoveryAdd( THEPL, qtu( qs ) ); + + services_discovery_descriptor_t *p_test = new services_discovery_descriptor_t; + playlist_ServicesDiscoveryControl( THEPL, qtu( qs ), SD_CMD_DESCRIPTOR, p_test ); + if( p_test->i_capabilities & SD_CAP_SEARCH ) + item->setData( 0, CAP_SEARCH_ROLE, true ); + } } #ifdef MEDIA_LIBRARY else if( i_type == SQL_ML_TYPE ) @@ -528,10 +535,11 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM 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() diff --git a/modules/gui/qt4/components/playlist/selector.hpp b/modules/gui/qt4/components/playlist/selector.hpp index 21d29773889a..68db8103bd87 100644 --- a/modules/gui/qt4/components/playlist/selector.hpp +++ b/modules/gui/qt4/components/playlist/selector.hpp @@ -60,7 +60,8 @@ enum { PL_ITEM_ROLE, //playlist_item_t* PL_ITEM_ID_ROLE, //playlist_item_t->i_id IN_ITEM_ROLE, //input_item_t->i_id - SPECIAL_ROLE //SpecialData + SPECIAL_ROLE, //SpecialData + CAP_SEARCH_ROLE, }; enum ItemAction { @@ -116,7 +117,7 @@ public: PLSelector( QWidget *p, intf_thread_t *_p_intf ); virtual ~PLSelector(); - void getCurrentSelectedItem( int *type, QString *name ); + void getCurrentItemInfos( int *type, bool *delayedSearch, QString *name ); int getCurrentItemCategory(); protected: diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index 979049fffd16..db7f78043bc5 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -151,8 +151,10 @@ void StandardPLPanel::search( const QString& searchText ) { int type; QString name; - p_selector->getCurrentSelectedItem( &type, &name ); - if( type != SD_TYPE ) + bool can_search; + p_selector->getCurrentItemInfos( &type, &can_search, &name ); + + if( type != SD_TYPE || !can_search ) { bool flat = ( currentView == iconView || currentView == listView || @@ -167,10 +169,12 @@ void StandardPLPanel::searchDelayed( const QString& searchText ) { int type; QString name; - p_selector->getCurrentSelectedItem( &type, &name ); + bool can_search; + p_selector->getCurrentItemInfos( &type, &can_search, &name ); - if( type == SD_TYPE ) + if( type == SD_TYPE && can_search ) { + msg_Err( p_intf, "SEARCHING DELAYED"); if( !name.isEmpty() && !searchText.isEmpty() ) playlist_ServicesDiscoveryControl( THEPL, qtu( name ), SD_CMD_SEARCH, qtu( searchText ) ); -- GitLab