1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 07:36:48 +02:00

* Style fixes.

This commit is contained in:
Christian Muehlhaeuser
2013-04-26 13:15:38 +02:00
parent 7bcf3e2e15
commit 69e19afbef
5 changed files with 108 additions and 97 deletions

View File

@@ -724,10 +724,9 @@ TomahawkWindow::winEvent( MSG* msg, long* result )
return false; return false;
} }
#endif // Q_OS_WIN #endif // Q_OS_WIN
void void
TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState ) TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
{ {

View File

@@ -1,21 +1,21 @@
/* /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
Copyright (C) 2011 Leo Franchi <lfranchi@kde.org> *
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
This program is free software; you can redistribute it and/or modify * Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
it under the terms of the GNU General Public License as published by *
the Free Software Foundation; either version 2 of the License, or * Tomahawk is free software: you can redistribute it and/or modify
(at your option) any later version. * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
This program is distributed in the hope that it will be useful, * (at your option) any later version.
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Tomahawk is distributed in the hope that it will be useful,
GNU General Public License for more details. * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License along * GNU General Public License for more details.
with this program; if not, write to the Free Software Foundation, Inc., *
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * You should have received a copy of the GNU General Public License
*/ * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "RecentPlaylistsModel.h" #include "RecentPlaylistsModel.h"
@@ -78,7 +78,7 @@ RecentPlaylistsModel::onRefresh()
void void
RecentPlaylistsModel::onReady() RecentPlaylistsModel::onReady()
{ {
foreach( const source_ptr& s, SourceList::instance()->sources() ) foreach ( const source_ptr& s, SourceList::instance()->sources() )
onSourceAdded( s ); onSourceAdded( s );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::QueuedConnection ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::QueuedConnection );
@@ -127,7 +127,7 @@ RecentPlaylistsModel::playlistsLoaded( const QList<DatabaseCommand_LoadAllSorted
QVariant QVariant
RecentPlaylistsModel::data( const QModelIndex& index, int role ) const RecentPlaylistsModel::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(); return QVariant();
playlist_ptr pl = m_playlists[index.row()]; playlist_ptr pl = m_playlists[index.row()];
@@ -139,11 +139,11 @@ RecentPlaylistsModel::data( const QModelIndex& index, int role ) const
return QVariant::fromValue< Tomahawk::playlist_ptr >( pl ); return QVariant::fromValue< Tomahawk::playlist_ptr >( pl );
case RecentlyPlayedPlaylistsModel::ArtistRole: case RecentlyPlayedPlaylistsModel::ArtistRole:
{ {
if( m_artists.value( pl ).isEmpty() ) if ( m_artists.value( pl ).isEmpty() )
{ {
QStringList artists; 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() ) ) if ( !artists.contains( entry->query()->track()->artist() ) )
artists << entry->query()->track()->artist(); artists << entry->query()->track()->artist();
@@ -241,7 +241,7 @@ void
RecentPlaylistsModel::onDynPlaylistsRemoved( QList< dynplaylist_ptr > playlists ) RecentPlaylistsModel::onDynPlaylistsRemoved( QList< dynplaylist_ptr > playlists )
{ {
QList< playlist_ptr > pls; QList< playlist_ptr > pls;
foreach( const dynplaylist_ptr& p, playlists ) foreach ( const dynplaylist_ptr& p, playlists )
pls << p; pls << p;
onPlaylistsRemoved( pls ); onPlaylistsRemoved( pls );
@@ -251,9 +251,9 @@ RecentPlaylistsModel::onDynPlaylistsRemoved( QList< dynplaylist_ptr > playlists
void void
RecentPlaylistsModel::onPlaylistsRemoved( QList< playlist_ptr > playlists ) 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 ); m_artists.remove( pl );

View File

@@ -1,22 +1,22 @@
/* /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* Copyright (C) 2011 Leo Franchi <lfranchi@kde.org>
* *
* This program is free software; you can redistribute it and/or modify * Copyright 2011, Leo Franchi <lfranchi@kde.org>
* it under the terms of the GNU General Public License as published by * Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* 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, * Tomahawk is free software: you can redistribute it and/or modify
* but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
* GNU General Public License for more details. * (at your option) any later version.
* *
* You should have received a copy of the GNU General Public License along * Tomahawk is distributed in the hope that it will be useful,
* with this program; if not, write to the Free Software Foundation, Inc., * but WITHOUT ANY WARRANTY; without even the implied warranty of
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 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 RECENTLPLAYLISTSMODEL_H #ifndef RECENTLPLAYLISTSMODEL_H
#define RECENTLPLAYLISTSMODEL_H #define RECENTLPLAYLISTSMODEL_H
@@ -42,7 +42,7 @@ public slots:
signals: signals:
void emptinessChanged( bool isEmpty ); void emptinessChanged( bool isEmpty );
void loadingStarted(); void loadingStarted();
void loadingFinished(); void loadingFinished();

View File

@@ -1,22 +1,22 @@
/* /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
Copyright (C) 2011 Leo Franchi <lfranchi@kde.org> *
Copyright (C) 2011 Jeff Mitchell <jeff@tomahawk-player.org> * Copyright 2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2011, Jeff Mitchell <jeff@tomahawk-player.org>
This program is free software; you can redistribute it and/or modify * Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
it under the terms of the GNU General Public License as published by *
the Free Software Foundation; either version 2 of the License, or * Tomahawk is free software: you can redistribute it and/or modify
(at your option) any later version. * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
This program is distributed in the hope that it will be useful, * (at your option) any later version.
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Tomahawk is distributed in the hope that it will be useful,
GNU General Public License for more details. * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License along * GNU General Public License for more details.
with this program; if not, write to the Free Software Foundation, Inc., *
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * You should have received a copy of the GNU General Public License
*/ * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "RecentlyPlayedPlaylistsModel.h" #include "RecentlyPlayedPlaylistsModel.h"
@@ -49,7 +49,7 @@ void
RecentlyPlayedPlaylistsModel::loadFromSettings() RecentlyPlayedPlaylistsModel::loadFromSettings()
{ {
// qDebug() << Q_FUNC_INFO; // qDebug() << Q_FUNC_INFO;
if( !m_waitingForSome ) if ( !m_waitingForSome )
return; return;
beginResetModel(); beginResetModel();
@@ -63,15 +63,16 @@ RecentlyPlayedPlaylistsModel::loadFromSettings()
// qDebug() << "loading playlist" << playlist_guids[i]; // qDebug() << "loading playlist" << playlist_guids[i];
playlist_ptr pl = m_cached.value( playlist_guids[i], Tomahawk::playlist_ptr() ); 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] ); pl = Tomahawk::Playlist::load( playlist_guids[i] );
if( pl.isNull() ) if ( pl.isNull() )
pl = Tomahawk::DynamicPlaylist::load( playlist_guids[i] ); pl = Tomahawk::DynamicPlaylist::load( playlist_guids[i] );
if ( !pl.isNull() ) { if ( !pl.isNull() )
{
m_recplaylists << pl; m_recplaylists << pl;
if( !m_cached.contains( playlist_guids[i] ) ) if ( !m_cached.contains( playlist_guids[i] ) )
{ {
if ( pl.dynamicCast< DynamicPlaylist >().isNull() ) if ( pl.dynamicCast< DynamicPlaylist >().isNull() )
connect( pl.data(), SIGNAL(revisionLoaded(Tomahawk::PlaylistRevision)), this, SLOT(playlistRevisionLoaded()) ); connect( pl.data(), SIGNAL(revisionLoaded(Tomahawk::PlaylistRevision)), this, SLOT(playlistRevisionLoaded()) );
@@ -91,7 +92,7 @@ RecentlyPlayedPlaylistsModel::loadFromSettings()
QVariant QVariant
RecentlyPlayedPlaylistsModel::data( const QModelIndex& index, int role ) const 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(); return QVariant();
playlist_ptr pl = m_recplaylists[index.row()]; 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 ); return QVariant::fromValue< Tomahawk::playlist_ptr >( pl );
case ArtistRole: case ArtistRole:
{ {
if( m_artists.value( pl ).isEmpty() ) if ( m_artists.value( pl ).isEmpty() )
{ {
QStringList artists; 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() ) ) if ( !artists.contains( entry->query()->track()->artist() ) )
artists << entry->query()->track()->artist(); artists << entry->query()->track()->artist();
@@ -149,6 +150,7 @@ RecentlyPlayedPlaylistsModel::data( const QModelIndex& index, int role ) const
} }
} }
void void
RecentlyPlayedPlaylistsModel::playlistRevisionLoaded() RecentlyPlayedPlaylistsModel::playlistRevisionLoaded()
{ {
@@ -169,11 +171,16 @@ RecentlyPlayedPlaylistsModel::playlistRevisionLoaded()
void void
RecentlyPlayedPlaylistsModel::onSourceAdded( const Tomahawk::source_ptr& source ) RecentlyPlayedPlaylistsModel::onSourceAdded( const Tomahawk::source_ptr& source )
{ {
connect( source.data(), SIGNAL( online() ), this, SLOT( sourceOnline() ) ); connect( source.data(), SIGNAL( online() ),
connect( source->dbCollection().data(), SIGNAL( playlistsAdded( QList<Tomahawk::playlist_ptr> ) ), SLOT( loadFromSettings() ) ); SLOT( sourceOnline() ) );
connect( source->dbCollection().data(), SIGNAL( playlistsDeleted( QList<Tomahawk::playlist_ptr> ) ), SLOT( onPlaylistsRemoved( QList<Tomahawk::playlist_ptr> ) ) );
connect( source->dbCollection().data(), SIGNAL( playlistsAdded( QList<Tomahawk::playlist_ptr> ) ),
SLOT( loadFromSettings() ) );
connect( source->dbCollection().data(), SIGNAL( playlistsDeleted( QList<Tomahawk::playlist_ptr> ) ),
SLOT( onPlaylistsRemoved( QList<Tomahawk::playlist_ptr> ) ) );
} }
void void
RecentlyPlayedPlaylistsModel::sourceOnline() RecentlyPlayedPlaylistsModel::sourceOnline()
{ {
@@ -194,8 +201,10 @@ RecentlyPlayedPlaylistsModel::sourceOnline()
void void
RecentlyPlayedPlaylistsModel::onPlaylistsRemoved( QList< playlist_ptr > playlists ) RecentlyPlayedPlaylistsModel::onPlaylistsRemoved( QList< playlist_ptr > playlists )
{ {
foreach( const playlist_ptr& pl, playlists ) { foreach ( const playlist_ptr& pl, playlists )
if( m_recplaylists.contains( pl ) ) { {
if ( m_recplaylists.contains( pl ) )
{
m_artists.remove( pl ); m_artists.remove( pl );
m_cached.remove( pl->guid() ); m_cached.remove( pl->guid() );
@@ -250,15 +259,18 @@ RecentlyPlayedPlaylistsModel::playlistChanged( Tomahawk::playlistinterface_ptr p
if ( pli.isNull() ) if ( pli.isNull() )
return; return;
if ( Playlist *pl = dynamic_cast< Playlist* >( pli.data() ) ) { if ( Playlist *pl = dynamic_cast< Playlist* >( pli.data() ) )
{
// look for it, qsharedpointer fail // look for it, qsharedpointer fail
playlist_ptr ptr; playlist_ptr ptr;
foreach( const playlist_ptr& test, m_recplaylists ) { foreach ( const playlist_ptr& test, m_recplaylists )
if( test.data() == pl ) {
if ( test.data() == pl )
ptr = test; ptr = test;
} }
if( !ptr.isNull() && m_artists.contains( ptr ) ) { if ( !ptr.isNull() && m_artists.contains( ptr ) )
{
m_artists[ ptr ] = QString(); m_artists[ ptr ] = QString();
} }

View File

@@ -1,22 +1,22 @@
/* /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
Copyright (C) 2011 Leo Franchi <lfranchi@kde.org> *
Copyright (C) 2011 Jeff Mitchell <jeff@tomahawk-player.org> * Copyright 2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2011, Jeff Mitchell <jeff@tomahawk-player.org>
This program is free software; you can redistribute it and/or modify * Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
it under the terms of the GNU General Public License as published by *
the Free Software Foundation; either version 2 of the License, or * Tomahawk is free software: you can redistribute it and/or modify
(at your option) any later version. * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
This program is distributed in the hope that it will be useful, * (at your option) any later version.
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Tomahawk is distributed in the hope that it will be useful,
GNU General Public License for more details. * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU General Public License along * GNU General Public License for more details.
with this program; if not, write to the Free Software Foundation, Inc., *
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * You should have received a copy of the GNU General Public License
*/ * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RECENTLYPLAYEDPLAYLISTSMODEL_H #ifndef RECENTLYPLAYEDPLAYLISTSMODEL_H
#define RECENTLYPLAYEDPLAYLISTSMODEL_H #define RECENTLYPLAYEDPLAYLISTSMODEL_H