diff --git a/src/TomahawkWindow.cpp b/src/TomahawkWindow.cpp index 884b64ef7..2e81f08e9 100644 --- a/src/TomahawkWindow.cpp +++ b/src/TomahawkWindow.cpp @@ -724,10 +724,9 @@ TomahawkWindow::winEvent( MSG* msg, long* result ) return false; } - - #endif // Q_OS_WIN + void TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState ) { diff --git a/src/libtomahawk/widgets/RecentPlaylistsModel.cpp b/src/libtomahawk/widgets/RecentPlaylistsModel.cpp index 1d44adfcc..563f58e45 100644 --- a/src/libtomahawk/widgets/RecentPlaylistsModel.cpp +++ b/src/libtomahawk/widgets/RecentPlaylistsModel.cpp @@ -1,21 +1,21 @@ -/* - Copyright (C) 2011 Leo Franchi - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - +/* === This file is part of Tomahawk Player - === + * + * Copyright 2011, Leo Franchi + * Copyright 2013, Christian Muehlhaeuser + * + * 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 . + */ #include "RecentPlaylistsModel.h" @@ -78,7 +78,7 @@ RecentPlaylistsModel::onRefresh() void RecentPlaylistsModel::onReady() { - foreach( const source_ptr& s, SourceList::instance()->sources() ) + foreach ( const source_ptr& s, SourceList::instance()->sources() ) onSourceAdded( s ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::QueuedConnection ); @@ -127,7 +127,7 @@ RecentPlaylistsModel::playlistsLoaded( const QList( pl ); case RecentlyPlayedPlaylistsModel::ArtistRole: { - if( m_artists.value( pl ).isEmpty() ) + if ( m_artists.value( pl ).isEmpty() ) { QStringList artists; - foreach( const Tomahawk::plentry_ptr& entry, pl->entries() ) + foreach ( const Tomahawk::plentry_ptr& entry, pl->entries() ) { if ( !artists.contains( entry->query()->track()->artist() ) ) artists << entry->query()->track()->artist(); @@ -241,7 +241,7 @@ void RecentPlaylistsModel::onDynPlaylistsRemoved( QList< dynplaylist_ptr > playlists ) { QList< playlist_ptr > pls; - foreach( const dynplaylist_ptr& p, playlists ) + foreach ( const dynplaylist_ptr& p, playlists ) pls << p; onPlaylistsRemoved( pls ); @@ -251,9 +251,9 @@ RecentPlaylistsModel::onDynPlaylistsRemoved( QList< dynplaylist_ptr > playlists void RecentPlaylistsModel::onPlaylistsRemoved( QList< playlist_ptr > playlists ) { - foreach( const playlist_ptr& pl, playlists ) + foreach ( const playlist_ptr& pl, playlists ) { - if( m_playlists.contains( pl ) ) + if ( m_playlists.contains( pl ) ) { m_artists.remove( pl ); diff --git a/src/libtomahawk/widgets/RecentPlaylistsModel.h b/src/libtomahawk/widgets/RecentPlaylistsModel.h index 115debf2f..d79986ce8 100644 --- a/src/libtomahawk/widgets/RecentPlaylistsModel.h +++ b/src/libtomahawk/widgets/RecentPlaylistsModel.h @@ -1,22 +1,22 @@ -/* - * Copyright (C) 2011 Leo Franchi +/* === This file is part of Tomahawk Player - === * - * This program 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 2 of the License, or - * (at your option) any later version. + * Copyright 2011, Leo Franchi + * Copyright 2013, Christian Muehlhaeuser * - * This program 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. + * 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. * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 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 . */ - #ifndef RECENTLPLAYLISTSMODEL_H #define RECENTLPLAYLISTSMODEL_H @@ -42,7 +42,7 @@ public slots: signals: void emptinessChanged( bool isEmpty ); - + void loadingStarted(); void loadingFinished(); diff --git a/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.cpp b/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.cpp index 28da33876..48d9ec2f3 100644 --- a/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.cpp +++ b/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.cpp @@ -1,22 +1,22 @@ -/* - Copyright (C) 2011 Leo Franchi - Copyright (C) 2011 Jeff Mitchell - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - +/* === This file is part of Tomahawk Player - === + * + * Copyright 2011, Leo Franchi + * Copyright 2011, Jeff Mitchell + * Copyright 2013, Christian Muehlhaeuser + * + * 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 . + */ #include "RecentlyPlayedPlaylistsModel.h" @@ -49,7 +49,7 @@ void RecentlyPlayedPlaylistsModel::loadFromSettings() { // qDebug() << Q_FUNC_INFO; - if( !m_waitingForSome ) + if ( !m_waitingForSome ) return; beginResetModel(); @@ -63,15 +63,16 @@ RecentlyPlayedPlaylistsModel::loadFromSettings() // qDebug() << "loading playlist" << playlist_guids[i]; playlist_ptr pl = m_cached.value( playlist_guids[i], Tomahawk::playlist_ptr() ); - if( pl.isNull() ) + if ( pl.isNull() ) pl = Tomahawk::Playlist::load( playlist_guids[i] ); - if( pl.isNull() ) + if ( pl.isNull() ) pl = Tomahawk::DynamicPlaylist::load( playlist_guids[i] ); - if ( !pl.isNull() ) { + if ( !pl.isNull() ) + { m_recplaylists << pl; - if( !m_cached.contains( playlist_guids[i] ) ) + if ( !m_cached.contains( playlist_guids[i] ) ) { if ( pl.dynamicCast< DynamicPlaylist >().isNull() ) connect( pl.data(), SIGNAL(revisionLoaded(Tomahawk::PlaylistRevision)), this, SLOT(playlistRevisionLoaded()) ); @@ -91,7 +92,7 @@ RecentlyPlayedPlaylistsModel::loadFromSettings() QVariant RecentlyPlayedPlaylistsModel::data( const QModelIndex& index, int role ) const { - if( !index.isValid() || !hasIndex( index.row(), index.column(), index.parent() ) ) + if ( !index.isValid() || !hasIndex( index.row(), index.column(), index.parent() ) ) return QVariant(); playlist_ptr pl = m_recplaylists[index.row()]; @@ -103,11 +104,11 @@ RecentlyPlayedPlaylistsModel::data( const QModelIndex& index, int role ) const return QVariant::fromValue< Tomahawk::playlist_ptr >( pl ); case ArtistRole: { - if( m_artists.value( pl ).isEmpty() ) + if ( m_artists.value( pl ).isEmpty() ) { QStringList artists; - foreach( const Tomahawk::plentry_ptr& entry, pl->entries() ) + foreach ( const Tomahawk::plentry_ptr& entry, pl->entries() ) { if ( !artists.contains( entry->query()->track()->artist() ) ) artists << entry->query()->track()->artist(); @@ -149,6 +150,7 @@ RecentlyPlayedPlaylistsModel::data( const QModelIndex& index, int role ) const } } + void RecentlyPlayedPlaylistsModel::playlistRevisionLoaded() { @@ -169,11 +171,16 @@ RecentlyPlayedPlaylistsModel::playlistRevisionLoaded() void RecentlyPlayedPlaylistsModel::onSourceAdded( const Tomahawk::source_ptr& source ) { - connect( source.data(), SIGNAL( online() ), this, SLOT( sourceOnline() ) ); - connect( source->dbCollection().data(), SIGNAL( playlistsAdded( QList ) ), SLOT( loadFromSettings() ) ); - connect( source->dbCollection().data(), SIGNAL( playlistsDeleted( QList ) ), SLOT( onPlaylistsRemoved( QList ) ) ); + connect( source.data(), SIGNAL( online() ), + SLOT( sourceOnline() ) ); + + connect( source->dbCollection().data(), SIGNAL( playlistsAdded( QList ) ), + SLOT( loadFromSettings() ) ); + connect( source->dbCollection().data(), SIGNAL( playlistsDeleted( QList ) ), + SLOT( onPlaylistsRemoved( QList ) ) ); } + void RecentlyPlayedPlaylistsModel::sourceOnline() { @@ -194,8 +201,10 @@ RecentlyPlayedPlaylistsModel::sourceOnline() void RecentlyPlayedPlaylistsModel::onPlaylistsRemoved( QList< playlist_ptr > playlists ) { - foreach( const playlist_ptr& pl, playlists ) { - if( m_recplaylists.contains( pl ) ) { + foreach ( const playlist_ptr& pl, playlists ) + { + if ( m_recplaylists.contains( pl ) ) + { m_artists.remove( pl ); m_cached.remove( pl->guid() ); @@ -250,15 +259,18 @@ RecentlyPlayedPlaylistsModel::playlistChanged( Tomahawk::playlistinterface_ptr p if ( pli.isNull() ) return; - if ( Playlist *pl = dynamic_cast< Playlist* >( pli.data() ) ) { + if ( Playlist *pl = dynamic_cast< Playlist* >( pli.data() ) ) + { // look for it, qsharedpointer fail playlist_ptr ptr; - foreach( const playlist_ptr& test, m_recplaylists ) { - if( test.data() == pl ) + foreach ( const playlist_ptr& test, m_recplaylists ) + { + if ( test.data() == pl ) ptr = test; } - if( !ptr.isNull() && m_artists.contains( ptr ) ) { + if ( !ptr.isNull() && m_artists.contains( ptr ) ) + { m_artists[ ptr ] = QString(); } diff --git a/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.h b/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.h index 7e14f4cf8..a37bbdc35 100644 --- a/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.h +++ b/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.h @@ -1,22 +1,22 @@ -/* - Copyright (C) 2011 Leo Franchi - Copyright (C) 2011 Jeff Mitchell - - This program 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 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - +/* === This file is part of Tomahawk Player - === + * + * Copyright 2011, Leo Franchi + * Copyright 2011, Jeff Mitchell + * Copyright 2013, Christian Muehlhaeuser + * + * 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 . + */ #ifndef RECENTLYPLAYEDPLAYLISTSMODEL_H #define RECENTLYPLAYEDPLAYLISTSMODEL_H