mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-07 17:42:35 +02:00
* A playlist's title now updates in the sidebar when it gets changed.
This commit is contained in:
parent
7aa844f81b
commit
f8df6db392
@ -29,6 +29,8 @@ DatabaseCommand_RenamePlaylist::exec( DatabaseImpl* lib )
|
||||
cre.bindValue( ":id", m_playlistguid );
|
||||
cre.bindValue( ":title", m_playlistTitle );
|
||||
|
||||
qDebug() << Q_FUNC_INFO << m_playlistTitle << m_playlistguid;
|
||||
|
||||
cre.exec();
|
||||
}
|
||||
|
||||
@ -46,6 +48,7 @@ DatabaseCommand_RenamePlaylist::postCommitHook()
|
||||
playlist_ptr playlist = source()->collection()->playlist( m_playlistguid );
|
||||
Q_ASSERT( !playlist.isNull() );
|
||||
|
||||
qDebug() << "Renaming old playlist" << playlist->title() << "to" << m_playlistTitle << m_playlistguid;
|
||||
playlist->setTitle( m_playlistTitle );
|
||||
|
||||
if( source()->isLocal() )
|
||||
|
@ -389,7 +389,7 @@ Playlist::setNewRevision( const QString& rev,
|
||||
|
||||
|
||||
source_ptr
|
||||
Playlist::author()
|
||||
Playlist::author() const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ Q_PROPERTY( QVariant query READ queryVariant WRITE setQueryVariant )
|
||||
public:
|
||||
PlaylistEntry();
|
||||
virtual ~PlaylistEntry();
|
||||
|
||||
|
||||
void setQuery( const Tomahawk::query_ptr& q );
|
||||
const Tomahawk::query_ptr& query() const;
|
||||
|
||||
|
||||
// I wish Qt did this for me once i specified the Q_PROPERTIES:
|
||||
void setQueryVariant( const QVariant& v );
|
||||
QVariant queryVariant() const;
|
||||
@ -59,7 +59,7 @@ public:
|
||||
source_ptr lastSource() const;
|
||||
void setLastSource( source_ptr s );
|
||||
|
||||
private:
|
||||
private:
|
||||
QString m_guid;
|
||||
Tomahawk::query_ptr m_query;
|
||||
QString m_annotation;
|
||||
@ -97,7 +97,7 @@ friend class ::DatabaseCommand_CreatePlaylist;
|
||||
|
||||
public:
|
||||
~Playlist();
|
||||
|
||||
|
||||
static Tomahawk::playlist_ptr load( const QString& guid );
|
||||
|
||||
// one CTOR is private, only called by DatabaseCommand_LoadAllPlaylists
|
||||
@ -113,14 +113,14 @@ public:
|
||||
|
||||
virtual void loadRevision( const QString& rev = "" );
|
||||
|
||||
source_ptr author();
|
||||
const QString& currentrevision() { return m_currentrevision; }
|
||||
const QString& title() { return m_title; }
|
||||
const QString& info() { return m_info; }
|
||||
const QString& creator() { return m_creator; }
|
||||
unsigned int lastmodified() { return m_lastmodified; }
|
||||
const QString& guid() { return m_guid; }
|
||||
bool shared() const { return m_shared; }
|
||||
source_ptr author() const;
|
||||
QString currentrevision() const { return m_currentrevision; }
|
||||
QString title() const { return m_title; }
|
||||
QString info() const { return m_info; }
|
||||
QString creator() const { return m_creator; }
|
||||
QString guid() const { return m_guid; }
|
||||
bool shared() const { return m_shared; }
|
||||
unsigned int lastmodified() const { return m_lastmodified; }
|
||||
|
||||
const QList< plentry_ptr >& entries() { return m_entries; }
|
||||
virtual void addEntry( const Tomahawk::query_ptr& query, const QString& oldrev );
|
||||
@ -132,7 +132,7 @@ public:
|
||||
// maybe friend QObjectHelper and make them private?
|
||||
explicit Playlist( const source_ptr& author );
|
||||
void setCurrentrevision( const QString& s ) { m_currentrevision = s; }
|
||||
void setTitle( const QString& s ) { m_title = s; }
|
||||
void setTitle( const QString& s ) { m_title = s; emit changed(); }
|
||||
void setInfo( const QString& s ) { m_info = s; }
|
||||
void setCreator( const QString& s ) { m_creator = s; }
|
||||
void setGuid( const QString& s ) { m_guid = s; }
|
||||
@ -148,12 +148,12 @@ public:
|
||||
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
|
||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||
virtual void setShuffled( bool ) {}
|
||||
|
||||
|
||||
virtual void setFilter( const QString& pattern ) {}
|
||||
|
||||
|
||||
signals:
|
||||
/// emitted when the playlist revision changes (whenever the playlist changes)
|
||||
void revisionLoaded( Tomahawk::PlaylistRevision );
|
||||
@ -161,6 +161,9 @@ signals:
|
||||
/// watch for this to see when newly created playlist is synced to DB (if you care)
|
||||
void created();
|
||||
|
||||
/// renamed etc.
|
||||
void changed();
|
||||
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
@ -201,24 +204,24 @@ protected:
|
||||
const QString& info,
|
||||
const QString& creator,
|
||||
bool shared );
|
||||
|
||||
|
||||
QList< plentry_ptr > newEntries( const QList< plentry_ptr >& entries );
|
||||
PlaylistRevision setNewRevision( const QString& rev,
|
||||
const QList<QString>& neworderedguids,
|
||||
const QList<QString>& oldorderedguids,
|
||||
bool is_newest_rev,
|
||||
const QMap< QString, Tomahawk::plentry_ptr >& addedmap );
|
||||
|
||||
|
||||
QList<plentry_ptr> addEntriesInternal( const QList<Tomahawk::query_ptr>& queries );
|
||||
|
||||
|
||||
private slots:
|
||||
void onResultsFound( const QList<Tomahawk::result_ptr>& results );
|
||||
void onResolvingFinished();
|
||||
|
||||
|
||||
private:
|
||||
Playlist();
|
||||
void init();
|
||||
|
||||
|
||||
source_ptr m_source;
|
||||
QString m_currentrevision;
|
||||
QString m_guid, m_title, m_info, m_creator;
|
||||
|
@ -41,7 +41,7 @@ SourceTreeItem::SourceTreeItem( const source_ptr& source, QObject* parent )
|
||||
SLOT( onPlaylistsAdded( QList<Tomahawk::playlist_ptr> ) ) );
|
||||
connect( source->collection().data(), SIGNAL( playlistsDeleted( QList<Tomahawk::playlist_ptr> ) ),
|
||||
SLOT( onPlaylistsDeleted( QList<Tomahawk::playlist_ptr> ) ) );
|
||||
|
||||
|
||||
connect( source->collection().data(), SIGNAL( dynamicPlaylistsAdded( QList<Tomahawk::dynplaylist_ptr> ) ),
|
||||
SLOT( onDynamicPlaylistsAdded( QList<Tomahawk::dynplaylist_ptr> ) ) );
|
||||
connect( source->collection().data(), SIGNAL( dynamicPlaylistsDeleted( QList<Tomahawk::dynplaylist_ptr> ) ),
|
||||
@ -88,14 +88,14 @@ SourceTreeItem::onPlaylistsAdded( const QList<playlist_ptr>& playlists )
|
||||
{
|
||||
m_playlists.append( p );
|
||||
qlonglong ptr = reinterpret_cast<qlonglong>( &m_playlists.last() );
|
||||
qDebug() << "Setting playlist ptr to:" << ptr;
|
||||
|
||||
|
||||
connect( p.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ),
|
||||
SLOT( onPlaylistLoaded( Tomahawk::PlaylistRevision ) ),
|
||||
Qt::QueuedConnection);
|
||||
|
||||
SLOT( onPlaylistLoaded( Tomahawk::PlaylistRevision ) ), Qt::QueuedConnection );
|
||||
connect( p.data(), SIGNAL( changed() ),
|
||||
SLOT( onPlaylistChanged() ), Qt::QueuedConnection );
|
||||
|
||||
qDebug() << "Playlist added:" << p->title() << p->creator() << p->info() << ptr;
|
||||
|
||||
|
||||
playlistAddedInternal( ptr, p, false );
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,7 @@ SourceTreeItem::onPlaylistsDeleted( const QList<playlist_ptr>& playlists )
|
||||
{
|
||||
qlonglong ptr = qlonglong( p.data() );
|
||||
qDebug() << "Playlist removed:" << p->title() << p->creator() << p->info() << ptr;
|
||||
|
||||
|
||||
QStandardItem* item = m_columns.at( 0 );
|
||||
int rows = item->rowCount();
|
||||
for ( int i = rows - 1; i >= 0; i-- )
|
||||
@ -118,7 +118,7 @@ SourceTreeItem::onPlaylistsDeleted( const QList<playlist_ptr>& playlists )
|
||||
qlonglong piptr = pi->data( PlaylistPointer ).toLongLong();
|
||||
playlist_ptr* pl = reinterpret_cast<playlist_ptr*>(piptr);
|
||||
SourcesModel::SourceType type = static_cast<SourcesModel::SourceType>( pi->data( Type ).toInt() );
|
||||
|
||||
|
||||
if ( type == SourcesModel::PlaylistSource && ptr == qlonglong( pl->data() ) )
|
||||
{
|
||||
m_playlists.removeAll( p );
|
||||
@ -133,8 +133,7 @@ void
|
||||
SourceTreeItem::onPlaylistLoaded( Tomahawk::PlaylistRevision revision )
|
||||
{
|
||||
qlonglong ptr = reinterpret_cast<qlonglong>( sender() );
|
||||
qDebug() << "sender ptr:" << ptr;
|
||||
|
||||
|
||||
QStandardItem* item = m_columns.at( 0 );
|
||||
int rows = item->rowCount();
|
||||
for ( int i = 0; i < rows; i++ )
|
||||
@ -143,10 +142,9 @@ SourceTreeItem::onPlaylistLoaded( Tomahawk::PlaylistRevision revision )
|
||||
qlonglong piptr = pi->data( PlaylistPointer ).toLongLong();
|
||||
playlist_ptr* pl = reinterpret_cast<playlist_ptr*>(piptr);
|
||||
SourcesModel::SourceType type = static_cast<SourcesModel::SourceType>( pi->data( Type ).toInt() );
|
||||
|
||||
|
||||
if ( type == SourcesModel::PlaylistSource && ptr == qlonglong( pl->data() ) )
|
||||
{
|
||||
qDebug() << "Found normal playlist!";
|
||||
pi->setEnabled( true );
|
||||
m_current_revisions.insert( pl->data()->guid(), revision.revisionguid );
|
||||
}
|
||||
@ -154,6 +152,38 @@ SourceTreeItem::onPlaylistLoaded( Tomahawk::PlaylistRevision revision )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeItem::onPlaylistChanged()
|
||||
{
|
||||
qlonglong ptr = reinterpret_cast<qlonglong>( sender() );
|
||||
|
||||
QStandardItem* item = m_columns.at( 0 );
|
||||
int rows = item->rowCount();
|
||||
for ( int i = 0; i < rows; i++ )
|
||||
{
|
||||
QStandardItem* pi = item->child( i );
|
||||
SourcesModel::SourceType type = static_cast<SourcesModel::SourceType>( pi->data( Type ).toInt() );
|
||||
|
||||
if ( type == SourcesModel::PlaylistSource )
|
||||
{
|
||||
qlonglong piptr = pi->data( PlaylistPointer ).toLongLong();
|
||||
playlist_ptr* pl = reinterpret_cast<playlist_ptr*>(piptr);
|
||||
|
||||
if ( ptr == qlonglong( pl->data() ) )
|
||||
pi->setText( pl->data()->title() );
|
||||
}
|
||||
if ( type == SourcesModel::DynamicPlaylistSource )
|
||||
{
|
||||
qlonglong piptr = pi->data( DynamicPlaylistPointer ).toLongLong();
|
||||
dynplaylist_ptr* pl = reinterpret_cast<dynplaylist_ptr*>(piptr);
|
||||
|
||||
if ( ptr == qlonglong( pl->data() ) )
|
||||
pi->setText( pl->data()->title() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeItem::onDynamicPlaylistsAdded( const QList< dynplaylist_ptr >& playlists )
|
||||
{
|
||||
@ -162,13 +192,14 @@ SourceTreeItem::onDynamicPlaylistsAdded( const QList< dynplaylist_ptr >& playlis
|
||||
{
|
||||
m_dynplaylists.append( p );
|
||||
qlonglong ptr = reinterpret_cast<qlonglong>( &m_dynplaylists.last() );
|
||||
// qDebug() << "Setting dynamic ptr to:" << ptr;
|
||||
|
||||
connect( p.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ),
|
||||
SLOT( onDynamicPlaylistLoaded( Tomahawk::DynamicPlaylistRevision ) ),
|
||||
Qt::QueuedConnection);
|
||||
|
||||
SLOT( onDynamicPlaylistLoaded( Tomahawk::DynamicPlaylistRevision ) ), Qt::QueuedConnection );
|
||||
connect( p.data(), SIGNAL( changed() ),
|
||||
SLOT( onPlaylistChanged() ), Qt::QueuedConnection );
|
||||
|
||||
// qDebug() << "Dynamic Playlist added:" << p->title() << p->creator() << p->info() << p->currentrevision() << ptr;
|
||||
|
||||
|
||||
playlistAddedInternal( ptr, p, true );
|
||||
}
|
||||
}
|
||||
@ -182,7 +213,7 @@ SourceTreeItem::onDynamicPlaylistsDeleted( const QList< dynplaylist_ptr >& playl
|
||||
{
|
||||
qlonglong ptr = qlonglong( p.data() );
|
||||
// qDebug() << "dynamic playlist removed:" << p->title() << p->creator() << p->info() << ptr;
|
||||
|
||||
|
||||
QStandardItem* item = m_columns.at( 0 );
|
||||
int rows = item->rowCount();
|
||||
for ( int i = rows - 1; i >= 0; i-- )
|
||||
@ -191,7 +222,8 @@ SourceTreeItem::onDynamicPlaylistsDeleted( const QList< dynplaylist_ptr >& playl
|
||||
qlonglong piptr = pi->data( DynamicPlaylistPointer ).toLongLong();
|
||||
dynplaylist_ptr* pl = reinterpret_cast<dynplaylist_ptr*>(piptr);
|
||||
SourcesModel::SourceType type = static_cast<SourcesModel::SourceType>( pi->data( Type ).toInt() );
|
||||
//qDebug() << "Deleting dynamic playlsit:" << pl->isNull();
|
||||
|
||||
//qDebug() << "Deleting dynamic playlist:" << pl->isNull();
|
||||
if ( type == SourcesModel::DynamicPlaylistSource && ptr == qlonglong( pl->data() ) )
|
||||
{
|
||||
m_dynplaylists.removeAll( p );
|
||||
@ -206,7 +238,7 @@ void
|
||||
SourceTreeItem::onDynamicPlaylistLoaded( DynamicPlaylistRevision revision )
|
||||
{
|
||||
qlonglong ptr = reinterpret_cast<qlonglong>( sender() );
|
||||
|
||||
|
||||
QStandardItem* item = m_columns.at( 0 );
|
||||
int rows = item->rowCount();
|
||||
for ( int i = 0; i < rows; i++ )
|
||||
@ -215,10 +247,9 @@ SourceTreeItem::onDynamicPlaylistLoaded( DynamicPlaylistRevision revision )
|
||||
qlonglong piptr = pi->data( DynamicPlaylistPointer ).toLongLong();
|
||||
playlist_ptr* pl = reinterpret_cast<playlist_ptr*>(piptr);
|
||||
SourcesModel::SourceType type = static_cast<SourcesModel::SourceType>( pi->data( Type ).toInt() );
|
||||
// qDebug() << "found dynamic playlist:" << (*pl)->title() << type;
|
||||
|
||||
if ( type == SourcesModel::DynamicPlaylistSource && ptr == qlonglong( pl->data() ) )
|
||||
{
|
||||
//qDebug() << "Found dynamicplaylist!";
|
||||
pi->setEnabled( true );
|
||||
m_current_dynamic_revisions.insert( pl->data()->guid(), revision.revisionguid );
|
||||
}
|
||||
@ -235,10 +266,10 @@ void SourceTreeItem::playlistAddedInternal( qlonglong ptr, const Tomahawk::playl
|
||||
subitem->setData( ptr, dynamic ? DynamicPlaylistPointer : PlaylistPointer );
|
||||
subitem->setData( dynamic ? SourcesModel::DynamicPlaylistSource : SourcesModel::PlaylistSource, Type );
|
||||
subitem->setData( (qlonglong)this, SourceItemPointer );
|
||||
|
||||
|
||||
m_columns.at( 0 )->appendRow( subitem );
|
||||
// Q_ASSERT( qobject_cast<QTreeView*>((parent()->parent()) ) );
|
||||
// qobject_cast<QTreeView*>((parent()->parent()))->expandAll();
|
||||
|
||||
|
||||
p->loadRevision();
|
||||
}
|
||||
|
@ -47,13 +47,15 @@ private slots:
|
||||
void onPlaylistsAdded( const QList<Tomahawk::playlist_ptr>& playlists );
|
||||
void onPlaylistsDeleted( const QList<Tomahawk::playlist_ptr>& playlists );
|
||||
void onPlaylistLoaded( Tomahawk::PlaylistRevision revision );
|
||||
|
||||
void onPlaylistChanged();
|
||||
|
||||
void onDynamicPlaylistsAdded( const QList<Tomahawk::dynplaylist_ptr>& playlists );
|
||||
void onDynamicPlaylistsDeleted( const QList<Tomahawk::dynplaylist_ptr>& playlists );
|
||||
void onDynamicPlaylistLoaded( Tomahawk::DynamicPlaylistRevision revision );
|
||||
|
||||
private:
|
||||
void playlistAddedInternal( qlonglong ptr, const Tomahawk::playlist_ptr& pl, bool dynamic );
|
||||
|
||||
|
||||
QList<QStandardItem*> m_columns;
|
||||
Tomahawk::source_ptr m_source;
|
||||
SourceTreeItemWidget* m_widget;
|
||||
|
Loading…
x
Reference in New Issue
Block a user