mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
Pimple PlaylistEntry
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PlaylistEntry.h"
|
||||
#include "PlaylistEntry_p.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
@@ -35,7 +35,6 @@ PlaylistEntry::PlaylistEntry()
|
||||
|
||||
PlaylistEntry::~PlaylistEntry()
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << m_query->toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,14 +54,16 @@ PlaylistEntry::setQueryVariant( const QVariant& v )
|
||||
QVariant
|
||||
PlaylistEntry::queryVariant() const
|
||||
{
|
||||
return m_query->toVariant();
|
||||
Q_D( const PlaylistEntry );
|
||||
return d->query->toVariant();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistEntry::setQuery( const Tomahawk::query_ptr& q )
|
||||
{
|
||||
m_query = q;
|
||||
Q_D( PlaylistEntry );
|
||||
d->query = q;
|
||||
|
||||
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( onQueryResolved( bool ) ) );
|
||||
}
|
||||
@@ -71,21 +72,24 @@ PlaylistEntry::setQuery( const Tomahawk::query_ptr& q )
|
||||
const Tomahawk::query_ptr&
|
||||
PlaylistEntry::query() const
|
||||
{
|
||||
return m_query;
|
||||
Q_D( const PlaylistEntry );
|
||||
return d->query;
|
||||
}
|
||||
|
||||
|
||||
source_ptr
|
||||
PlaylistEntry::lastSource() const
|
||||
{
|
||||
return m_lastsource;
|
||||
Q_D( const PlaylistEntry );
|
||||
return d->lastsource;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistEntry::setLastSource( source_ptr s )
|
||||
{
|
||||
m_lastsource = s;
|
||||
Q_D( PlaylistEntry );
|
||||
d->lastsource = s;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,10 +107,11 @@ PlaylistEntry::onQueryResolved( bool hasResults )
|
||||
void
|
||||
PlaylistEntry::setResultHint( const QString& s )
|
||||
{
|
||||
if ( m_resulthint == s )
|
||||
Q_D( PlaylistEntry );
|
||||
if ( d->resulthint == s )
|
||||
return;
|
||||
|
||||
m_resulthint = s;
|
||||
d->resulthint = s;
|
||||
emit resultChanged();
|
||||
}
|
||||
|
||||
@@ -114,18 +119,99 @@ PlaylistEntry::setResultHint( const QString& s )
|
||||
QString
|
||||
PlaylistEntry::hintFromQuery() const
|
||||
{
|
||||
Q_D( const PlaylistEntry );
|
||||
|
||||
QString resultHint, foundResult;
|
||||
if ( !m_query->results().isEmpty() )
|
||||
foundResult = m_query->results().first()->url();
|
||||
else if ( !m_query->resultHint().isEmpty() )
|
||||
foundResult = m_query->resultHint();
|
||||
if ( !d->query->results().isEmpty() )
|
||||
foundResult = d->query->results().first()->url();
|
||||
else if ( !d->query->resultHint().isEmpty() )
|
||||
foundResult = d->query->resultHint();
|
||||
|
||||
if ( foundResult.startsWith( "file://" ) ||
|
||||
foundResult.startsWith( "servent://" ) || // Save resulthints for local files and peers automatically
|
||||
( TomahawkUtils::whitelistedHttpResultHint( foundResult ) && m_query->saveHTTPResultHint() ) )
|
||||
( TomahawkUtils::whitelistedHttpResultHint( foundResult ) && d->query->saveHTTPResultHint() ) )
|
||||
{
|
||||
resultHint = foundResult;
|
||||
}
|
||||
|
||||
return resultHint;
|
||||
}
|
||||
|
||||
bool
|
||||
PlaylistEntry::isValid() const
|
||||
{
|
||||
Q_D( const PlaylistEntry );
|
||||
|
||||
return !d->query.isNull();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PlaylistEntry::guid() const
|
||||
{
|
||||
Q_D( const PlaylistEntry );
|
||||
return d->guid;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistEntry::setGuid( const QString& s )
|
||||
{
|
||||
Q_D( PlaylistEntry );
|
||||
d->guid = s;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PlaylistEntry::annotation() const
|
||||
{
|
||||
Q_D( const PlaylistEntry );
|
||||
return d->annotation;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistEntry::setAnnotation( const QString& s )
|
||||
{
|
||||
Q_D( PlaylistEntry );
|
||||
d->annotation = s;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PlaylistEntry::resultHint() const
|
||||
{
|
||||
Q_D( const PlaylistEntry );
|
||||
return d->resulthint;
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
PlaylistEntry::duration() const
|
||||
{
|
||||
Q_D( const PlaylistEntry );
|
||||
return d->duration;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistEntry::setDuration( unsigned int i )
|
||||
{
|
||||
Q_D( PlaylistEntry );
|
||||
d->duration = i;
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
PlaylistEntry::lastmodified() const
|
||||
{
|
||||
Q_D( const PlaylistEntry );
|
||||
return d->lastmodified;
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistEntry::setLastmodified( unsigned int i )
|
||||
{
|
||||
Q_D( PlaylistEntry );
|
||||
d->lastmodified = i;
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.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
|
||||
@@ -34,6 +35,8 @@
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class PlaylistEntryPrivate;
|
||||
|
||||
class DLLEXPORT PlaylistEntry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -47,7 +50,7 @@ public:
|
||||
PlaylistEntry();
|
||||
virtual ~PlaylistEntry();
|
||||
|
||||
bool isValid() const { return !m_query.isNull(); }
|
||||
bool isValid() const;
|
||||
|
||||
void setQuery( const Tomahawk::query_ptr& q );
|
||||
const Tomahawk::query_ptr& query() const;
|
||||
@@ -55,20 +58,20 @@ public:
|
||||
void setQueryVariant( const QVariant& v );
|
||||
QVariant queryVariant() const;
|
||||
|
||||
QString guid() const { return m_guid; }
|
||||
void setGuid( const QString& s ) { m_guid = s; }
|
||||
QString guid() const;
|
||||
void setGuid( const QString& s );
|
||||
|
||||
QString annotation() const { return m_annotation; }
|
||||
void setAnnotation( const QString& s ) { m_annotation = s; }
|
||||
QString annotation() const;
|
||||
void setAnnotation( const QString& s );
|
||||
|
||||
QString resultHint() const { return m_resulthint; }
|
||||
QString resultHint() const;
|
||||
void setResultHint( const QString& s );
|
||||
|
||||
unsigned int duration() const { return m_duration; }
|
||||
void setDuration( unsigned int i ) { m_duration = i; }
|
||||
unsigned int duration() const;
|
||||
void setDuration( unsigned int i );
|
||||
|
||||
unsigned int lastmodified() const { return m_lastmodified; }
|
||||
void setLastmodified( unsigned int i ) { m_lastmodified = i; }
|
||||
unsigned int lastmodified() const;
|
||||
void setLastmodified( unsigned int i );
|
||||
|
||||
source_ptr lastSource() const;
|
||||
void setLastSource( source_ptr s );
|
||||
@@ -80,15 +83,10 @@ private slots:
|
||||
void onQueryResolved( bool hasResults );
|
||||
|
||||
private:
|
||||
QString hintFromQuery() const;
|
||||
Q_DECLARE_PRIVATE( PlaylistEntry )
|
||||
PlaylistEntryPrivate* d_ptr;
|
||||
|
||||
QString m_guid;
|
||||
Tomahawk::query_ptr m_query;
|
||||
QString m_annotation;
|
||||
unsigned int m_duration;
|
||||
unsigned int m_lastmodified;
|
||||
source_ptr m_lastsource;
|
||||
QString m_resulthint;
|
||||
QString hintFromQuery() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
52
src/libtomahawk/PlaylistEntry_p.h
Normal file
52
src/libtomahawk/PlaylistEntry_p.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.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/>.
|
||||
*/
|
||||
|
||||
#ifndef PLAYLISTENTRY_P_H
|
||||
#define PLAYLISTENTRY_P_H
|
||||
|
||||
#include "PlaylistEntry.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class PlaylistEntryPrivate
|
||||
{
|
||||
public:
|
||||
PlaylistEntryPrivate( PlaylistEntry* q )
|
||||
: q_ptr( q )
|
||||
{
|
||||
}
|
||||
|
||||
Q_DECLARE_PUBLIC( PlaylistEntry )
|
||||
PlaylistEntry* q_ptr;
|
||||
private:
|
||||
QString guid;
|
||||
Tomahawk::query_ptr query;
|
||||
QString annotation;
|
||||
unsigned int duration;
|
||||
unsigned int lastmodified;
|
||||
source_ptr lastsource;
|
||||
QString resulthint;
|
||||
};
|
||||
|
||||
} // Tomahawk
|
||||
|
||||
#endif // PLAYLISTENTRY_P_H
|
Reference in New Issue
Block a user