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 )
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 */
DCONNECT( selector, activated( playlist_item_t * ),
......
......@@ -887,7 +887,7 @@ void PLModel::search( const QString& search_text, const QModelIndex & idx, bool
endRemoveRows( );
beginInsertRows( idx, 0, searchRoot->children.size() - 1 );
updateChildren( searchRoot );
updateChildren( searchRoot ); // The PL_LOCK is needed here
endInsertRows();
PL_UNLOCK;
......
......@@ -500,3 +500,9 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM
QStyle::PE_IndicatorArrowDown :
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
public:
PLSelector( QWidget *p, intf_thread_t *_p_intf );
virtual ~PLSelector();
void getCurrentSelectedItem( int *type, QString *name );
protected:
friend class PlaylistWidget;
......
......@@ -31,6 +31,7 @@
#include "components/playlist/playlist_model.hpp"
#include "components/playlist/standardpanel.hpp"
#include "components/playlist/icon_view.hpp"
#include "components/playlist/selector.hpp"
#include "util/customwidgets.hpp"
#include "menus.hpp"
......@@ -60,8 +61,10 @@ static const QString viewNames[] = { qtr( "Detailed View" ),
StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
intf_thread_t *_p_intf,
playlist_t *p_playlist,
playlist_item_t *p_root ):
QWidget( _parent ), p_intf( _p_intf )
playlist_item_t *p_root,
PLSelector *_p_selector ):
QWidget( _parent ), p_intf( _p_intf ),
p_selector( _p_selector )
{
layout = new QGridLayout( this );
layout->setSpacing( 0 ); layout->setMargin( 0 );
......@@ -208,10 +211,21 @@ void StandardPLPanel::toggleColumnShown( int i )
/* Search in the playlist */
void StandardPLPanel::search( const QString& searchText )
{
int type;
QString name;
p_selector->getCurrentSelectedItem( &type, &name );
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 */
......
......@@ -56,7 +56,7 @@ class StandardPLPanel: public QWidget
public:
StandardPLPanel( PlaylistWidget *, intf_thread_t *,
playlist_t *,playlist_item_t * );
playlist_t *, playlist_item_t *, PLSelector * );
virtual ~StandardPLPanel();
protected:
friend class PlaylistWidget;
......@@ -78,6 +78,7 @@ private:
QGridLayout *layout;
LocationBar *locationBar;
SearchLineEdit *searchEdit;
PLSelector *p_selector;
QTreeView *treeView;
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