mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-15 18:44:30 +02:00
Pimple LoadAllPlaylists
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DatabaseCommand_LoadAllPlaylists.h"
|
#include "DatabaseCommand_LoadAllPlaylists_p.h"
|
||||||
|
|
||||||
#include "DatabaseImpl.h"
|
#include "DatabaseImpl.h"
|
||||||
#include "Playlist.h"
|
#include "Playlist.h"
|
||||||
@@ -30,20 +30,19 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
|
|
||||||
DatabaseCommand_LoadAllPlaylists::DatabaseCommand_LoadAllPlaylists( const source_ptr& s, QObject* parent )
|
DatabaseCommand_LoadAllPlaylists::DatabaseCommand_LoadAllPlaylists( const source_ptr& s, QObject* parent )
|
||||||
: DatabaseCommand( s, parent )
|
: DatabaseCommand( parent, new DatabaseCommand_LoadAllPlaylistsPrivate( this, s ) )
|
||||||
, m_limitAmount( 0 )
|
|
||||||
, m_sortOrder( None )
|
|
||||||
, m_sortDescending( false )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi )
|
DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi )
|
||||||
{
|
{
|
||||||
|
Q_D( DatabaseCommand_LoadAllPlaylists );
|
||||||
|
|
||||||
TomahawkSqlQuery query = dbi->newquery();
|
TomahawkSqlQuery query = dbi->newquery();
|
||||||
QString orderToken, sourceToken;
|
QString orderToken, sourceToken;
|
||||||
|
|
||||||
switch ( m_sortOrder )
|
switch ( d->sortOrder )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
@@ -62,9 +61,9 @@ DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi )
|
|||||||
"%2 %3 %4"
|
"%2 %3 %4"
|
||||||
)
|
)
|
||||||
.arg( sourceToken )
|
.arg( sourceToken )
|
||||||
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( orderToken ) : QString() )
|
.arg( d->sortOrder > 0 ? QString( "ORDER BY %1" ).arg( orderToken ) : QString() )
|
||||||
.arg( m_sortDescending ? "DESC" : QString() )
|
.arg( d->sortDescending ? "DESC" : QString() )
|
||||||
.arg( m_limitAmount > 0 ? QString( "LIMIT 0, %1" ).arg( m_limitAmount ) : QString() ) );
|
.arg( d->limitAmount > 0 ? QString( "LIMIT 0, %1" ).arg( d->limitAmount ) : QString() ) );
|
||||||
|
|
||||||
QList<playlist_ptr> plists;
|
QList<playlist_ptr> plists;
|
||||||
while ( query.next() )
|
while ( query.next() )
|
||||||
@@ -90,20 +89,23 @@ DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi )
|
|||||||
void
|
void
|
||||||
DatabaseCommand_LoadAllPlaylists::setLimit( unsigned int limit )
|
DatabaseCommand_LoadAllPlaylists::setLimit( unsigned int limit )
|
||||||
{
|
{
|
||||||
m_limitAmount = limit;
|
Q_D( DatabaseCommand_LoadAllPlaylists );
|
||||||
|
d->limitAmount = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DatabaseCommand_LoadAllPlaylists::setSortOrder( DatabaseCommand_LoadAllPlaylists::SortOrder order )
|
DatabaseCommand_LoadAllPlaylists::setSortOrder( DatabaseCommand_LoadAllPlaylists::SortOrder order )
|
||||||
{
|
{
|
||||||
m_sortOrder = order;
|
Q_D( DatabaseCommand_LoadAllPlaylists );
|
||||||
|
d->sortOrder = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DatabaseCommand_LoadAllPlaylists::setSortDescending( bool descending )
|
DatabaseCommand_LoadAllPlaylists::setSortDescending( bool descending )
|
||||||
{
|
{
|
||||||
m_sortDescending = descending;
|
Q_D( DatabaseCommand_LoadAllPlaylists );
|
||||||
|
d->sortDescending = descending;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
|
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
#ifndef DATABASECOMMAND_LOADALLPLAYLIST_H
|
#ifndef DATABASECOMMAND_LOADALLPLAYLIST_H
|
||||||
#define DATABASECOMMAND_LOADALLPLAYLIST_H
|
#define DATABASECOMMAND_LOADALLPLAYLIST_H
|
||||||
|
|
||||||
@@ -31,6 +33,8 @@
|
|||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class DatabaseCommand_LoadAllPlaylistsPrivate;
|
||||||
|
|
||||||
class DLLEXPORT DatabaseCommand_LoadAllPlaylists : public DatabaseCommand
|
class DLLEXPORT DatabaseCommand_LoadAllPlaylists : public DatabaseCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -60,9 +64,7 @@ signals:
|
|||||||
void done( const QList<Tomahawk::playlist_ptr>& playlists );
|
void done( const QList<Tomahawk::playlist_ptr>& playlists );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int m_limitAmount;
|
Q_DECLARE_PRIVATE( DatabaseCommand_LoadAllPlaylists )
|
||||||
SortOrder m_sortOrder;
|
|
||||||
bool m_sortDescending;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tomahawk
|
} // namespace Tomahawk
|
||||||
|
@@ -0,0 +1,53 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
* Copyright 2013, 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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
|
Reference in New Issue
Block a user