Commit 884b7e4a authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4: restore search in SD

Close #5545
(cherry picked from commit d1902eb8d655d269f342d0562d0e63c1b0ab136d)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 7dc8626c
...@@ -278,7 +278,14 @@ void PLSelector::setSource( QTreeWidgetItem *item ) ...@@ -278,7 +278,14 @@ void PLSelector::setSource( QTreeWidgetItem *item )
QString qs = item->data( 0, NAME_ROLE ).toString(); QString qs = item->data( 0, NAME_ROLE ).toString();
sd_loaded = playlist_IsServicesDiscoveryLoaded( THEPL, qtu( qs ) ); sd_loaded = playlist_IsServicesDiscoveryLoaded( THEPL, qtu( qs ) );
if( !sd_loaded ) if( !sd_loaded )
{
playlist_ServicesDiscoveryAdd( THEPL, qtu( qs ) ); 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 #ifdef MEDIA_LIBRARY
else if( i_type == SQL_ML_TYPE ) else if( i_type == SQL_ML_TYPE )
...@@ -528,10 +535,11 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM ...@@ -528,10 +535,11 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM
QStyle::PE_IndicatorArrowRight, &option, painter ); 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(); *type = currentItem()->data( 0, TYPE_ROLE ).toInt();
*string = currentItem()->data( 0, NAME_ROLE ).toString(); *string = currentItem()->data( 0, NAME_ROLE ).toString();
*can_delay_search = currentItem()->data( 0, CAP_SEARCH_ROLE ).toBool();
} }
int PLSelector::getCurrentItemCategory() int PLSelector::getCurrentItemCategory()
......
...@@ -60,7 +60,8 @@ enum { ...@@ -60,7 +60,8 @@ enum {
PL_ITEM_ROLE, //playlist_item_t* PL_ITEM_ROLE, //playlist_item_t*
PL_ITEM_ID_ROLE, //playlist_item_t->i_id PL_ITEM_ID_ROLE, //playlist_item_t->i_id
IN_ITEM_ROLE, //input_item_t->i_id IN_ITEM_ROLE, //input_item_t->i_id
SPECIAL_ROLE //SpecialData SPECIAL_ROLE, //SpecialData
CAP_SEARCH_ROLE,
}; };
enum ItemAction { enum ItemAction {
...@@ -116,7 +117,7 @@ public: ...@@ -116,7 +117,7 @@ public:
PLSelector( QWidget *p, intf_thread_t *_p_intf ); PLSelector( QWidget *p, intf_thread_t *_p_intf );
virtual ~PLSelector(); virtual ~PLSelector();
void getCurrentSelectedItem( int *type, QString *name ); void getCurrentItemInfos( int *type, bool *delayedSearch, QString *name );
int getCurrentItemCategory(); int getCurrentItemCategory();
protected: protected:
......
...@@ -151,8 +151,10 @@ void StandardPLPanel::search( const QString& searchText ) ...@@ -151,8 +151,10 @@ void StandardPLPanel::search( const QString& searchText )
{ {
int type; int type;
QString name; QString name;
p_selector->getCurrentSelectedItem( &type, &name ); bool can_search;
if( type != SD_TYPE ) p_selector->getCurrentItemInfos( &type, &can_search, &name );
if( type != SD_TYPE || !can_search )
{ {
bool flat = ( currentView == iconView || bool flat = ( currentView == iconView ||
currentView == listView || currentView == listView ||
...@@ -167,10 +169,12 @@ void StandardPLPanel::searchDelayed( const QString& searchText ) ...@@ -167,10 +169,12 @@ void StandardPLPanel::searchDelayed( const QString& searchText )
{ {
int type; int type;
QString name; 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() ) if( !name.isEmpty() && !searchText.isEmpty() )
playlist_ServicesDiscoveryControl( THEPL, qtu( name ), SD_CMD_SEARCH, playlist_ServicesDiscoveryControl( THEPL, qtu( name ), SD_CMD_SEARCH,
qtu( searchText ) ); qtu( searchText ) );
......
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