diff --git a/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists.cpp b/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists.cpp index 597448cc4..dabb8675e 100644 --- a/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists.cpp +++ b/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists.cpp @@ -17,7 +17,7 @@ * along with Tomahawk. If not, see . */ -#include "DatabaseCommand_LoadAllPlaylists.h" +#include "DatabaseCommand_LoadAllPlaylists_p.h" #include "DatabaseImpl.h" #include "Playlist.h" @@ -30,20 +30,19 @@ using namespace Tomahawk; DatabaseCommand_LoadAllPlaylists::DatabaseCommand_LoadAllPlaylists( const source_ptr& s, QObject* parent ) - : DatabaseCommand( s, parent ) - , m_limitAmount( 0 ) - , m_sortOrder( None ) - , m_sortDescending( false ) + : DatabaseCommand( parent, new DatabaseCommand_LoadAllPlaylistsPrivate( this, s ) ) { } void DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi ) { + Q_D( DatabaseCommand_LoadAllPlaylists ); + TomahawkSqlQuery query = dbi->newquery(); QString orderToken, sourceToken; - switch ( m_sortOrder ) + switch ( d->sortOrder ) { case 0: break; @@ -62,9 +61,9 @@ DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi ) "%2 %3 %4" ) .arg( sourceToken ) - .arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( orderToken ) : QString() ) - .arg( m_sortDescending ? "DESC" : QString() ) - .arg( m_limitAmount > 0 ? QString( "LIMIT 0, %1" ).arg( m_limitAmount ) : QString() ) ); + .arg( d->sortOrder > 0 ? QString( "ORDER BY %1" ).arg( orderToken ) : QString() ) + .arg( d->sortDescending ? "DESC" : QString() ) + .arg( d->limitAmount > 0 ? QString( "LIMIT 0, %1" ).arg( d->limitAmount ) : QString() ) ); QList plists; while ( query.next() ) @@ -90,20 +89,23 @@ DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi ) void DatabaseCommand_LoadAllPlaylists::setLimit( unsigned int limit ) { - m_limitAmount = limit; + Q_D( DatabaseCommand_LoadAllPlaylists ); + d->limitAmount = limit; } void DatabaseCommand_LoadAllPlaylists::setSortOrder( DatabaseCommand_LoadAllPlaylists::SortOrder order ) { - m_sortOrder = order; + Q_D( DatabaseCommand_LoadAllPlaylists ); + d->sortOrder = order; } void DatabaseCommand_LoadAllPlaylists::setSortDescending( bool descending ) { - m_sortDescending = descending; + Q_D( DatabaseCommand_LoadAllPlaylists ); + d->sortDescending = descending; } diff --git a/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists.h b/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists.h index da19fdd9b..19a87d96b 100644 --- a/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists.h +++ b/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists.h @@ -2,6 +2,7 @@ * * Copyright 2010-2011, Christian Muehlhaeuser * Copyright 2011, Leo Franchi + * Copyright 2013, Uwe L. Korn * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +18,7 @@ * along with Tomahawk. If not, see . */ +#pragma once #ifndef DATABASECOMMAND_LOADALLPLAYLIST_H #define DATABASECOMMAND_LOADALLPLAYLIST_H @@ -31,6 +33,8 @@ namespace Tomahawk { +class DatabaseCommand_LoadAllPlaylistsPrivate; + class DLLEXPORT DatabaseCommand_LoadAllPlaylists : public DatabaseCommand { Q_OBJECT @@ -60,9 +64,7 @@ signals: void done( const QList& playlists ); private: - unsigned int m_limitAmount; - SortOrder m_sortOrder; - bool m_sortDescending; + Q_DECLARE_PRIVATE( DatabaseCommand_LoadAllPlaylists ) }; } // namespace Tomahawk diff --git a/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists_p.h b/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists_p.h new file mode 100644 index 000000000..108d7969c --- /dev/null +++ b/src/libtomahawk/database/DatabaseCommand_LoadAllPlaylists_p.h @@ -0,0 +1,53 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2011, Leo Franchi + * Copyright 2013, Uwe L. Korn + * + * 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 . + */ + +#pragma once +#ifndef DATABASECOMMAND_LOADALLPLAYLISTS_P_H +#define DATABASECOMMAND_LOADALLPLAYLISTS_P_H + +#include "DatabaseCommand_LoadAllPlaylists.h" + +#include "DatabaseCommand_p.h" + +namespace Tomahawk +{ + +class DatabaseCommand_LoadAllPlaylistsPrivate: public DatabaseCommandPrivate +{ +public: + DatabaseCommand_LoadAllPlaylistsPrivate( DatabaseCommand_LoadAllPlaylists* q, const source_ptr& s ) + : DatabaseCommandPrivate( q, s ) + , limitAmount( 0 ) + , sortOrder( DatabaseCommand_LoadAllPlaylists::None ) + , sortDescending( false ) + { + } + + Q_DECLARE_PUBLIC( DatabaseCommand_LoadAllPlaylists ) + +private: + unsigned int limitAmount; + DatabaseCommand_LoadAllPlaylists::SortOrder sortOrder; + bool sortDescending; +}; + +} + +#endif // DATABASECOMMAND_LOADALLPLAYLISTS_P_H