1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-21 00:12:06 +02:00

Always use C++11 std::function

Conflicts:
	src/libtomahawk/ViewManager.h
	src/tomahawk/sourcetree/SourcesModel.cpp
This commit is contained in:
Uwe L. Korn 2014-09-17 21:50:36 +01:00
parent 2c1cf4719f
commit 0903c6e41f
23 changed files with 117 additions and 116 deletions

View File

@ -240,8 +240,10 @@ Api_v1::sid( QxtWebRequestEvent* event, QString unused )
return send404( event );
}
function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
bind( &Api_v1::processSid, this, event, rp, _1, _2 );
std::function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
std::bind( &Api_v1::processSid, this, event, rp,
std::placeholders::_1,
std::placeholders::_2 );
Tomahawk::UrlHandler::getIODeviceForUrl( rp, rp->url(), callback );
}

View File

@ -25,7 +25,7 @@
using namespace Tomahawk;
FuncTimeout::FuncTimeout( int ms, function< void() > func, QObject* besafe )
FuncTimeout::FuncTimeout( int ms, std::function< void() > func, QObject* besafe )
: m_func( func )
, m_watch( QPointer< QObject >( besafe ) )
{

View File

@ -19,11 +19,11 @@
#ifndef FUNCTIMEOUT_H
#define FUNCTIMEOUT_H
#include <functional>
#include <QObject>
#include <QPointer>
#include "utils/tr1-functional.h"
#include "DllMacro.h"
/*
@ -41,7 +41,7 @@ class DLLEXPORT FuncTimeout : public QObject
Q_OBJECT
public:
FuncTimeout( int ms, function<void()> func, QObject* besafe );
FuncTimeout( int ms, std::function<void()> func, QObject* besafe );
~FuncTimeout();
@ -49,7 +49,7 @@ public slots:
void exec();
private:
function<void()> m_func;
std::function<void()> m_func;
QPointer< QObject > m_watch;
};

View File

@ -564,7 +564,7 @@ Pipeline::shunt( const query_ptr& q )
if ( r->timeout() > 0 )
{
d->qidsTimeout.insert( q->id(), true );
new FuncTimeout( r->timeout(), bind( &Pipeline::timeoutShunt, this, q ), this );
new FuncTimeout( r->timeout(), std::bind( &Pipeline::timeoutShunt, this, q ), this );
}
}
else
@ -616,7 +616,7 @@ Pipeline::setQIDState( const Tomahawk::query_ptr& query, int state )
{
d->qidsState.insert( query->id(), state );
new FuncTimeout( 0, bind( &Pipeline::shunt, this, query ), this );
new FuncTimeout( 0, std::bind( &Pipeline::shunt, this, query ), this );
}
else
{
@ -626,7 +626,7 @@ Pipeline::setQIDState( const Tomahawk::query_ptr& query, int state )
if ( !d->queries_temporary.contains( query ) )
d->qids.remove( query->id() );
new FuncTimeout( 0, bind( &Pipeline::shuntNext, this ), this );
new FuncTimeout( 0, std::bind( &Pipeline::shuntNext, this ), this );
}
}

View File

@ -24,19 +24,20 @@
#include "DllMacro.h"
#include "Typedefs.h"
#include "Query.h"
#include "utils/tr1-functional.h"
#include <QObject>
#include <QList>
#include <QStringList>
#include <functional>
namespace Tomahawk
{
class PipelinePrivate;
class Resolver;
class ExternalResolver;
typedef function<Tomahawk::ExternalResolver*( QString, QString, QStringList )> ResolverFactoryFunc;
typedef std::function<Tomahawk::ExternalResolver*( QString, QString, QStringList )> ResolverFactoryFunc;
class DLLEXPORT Pipeline : public QObject
{

View File

@ -40,12 +40,18 @@ initialiseDefaultIOFactories()
{
{
// _1 = result, _2 = callback function for IODevice
IODeviceFactoryFunc fac = bind( localFileIODeviceFactory, _1, _2, _3 );
IODeviceFactoryFunc fac = std::bind( localFileIODeviceFactory,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3 );
iofactories.insert( "file", fac );
}
{
IODeviceFactoryFunc fac = bind( httpIODeviceFactory, _1, _2, _3 );
IODeviceFactoryFunc fac = std::bind( httpIODeviceFactory,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3 );
iofactories.insert( "http", fac );
iofactories.insert( "https", fac );
}
@ -66,7 +72,7 @@ registerIODeviceFactory( const QString &proto, IODeviceFactoryFunc fac )
void
getIODeviceForUrl( const Tomahawk::result_ptr& result, const QString& url,
function< void ( const QString, QSharedPointer< QIODevice > ) > callback )
std::function< void ( const QString, QSharedPointer< QIODevice > ) > callback )
{
if ( iofactories.isEmpty() )
{
@ -96,7 +102,7 @@ getIODeviceForUrl( const Tomahawk::result_ptr& result, const QString& url,
void
localFileIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
IODeviceCallback callback )
{
// ignore "file://" at front of url
QFile* io = new QFile( url.mid( QString( "file://" ).length() ) );
@ -111,7 +117,7 @@ localFileIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
void
httpIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
IODeviceCallback callback )
{
QNetworkRequest req( url );
// Follow HTTP Redirects
@ -125,7 +131,8 @@ httpIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
void
getUrlTranslation( const Tomahawk::result_ptr& result, const QString& url, function< void ( const QString& ) > callback )
getUrlTranslation( const Tomahawk::result_ptr& result, const QString& url,
std::function< void ( const QString& ) > callback )
{
QRegExp rx( "^([a-zA-Z0-9]+)://(.+)$" );
if ( rx.indexIn( url ) == -1 )

View File

@ -24,13 +24,14 @@
#include "DllMacro.h"
#include "Typedefs.h"
#include "utils/tr1-functional.h"
typedef function< void( const Tomahawk::result_ptr&, const QString&,
function< void( const QString&, QSharedPointer< QIODevice >& ) > )> IODeviceFactoryFunc;
typedef function< void( const Tomahawk::result_ptr&, const QString&,
function< void( const QString& ) > )> UrlTranslatorFunc;
typedef function< void ( const QString&, QSharedPointer< QIODevice >& ) > IODeviceCallback;
#include <functional>
typedef std::function< void( const Tomahawk::result_ptr&, const QString&,
std::function< void( const QString&, QSharedPointer< QIODevice >& ) > )> IODeviceFactoryFunc;
typedef std::function< void( const Tomahawk::result_ptr&, const QString&,
std::function< void( const QString& ) > )> UrlTranslatorFunc;
typedef std::function< void ( const QString&, QSharedPointer< QIODevice >& ) > IODeviceCallback;
namespace Tomahawk
@ -40,12 +41,12 @@ namespace UrlHandler
{
DLLEXPORT void getIODeviceForUrl( const Tomahawk::result_ptr&, const QString& url,
function< void ( const QString, QSharedPointer< QIODevice > ) > callback );
std::function< void ( const QString, QSharedPointer< QIODevice > ) > callback );
DLLEXPORT void registerIODeviceFactory( const QString& proto, IODeviceFactoryFunc fac );
DLLEXPORT void localFileIODeviceFactory( const Tomahawk::result_ptr& result, const QString& url,
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
std::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
DLLEXPORT void httpIODeviceFactory( const Tomahawk::result_ptr& result, const QString& url,
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
std::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
} // namespace UrlHandler
} // namespace Tomahawk

View File

@ -26,7 +26,6 @@
#include "collection/Collection.h"
#include "PlaylistInterface.h"
#include "playlist/QueueView.h"
#include "utils/tr1-functional.h"
#include <QObject>
#include <QHash>
@ -34,6 +33,8 @@
#include "DllMacro.h"
#include <functional>
class AlbumModel;
class GridView;
class AlbumInfoWidget;
@ -159,7 +160,7 @@ private:
QHash< QString, Tomahawk::ViewPage* > m_dynamicPages;
QHash< QString, QPointer< Tomahawk::ViewPagePlugin > > m_dynamicPagePlugins;
QHash< QString, function< Tomahawk::ViewPage*() > > m_dynamicPagesInstanceLoaders;
QHash< QString, std::function< Tomahawk::ViewPage*() > > m_dynamicPagesInstanceLoaders;
QHash< Tomahawk::dynplaylist_ptr, QPointer<Tomahawk::DynamicWidget> > m_dynamicWidgets;
QHash< Tomahawk::collection_ptr, QPointer<FlexibleTreeView> > m_collectionViews;

View File

@ -365,7 +365,10 @@ LastFmConfig::syncLoved()
foreach ( const Tomahawk::track_ptr& lastfmLoved, m_lastfmLoved )
{
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if( myLoved.begin(), myLoved.end(), bind( &trackEquality, _1, lastfmLoved ) );
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if(
myLoved.begin(), myLoved.end(),
std::bind( &trackEquality, std::placeholders::_1,
lastfmLoved ) );
if ( iter == myLoved.constEnd() )
{
// qDebug() << "Found last.fm loved track that we didn't have loved locally:" << lastfmLoved->track() << lastfmLoved->artist();
@ -376,7 +379,10 @@ LastFmConfig::syncLoved()
foreach ( const Tomahawk::track_ptr& localLoved, myLoved )
{
qDebug() << "CHECKING FOR LOCAL LOVED ON LAST.FM TOO:" << m_localLoved[ localLoved ].value.toString() << localLoved->track() << localLoved->artist();
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if( m_lastfmLoved.begin(), m_lastfmLoved.end(), bind( &trackEquality, _1, localLoved ) );
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if(
m_lastfmLoved.begin(), m_lastfmLoved.end(),
std::bind( &trackEquality, std::placeholders::_1,
localLoved ) );
qDebug() << "Result:" << (iter == m_lastfmLoved.constEnd());
// If we unloved it locally, but it's still loved on last.fm, unlove it

View File

@ -709,8 +709,10 @@ AudioEngine::performLoadIODevice( const result_ptr& result, const QString& url )
if ( !TomahawkUtils::isLocalResult( url ) && !TomahawkUtils::isHttpResult( url )
&& !TomahawkUtils::isRtmpResult( url ) )
{
function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
bind( &AudioEngine::performLoadTrack, this, result, _1, _2 );
std::function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
std::bind( &AudioEngine::performLoadTrack, this, result,
std::placeholders::_1,
std::placeholders::_2 );
Tomahawk::UrlHandler::getIODeviceForUrl( result, url, callback );
}
else

View File

@ -87,7 +87,10 @@ Servent::Servent( QObject* parent )
setProxy( QNetworkProxy::NoProxy );
IODeviceFactoryFunc fac = bind( &Servent::remoteIODeviceFactory, this, _1, _2, _3 );
IODeviceFactoryFunc fac = std::bind( &Servent::remoteIODeviceFactory, this,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3 );
Tomahawk::UrlHandler::registerIODeviceFactory( "servent", fac );
}
@ -1243,7 +1246,7 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
void
Servent::remoteIODeviceFactory( const Tomahawk::result_ptr& result, const QString& url,
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
std::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
{
QSharedPointer<QIODevice> sp;

View File

@ -29,11 +29,12 @@
#include "DllMacro.h"
#include "Typedefs.h"
#include "utils/tr1-functional.h"
#include <QHostAddress>
#include <QTcpServer>
#include <functional>
class Connection;
class Connector;
class ControlConnection;
@ -91,7 +92,7 @@ public:
ControlConnection* lookupControlConnection( const QString& nodeid );
void remoteIODeviceFactory( const Tomahawk::result_ptr& result, const QString& url,
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
std::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
// you may call this method as often as you like for the same peerInfo, dupe checking is done inside
void registerPeer( const Tomahawk::peerinfo_ptr& peerInfo );

View File

@ -185,8 +185,9 @@ StreamConnection::startSending( const Tomahawk::result_ptr& result )
m_result = result;
qDebug() << "Starting to transmit" << m_result->url();
function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
bind( &StreamConnection::reallyStartSending, this, result, _1, _2 );
std::function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
std::bind( &StreamConnection::reallyStartSending, this, result,
std::placeholders::_1, std::placeholders::_2 );
Tomahawk::UrlHandler::getIODeviceForUrl( m_result, m_result->url(), callback );
}

View File

@ -442,9 +442,11 @@ JSResolverHelper::addCustomUrlHandler( const QString& protocol,
{
m_urlCallbackIsAsync = ( isAsynchronous.toLower() == "true" ) ? true : false;
function< void( const Tomahawk::result_ptr&, const QString&,
function< void( const QString&, QSharedPointer< QIODevice >& ) > )> fac =
bind( &JSResolverHelper::customIODeviceFactory, this, _1, _2, _3 );
std::function< void( const Tomahawk::result_ptr&, const QString&,
std::function< void( const QString&, QSharedPointer< QIODevice >& ) > )> fac =
std::bind( &JSResolverHelper::customIODeviceFactory, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3 );
Tomahawk::UrlHandler::registerIODeviceFactory( protocol, fac );
m_urlCallback = callbackFuncName;
@ -460,7 +462,7 @@ JSResolverHelper::reportStreamUrl( const QString& qid, const QString& streamUrl
void
JSResolverHelper::customIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
std::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
{
//can be sync or async
if ( m_urlCallbackIsAsync )
@ -492,7 +494,7 @@ JSResolverHelper::reportStreamUrl( const QString& qid,
if ( !m_streamCallbacks.contains( qid ) )
return;
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback = m_streamCallbacks.take( qid );
std::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback = m_streamCallbacks.take( qid );
QMap<QString, QString> parsedHeaders;
foreach ( const QString& key, headers.keys()) {
@ -872,7 +874,7 @@ JSResolverHelper::deleteFuzzyIndex()
void
JSResolverHelper::returnStreamUrl( const QString& streamUrl, const QMap<QString, QString>& headers,
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
std::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
{
if ( streamUrl.isEmpty() || !( TomahawkUtils::isHttpResult( streamUrl ) || TomahawkUtils::isHttpsResult( streamUrl ) ) )
{
@ -898,7 +900,7 @@ JSResolverHelper::returnStreamUrl( const QString& streamUrl, const QMap<QString,
Q_DECLARE_METATYPE( IODeviceCallback )
void
JSResolverHelper::gotStreamUrl( function< void( const QString&, QSharedPointer< QIODevice >& ) > callback, NetworkReply* reply )
JSResolverHelper::gotStreamUrl( std::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback, NetworkReply* reply )
{
// std::functions cannot accept temporaries as parameters
QSharedPointer< QIODevice > sp = QSharedPointer< QIODevice >( reply->reply(), &QObject::deleteLater );

View File

@ -27,14 +27,15 @@
#include "UrlHandler.h"
#include "database/fuzzyindex/FuzzyIndex.h"
#include "utils/NetworkReply.h"
#include "utils/tr1-functional.h"
#include <QObject>
#include <QVariantMap>
#include <functional>
class JSResolver;
Q_DECLARE_METATYPE( function< void( QSharedPointer< QIODevice >& ) > )
Q_DECLARE_METATYPE( std::function< void( QSharedPointer< QIODevice >& ) > )
class DLLEXPORT JSResolverHelper : public QObject
{
@ -108,7 +109,7 @@ public:
* INTERNAL USE ONLY!
*/
void customIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback ); // async
std::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback ); // async
public slots:
QByteArray readRaw( const QString& fileName );
@ -141,7 +142,7 @@ private slots:
private:
Tomahawk::query_ptr parseTrack( const QVariantMap& track );
void returnStreamUrl( const QString& streamUrl, const QMap<QString, QString>& headers,
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback );
std::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback );
bool indexDataFromVariant( const QVariantMap& map, struct Tomahawk::IndexData& indexData );
QVariantList searchInFuzzyIndex( const Tomahawk::query_ptr& query );
@ -149,8 +150,8 @@ private:
QVariantMap m_resolverConfig;
JSResolver* m_resolver;
QString m_scriptPath, m_urlCallback, m_urlTranslator;
QHash< QString, function< void( const QString&, QSharedPointer< QIODevice >& ) > > m_streamCallbacks;
QHash< QString, function< void( const QString& ) > > m_translatorCallbacks;
QHash< QString, std::function< void( const QString&, QSharedPointer< QIODevice >& ) > > m_streamCallbacks;
QHash< QString, std::function< void( const QString& ) > > m_translatorCallbacks;
bool m_urlCallbackIsAsync;
QString m_pendingUrl;
Tomahawk::album_ptr m_pendingAlbum;

