Commit 7310bac2 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: search the SD if possible.

parent 40b4d780
...@@ -93,7 +93,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par ) ...@@ -93,7 +93,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
PL_UNLOCK; PL_UNLOCK;
rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root ); rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root, selector );
/* Connect the activation of the selector to a redefining of the PL */ /* Connect the activation of the selector to a redefining of the PL */
DCONNECT( selector, activated( playlist_item_t * ), DCONNECT( selector, activated( playlist_item_t * ),
......
...@@ -887,7 +887,7 @@ void PLModel::search( const QString& search_text, const QModelIndex & idx, bool ...@@ -887,7 +887,7 @@ void PLModel::search( const QString& search_text, const QModelIndex & idx, bool
endRemoveRows( ); endRemoveRows( );
beginInsertRows( idx, 0, searchRoot->children.size() - 1 ); beginInsertRows( idx, 0, searchRoot->children.size() - 1 );
updateChildren( searchRoot ); updateChildren( searchRoot ); // The PL_LOCK is needed here
endInsertRows(); endInsertRows();
PL_UNLOCK; PL_UNLOCK;
......
...@@ -500,3 +500,9 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM ...@@ -500,3 +500,9 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM
QStyle::PE_IndicatorArrowDown : QStyle::PE_IndicatorArrowDown :
QStyle::PE_IndicatorArrowRight, &option, painter ); QStyle::PE_IndicatorArrowRight, &option, painter );
} }
void PLSelector::getCurrentSelectedItem( int* type, QString *string)
{
*type = currentItem()->data( 0, TYPE_ROLE ).toInt();
*string = currentItem()->data( 0, NAME_ROLE ).toString();
}
...@@ -114,6 +114,8 @@ class PLSelector: public QTreeWidget ...@@ -114,6 +114,8 @@ class PLSelector: public QTreeWidget
public: 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 );
protected: protected:
friend class PlaylistWidget; friend class PlaylistWidget;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "components/playlist/playlist_model.hpp" #include "components/playlist/playlist_model.hpp"
#include "components/playlist/standardpanel.hpp" #include "components/playlist/standardpanel.hpp"
#include "components/playlist/icon_view.hpp" #include "components/playlist/icon_view.hpp"
#include "components/playlist/selector.hpp"
#include "util/customwidgets.hpp" #include "util/customwidgets.hpp"
#include "menus.hpp" #include "menus.hpp"
...@@ -60,8 +61,10 @@ static const QString viewNames[] = { qtr( "Detailed View" ), ...@@ -60,8 +61,10 @@ static const QString viewNames[] = { qtr( "Detailed View" ),
StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
intf_thread_t *_p_intf, intf_thread_t *_p_intf,
playlist_t *p_playlist, playlist_t *p_playlist,
playlist_item_t *p_root ): playlist_item_t *p_root,
QWidget( _parent ), p_intf( _p_intf ) PLSelector *_p_selector ):
QWidget( _parent ), p_intf( _p_intf ),
p_selector( _p_selector )
{ {
layout = new QGridLayout( this ); layout = new QGridLayout( this );
layout->setSpacing( 0 ); layout->setMargin( 0 ); layout->setSpacing( 0 ); layout->setMargin( 0 );
...@@ -208,10 +211,21 @@ void StandardPLPanel::toggleColumnShown( int i ) ...@@ -208,10 +211,21 @@ void StandardPLPanel::toggleColumnShown( int i )
/* Search in the playlist */ /* Search in the playlist */
void StandardPLPanel::search( const QString& searchText ) void StandardPLPanel::search( const QString& searchText )
{ {
bool flat = currentView == iconView || currentView == listView; int type;
model->search( searchText, QString name;
flat ? currentView->rootIndex() : QModelIndex(), p_selector->getCurrentSelectedItem( &type, &name );
!flat ); if( type != SD_TYPE )
{
bool flat = currentView == iconView || currentView == listView;
model->search( searchText,
flat ? currentView->rootIndex() : QModelIndex(),
!flat );
}
else
{
if( !name.isEmpty() )
playlist_QueryServicesDiscovery( THEPL, qtu(name), qtu(searchText) );
}
} }
/* Set the root of the new Playlist */ /* Set the root of the new Playlist */
......
...@@ -56,7 +56,7 @@ class StandardPLPanel: public QWidget ...@@ -56,7 +56,7 @@ class StandardPLPanel: public QWidget
public: public:
StandardPLPanel( PlaylistWidget *, intf_thread_t *, StandardPLPanel( PlaylistWidget *, intf_thread_t *,
playlist_t *,playlist_item_t * ); playlist_t *, playlist_item_t *, PLSelector * );
virtual ~StandardPLPanel(); virtual ~StandardPLPanel();
protected: protected:
friend class PlaylistWidget; friend class PlaylistWidget;
...@@ -78,6 +78,7 @@ private: ...@@ -78,6 +78,7 @@ private:
QGridLayout *layout; QGridLayout *layout;
LocationBar *locationBar; LocationBar *locationBar;
SearchLineEdit *searchEdit; SearchLineEdit *searchEdit;
PLSelector *p_selector;
QTreeView *treeView; QTreeView *treeView;
PlIconView *iconView; PlIconView *iconView;
......
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