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