View File

@ -54,7 +54,7 @@ Closure::Closure(QObject* sender,
Closure::Closure(QObject* sender,
const char* signal,
function<void()> callback)
std::function<void()> callback)
: callback_(callback) {
Connect(sender, signal);
}

View File

@ -23,13 +23,14 @@
#include "config.h"
#include "DllMacro.h"
#include "utils/tr1-functional.h"
#include <QMetaMethod>
#include <QObject>
#include <QPointer>
#include <QSharedPointer>
#include <functional>
namespace _detail {
class DLLEXPORT ClosureArgumentWrapper {
@ -64,7 +65,7 @@ class DLLEXPORT Closure : public QObject {
const ClosureArgumentWrapper* val3 = 0);
Closure(QObject* sender, const char* signal,
function<void()> callback);
std::function<void()> callback);
void setAutoDelete( bool autoDelete ) { autoDelete_ = autoDelete; }
@ -89,7 +90,7 @@ class DLLEXPORT Closure : public QObject {
void Connect(QObject* sender, const char* signal);
QMetaMethod slot_;
function<void()> callback_;
std::function<void()> callback_;
bool autoDelete_;
QPointer<QObject> outOfThreadReceiver_;

View File

@ -1,42 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2014, Uwe L. Korn <uwelk@xhochy.com>
*
* 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 TOMAHAWK_TR1_FUNCTIONAL
#define TOMAHAWK_TR1_FUNCTIONAL
#include "config.h"
#if defined(_WEBSOCKETPP_CPP11_STL_) || defined(CXX_STD_FUNCTIONAL)
#include <functional>
using std::function;
using std::bind;
using std::placeholders::_1;
using std::placeholders::_2;
using std::placeholders::_3;
using std::placeholders::_4;
#else
#include <tr1/functional>
using std::tr1::function;
using std::tr1::bind;
using std::tr1::placeholders::_1;
using std::tr1::placeholders::_2;
using std::tr1::placeholders::_3;
using std::tr1::placeholders::_4;
#endif
#endif

View File

@ -224,8 +224,12 @@ TomahawkApp::init()
tDebug() << "Init Database.";
initDatabase();
Pipeline::instance()->addExternalResolverFactory( bind( &JSResolver::factory, _1, _2, _3 ) );
Pipeline::instance()->addExternalResolverFactory( bind( &ScriptResolver::factory, _1, _2, _3 ) );
Pipeline::instance()->addExternalResolverFactory(
std::bind( &JSResolver::factory, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3 ) );
Pipeline::instance()->addExternalResolverFactory(
std::bind( &ScriptResolver::factory, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3 ) );
new ActionCollection( this );
connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );

View File

@ -330,9 +330,10 @@ SourcesModel::appendPageItem( const QString& name, ViewPage* page, int sortValue
QModelIndex parentIndex = indexFromItem( m_browse );
beginInsertRows( parentIndex, rowCount( parentIndex ), rowCount( parentIndex ) );
GenericPageItem* pageItem = new GenericPageItem( this, m_browse, page->title(), page->pixmap(),
bind( &ViewManager::showDynamicPage, ViewManager::instance(), name ),
bind( &ViewManager::dynamicPageWidget, ViewManager::instance(), name ) );
GenericPageItem* pageItem = new GenericPageItem( this, m_browse, page->title(),
page->pixmap(),
std::bind( &ViewManager::showDynamicPage, ViewManager::instance(), name ),
std::bind( &ViewManager::dynamicPageWidget, ViewManager::instance(), name ) );
pageItem->setDeletable( page->isDeletable() );
if ( sortValue )

View File

@ -27,7 +27,10 @@ using namespace Tomahawk;
/// Generic page item
GenericPageItem::GenericPageItem( SourcesModel* model, SourceTreeItem* parent, const QString& text, const QIcon& icon, function< ViewPage* () > show, function< ViewPage* () > get )
GenericPageItem::GenericPageItem( SourcesModel* model, SourceTreeItem* parent,
const QString& text, const QIcon& icon,
std::function< ViewPage* () > show,
std::function< ViewPage* () > get )
: SourceTreeItem( model, parent, SourcesModel::GenericPage )
, m_icon( icon )
, m_text( text )

View File

@ -20,7 +20,8 @@
#define GENERIC_PAGE_ITEM_H
#include "SourceTreeItem.h"
#include "utils/tr1-functional.h"
#include <functional>
// generic item that has some name, some text, and calls a certain slot when activated. badabing!
class GenericPageItem : public SourceTreeItem
@ -28,7 +29,10 @@ class GenericPageItem : public SourceTreeItem
Q_OBJECT
public:
// takes 2 function pointers: show: called when wanting to show the desired view page. get: called to get the view page from ViewManager if it exists
GenericPageItem( SourcesModel* model, SourceTreeItem* parent, const QString& text, const QIcon& icon, function<Tomahawk::ViewPage*()> show, function<Tomahawk::ViewPage*()> get );
GenericPageItem( SourcesModel* model, SourceTreeItem* parent,
const QString& text, const QIcon& icon,
std::function<Tomahawk::ViewPage*()> show,
std::function<Tomahawk::ViewPage*()> get );
virtual ~GenericPageItem();
virtual QString text() const;
@ -53,8 +57,8 @@ private:
QIcon m_icon;
QString m_text;
int m_sortValue;
function< Tomahawk::ViewPage*() > m_show;
function< Tomahawk::ViewPage*() > m_get;
std::function< Tomahawk::ViewPage*() > m_show;
std::function< Tomahawk::ViewPage*() > m_get;
};
#endif

View File

@ -77,13 +77,15 @@ SourceItem::SourceItem( SourcesModel* mdl, SourceTreeItem* parent, const Tomahaw
bind( &SourceItem::sourceInfoClicked, this ),
bind( &SourceItem::getSourceInfoPage, this ) );*/
m_latestAdditionsItem = new GenericPageItem( model(), this, tr( "Latest Additions" ), ImageRegistry::instance()->icon( RESPATH "images/new-additions.svg" ),
bind( &SourceItem::latestAdditionsClicked, this ),
bind( &SourceItem::getLatestAdditionsPage, this ) );
m_latestAdditionsItem = new GenericPageItem( model(), this, tr( "Latest Additions" ),
ImageRegistry::instance()->icon( RESPATH "images/new-additions.svg" ),
std::bind( &SourceItem::latestAdditionsClicked, this ),
std::bind( &SourceItem::getLatestAdditionsPage, this ) );
m_recentPlaysItem = new GenericPageItem( model(), this, tr( "History" ), ImageRegistry::instance()->icon( RESPATH "images/recently-played.svg" ),
bind( &SourceItem::recentPlaysClicked, this ),
bind( &SourceItem::getRecentPlaysPage, this ) );
m_recentPlaysItem = new GenericPageItem( model(), this, tr( "History" ),
ImageRegistry::instance()->icon( RESPATH "images/recently-played.svg" ),
std::bind( &SourceItem::recentPlaysClicked, this ),
std::bind( &SourceItem::getRecentPlaysPage, this ) );
new LovedTracksItem( model(), this );
@ -377,8 +379,8 @@ SourceItem::performAddCollectionItem( const collection_ptr& collection )
this,
collection->itemName(),
collection->icon(),
boost::bind( &SourceItem::collectionClicked, this, collection ),
boost::bind( &SourceItem::getCollectionPage, this, collection ) );
std::bind( &SourceItem::collectionClicked, this, collection ),
std::bind( &SourceItem::getCollectionPage, this, collection ) );
i->setSortValue( -340 );
item = i;
}