mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Separate filter from FlexibleHeader, give collections their own header.
This commit is contained in:
parent
a5f2b0eccd
commit
76044bd054
@ -62,6 +62,7 @@ set( libGuiSources
|
||||
playlist/GridItemDelegate.cpp
|
||||
playlist/GridView.cpp
|
||||
playlist/TreeView.cpp
|
||||
playlist/TreeWidget.cpp
|
||||
playlist/ViewHeader.cpp
|
||||
playlist/LovedTracksModel.cpp
|
||||
playlist/RecentlyAddedModel.cpp
|
||||
@ -117,6 +118,7 @@ set( libGuiSources
|
||||
|
||||
widgets/AnimatedCounterLabel.cpp
|
||||
widgets/BasicHeader.cpp
|
||||
widgets/FilterHeader.cpp
|
||||
widgets/Breadcrumb.cpp
|
||||
widgets/BreadcrumbButton.cpp
|
||||
widgets/CheckDirTree.cpp
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "playlist/PlayableProxyModel.h"
|
||||
#include "playlist/PlayableModel.h"
|
||||
#include "playlist/TreeView.h"
|
||||
#include "playlist/TreeWidget.h"
|
||||
#include "playlist/GridView.h"
|
||||
#include "playlist/AlbumModel.h"
|
||||
#include "SourceList.h"
|
||||
@ -92,10 +93,10 @@ ViewManager::ViewManager( QObject* parent )
|
||||
m_widget->layout()->addWidget( m_stack );
|
||||
m_widget->layout()->addWidget( m_contextWidget );
|
||||
|
||||
m_superCollectionView = new TreeView();
|
||||
m_superCollectionView->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
||||
m_superCollectionView = new TreeWidget();
|
||||
m_superCollectionView->view()->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
||||
m_superCollectionModel = new TreeModel( m_superCollectionView );
|
||||
m_superCollectionView->setTreeModel( m_superCollectionModel );
|
||||
m_superCollectionView->view()->setTreeModel( m_superCollectionModel );
|
||||
// m_superCollectionView->proxyModel()->setShowOfflineResults( false );
|
||||
|
||||
m_stack->setContentsMargins( 0, 0, 0, 0 );
|
||||
@ -270,28 +271,28 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
|
||||
{
|
||||
m_currentCollection = collection;
|
||||
|
||||
TreeView* view;
|
||||
if ( !m_treeViews.contains( collection ) || m_treeViews.value( collection ).isNull() )
|
||||
TreeWidget* widget;
|
||||
if ( !m_treeWidgets.contains( collection ) || m_treeWidgets.value( collection ).isNull() )
|
||||
{
|
||||
view = new TreeView();
|
||||
view->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
||||
widget = new TreeWidget();
|
||||
widget->view()->proxyModel()->setStyle( PlayableProxyModel::Collection );
|
||||
TreeModel* model = new TreeModel();
|
||||
view->setTreeModel( model );
|
||||
widget->view()->setTreeModel( model );
|
||||
|
||||
if ( !collection.isNull() )
|
||||
view->setEmptyTip( collection->emptyText() );
|
||||
widget->view()->setEmptyTip( collection->emptyText() );
|
||||
|
||||
model->addCollection( collection );
|
||||
|
||||
m_treeViews.insert( collection, view );
|
||||
m_treeWidgets.insert( collection, widget );
|
||||
}
|
||||
else
|
||||
{
|
||||
view = m_treeViews.value( collection ).data();
|
||||
widget = m_treeWidgets.value( collection ).data();
|
||||
}
|
||||
|
||||
setPage( view );
|
||||
return view;
|
||||
setPage( widget );
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
||||
@ -800,7 +801,7 @@ ViewManager::recentPlaysWidget() const
|
||||
}
|
||||
|
||||
|
||||
TreeView*
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::superCollectionView() const
|
||||
{
|
||||
return m_superCollectionView;
|
||||
|
@ -37,7 +37,7 @@ class AlbumModel;
|
||||
class GridView;
|
||||
class AlbumInfoWidget;
|
||||
class ArtistInfoWidget;
|
||||
class TreeView;
|
||||
class TreeWidget;
|
||||
class CollectionModel;
|
||||
class ContextWidget;
|
||||
class FlexibleView;
|
||||
@ -91,7 +91,7 @@ public:
|
||||
Tomahawk::ViewPage* whatsHotWidget() const;
|
||||
Tomahawk::ViewPage* newReleasesWidget() const;
|
||||
Tomahawk::ViewPage* recentPlaysWidget() const;
|
||||
TreeView* superCollectionView() const;
|
||||
Tomahawk::ViewPage* superCollectionView() const;
|
||||
|
||||
/// Get the view page for the given item. Not pretty...
|
||||
Tomahawk::ViewPage* pageForPlaylist( const Tomahawk::playlist_ptr& pl ) const;
|
||||
@ -175,7 +175,7 @@ private:
|
||||
AnimatedSplitter* m_splitter;
|
||||
|
||||
TreeModel* m_superCollectionModel;
|
||||
TreeView* m_superCollectionView;
|
||||
TreeWidget* m_superCollectionView;
|
||||
QueueView* m_queue;
|
||||
WelcomeWidget* m_welcomeWidget;
|
||||
WhatsHotWidget* m_whatsHotWidget;
|
||||
@ -185,7 +185,7 @@ private:
|
||||
QList< Tomahawk::collection_ptr > m_superCollections;
|
||||
|
||||
QHash< Tomahawk::dynplaylist_ptr, QPointer<Tomahawk::DynamicWidget> > m_dynamicWidgets;
|
||||
QHash< Tomahawk::collection_ptr, QPointer<TreeView> > m_treeViews;
|
||||
QHash< Tomahawk::collection_ptr, QPointer<TreeWidget> > m_treeWidgets;
|
||||
QHash< Tomahawk::artist_ptr, QPointer<ArtistInfoWidget> > m_artistViews;
|
||||
QHash< Tomahawk::album_ptr, QPointer<AlbumInfoWidget> > m_albumViews;
|
||||
QHash< Tomahawk::query_ptr, QPointer<TrackInfoWidget> > m_trackViews;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2012-2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -30,7 +30,6 @@
|
||||
|
||||
#include "playlist/FlexibleView.h"
|
||||
#include "ViewManager.h"
|
||||
#include "thirdparty/Qocoa/qsearchfield.h"
|
||||
#include "utils/Closure.h"
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
@ -41,7 +40,7 @@ using namespace Tomahawk;
|
||||
|
||||
|
||||
FlexibleHeader::FlexibleHeader( FlexibleView* parent )
|
||||
: BasicHeader( parent )
|
||||
: FilterHeader( parent )
|
||||
, m_parent( parent )
|
||||
{
|
||||
QFile f( RESPATH "stylesheets/topbar-radiobuttons.css" );
|
||||
@ -81,17 +80,9 @@ FlexibleHeader::FlexibleHeader( FlexibleView* parent )
|
||||
outerModeLayout->addWidget( modeWidget );
|
||||
outerModeLayout->addStretch();
|
||||
|
||||
m_filterField = new QSearchField( this );
|
||||
m_filterField->setPlaceholderText( tr( "Filter..." ) );
|
||||
m_filterField->setFixedWidth( 220 );
|
||||
m_mainLayout->addWidget( m_filterField );
|
||||
|
||||
TomahawkUtils::unmarginLayout( outerModeLayout );
|
||||
TomahawkUtils::unmarginLayout( modeLayout );
|
||||
|
||||
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
||||
connect( m_filterField, SIGNAL( textChanged( QString ) ), SLOT( onFilterEdited() ) );
|
||||
|
||||
NewClosure( m_radioNormal, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Flat )->setAutoDelete( false );
|
||||
NewClosure( m_radioDetailed, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Detailed )->setAutoDelete( false );
|
||||
NewClosure( m_radioCloud, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Grid )->setAutoDelete( false );
|
||||
@ -103,32 +94,6 @@ FlexibleHeader::~FlexibleHeader()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FlexibleHeader::setFilter( const QString& filter )
|
||||
{
|
||||
m_filterField->setText( filter );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FlexibleHeader::onFilterEdited()
|
||||
{
|
||||
m_filter = m_filterField->text();
|
||||
|
||||
m_filterTimer.stop();
|
||||
m_filterTimer.setInterval( 280 );
|
||||
m_filterTimer.setSingleShot( true );
|
||||
m_filterTimer.start();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FlexibleHeader::applyFilter()
|
||||
{
|
||||
emit filterTextChanged( m_filterField->text() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FlexibleHeader::changeEvent( QEvent* e )
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2012-2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,18 +20,14 @@
|
||||
#ifndef FLEXIBLEHEADER_H
|
||||
#define FLEXIBLEHEADER_H
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include "widgets/BasicHeader.h"
|
||||
#include "DllMacro.h"
|
||||
#include "widgets/FilterHeader.h"
|
||||
#include "Artist.h"
|
||||
|
||||
class QPaintEvent;
|
||||
class FlexibleView;
|
||||
class QRadioButton;
|
||||
class QSearchField;
|
||||
|
||||
class DLLEXPORT FlexibleHeader : public BasicHeader
|
||||
class DLLEXPORT FlexibleHeader : public FilterHeader
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -39,30 +35,16 @@ public:
|
||||
FlexibleHeader( FlexibleView* parent );
|
||||
~FlexibleHeader();
|
||||
|
||||
public slots:
|
||||
void setFilter( const QString& filter );
|
||||
|
||||
signals:
|
||||
void filterTextChanged( const QString& filter );
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
|
||||
private slots:
|
||||
void onFilterEdited();
|
||||
void applyFilter();
|
||||
|
||||
private:
|
||||
FlexibleView* m_parent;
|
||||
|
||||
QString m_filter;
|
||||
QTimer m_filterTimer;
|
||||
|
||||
QRadioButton* m_radioCloud;
|
||||
QRadioButton* m_radioDetailed;
|
||||
QRadioButton* m_radioNormal;
|
||||
|
||||
QSearchField* m_filterField;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -125,6 +125,13 @@ TreeProxyModel::setFilter( const QString& pattern )
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
TreeProxyModel::filter() const
|
||||
{
|
||||
return m_filter;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeProxyModel::onFilterArtists( const QList<Tomahawk::artist_ptr>& artists )
|
||||
{
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
virtual void setSourcePlayableModel( PlayableModel* ) { Q_ASSERT( false ); }
|
||||
|
||||
virtual void setFilter( const QString& pattern );
|
||||
virtual QString filter() const;
|
||||
|
||||
QModelIndex indexFromArtist( const Tomahawk::artist_ptr& artist ) const;
|
||||
QModelIndex indexFromAlbum( const Tomahawk::album_ptr& album ) const;
|
||||
|
@ -147,6 +147,7 @@ TreeView::setTreeModel( TreeModel* model )
|
||||
setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
|
||||
}
|
||||
|
||||
connect( model, SIGNAL( changed() ), this, SIGNAL( modelChanged() ) );
|
||||
emit modelChanged();
|
||||
|
||||
/* setColumnHidden( PlayableModel::Score, true ); // Hide score column per default
|
||||
@ -290,9 +291,9 @@ TreeView::onFilterChangeFinished()
|
||||
if ( selectedIndexes().count() )
|
||||
scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter );
|
||||
|
||||
if ( !filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() )
|
||||
if ( !proxyModel()->filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() )
|
||||
{
|
||||
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( filter() ) );
|
||||
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) );
|
||||
m_overlay->show();
|
||||
}
|
||||
else
|
||||
@ -394,7 +395,7 @@ TreeView::onCustomContextMenu( const QPoint& pos )
|
||||
m_contextMenu->setQueries( queries );
|
||||
m_contextMenu->setArtists( artists );
|
||||
m_contextMenu->setAlbums( albums );
|
||||
m_contextMenu->setPlaylistInterface( playlistInterface() );
|
||||
m_contextMenu->setPlaylistInterface( proxyModel()->playlistInterface() );
|
||||
|
||||
m_contextMenu->exec( viewport()->mapToGlobal( pos ) );
|
||||
}
|
||||
@ -527,12 +528,3 @@ TreeView::guid() const
|
||||
|
||||
return m_guid;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TreeView::setFilter( const QString& filter )
|
||||
{
|
||||
ViewPage::setFilter( filter );
|
||||
m_proxyModel->setFilter( filter );
|
||||
return true;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class AnimatedSpinner;
|
||||
class OverlayWidget;
|
||||
class TreeModel;
|
||||
|
||||
class DLLEXPORT TreeView : public QTreeView, public Tomahawk::ViewPage
|
||||
class DLLEXPORT TreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -63,15 +63,6 @@ public:
|
||||
|
||||
void setEmptyTip( const QString& tip );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
|
||||
|
||||
virtual QString title() const { return m_model->title(); }
|
||||
virtual QString description() const { return m_model->description(); }
|
||||
virtual QPixmap pixmap() const { return m_model->icon(); }
|
||||
|
||||
virtual bool showFilter() const { return true; }
|
||||
virtual bool setFilter( const QString& filter );
|
||||
virtual bool jumpToCurrentTrack();
|
||||
|
||||
QModelIndex hoveredIndex() const { return m_hoveredIndex; }
|
||||
|
125
src/libtomahawk/playlist/TreeWidget.cpp
Normal file
125
src/libtomahawk/playlist/TreeWidget.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "TreeWidget.h"
|
||||
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
|
||||
TreeWidget::TreeWidget( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_view( new TreeView( this ) )
|
||||
, m_header( new FilterHeader( this ) )
|
||||
{
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget( m_header );
|
||||
mainLayout->addWidget( m_view );
|
||||
setLayout( mainLayout );
|
||||
TomahawkUtils::unmarginLayout( mainLayout );
|
||||
|
||||
connect( m_header, SIGNAL( filterTextChanged( QString ) ),
|
||||
this, SLOT( setFilter( QString ) ) );
|
||||
connect( m_view, SIGNAL( modelChanged() ),
|
||||
this, SLOT( onModelChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
TreeWidget::~TreeWidget()
|
||||
{}
|
||||
|
||||
|
||||
TreeView*
|
||||
TreeWidget::view() const
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
|
||||
|
||||
QWidget*
|
||||
TreeWidget::widget()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
TreeWidget::playlistInterface() const
|
||||
{
|
||||
return m_view->proxyModel()->playlistInterface();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
TreeWidget::title() const
|
||||
{
|
||||
return m_view->model()->title();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
TreeWidget::description() const
|
||||
{
|
||||
return m_view->model()->description();
|
||||
}
|
||||
|
||||
|
||||
QPixmap
|
||||
TreeWidget::pixmap() const
|
||||
{
|
||||
return m_view->model()->icon();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TreeWidget::showFilter() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TreeWidget::setFilter( const QString& filter )
|
||||
{
|
||||
ViewPage::setFilter( filter );
|
||||
m_view->proxyModel()->setFilter( filter );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeWidget::onModelChanged()
|
||||
{
|
||||
m_header->setCaption( m_view->model()->title() );
|
||||
m_header->setDescription( m_view->model()->description() );
|
||||
m_header->setPixmap( m_view->model()->icon() );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TreeWidget::jumpToCurrentTrack()
|
||||
{
|
||||
return m_view->jumpToCurrentTrack();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TreeWidget::showInfoBar() const
|
||||
{
|
||||
return false;
|
||||
}
|
60
src/libtomahawk/playlist/TreeWidget.h
Normal file
60
src/libtomahawk/playlist/TreeWidget.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TREEWIDGET_H
|
||||
#define TREEWIDGET_H
|
||||
|
||||
#include "TreeView.h"
|
||||
#include "ViewPage.h"
|
||||
#include "widgets/FilterHeader.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class DLLEXPORT TreeWidget : public QWidget, public Tomahawk::ViewPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TreeWidget( QWidget* parent = 0 );
|
||||
virtual ~TreeWidget();
|
||||
|
||||
TreeView* view() const;
|
||||
|
||||
virtual QWidget* widget();
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
|
||||
|
||||
virtual QString title() const;
|
||||
virtual QString description() const;
|
||||
virtual QPixmap pixmap() const;
|
||||
|
||||
virtual bool showFilter() const;
|
||||
virtual bool jumpToCurrentTrack();
|
||||
|
||||
virtual bool showInfoBar() const;
|
||||
|
||||
public slots:
|
||||
virtual bool setFilter( const QString& filter );
|
||||
|
||||
private slots:
|
||||
void onModelChanged();
|
||||
|
||||
private:
|
||||
TreeView* m_view;
|
||||
BasicHeader* m_header;
|
||||
};
|
||||
|
||||
#endif // TREEWIDGET_H
|
@ -31,8 +31,6 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
QPixmap* BasicHeader::s_tiledHeader = 0;
|
||||
|
||||
|
||||
BasicHeader::BasicHeader( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
@ -55,6 +53,7 @@ BasicHeader::BasicHeader( QWidget* parent )
|
||||
m_verticalLayout->addStretch();
|
||||
|
||||
m_mainLayout->addSpacing( 16 );
|
||||
m_mainLayout->setStretchFactor( m_verticalLayout, 2 );
|
||||
|
||||
QPalette pal = palette();
|
||||
pal.setColor( QPalette::Foreground, Qt::white );
|
||||
|
@ -50,8 +50,6 @@ protected:
|
||||
|
||||
QBoxLayout* m_mainLayout;
|
||||
QBoxLayout* m_verticalLayout;
|
||||
|
||||
static QPixmap* s_tiledHeader;
|
||||
};
|
||||
|
||||
#endif // BASICHEADER_H
|
||||
|
66
src/libtomahawk/widgets/FilterHeader.cpp
Normal file
66
src/libtomahawk/widgets/FilterHeader.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "FilterHeader.h"
|
||||
|
||||
#include "thirdparty/Qocoa/qsearchfield.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
|
||||
FilterHeader::FilterHeader( QWidget* parent )
|
||||
: BasicHeader( parent )
|
||||
{
|
||||
m_filterField = new QSearchField( this );
|
||||
m_filterField->setPlaceholderText( tr( "Filter..." ) );
|
||||
m_filterField->setFixedWidth( 220 );
|
||||
m_mainLayout->addWidget( m_filterField );
|
||||
|
||||
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
||||
connect( m_filterField, SIGNAL( textChanged( QString ) ), SLOT( onFilterEdited() ) );
|
||||
}
|
||||
|
||||
|
||||
FilterHeader::~FilterHeader()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilterHeader::setFilter( const QString& filter )
|
||||
{
|
||||
m_filterField->setText( filter );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilterHeader::onFilterEdited()
|
||||
{
|
||||
m_filter = m_filterField->text();
|
||||
|
||||
m_filterTimer.stop();
|
||||
m_filterTimer.setInterval( 280 );
|
||||
m_filterTimer.setSingleShot( true );
|
||||
m_filterTimer.start();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilterHeader::applyFilter()
|
||||
{
|
||||
emit filterTextChanged( m_filterField->text() );
|
||||
}
|
54
src/libtomahawk/widgets/FilterHeader.h
Normal file
54
src/libtomahawk/widgets/FilterHeader.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FILTERHEADER_H
|
||||
#define FILTERHEADER_H
|
||||
|
||||
#include "widgets/BasicHeader.h"
|
||||
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
class QSearchField;
|
||||
|
||||
class DLLEXPORT FilterHeader : public BasicHeader
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FilterHeader( QWidget *parent = 0 );
|
||||
virtual ~FilterHeader();
|
||||
|
||||
public slots:
|
||||
void setFilter( const QString& filter );
|
||||
|
||||
signals:
|
||||
void filterTextChanged( const QString& filter );
|
||||
|
||||
private slots:
|
||||
void onFilterEdited();
|
||||
void applyFilter();
|
||||
|
||||
private:
|
||||
QString m_filter;
|
||||
QTimer m_filterTimer;
|
||||
|
||||
QSearchField* m_filterField;
|
||||
};
|
||||
|
||||
#endif // FILTERHEADER_H
|
@ -107,7 +107,7 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
|
||||
|
||||
MetaPlaylistInterface* mpl = new MetaPlaylistInterface();
|
||||
mpl->addChildInterface( ui->tracksViewLeft->playlistInterface() );
|
||||
mpl->addChildInterface( ui->artistsViewLeft->playlistInterface() );
|
||||
mpl->addChildInterface( ui->artistsViewLeft->proxyModel()->playlistInterface() );
|
||||
mpl->addChildInterface( ui->albumsView->playlistInterface() );
|
||||
m_playlistInterface = playlistinterface_ptr( mpl );
|
||||
}
|
||||
@ -138,7 +138,7 @@ WhatsHotWidget::playlistInterface() const
|
||||
bool
|
||||
WhatsHotWidget::isBeingPlayed() const
|
||||
{
|
||||
if ( AudioEngine::instance()->currentTrackPlaylist() == ui->artistsViewLeft->playlistInterface() )
|
||||
if ( AudioEngine::instance()->currentTrackPlaylist() == ui->artistsViewLeft->proxyModel()->playlistInterface() )
|
||||
return true;
|
||||
|
||||
if ( AudioEngine::instance()->currentTrackPlaylist() == ui->tracksViewLeft->playlistInterface() )
|
||||
|
Loading…
x
Reference in New Issue
Block a user