Merge branch 'master' into jreen-tpqt4-comp
2
.gitignore
vendored
@@ -10,3 +10,5 @@ moc_*
|
|||||||
*~
|
*~
|
||||||
/tomahawk
|
/tomahawk
|
||||||
thirdparty/qtweetlib/WARNING-twitter-api-keys
|
thirdparty/qtweetlib/WARNING-twitter-api-keys
|
||||||
|
.kdev4
|
||||||
|
tomahawk.kdev4
|
||||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 110 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 2.5 KiB |
@@ -36,7 +36,7 @@ namespace InfoSystem {
|
|||||||
class InfoSystemCache;
|
class InfoSystemCache;
|
||||||
|
|
||||||
enum InfoType {
|
enum InfoType {
|
||||||
InfoTrackID,
|
InfoTrackID = 0,
|
||||||
InfoTrackArtist,
|
InfoTrackArtist,
|
||||||
InfoTrackAlbum,
|
InfoTrackAlbum,
|
||||||
InfoTrackGenre,
|
InfoTrackGenre,
|
||||||
|
@@ -17,29 +17,128 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include "infosystemcache.h"
|
#include "infosystemcache.h"
|
||||||
|
|
||||||
void
|
|
||||||
Tomahawk::InfoSystem::InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace InfoSystem
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
InfoSystemCache::InfoSystemCache( QObject* parent )
|
||||||
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if( !m_memCache.contains( type ) || !m_memCache[type].contains( criteria ) )
|
QString cacheBaseDir = QDesktopServices::storageLocation( QDesktopServices::CacheLocation );
|
||||||
|
for( int i = 0; i <= InfoNoInfo; i++ )
|
||||||
|
{
|
||||||
|
InfoType type = (InfoType)(i);
|
||||||
|
if( m_dirtySet.contains( type ) && m_dataCache.contains( type ) )
|
||||||
|
{
|
||||||
|
QString cacheDir = cacheBaseDir + QString::number( i );
|
||||||
|
QDir dir( cacheDir );
|
||||||
|
if( dir.exists() && QFile::exists( QString( cacheDir + '/' + QString::number( i ) ) ) )
|
||||||
|
loadCache( type, QString( cacheDir + '/' + QString::number( i ) ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InfoSystemCache::~InfoSystemCache()
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
qDebug() << "Saving infosystemcache to disk";
|
||||||
|
QString cacheBaseDir = QDesktopServices::storageLocation( QDesktopServices::CacheLocation );
|
||||||
|
for( int i = 0; i <= InfoNoInfo; i++ )
|
||||||
|
{
|
||||||
|
InfoType type = (InfoType)(i);
|
||||||
|
if( m_dirtySet.contains( type ) && m_dataCache.contains( type ) )
|
||||||
|
{
|
||||||
|
QString cacheDir = cacheBaseDir + QString::number( i );
|
||||||
|
saveCache( type, cacheDir );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
if( !m_dataCache.contains( type ) || !m_dataCache[type].contains( criteria ) )
|
||||||
{
|
{
|
||||||
emit notInCache( criteria, caller, type, input, customData );
|
emit notInCache( criteria, caller, type, input, customData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit info( caller, type, input, m_memCache[type][criteria], customData );
|
emit info( caller, type, input, m_dataCache[type][criteria], customData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Tomahawk::InfoSystem::InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output )
|
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
QHash< InfoCacheCriteria, QVariant > typecache;
|
QHash< InfoCacheCriteria, QVariant > typedatacache;
|
||||||
if( m_memCache.contains( type ) )
|
QHash< InfoCacheCriteria, QDateTime > typetimecache;
|
||||||
typecache = m_memCache[type];
|
typedatacache[criteria] = output;
|
||||||
typecache[criteria] = output;
|
typetimecache[criteria] = QDateTime::currentDateTimeUtc();
|
||||||
m_memCache[type] = typecache;
|
m_dataCache[type] = typedatacache;
|
||||||
|
m_timeCache[type] = typetimecache;
|
||||||
|
m_dirtySet.insert( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InfoSystemCache::loadCache( InfoType type, const QString &cacheDir )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InfoSystemCache::saveCache( InfoType type, const QString &cacheDir )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
QDir dir( cacheDir );
|
||||||
|
if( !dir.exists( cacheDir ) )
|
||||||
|
{
|
||||||
|
qDebug() << "Creating cache directory " << cacheDir;
|
||||||
|
if( !dir.mkpath( cacheDir ) )
|
||||||
|
{
|
||||||
|
qDebug() << "Failed to create cache dir! Bailing...";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QSettings cacheFile( QString( cacheDir + '/' + QString::number( (int)type ) ), QSettings::IniFormat );
|
||||||
|
|
||||||
|
foreach( InfoCacheCriteria criteria, m_dataCache[type].keys() )
|
||||||
|
{
|
||||||
|
cacheFile.beginGroup( "type_" + QString::number( type ) );
|
||||||
|
cacheFile.beginWriteArray( "criteria" );
|
||||||
|
QStringList keys = criteria.keys();
|
||||||
|
for( int i = 0; i < criteria.size(); i++ )
|
||||||
|
{
|
||||||
|
cacheFile.setArrayIndex( i );
|
||||||
|
cacheFile.setValue( keys.at( i ), criteria[keys.at( i )] );
|
||||||
|
}
|
||||||
|
cacheFile.endArray();
|
||||||
|
cacheFile.setValue( "data", m_dataCache[type][criteria] );
|
||||||
|
cacheFile.setValue( "time", m_timeCache[type][criteria] );
|
||||||
|
cacheFile.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_dirtySet.remove( type );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} //namespace InfoSystem
|
||||||
|
|
||||||
|
} //namespace Tomahawk
|
@@ -19,6 +19,7 @@
|
|||||||
#ifndef TOMAHAWK_INFOSYSTEMCACHE_H
|
#ifndef TOMAHAWK_INFOSYSTEMCACHE_H
|
||||||
#define TOMAHAWK_INFOSYSTEMCACHE_H
|
#define TOMAHAWK_INFOSYSTEMCACHE_H
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
@@ -35,16 +36,9 @@ class InfoSystemCache : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InfoSystemCache( QObject *parent = 0 )
|
InfoSystemCache( QObject *parent = 0 );
|
||||||
: QObject( parent )
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~InfoSystemCache()
|
virtual ~InfoSystemCache();
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void notInCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
void notInCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||||
@@ -55,7 +49,12 @@ public slots:
|
|||||||
void updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
void updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash< InfoType, QHash< InfoCacheCriteria, QVariant > > m_memCache;
|
void loadCache( InfoType type, const QString &cache );
|
||||||
|
void saveCache( InfoType type, const QString &cache );
|
||||||
|
|
||||||
|
QHash< InfoType, QHash< InfoCacheCriteria, QVariant > > m_dataCache;
|
||||||
|
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_timeCache;
|
||||||
|
QSet< InfoType > m_dirtySet;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace InfoSystem
|
} //namespace InfoSystem
|
||||||
|
@@ -78,7 +78,6 @@ set( libSources
|
|||||||
playlist/collectionflatmodel.cpp
|
playlist/collectionflatmodel.cpp
|
||||||
playlist/collectionview.cpp
|
playlist/collectionview.cpp
|
||||||
playlist/playlistmanager.cpp
|
playlist/playlistmanager.cpp
|
||||||
playlist/plitem.cpp
|
|
||||||
playlist/playlistmodel.cpp
|
playlist/playlistmodel.cpp
|
||||||
playlist/playlistproxymodel.cpp
|
playlist/playlistproxymodel.cpp
|
||||||
playlist/playlistview.cpp
|
playlist/playlistview.cpp
|
||||||
@@ -86,6 +85,7 @@ set( libSources
|
|||||||
playlist/queueproxymodel.cpp
|
playlist/queueproxymodel.cpp
|
||||||
playlist/queueview.cpp
|
playlist/queueview.cpp
|
||||||
playlist/trackmodel.cpp
|
playlist/trackmodel.cpp
|
||||||
|
playlist/trackmodelitem.cpp
|
||||||
playlist/trackproxymodel.cpp
|
playlist/trackproxymodel.cpp
|
||||||
playlist/trackview.cpp
|
playlist/trackview.cpp
|
||||||
playlist/trackheader.cpp
|
playlist/trackheader.cpp
|
||||||
@@ -232,7 +232,6 @@ set( libHeaders
|
|||||||
playlist/collectionflatmodel.h
|
playlist/collectionflatmodel.h
|
||||||
playlist/collectionview.h
|
playlist/collectionview.h
|
||||||
playlist/playlistmanager.h
|
playlist/playlistmanager.h
|
||||||
playlist/plitem.h
|
|
||||||
playlist/playlistmodel.h
|
playlist/playlistmodel.h
|
||||||
playlist/playlistproxymodel.h
|
playlist/playlistproxymodel.h
|
||||||
playlist/playlistview.h
|
playlist/playlistview.h
|
||||||
@@ -240,6 +239,7 @@ set( libHeaders
|
|||||||
playlist/queueproxymodel.h
|
playlist/queueproxymodel.h
|
||||||
playlist/queueview.h
|
playlist/queueview.h
|
||||||
playlist/trackmodel.h
|
playlist/trackmodel.h
|
||||||
|
playlist/trackmodelitem.h
|
||||||
playlist/trackproxymodel.h
|
playlist/trackproxymodel.h
|
||||||
playlist/trackview.h
|
playlist/trackview.h
|
||||||
playlist/trackheader.h
|
playlist/trackheader.h
|
||||||
|
@@ -138,7 +138,8 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
QList<Tomahawk::result_ptr> results;
|
QList<Tomahawk::result_ptr> results;
|
||||||
results << result;
|
results << result;
|
||||||
qry->addResults( results );
|
qry->addResults( results );
|
||||||
|
qry->setResolveFinished( true );
|
||||||
|
|
||||||
ql << qry;
|
ql << qry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -229,6 +229,8 @@ Playlist::reportDeleted( const Tomahawk::playlist_ptr& self )
|
|||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
Q_ASSERT( self.data() == this );
|
Q_ASSERT( self.data() == this );
|
||||||
m_source->collection()->deletePlaylist( self );
|
m_source->collection()->deletePlaylist( self );
|
||||||
|
|
||||||
|
emit deleted( self );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -182,6 +182,9 @@ signals:
|
|||||||
/// renamed etc.
|
/// renamed etc.
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
/// was deleted, eh?
|
||||||
|
void deleted( const Tomahawk::playlist_ptr& pl );
|
||||||
|
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -42,11 +42,11 @@ CollectionFlatModel::~CollectionFlatModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CollectionFlatModel::addCollections( const QList< collection_ptr >& collections )
|
CollectionFlatModel::addCollections( const QList< collection_ptr >& collections )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Adding collections!";
|
qDebug() << Q_FUNC_INFO << "Adding collections!";
|
||||||
foreach( const collection_ptr& col, collections )
|
foreach( const collection_ptr& col, collections )
|
||||||
{
|
{
|
||||||
addCollection( col );
|
addCollection( col );
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ CollectionFlatModel::removeCollection( const collection_ptr& collection )
|
|||||||
QTime timer;
|
QTime timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
// QList<PlItem*> plitems = m_collectionIndex.values( collection );
|
// QList<TrackModelItem*> plitems = m_collectionIndex.values( collection );
|
||||||
QList< QPair< int, int > > rows;
|
QList< QPair< int, int > > rows;
|
||||||
QList< QPair< int, int > > sortrows;
|
QList< QPair< int, int > > sortrows;
|
||||||
QPair< int, int > row;
|
QPair< int, int > row;
|
||||||
@@ -167,7 +167,7 @@ CollectionFlatModel::removeCollection( const collection_ptr& collection )
|
|||||||
emit beginRemoveRows( QModelIndex(), row.first, row.second );
|
emit beginRemoveRows( QModelIndex(), row.first, row.second );
|
||||||
for ( int i = row.second; i >= row.first; i-- )
|
for ( int i = row.second; i >= row.first; i-- )
|
||||||
{
|
{
|
||||||
PlItem* item = itemFromIndex( index( i, 0, QModelIndex() ) );
|
TrackModelItem* item = itemFromIndex( index( i, 0, QModelIndex() ) );
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
emit endRemoveRows();
|
emit endRemoveRows();
|
||||||
@@ -212,12 +212,12 @@ CollectionFlatModel::processTracksToAdd()
|
|||||||
emit beginInsertRows( QModelIndex(), c, c + maxc - 1 );
|
emit beginInsertRows( QModelIndex(), c, c + maxc - 1 );
|
||||||
//beginResetModel();
|
//beginResetModel();
|
||||||
|
|
||||||
PlItem* plitem;
|
TrackModelItem* plitem;
|
||||||
QList< Tomahawk::query_ptr >::iterator iter = m_tracksToAdd.begin();
|
QList< Tomahawk::query_ptr >::iterator iter = m_tracksToAdd.begin();
|
||||||
|
|
||||||
for( int i = 0; i < maxc; ++i )
|
for( int i = 0; i < maxc; ++i )
|
||||||
{
|
{
|
||||||
plitem = new PlItem( *iter, m_rootItem );
|
plitem = new TrackModelItem( *iter, m_rootItem );
|
||||||
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
||||||
|
|
||||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||||
@@ -245,7 +245,7 @@ CollectionFlatModel::onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks )
|
|||||||
QList<Tomahawk::query_ptr> t = tracks;
|
QList<Tomahawk::query_ptr> t = tracks;
|
||||||
for ( int i = rowCount( QModelIndex() ); i >= 0 && t.count(); i-- )
|
for ( int i = rowCount( QModelIndex() ); i >= 0 && t.count(); i-- )
|
||||||
{
|
{
|
||||||
PlItem* item = itemFromIndex( index( i, 0, QModelIndex() ) );
|
TrackModelItem* item = itemFromIndex( index( i, 0, QModelIndex() ) );
|
||||||
if ( !item )
|
if ( !item )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ CollectionFlatModel::onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks )
|
|||||||
void
|
void
|
||||||
CollectionFlatModel::onDataChanged()
|
CollectionFlatModel::onDataChanged()
|
||||||
{
|
{
|
||||||
PlItem* p = (PlItem*)sender();
|
TrackModelItem* p = (TrackModelItem*)sender();
|
||||||
// emit itemSizeChanged( p->index );
|
// emit itemSizeChanged( p->index );
|
||||||
|
|
||||||
if ( p )
|
if ( p )
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include "plitem.h"
|
#include "trackmodelitem.h"
|
||||||
#include "trackmodel.h"
|
#include "trackmodel.h"
|
||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -40,7 +40,6 @@ CollectionModel::CollectionModel( QObject* parent )
|
|||||||
|
|
||||||
CollectionModel::~CollectionModel()
|
CollectionModel::~CollectionModel()
|
||||||
{
|
{
|
||||||
// delete m_rootItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -50,8 +49,8 @@ CollectionModel::index( int row, int column, const QModelIndex& parent ) const
|
|||||||
if ( !m_rootItem || row < 0 || column < 0 )
|
if ( !m_rootItem || row < 0 || column < 0 )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* parentItem = itemFromIndex( parent );
|
TrackModelItem* parentItem = itemFromIndex( parent );
|
||||||
PlItem* childItem = parentItem->children.value( row );
|
TrackModelItem* childItem = parentItem->children.value( row );
|
||||||
if ( !childItem )
|
if ( !childItem )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ CollectionModel::rowCount( const QModelIndex& parent ) const
|
|||||||
if ( parent.column() > 0 )
|
if ( parent.column() > 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
PlItem* parentItem = itemFromIndex( parent );
|
TrackModelItem* parentItem = itemFromIndex( parent );
|
||||||
if ( !parentItem )
|
if ( !parentItem )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -83,15 +82,15 @@ CollectionModel::columnCount( const QModelIndex& parent ) const
|
|||||||
QModelIndex
|
QModelIndex
|
||||||
CollectionModel::parent( const QModelIndex& child ) const
|
CollectionModel::parent( const QModelIndex& child ) const
|
||||||
{
|
{
|
||||||
PlItem* entry = itemFromIndex( child );
|
TrackModelItem* entry = itemFromIndex( child );
|
||||||
if ( !entry )
|
if ( !entry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* parentEntry = entry->parent;
|
TrackModelItem* parentEntry = entry->parent;
|
||||||
if ( !parentEntry )
|
if ( !parentEntry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* grandparentEntry = parentEntry->parent;
|
TrackModelItem* grandparentEntry = parentEntry->parent;
|
||||||
if ( !grandparentEntry )
|
if ( !grandparentEntry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
@@ -106,7 +105,7 @@ CollectionModel::data( const QModelIndex& index, int role ) const
|
|||||||
if ( role != Qt::DisplayRole )
|
if ( role != Qt::DisplayRole )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
PlItem* entry = itemFromIndex( index );
|
TrackModelItem* entry = itemFromIndex( index );
|
||||||
if ( !entry )
|
if ( !entry )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@@ -199,7 +198,7 @@ CollectionModel::removeCollection( const collection_ptr& collection )
|
|||||||
disconnect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
|
disconnect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
|
||||||
this, SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
|
this, SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
|
||||||
|
|
||||||
QList<PlItem*> plitems = m_collectionIndex.values( collection );
|
QList<TrackModelItem*> plitems = m_collectionIndex.values( collection );
|
||||||
|
|
||||||
m_collectionIndex.remove( collection );
|
m_collectionIndex.remove( collection );
|
||||||
}
|
}
|
||||||
@@ -210,17 +209,17 @@ CollectionModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const
|
|||||||
{
|
{
|
||||||
// int c = rowCount( QModelIndex() );
|
// int c = rowCount( QModelIndex() );
|
||||||
|
|
||||||
PlItem* plitem;
|
TrackModelItem* plitem;
|
||||||
foreach( const Tomahawk::query_ptr& query, tracks )
|
foreach( const Tomahawk::query_ptr& query, tracks )
|
||||||
{
|
{
|
||||||
PlItem* parent = m_rootItem;
|
TrackModelItem* parent = m_rootItem;
|
||||||
if ( parent->hash.contains( query->artist() ) )
|
if ( parent->hash.contains( query->artist() ) )
|
||||||
{
|
{
|
||||||
parent = parent->hash.value( query->artist() );
|
parent = parent->hash.value( query->artist() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parent = new PlItem( query->artist(), m_rootItem );
|
parent = new TrackModelItem( query->artist(), m_rootItem );
|
||||||
m_rootItem->hash.insert( query->artist(), parent );
|
m_rootItem->hash.insert( query->artist(), parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,14 +231,14 @@ CollectionModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlItem* subitem = new PlItem( query->album(), parent );
|
TrackModelItem* subitem = new TrackModelItem( query->album(), parent );
|
||||||
parent->hash.insert( query->album(), subitem );
|
parent->hash.insert( query->album(), subitem );
|
||||||
parent->childCount++;
|
parent->childCount++;
|
||||||
subitem->childCount++;
|
subitem->childCount++;
|
||||||
parent = subitem;
|
parent = subitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
plitem = new PlItem( query, parent );
|
plitem = new TrackModelItem( query, parent );
|
||||||
m_collectionIndex.insertMulti( collection, plitem );
|
m_collectionIndex.insertMulti( collection, plitem );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,11 +274,11 @@ CollectionModel::onSourceOffline( Tomahawk::source_ptr src )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem*
|
TrackModelItem*
|
||||||
CollectionModel::itemFromIndex( const QModelIndex& index ) const
|
CollectionModel::itemFromIndex( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
if ( index.isValid() )
|
if ( index.isValid() )
|
||||||
return static_cast<PlItem*>( index.internalPointer() );
|
return static_cast<TrackModelItem*>( index.internalPointer() );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_rootItem;
|
return m_rootItem;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include "plitem.h"
|
#include "trackmodelitem.h"
|
||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode mode ) {}
|
virtual void setRepeatMode( PlaylistInterface::RepeatMode mode ) {}
|
||||||
virtual void setShuffled( bool shuffled ) {}
|
virtual void setShuffled( bool shuffled ) {}
|
||||||
|
|
||||||
PlItem* itemFromIndex( const QModelIndex& index ) const;
|
TrackModelItem* itemFromIndex( const QModelIndex& index ) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
@@ -79,8 +79,8 @@ private slots:
|
|||||||
void onSourceOffline( Tomahawk::source_ptr src );
|
void onSourceOffline( Tomahawk::source_ptr src );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlItem* m_rootItem;
|
TrackModelItem* m_rootItem;
|
||||||
QMap< Tomahawk::collection_ptr, PlItem* > m_collectionIndex;
|
QMap< Tomahawk::collection_ptr, TrackModelItem* > m_collectionIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COLLECTIONMODEL_H
|
#endif // COLLECTIONMODEL_H
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -35,8 +35,8 @@ CollectionProxyModel::CollectionProxyModel( QObject* parent )
|
|||||||
bool
|
bool
|
||||||
CollectionProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
|
CollectionProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
|
||||||
{
|
{
|
||||||
PlItem* p1 = itemFromIndex( left );
|
TrackModelItem* p1 = itemFromIndex( left );
|
||||||
PlItem* p2 = itemFromIndex( right );
|
TrackModelItem* p2 = itemFromIndex( right );
|
||||||
|
|
||||||
if ( !p1 )
|
if ( !p1 )
|
||||||
return true;
|
return true;
|
||||||
|
@@ -265,6 +265,8 @@ DynamicPlaylist::reportDeleted( const Tomahawk::dynplaylist_ptr& self )
|
|||||||
Q_ASSERT( self.data() == this );
|
Q_ASSERT( self.data() == this );
|
||||||
// will emit Collection::playlistDeleted(...)
|
// will emit Collection::playlistDeleted(...)
|
||||||
author()->collection()->deleteDynamicPlaylist( self );
|
author()->collection()->deleteDynamicPlaylist( self );
|
||||||
|
|
||||||
|
emit deleted( self );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPlaylist::addEntries(const QList< query_ptr >& queries, const QString& oldrev)
|
void DynamicPlaylist::addEntries(const QList< query_ptr >& queries, const QString& oldrev)
|
||||||
|
@@ -113,6 +113,8 @@ signals:
|
|||||||
/// emitted when the playlist revision changes (whenever the playlist changes)
|
/// emitted when the playlist revision changes (whenever the playlist changes)
|
||||||
void dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision );
|
void dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision );
|
||||||
|
|
||||||
|
void deleted( const Tomahawk::dynplaylist_ptr& pl );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// want to update the playlist from the model?
|
// want to update the playlist from the model?
|
||||||
// generate a newrev using uuid() and call this:
|
// generate a newrev using uuid() and call this:
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -58,30 +58,30 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
|||||||
, m_controls( 0 )
|
, m_controls( 0 )
|
||||||
, m_view( 0 )
|
, m_view( 0 )
|
||||||
, m_model()
|
, m_model()
|
||||||
{
|
{
|
||||||
m_controls = new CollapsibleControls( this );
|
m_controls = new CollapsibleControls( this );
|
||||||
m_layout->addWidget( m_controls );
|
m_layout->addWidget( m_controls );
|
||||||
setContentsMargins( 0, 0, 0, 1 ); // to align the bottom with the bottom of the sourcelist
|
setContentsMargins( 0, 0, 0, 1 ); // to align the bottom with the bottom of the sourcelist
|
||||||
|
|
||||||
m_model = new DynamicModel( this );
|
m_model = new DynamicModel( this );
|
||||||
m_view = new DynamicView( this );
|
m_view = new DynamicView( this );
|
||||||
m_view->setModel( m_model );
|
m_view->setModel( m_model );
|
||||||
m_view->setContentsMargins( 0, 0, 0, 0 );
|
m_view->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_layout->addWidget( m_view, 1 );
|
m_layout->addWidget( m_view, 1 );
|
||||||
|
|
||||||
connect( m_model, SIGNAL( collapseFromTo( int, int ) ), m_view, SLOT( collapseEntries( int, int ) ) );
|
connect( m_model, SIGNAL( collapseFromTo( int, int ) ), m_view, SLOT( collapseEntries( int, int ) ) );
|
||||||
connect( m_model, SIGNAL( trackGenerationFailure( QString ) ), this, SLOT( stationFailed( QString ) ) );
|
connect( m_model, SIGNAL( trackGenerationFailure( QString ) ), this, SLOT( stationFailed( QString ) ) );
|
||||||
|
|
||||||
m_loading = new LoadingSpinner( m_view );
|
m_loading = new LoadingSpinner( m_view );
|
||||||
connect( m_model, SIGNAL( tracksAdded() ), m_loading, SLOT( fadeOut() ) );
|
connect( m_model, SIGNAL( tracksAdded() ), m_loading, SLOT( fadeOut() ) );
|
||||||
|
|
||||||
m_setup = new DynamicSetupWidget( playlist, this );
|
m_setup = new DynamicSetupWidget( playlist, this );
|
||||||
m_setup->fadeIn();
|
m_setup->fadeIn();
|
||||||
|
|
||||||
connect( m_model, SIGNAL( tracksAdded() ), this, SLOT( tracksAdded() ) );
|
connect( m_model, SIGNAL( tracksAdded() ), this, SLOT( tracksAdded() ) );
|
||||||
|
|
||||||
loadDynamicPlaylist( playlist );
|
loadDynamicPlaylist( playlist );
|
||||||
|
|
||||||
m_layout->setContentsMargins( 0, 0, 0, 0 );
|
m_layout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_layout->setMargin( 0 );
|
m_layout->setMargin( 0 );
|
||||||
m_layout->setSpacing( 0 );
|
m_layout->setSpacing( 0 );
|
||||||
@@ -103,7 +103,7 @@ DynamicWidget::~DynamicWidget()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::loadDynamicPlaylist( const Tomahawk::dynplaylist_ptr& playlist )
|
DynamicWidget::loadDynamicPlaylist( const Tomahawk::dynplaylist_ptr& playlist )
|
||||||
{
|
{
|
||||||
// special case: if we have launched multiple setRevision calls, and the number of controls is different, it means that we're getting an intermediate setRevision
|
// special case: if we have launched multiple setRevision calls, and the number of controls is different, it means that we're getting an intermediate setRevision
|
||||||
@@ -114,59 +114,61 @@ DynamicWidget::loadDynamicPlaylist( const Tomahawk::dynplaylist_ptr& playlist )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_seqRevLaunched = 0;
|
m_seqRevLaunched = 0;
|
||||||
|
|
||||||
// if we're being told to load the same dynamic playlist over again, only do it if the controls have a different number
|
// if we're being told to load the same dynamic playlist over again, only do it if the controls have a different number
|
||||||
if( !m_playlist.isNull() && ( m_playlist.data() == playlist.data() ) // same playlist pointer
|
if( !m_playlist.isNull() && ( m_playlist.data() == playlist.data() ) // same playlist pointer
|
||||||
&& m_playlist->generator()->controls().size() == playlist->generator()->controls().size() ) {
|
&& m_playlist->generator()->controls().size() == playlist->generator()->controls().size() ) {
|
||||||
// we can skip our work. just let the dynamiccontrollist show the difference
|
// we can skip our work. just let the dynamiccontrollist show the difference
|
||||||
m_controls->setControls( m_playlist, m_playlist->author()->isLocal() );
|
m_controls->setControls( m_playlist, m_playlist->author()->isLocal() );
|
||||||
|
|
||||||
m_playlist = playlist;
|
m_playlist = playlist;
|
||||||
|
|
||||||
if( !m_runningOnDemand ) {
|
if( !m_runningOnDemand ) {
|
||||||
m_model->loadPlaylist( m_playlist );
|
m_model->loadPlaylist( m_playlist );
|
||||||
} else if( !m_controlsChanged ) { // if the controls changed, we already dealt with that and don't want to change station yet
|
} else if( !m_controlsChanged ) { // if the controls changed, we already dealt with that and don't want to change station yet
|
||||||
m_model->changeStation();
|
m_model->changeStation();
|
||||||
}
|
}
|
||||||
m_controlsChanged = false;
|
m_controlsChanged = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !m_playlist.isNull() ) {
|
if( !m_playlist.isNull() ) {
|
||||||
disconnect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
disconnect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
||||||
disconnect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ), this, SLOT(onRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ) );
|
disconnect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ), this, SLOT(onRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ) );
|
||||||
disconnect( m_playlist->generator().data(), SIGNAL( error( QString, QString ) ), this, SLOT( generatorError( QString, QString ) ) );
|
disconnect( m_playlist->generator().data(), SIGNAL( error( QString, QString ) ), this, SLOT( generatorError( QString, QString ) ) );
|
||||||
|
disconnect( m_playlist.data(), SIGNAL( deleted( Tomahawk::dynplaylist_ptr ) ), this, SLOT( onDeleted() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_playlist = playlist;
|
m_playlist = playlist;
|
||||||
m_view->setOnDemand( m_playlist->mode() == OnDemand );
|
m_view->setOnDemand( m_playlist->mode() == OnDemand );
|
||||||
m_view->setReadOnly( !m_playlist->author()->isLocal() );
|
m_view->setReadOnly( !m_playlist->author()->isLocal() );
|
||||||
m_model->loadPlaylist( m_playlist );
|
m_model->loadPlaylist( m_playlist );
|
||||||
m_controlsChanged = false;
|
m_controlsChanged = false;
|
||||||
m_setup->setPlaylist( m_playlist );
|
m_setup->setPlaylist( m_playlist );
|
||||||
|
|
||||||
|
|
||||||
if( !m_playlist->author()->isLocal() ) { // hide controls, as we show the description in the summary
|
if( !m_playlist->author()->isLocal() ) { // hide controls, as we show the description in the summary
|
||||||
m_layout->removeWidget( m_controls );
|
m_layout->removeWidget( m_controls );
|
||||||
} else if( m_layout->indexOf( m_controls ) == -1 ) {
|
} else if( m_layout->indexOf( m_controls ) == -1 ) {
|
||||||
m_layout->insertWidget( 0, m_controls );
|
m_layout->insertWidget( 0, m_controls );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_playlist->mode() == OnDemand && !m_playlist->generator()->controls().isEmpty() )
|
if( m_playlist->mode() == OnDemand && !m_playlist->generator()->controls().isEmpty() )
|
||||||
showPreview();
|
showPreview();
|
||||||
|
|
||||||
if( !m_playlist.isNull() )
|
if( !m_playlist.isNull() )
|
||||||
m_controls->setControls( m_playlist, m_playlist->author()->isLocal() );
|
m_controls->setControls( m_playlist, m_playlist->author()->isLocal() );
|
||||||
|
|
||||||
connect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
connect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
||||||
connect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ) );
|
connect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ) );
|
||||||
connect( m_playlist->generator().data(), SIGNAL( error( QString, QString ) ), this, SLOT( generatorError( QString, QString ) ) );
|
connect( m_playlist->generator().data(), SIGNAL( error( QString, QString ) ), this, SLOT( generatorError( QString, QString ) ) );
|
||||||
|
connect( m_playlist.data(), SIGNAL( deleted( Tomahawk::dynplaylist_ptr ) ), this, SLOT( onDeleted() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev )
|
DynamicWidget::onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev )
|
||||||
{
|
{
|
||||||
qDebug() << "DynamicWidget::onRevisionLoaded";
|
qDebug() << "DynamicWidget::onRevisionLoaded";
|
||||||
@@ -178,7 +180,7 @@ DynamicWidget::onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistInterface*
|
PlaylistInterface*
|
||||||
DynamicWidget::playlistInterface() const
|
DynamicWidget::playlistInterface() const
|
||||||
{
|
{
|
||||||
return m_view->proxyModel();
|
return m_view->proxyModel();
|
||||||
@@ -192,36 +194,36 @@ DynamicWidget::sizeHint() const
|
|||||||
return QSize( 5000, 5000 );
|
return QSize( 5000, 5000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::resizeEvent(QResizeEvent* )
|
DynamicWidget::resizeEvent(QResizeEvent* )
|
||||||
{
|
{
|
||||||
layoutFloatingWidgets();
|
layoutFloatingWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::layoutFloatingWidgets()
|
DynamicWidget::layoutFloatingWidgets()
|
||||||
{
|
{
|
||||||
if( !m_runningOnDemand ) {
|
if( !m_runningOnDemand ) {
|
||||||
int x = ( width() / 2 ) - ( m_setup->size().width() / 2 );
|
int x = ( width() / 2 ) - ( m_setup->size().width() / 2 );
|
||||||
int y = height() - m_setup->size().height() - 40; // padding
|
int y = height() - m_setup->size().height() - 40; // padding
|
||||||
|
|
||||||
m_setup->move( x, y );
|
m_setup->move( x, y );
|
||||||
} else if( m_runningOnDemand && m_steering ) {
|
} else if( m_runningOnDemand && m_steering ) {
|
||||||
int x = ( width() / 2 ) - ( m_steering->size().width() / 2 );
|
int x = ( width() / 2 ) - ( m_steering->size().width() / 2 );
|
||||||
int y = height() - m_steering->size().height() - 40; // padding
|
int y = height() - m_steering->size().height() - 40; // padding
|
||||||
|
|
||||||
m_steering->move( x, y );
|
m_steering->move( x, y );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::playlistChanged( PlaylistInterface* pl )
|
DynamicWidget::playlistChanged( PlaylistInterface* pl )
|
||||||
{
|
{
|
||||||
if( pl == static_cast< PlaylistInterface* >( m_view->proxyModel() ) ) { // same playlist
|
if( pl == static_cast< PlaylistInterface* >( m_view->proxyModel() ) ) { // same playlist
|
||||||
m_activePlaylist = true;
|
m_activePlaylist = true;
|
||||||
} else {
|
} else {
|
||||||
m_activePlaylist = false;
|
m_activePlaylist = false;
|
||||||
|
|
||||||
// user started playing something somewhere else, so give it a rest
|
// user started playing something somewhere else, so give it a rest
|
||||||
if( m_runningOnDemand ) {
|
if( m_runningOnDemand ) {
|
||||||
stopStation( false );
|
stopStation( false );
|
||||||
@@ -229,7 +231,7 @@ DynamicWidget::playlistChanged( PlaylistInterface* pl )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::showEvent(QShowEvent* )
|
DynamicWidget::showEvent(QShowEvent* )
|
||||||
{
|
{
|
||||||
if( !m_playlist.isNull() && !m_runningOnDemand ) {
|
if( !m_playlist.isNull() && !m_runningOnDemand ) {
|
||||||
@@ -238,7 +240,7 @@ DynamicWidget::showEvent(QShowEvent* )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::generate( int num )
|
DynamicWidget::generate( int num )
|
||||||
{
|
{
|
||||||
// get the items from the generator, and put them in the playlist
|
// get the items from the generator, and put them in the playlist
|
||||||
@@ -247,27 +249,27 @@ DynamicWidget::generate( int num )
|
|||||||
m_playlist->generator()->generate( num );
|
m_playlist->generator()->generate( num );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::stationFailed( const QString& msg )
|
DynamicWidget::stationFailed( const QString& msg )
|
||||||
{
|
{
|
||||||
m_view->setDynamicWorking( false );
|
m_view->setDynamicWorking( false );
|
||||||
m_view->showMessage( msg );
|
m_view->showMessage( msg );
|
||||||
m_loading->fadeOut();
|
m_loading->fadeOut();
|
||||||
|
|
||||||
stopStation( false );
|
stopStation( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::trackStarted()
|
DynamicWidget::trackStarted()
|
||||||
{
|
{
|
||||||
if( m_activePlaylist && !m_playlist.isNull() &&
|
if( m_activePlaylist && !m_playlist.isNull() &&
|
||||||
m_playlist->mode() == OnDemand && !m_runningOnDemand ) {
|
m_playlist->mode() == OnDemand && !m_runningOnDemand ) {
|
||||||
|
|
||||||
startStation();
|
startStation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::tracksAdded()
|
DynamicWidget::tracksAdded()
|
||||||
{
|
{
|
||||||
if( m_playlist->mode() == OnDemand && m_runningOnDemand && m_setup->isVisible() )
|
if( m_playlist->mode() == OnDemand && m_runningOnDemand && m_setup->isVisible() )
|
||||||
@@ -275,94 +277,94 @@ DynamicWidget::tracksAdded()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::stopStation( bool stopPlaying )
|
DynamicWidget::stopStation( bool stopPlaying )
|
||||||
{
|
{
|
||||||
m_model->stopOnDemand( stopPlaying );
|
m_model->stopOnDemand( stopPlaying );
|
||||||
m_runningOnDemand = false;
|
m_runningOnDemand = false;
|
||||||
|
|
||||||
// TODO until i add a qwidget interface
|
// TODO until i add a qwidget interface
|
||||||
QMetaObject::invokeMethod( m_steering, "fadeOut", Qt::DirectConnection );
|
QMetaObject::invokeMethod( m_steering, "fadeOut", Qt::DirectConnection );
|
||||||
m_setup->fadeIn();
|
m_setup->fadeIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::startStation()
|
DynamicWidget::startStation()
|
||||||
{
|
{
|
||||||
m_runningOnDemand = true;
|
m_runningOnDemand = true;
|
||||||
m_model->startOnDemand();
|
m_model->startOnDemand();
|
||||||
|
|
||||||
m_setup->fadeOut();
|
m_setup->fadeOut();
|
||||||
// show the steering controls
|
// show the steering controls
|
||||||
if( m_playlist->generator()->onDemandSteerable() ) {
|
if( m_playlist->generator()->onDemandSteerable() ) {
|
||||||
// position it horizontally centered, above the botton.
|
// position it horizontally centered, above the botton.
|
||||||
m_steering = m_playlist->generator()->steeringWidget();
|
m_steering = m_playlist->generator()->steeringWidget();
|
||||||
Q_ASSERT( m_steering );
|
Q_ASSERT( m_steering );
|
||||||
|
|
||||||
int x = ( width() / 2 ) - ( m_steering->size().width() / 2 );
|
int x = ( width() / 2 ) - ( m_steering->size().width() / 2 );
|
||||||
int y = height() - m_steering->size().height() - 40; // padding
|
int y = height() - m_steering->size().height() - 40; // padding
|
||||||
|
|
||||||
m_steering->setParent( this );
|
m_steering->setParent( this );
|
||||||
m_steering->move( x, y );
|
m_steering->move( x, y );
|
||||||
|
|
||||||
// TODO until i add a qwidget interface
|
// TODO until i add a qwidget interface
|
||||||
QMetaObject::invokeMethod( m_steering, "fadeIn", Qt::DirectConnection );
|
QMetaObject::invokeMethod( m_steering, "fadeIn", Qt::DirectConnection );
|
||||||
|
|
||||||
connect( m_steering, SIGNAL( resized() ), this, SLOT( layoutFloatingWidgets() ) );
|
connect( m_steering, SIGNAL( resized() ), this, SLOT( layoutFloatingWidgets() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::playlistTypeChanged( QString )
|
DynamicWidget::playlistTypeChanged( QString )
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::tracksGenerated( const QList< query_ptr >& queries )
|
DynamicWidget::tracksGenerated( const QList< query_ptr >& queries )
|
||||||
{
|
{
|
||||||
int limit = -1; // only limit the "preview" of a station
|
int limit = -1; // only limit the "preview" of a station
|
||||||
if( m_playlist->author()->isLocal() && m_playlist->mode() == Static ) {
|
if( m_playlist->author()->isLocal() && m_playlist->mode() == Static ) {
|
||||||
m_resolveOnNextLoad = true;
|
m_resolveOnNextLoad = true;
|
||||||
} else if( m_playlist->mode() == OnDemand )
|
} else if( m_playlist->mode() == OnDemand )
|
||||||
limit = 5;
|
limit = 5;
|
||||||
|
|
||||||
if( m_playlist->mode() != OnDemand )
|
if( m_playlist->mode() != OnDemand )
|
||||||
m_loading->fadeOut();
|
m_loading->fadeOut();
|
||||||
m_model->tracksGenerated( queries, limit );
|
m_model->tracksGenerated( queries, limit );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::controlsChanged()
|
DynamicWidget::controlsChanged()
|
||||||
{
|
{
|
||||||
// controlsChanged() is emitted when a control is added or removed
|
// controlsChanged() is emitted when a control is added or removed
|
||||||
// in the case of addition, it's blank by default... so to avoid an error
|
// in the case of addition, it's blank by default... so to avoid an error
|
||||||
// when playing a station just ignore it till we're ready and get a controlChanged()
|
// when playing a station just ignore it till we're ready and get a controlChanged()
|
||||||
m_controlsChanged = true;
|
m_controlsChanged = true;
|
||||||
|
|
||||||
if( !m_playlist->author()->isLocal() )
|
if( !m_playlist->author()->isLocal() )
|
||||||
return;
|
return;
|
||||||
m_playlist->createNewRevision();
|
m_playlist->createNewRevision();
|
||||||
m_seqRevLaunched++;
|
m_seqRevLaunched++;
|
||||||
|
|
||||||
emit descriptionChanged( m_playlist->generator()->sentenceSummary() );
|
emit descriptionChanged( m_playlist->generator()->sentenceSummary() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::controlChanged( const Tomahawk::dyncontrol_ptr& control )
|
DynamicWidget::controlChanged( const Tomahawk::dyncontrol_ptr& control )
|
||||||
{
|
{
|
||||||
if( !m_playlist->author()->isLocal() )
|
if( !m_playlist->author()->isLocal() )
|
||||||
return;
|
return;
|
||||||
m_playlist->createNewRevision();
|
m_playlist->createNewRevision();
|
||||||
m_seqRevLaunched++;
|
m_seqRevLaunched++;
|
||||||
|
|
||||||
showPreview();
|
showPreview();
|
||||||
|
|
||||||
emit descriptionChanged( m_playlist->generator()->sentenceSummary() );
|
emit descriptionChanged( m_playlist->generator()->sentenceSummary() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::showPreview()
|
DynamicWidget::showPreview()
|
||||||
{
|
{
|
||||||
if( m_playlist->mode() == OnDemand && !m_runningOnDemand && m_model->rowCount( QModelIndex() ) == 0 ) { // if this is a not running station, preview matching tracks
|
if( m_playlist->mode() == OnDemand && !m_runningOnDemand && m_model->rowCount( QModelIndex() ) == 0 ) { // if this is a not running station, preview matching tracks
|
||||||
@@ -371,7 +373,7 @@ DynamicWidget::showPreview()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::generatorError( const QString& title, const QString& content )
|
DynamicWidget::generatorError( const QString& title, const QString& content )
|
||||||
{
|
{
|
||||||
if( m_runningOnDemand ) {
|
if( m_runningOnDemand ) {
|
||||||
@@ -384,17 +386,17 @@ DynamicWidget::generatorError( const QString& title, const QString& content )
|
|||||||
|
|
||||||
void
|
void
|
||||||
DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity )
|
DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity )
|
||||||
{
|
{
|
||||||
p.setBackgroundMode( Qt::TransparentMode );
|
p.setBackgroundMode( Qt::TransparentMode );
|
||||||
p.setRenderHint( QPainter::Antialiasing );
|
p.setRenderHint( QPainter::Antialiasing );
|
||||||
p.setOpacity( opacity );
|
p.setOpacity( opacity );
|
||||||
|
|
||||||
QPen pen( pal.dark().color(), .5 );
|
QPen pen( pal.dark().color(), .5 );
|
||||||
p.setPen( pen );
|
p.setPen( pen );
|
||||||
p.setBrush( pal.highlight() );
|
p.setBrush( pal.highlight() );
|
||||||
|
|
||||||
p.drawRoundedRect( r, 10, 10 );
|
p.drawRoundedRect( r, 10, 10 );
|
||||||
|
|
||||||
p.setOpacity( opacity + .2 );
|
p.setOpacity( opacity + .2 );
|
||||||
p.setBrush( QBrush() );
|
p.setBrush( QBrush() );
|
||||||
p.setPen( pen );
|
p.setPen( pen );
|
||||||
@@ -407,3 +409,10 @@ DynamicWidget::jumpToCurrentTrack()
|
|||||||
m_view->scrollTo( m_view->proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
m_view->scrollTo( m_view->proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicWidget::onDeleted()
|
||||||
|
{
|
||||||
|
emit destroyed( widget() );
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -58,57 +58,59 @@ class CollapsibleControls;
|
|||||||
*/
|
*/
|
||||||
class DynamicWidget : public QWidget, public Tomahawk::ViewPage
|
class DynamicWidget : public QWidget, public Tomahawk::ViewPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DynamicWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0);
|
explicit DynamicWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0);
|
||||||
virtual ~DynamicWidget();
|
virtual ~DynamicWidget();
|
||||||
|
|
||||||
void loadDynamicPlaylist( const dynplaylist_ptr& playlist );
|
void loadDynamicPlaylist( const dynplaylist_ptr& playlist );
|
||||||
|
|
||||||
virtual PlaylistInterface* playlistInterface() const;
|
virtual PlaylistInterface* playlistInterface() const;
|
||||||
|
|
||||||
virtual QSize sizeHint() const;
|
virtual QSize sizeHint() const;
|
||||||
virtual void resizeEvent( QResizeEvent* );
|
virtual void resizeEvent( QResizeEvent* );
|
||||||
virtual void showEvent(QShowEvent* );
|
virtual void showEvent(QShowEvent* );
|
||||||
|
|
||||||
static void paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity = .95 );
|
static void paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity = .95 );
|
||||||
|
|
||||||
virtual QWidget* widget() { return this; }
|
virtual QWidget* widget() { return this; }
|
||||||
|
|
||||||
virtual QString title() const { return m_model->title(); }
|
virtual QString title() const { return m_model->title(); }
|
||||||
virtual QString description() const { return m_model->description(); }
|
virtual QString description() const { return m_model->description(); }
|
||||||
virtual QPixmap pixmap() const { return QPixmap( RESPATH "images/playlist-icon.png" ); }
|
virtual QPixmap pixmap() const { return QPixmap( RESPATH "images/playlist-icon.png" ); }
|
||||||
|
|
||||||
virtual bool jumpToCurrentTrack();
|
virtual bool jumpToCurrentTrack();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev );
|
void onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev );
|
||||||
void playlistTypeChanged(QString);
|
void playlistTypeChanged(QString);
|
||||||
|
|
||||||
void startStation();
|
void startStation();
|
||||||
void stopStation( bool stopPlaying = true );
|
void stopStation( bool stopPlaying = true );
|
||||||
|
|
||||||
void trackStarted();
|
void trackStarted();
|
||||||
void stationFailed( const QString& );
|
void stationFailed( const QString& );
|
||||||
|
|
||||||
void playlistChanged( PlaylistInterface* );
|
void playlistChanged( PlaylistInterface* );
|
||||||
void tracksAdded();
|
void tracksAdded();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void descriptionChanged( const QString& caption );
|
void descriptionChanged( const QString& caption );
|
||||||
|
void destroyed( QWidget* widget );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void generate( int = -1 );
|
void generate( int = -1 );
|
||||||
void tracksGenerated( const QList< Tomahawk::query_ptr>& queries );
|
void tracksGenerated( const QList< Tomahawk::query_ptr>& queries );
|
||||||
void generatorError( const QString& title, const QString& content );
|
void generatorError( const QString& title, const QString& content );
|
||||||
|
|
||||||
void controlsChanged();
|
void controlsChanged();
|
||||||
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
|
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
|
||||||
void showPreview();
|
void showPreview();
|
||||||
|
|
||||||
void layoutFloatingWidgets();
|
|
||||||
|
|
||||||
private:
|
void layoutFloatingWidgets();
|
||||||
|
void onDeleted();
|
||||||
|
|
||||||
|
private:
|
||||||
dynplaylist_ptr m_playlist;
|
dynplaylist_ptr m_playlist;
|
||||||
QVBoxLayout* m_layout;
|
QVBoxLayout* m_layout;
|
||||||
bool m_resolveOnNextLoad;
|
bool m_resolveOnNextLoad;
|
||||||
@@ -117,17 +119,17 @@ private:
|
|||||||
|
|
||||||
// loading animation
|
// loading animation
|
||||||
LoadingSpinner* m_loading;
|
LoadingSpinner* m_loading;
|
||||||
|
|
||||||
// setup controls
|
// setup controls
|
||||||
DynamicSetupWidget* m_setup;
|
DynamicSetupWidget* m_setup;
|
||||||
|
|
||||||
// used in OnDemand mode
|
// used in OnDemand mode
|
||||||
bool m_runningOnDemand;
|
bool m_runningOnDemand;
|
||||||
bool m_controlsChanged;
|
bool m_controlsChanged;
|
||||||
QWidget* m_steering;
|
QWidget* m_steering;
|
||||||
|
|
||||||
CollapsibleControls* m_controls;
|
CollapsibleControls* m_controls;
|
||||||
|
|
||||||
DynamicView* m_view;
|
DynamicView* m_view;
|
||||||
DynamicModel* m_model;
|
DynamicModel* m_model;
|
||||||
};
|
};
|
||||||
|
@@ -81,7 +81,7 @@ LoadingSpinner::hideFinished()
|
|||||||
QSize
|
QSize
|
||||||
LoadingSpinner::sizeHint() const
|
LoadingSpinner::sizeHint() const
|
||||||
{
|
{
|
||||||
return QSize( 64, 64 );
|
return QSize( 31, 31 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -99,7 +99,7 @@ LoadingSpinner::reposition()
|
|||||||
int x = ( parentWidget()->width() / 2 ) - ( width() / 2 );
|
int x = ( parentWidget()->width() / 2 ) - ( width() / 2 );
|
||||||
int y = ( parentWidget()->height() / 2 ) - ( height() / 2 );
|
int y = ( parentWidget()->height() / 2 ) - ( height() / 2 );
|
||||||
move( x, y );
|
move( x, y );
|
||||||
resize( 64, 64 );
|
resize( 31, 31 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -24,10 +24,10 @@
|
|||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
|
|
||||||
#include "playlist/plitem.h"
|
#include "trackmodelitem.h"
|
||||||
#include "playlist/trackproxymodel.h"
|
#include "trackproxymodel.h"
|
||||||
#include "playlist/trackview.h"
|
#include "trackview.h"
|
||||||
#include "playlist/trackheader.h"
|
#include "trackheader.h"
|
||||||
|
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ PlaylistItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem&
|
|||||||
void
|
void
|
||||||
PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
PlItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
|
TrackModelItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
|
||||||
if ( !item || item->query().isNull() )
|
if ( !item || item->query().isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "playlistmanager.h"
|
#include "playlistmanager.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QMetaMethod>
|
||||||
|
|
||||||
#include "audio/audioengine.h"
|
#include "audio/audioengine.h"
|
||||||
#include "utils/animatedsplitter.h"
|
#include "utils/animatedsplitter.h"
|
||||||
@@ -167,7 +168,7 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
|||||||
{
|
{
|
||||||
view = m_playlistViews.value( playlist );
|
view = m_playlistViews.value( playlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
setPage( view );
|
setPage( view );
|
||||||
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
||||||
emit numSourcesChanged( SourceList::instance()->count() );
|
emit numSourcesChanged( SourceList::instance()->count() );
|
||||||
@@ -176,23 +177,25 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
||||||
{
|
{
|
||||||
if ( !m_dynamicWidgets.contains( playlist ) )
|
if ( !m_dynamicWidgets.contains( playlist ) )
|
||||||
{
|
{
|
||||||
m_dynamicWidgets[ playlist ] = new Tomahawk::DynamicWidget( playlist, m_stack );
|
m_dynamicWidgets[ playlist ] = new Tomahawk::DynamicWidget( playlist, m_stack );
|
||||||
|
|
||||||
|
connect( playlist.data(), SIGNAL( deleted( Tomahawk::dynplaylist_ptr ) ), this, SLOT( onDynamicDeleted( Tomahawk::dynplaylist_ptr ) ) );
|
||||||
|
|
||||||
playlist->resolve();
|
playlist->resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
setPage( m_dynamicWidgets.value( playlist ) );
|
setPage( m_dynamicWidgets.value( playlist ) );
|
||||||
|
|
||||||
if ( playlist->mode() == Tomahawk::OnDemand )
|
if ( playlist->mode() == Tomahawk::OnDemand )
|
||||||
m_queueView->hide();
|
m_queueView->hide();
|
||||||
else
|
else
|
||||||
m_queueView->show();
|
m_queueView->show();
|
||||||
|
|
||||||
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
||||||
emit numSourcesChanged( SourceList::instance()->count() );
|
emit numSourcesChanged( SourceList::instance()->count() );
|
||||||
|
|
||||||
@@ -220,7 +223,7 @@ PlaylistManager::show( const Tomahawk::artist_ptr& artist )
|
|||||||
{
|
{
|
||||||
view = m_artistViews.value( artist );
|
view = m_artistViews.value( artist );
|
||||||
}
|
}
|
||||||
|
|
||||||
setPage( view );
|
setPage( view );
|
||||||
emit numSourcesChanged( 1 );
|
emit numSourcesChanged( 1 );
|
||||||
|
|
||||||
@@ -247,7 +250,7 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
|
|||||||
{
|
{
|
||||||
view = m_albumViews.value( album );
|
view = m_albumViews.value( album );
|
||||||
}
|
}
|
||||||
|
|
||||||
setPage( view );
|
setPage( view );
|
||||||
emit numSourcesChanged( 1 );
|
emit numSourcesChanged( 1 );
|
||||||
|
|
||||||
@@ -334,11 +337,6 @@ PlaylistManager::show( const Tomahawk::source_ptr& source )
|
|||||||
bool
|
bool
|
||||||
PlaylistManager::show( ViewPage* page )
|
PlaylistManager::show( ViewPage* page )
|
||||||
{
|
{
|
||||||
if ( m_stack->indexOf( page->widget() ) < 0 )
|
|
||||||
{
|
|
||||||
connect( page->widget(), SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
setPage( page );
|
setPage( page );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -359,10 +357,10 @@ PlaylistManager::showSuperCollection()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_superCollectionFlatModel->addCollections( toAdd );
|
m_superCollectionFlatModel->addCollections( toAdd );
|
||||||
|
|
||||||
m_superCollectionFlatModel->setTitle( tr( "All available tracks" ) );
|
m_superCollectionFlatModel->setTitle( tr( "All available tracks" ) );
|
||||||
m_superAlbumModel->setTitle( tr( "All available albums" ) );
|
m_superAlbumModel->setTitle( tr( "All available albums" ) );
|
||||||
|
|
||||||
if ( m_currentMode == 0 )
|
if ( m_currentMode == 0 )
|
||||||
{
|
{
|
||||||
setPage( m_superCollectionView );
|
setPage( m_superCollectionView );
|
||||||
@@ -472,7 +470,7 @@ PlaylistManager::historyForward()
|
|||||||
{
|
{
|
||||||
if ( m_historyPosition >= m_pageHistory.count() - 1 )
|
if ( m_historyPosition >= m_pageHistory.count() - 1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
showHistory( m_historyPosition + 1 );
|
showHistory( m_historyPosition + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,6 +487,7 @@ PlaylistManager::showHistory( int historyPosition )
|
|||||||
|
|
||||||
setHistoryPosition( historyPosition );
|
setHistoryPosition( historyPosition );
|
||||||
ViewPage* page = m_pageHistory.at( historyPosition );
|
ViewPage* page = m_pageHistory.at( historyPosition );
|
||||||
|
qDebug() << "Showing page after a deleting:" << page->widget()->metaObject()->className();
|
||||||
setPage( page, false );
|
setPage( page, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,11 +538,11 @@ PlaylistManager::setPage( ViewPage* page, bool trackHistory )
|
|||||||
setHistoryPosition( m_pageHistory.count() - 1 );
|
setHistoryPosition( m_pageHistory.count() - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( playlistForInterface( currentPlaylistInterface() ) )
|
if ( !playlistForInterface( currentPlaylistInterface() ).isNull() )
|
||||||
emit playlistActivated( playlistForInterface( currentPlaylistInterface() ) );
|
emit playlistActivated( playlistForInterface( currentPlaylistInterface() ) );
|
||||||
if ( dynamicPlaylistForInterface( currentPlaylistInterface() ) )
|
if ( !dynamicPlaylistForInterface( currentPlaylistInterface() ).isNull() )
|
||||||
emit dynamicPlaylistActivated( dynamicPlaylistForInterface( currentPlaylistInterface() ) );
|
emit dynamicPlaylistActivated( dynamicPlaylistForInterface( currentPlaylistInterface() ) );
|
||||||
if ( collectionForInterface( currentPlaylistInterface() ) )
|
if ( !collectionForInterface( currentPlaylistInterface() ).isNull() )
|
||||||
emit collectionActivated( collectionForInterface( currentPlaylistInterface() ) );
|
emit collectionActivated( collectionForInterface( currentPlaylistInterface() ) );
|
||||||
if ( isSuperCollectionVisible() )
|
if ( isSuperCollectionVisible() )
|
||||||
emit superCollectionActivated();
|
emit superCollectionActivated();
|
||||||
@@ -554,12 +553,19 @@ PlaylistManager::setPage( ViewPage* page, bool trackHistory )
|
|||||||
AudioEngine::instance()->setPlaylist( currentPlaylistInterface() );
|
AudioEngine::instance()->setPlaylist( currentPlaylistInterface() );
|
||||||
|
|
||||||
// UGH!
|
// UGH!
|
||||||
if( QObject* obj = dynamic_cast< QObject* >( currentPage() ) ) {
|
if ( QObject* obj = dynamic_cast< QObject* >( currentPage() ) )
|
||||||
// qDebug() << SIGNAL( descriptionChanged( QString ) ) << QMetaObject::normalizedSignature( SIGNAL( descriptionChanged( QString ) ) ) << obj->metaObject()->indexOfSignal( QMetaObject::normalizedSignature( SIGNAL( descriptionChanged( QString ) ) ) );
|
{
|
||||||
// if( obj->metaObject()->indexOfSignal( QMetaObject::normalizedSignature( SIGNAL( descriptionChanged( QString ) ) ) ) > -1 ) // if the signal exists (just to hide the qobject runtime warning...)
|
// if the signal exists (just to hide the qobject runtime warning...)
|
||||||
connect( obj, SIGNAL( descriptionChanged( QString ) ), m_infobar, SLOT( setDescription( QString ) ) );
|
if( obj->metaObject()->indexOfSignal( "descriptionChanged(QString)" ) > -1 )
|
||||||
|
connect( obj, SIGNAL( descriptionChanged( QString ) ), m_infobar, SLOT( setDescription( QString ) ), Qt::UniqueConnection );
|
||||||
}
|
}
|
||||||
|
if ( QObject* obj = dynamic_cast< QObject* >( currentPage() ) )
|
||||||
|
{
|
||||||
|
// if the signal exists (just to hide the qobject runtime warning...)
|
||||||
|
if( obj->metaObject()->indexOfSignal( "destroyed(QWidget*)" ) > -1 )
|
||||||
|
connect( obj, SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ), Qt::UniqueConnection );
|
||||||
|
}
|
||||||
|
|
||||||
m_stack->setCurrentWidget( page->widget() );
|
m_stack->setCurrentWidget( page->widget() );
|
||||||
updateView();
|
updateView();
|
||||||
}
|
}
|
||||||
@@ -619,7 +625,7 @@ PlaylistManager::updateView()
|
|||||||
emit modeChanged( currentPlaylistInterface()->viewMode() );
|
emit modeChanged( currentPlaylistInterface()->viewMode() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( currentPage()->queueVisible() )
|
if ( currentPage()->queueVisible() )
|
||||||
m_queueView->show();
|
m_queueView->show();
|
||||||
else
|
else
|
||||||
m_queueView->hide();
|
m_queueView->hide();
|
||||||
@@ -641,14 +647,23 @@ PlaylistManager::updateView()
|
|||||||
void
|
void
|
||||||
PlaylistManager::onWidgetDestroyed( QWidget* widget )
|
PlaylistManager::onWidgetDestroyed( QWidget* widget )
|
||||||
{
|
{
|
||||||
qDebug() << "Destroyed child:" << widget;
|
qDebug() << "Destroyed child:" << widget << widget->metaObject()->className();
|
||||||
|
|
||||||
bool resetWidget = ( m_stack->currentWidget() == widget );
|
bool resetWidget = ( m_stack->currentWidget() == widget );
|
||||||
m_stack->removeWidget( widget );
|
|
||||||
|
|
||||||
for ( int i = 0; i < m_pageHistory.count(); i++ )
|
for ( int i = 0; i < m_pageHistory.count(); i++ )
|
||||||
{
|
{
|
||||||
ViewPage* page = m_pageHistory.at( i );
|
ViewPage* page = m_pageHistory.at( i );
|
||||||
|
|
||||||
|
if ( !playlistForInterface( page->playlistInterface() ).isNull() )
|
||||||
|
{
|
||||||
|
m_playlistViews.remove( playlistForInterface( page->playlistInterface() ) );
|
||||||
|
}
|
||||||
|
if ( !dynamicPlaylistForInterface( page->playlistInterface() ).isNull() )
|
||||||
|
{
|
||||||
|
m_dynamicWidgets.remove( dynamicPlaylistForInterface( page->playlistInterface() ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( page->widget() == widget )
|
if ( page->widget() == widget )
|
||||||
{
|
{
|
||||||
m_pageHistory.removeAt( i );
|
m_pageHistory.removeAt( i );
|
||||||
@@ -658,6 +673,8 @@ PlaylistManager::onWidgetDestroyed( QWidget* widget )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_stack->removeWidget( widget );
|
||||||
|
|
||||||
if ( resetWidget )
|
if ( resetWidget )
|
||||||
{
|
{
|
||||||
if ( m_pageHistory.count() )
|
if ( m_pageHistory.count() )
|
||||||
@@ -682,7 +699,7 @@ PlaylistManager::setShuffled( bool enabled )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistManager::createPlaylist( const Tomahawk::source_ptr& src,
|
PlaylistManager::createPlaylist( const Tomahawk::source_ptr& src,
|
||||||
const QVariant& contents )
|
const QVariant& contents )
|
||||||
{
|
{
|
||||||
@@ -692,7 +709,7 @@ PlaylistManager::createPlaylist( const Tomahawk::source_ptr& src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistManager::createDynamicPlaylist( const Tomahawk::source_ptr& src,
|
PlaylistManager::createDynamicPlaylist( const Tomahawk::source_ptr& src,
|
||||||
const QVariant& contents )
|
const QVariant& contents )
|
||||||
{
|
{
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -104,7 +104,7 @@ signals:
|
|||||||
void collectionActivated( const Tomahawk::collection_ptr& collection );
|
void collectionActivated( const Tomahawk::collection_ptr& collection );
|
||||||
void playlistActivated( const Tomahawk::playlist_ptr& playlist );
|
void playlistActivated( const Tomahawk::playlist_ptr& playlist );
|
||||||
void dynamicPlaylistActivated( const Tomahawk::dynplaylist_ptr& playlist );
|
void dynamicPlaylistActivated( const Tomahawk::dynplaylist_ptr& playlist );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool showSuperCollection();
|
bool showSuperCollection();
|
||||||
void showWelcomePage();
|
void showWelcomePage();
|
||||||
@@ -123,18 +123,19 @@ public slots:
|
|||||||
|
|
||||||
void setRepeatMode( PlaylistInterface::RepeatMode mode );
|
void setRepeatMode( PlaylistInterface::RepeatMode mode );
|
||||||
void setShuffled( bool enabled );
|
void setShuffled( bool enabled );
|
||||||
|
|
||||||
// called by the playlist creation dbcmds
|
// called by the playlist creation dbcmds
|
||||||
void createPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents );
|
void createPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents );
|
||||||
void createDynamicPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents );
|
void createDynamicPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents );
|
||||||
|
|
||||||
// ugh need to set up the connection in tomahawk to libtomahawk
|
// ugh need to set up the connection in tomahawk to libtomahawk
|
||||||
void onPlayClicked();
|
void onPlayClicked();
|
||||||
void onPauseClicked();
|
void onPauseClicked();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setFilter( const QString& filter );
|
void setFilter( const QString& filter );
|
||||||
void applyFilter();
|
void applyFilter();
|
||||||
|
|
||||||
void onWidgetDestroyed( QWidget* widget );
|
void onWidgetDestroyed( QWidget* widget );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -146,7 +147,7 @@ private:
|
|||||||
Tomahawk::playlist_ptr playlistForInterface( PlaylistInterface* interface ) const;
|
Tomahawk::playlist_ptr playlistForInterface( PlaylistInterface* interface ) const;
|
||||||
Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( PlaylistInterface* interface ) const;
|
Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( PlaylistInterface* interface ) const;
|
||||||
Tomahawk::collection_ptr collectionForInterface( PlaylistInterface* interface ) const;
|
Tomahawk::collection_ptr collectionForInterface( PlaylistInterface* interface ) const;
|
||||||
|
|
||||||
QWidget* m_widget;
|
QWidget* m_widget;
|
||||||
InfoBar* m_infobar;
|
InfoBar* m_infobar;
|
||||||
TopBar* m_topbar;
|
TopBar* m_topbar;
|
||||||
@@ -161,7 +162,7 @@ private:
|
|||||||
CollectionFlatModel* m_superCollectionFlatModel;
|
CollectionFlatModel* m_superCollectionFlatModel;
|
||||||
CollectionView* m_superCollectionView;
|
CollectionView* m_superCollectionView;
|
||||||
WelcomeWidget* m_welcomeWidget;
|
WelcomeWidget* m_welcomeWidget;
|
||||||
|
|
||||||
QList< Tomahawk::collection_ptr > m_superCollections;
|
QList< Tomahawk::collection_ptr > m_superCollections;
|
||||||
|
|
||||||
QHash< Tomahawk::dynplaylist_ptr, Tomahawk::DynamicWidget* > m_dynamicWidgets;
|
QHash< Tomahawk::dynplaylist_ptr, Tomahawk::DynamicWidget* > m_dynamicWidgets;
|
||||||
@@ -171,13 +172,13 @@ private:
|
|||||||
QHash< Tomahawk::album_ptr, PlaylistView* > m_albumViews;
|
QHash< Tomahawk::album_ptr, PlaylistView* > m_albumViews;
|
||||||
QHash< Tomahawk::playlist_ptr, PlaylistView* > m_playlistViews;
|
QHash< Tomahawk::playlist_ptr, PlaylistView* > m_playlistViews;
|
||||||
QHash< Tomahawk::source_ptr, SourceInfoWidget* > m_sourceViews;
|
QHash< Tomahawk::source_ptr, SourceInfoWidget* > m_sourceViews;
|
||||||
|
|
||||||
QList<Tomahawk::ViewPage*> m_pageHistory;
|
QList<Tomahawk::ViewPage*> m_pageHistory;
|
||||||
int m_historyPosition;
|
int m_historyPosition;
|
||||||
|
|
||||||
Tomahawk::collection_ptr m_currentCollection;
|
Tomahawk::collection_ptr m_currentCollection;
|
||||||
int m_currentMode;
|
int m_currentMode;
|
||||||
|
|
||||||
QTimer m_filterTimer;
|
QTimer m_filterTimer;
|
||||||
QString m_filter;
|
QString m_filter;
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -71,7 +71,10 @@ void
|
|||||||
PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEntries )
|
PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEntries )
|
||||||
{
|
{
|
||||||
if ( !m_playlist.isNull() )
|
if ( !m_playlist.isNull() )
|
||||||
|
{
|
||||||
disconnect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
disconnect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
||||||
|
disconnect( m_playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( rowCount( QModelIndex() ) && loadEntries )
|
if ( rowCount( QModelIndex() ) && loadEntries )
|
||||||
{
|
{
|
||||||
@@ -80,6 +83,7 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
|
|
||||||
m_playlist = playlist;
|
m_playlist = playlist;
|
||||||
connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
||||||
|
connect( playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );
|
||||||
|
|
||||||
setReadOnly( !m_playlist->author()->isLocal() );
|
setReadOnly( !m_playlist->author()->isLocal() );
|
||||||
setTitle( playlist->title() );
|
setTitle( playlist->title() );
|
||||||
@@ -88,23 +92,28 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
if ( !loadEntries )
|
if ( !loadEntries )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlItem* plitem;
|
TrackModelItem* plitem;
|
||||||
QList<plentry_ptr> entries = playlist->entries();
|
QList<plentry_ptr> entries = playlist->entries();
|
||||||
if ( entries.count() )
|
if ( entries.count() )
|
||||||
{
|
{
|
||||||
int c = rowCount( QModelIndex() );
|
int c = rowCount( QModelIndex() );
|
||||||
|
|
||||||
qDebug() << "Starting loading" << playlist->title();
|
qDebug() << "Starting loading" << playlist->title();
|
||||||
emit loadingStarts();
|
|
||||||
emit beginInsertRows( QModelIndex(), c, c + entries.count() - 1 );
|
emit beginInsertRows( QModelIndex(), c, c + entries.count() - 1 );
|
||||||
|
|
||||||
|
m_waitingForResolved.clear();
|
||||||
foreach( const plentry_ptr& entry, entries )
|
foreach( const plentry_ptr& entry, entries )
|
||||||
{
|
{
|
||||||
qDebug() << entry->query()->toString();
|
qDebug() << entry->query()->toString();
|
||||||
plitem = new PlItem( entry, m_rootItem );
|
plitem = new TrackModelItem( entry, m_rootItem );
|
||||||
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
||||||
|
|
||||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||||
|
|
||||||
|
if( !entry->query()->resolvingFinished() && entry->query()->playable() ) {
|
||||||
|
m_waitingForResolved.append( entry->query().data() );
|
||||||
|
connect( entry->query().data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolved( bool ) ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
@@ -112,7 +121,9 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
else
|
else
|
||||||
qDebug() << "Playlist seems empty:" << playlist->title();
|
qDebug() << "Playlist seems empty:" << playlist->title();
|
||||||
|
|
||||||
emit loadingFinished();
|
if( !m_waitingForResolved.isEmpty() )
|
||||||
|
emit loadingStarted();
|
||||||
|
|
||||||
emit trackCountChanged( rowCount( QModelIndex() ) );
|
emit trackCountChanged( rowCount( QModelIndex() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +149,7 @@ PlaylistModel::loadHistory( const Tomahawk::source_ptr& source, unsigned int amo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistModel::clear()
|
PlaylistModel::clear()
|
||||||
{
|
{
|
||||||
if ( rowCount( QModelIndex() ) )
|
if ( rowCount( QModelIndex() ) )
|
||||||
@@ -147,7 +158,7 @@ PlaylistModel::clear()
|
|||||||
delete m_rootItem;
|
delete m_rootItem;
|
||||||
m_rootItem = 0;
|
m_rootItem = 0;
|
||||||
emit endResetModel();
|
emit endResetModel();
|
||||||
m_rootItem = new PlItem( 0, this );
|
m_rootItem = new TrackModelItem( 0, this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,6 +214,19 @@ PlaylistModel::insert( unsigned int row, const Tomahawk::query_ptr& query )
|
|||||||
onTracksInserted( row, ql );
|
onTracksInserted( row, ql );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistModel::trackResolved( bool )
|
||||||
|
{
|
||||||
|
Tomahawk::Query* q = qobject_cast< Query* >( sender() );
|
||||||
|
Q_ASSERT( q );
|
||||||
|
|
||||||
|
m_waitingForResolved.removeAll( q );
|
||||||
|
disconnect( q, SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolved( bool ) ) );
|
||||||
|
|
||||||
|
if( m_waitingForResolved.isEmpty() )
|
||||||
|
emit loadingFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
PlaylistModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
@@ -228,13 +252,13 @@ PlaylistModel::onTracksInserted( unsigned int row, const QList<Tomahawk::query_p
|
|||||||
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
PlItem* plitem;
|
TrackModelItem* plitem;
|
||||||
foreach( const query_ptr& query, tracks )
|
foreach( const query_ptr& query, tracks )
|
||||||
{
|
{
|
||||||
plentry_ptr entry = plentry_ptr( new PlaylistEntry() );
|
plentry_ptr entry = plentry_ptr( new PlaylistEntry() );
|
||||||
entry->setQuery( query );
|
entry->setQuery( query );
|
||||||
|
|
||||||
plitem = new PlItem( entry, m_rootItem, row + i );
|
plitem = new TrackModelItem( entry, m_rootItem, row + i );
|
||||||
plitem->index = createIndex( row + i, 0, plitem );
|
plitem->index = createIndex( row + i, 0, plitem );
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
@@ -250,7 +274,7 @@ PlaylistModel::onTracksInserted( unsigned int row, const QList<Tomahawk::query_p
|
|||||||
void
|
void
|
||||||
PlaylistModel::onDataChanged()
|
PlaylistModel::onDataChanged()
|
||||||
{
|
{
|
||||||
PlItem* p = (PlItem*)sender();
|
TrackModelItem* p = (TrackModelItem*)sender();
|
||||||
if ( p && p->index.isValid() )
|
if ( p && p->index.isValid() )
|
||||||
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount() - 1 ) );
|
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount() - 1 ) );
|
||||||
}
|
}
|
||||||
@@ -326,7 +350,7 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
e->setAnnotation( "" ); // FIXME
|
e->setAnnotation( "" ); // FIXME
|
||||||
e->setQuery( query );
|
e->setQuery( query );
|
||||||
|
|
||||||
PlItem* plitem = new PlItem( e, m_rootItem, beginRow );
|
TrackModelItem* plitem = new TrackModelItem( e, m_rootItem, beginRow );
|
||||||
plitem->index = createIndex( beginRow++, 0, plitem );
|
plitem->index = createIndex( beginRow++, 0, plitem );
|
||||||
|
|
||||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||||
@@ -387,7 +411,7 @@ PlaylistModel::playlistEntries() const
|
|||||||
if ( !idx.isValid() )
|
if ( !idx.isValid() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PlItem* item = itemFromIndex( idx );
|
TrackModelItem* item = itemFromIndex( idx );
|
||||||
if ( item )
|
if ( item )
|
||||||
l << item->entry();
|
l << item->entry();
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include "plitem.h"
|
#include "trackmodelitem.h"
|
||||||
#include "trackmodel.h"
|
#include "trackmodel.h"
|
||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
@@ -71,8 +71,7 @@ signals:
|
|||||||
|
|
||||||
void itemSizeChanged( const QModelIndex& index );
|
void itemSizeChanged( const QModelIndex& index );
|
||||||
|
|
||||||
void loadingStarts();
|
void playlistDeleted();
|
||||||
void loadingFinished();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDataChanged();
|
void onDataChanged();
|
||||||
@@ -83,11 +82,14 @@ private slots:
|
|||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
void onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks );
|
void onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
|
void trackResolved( bool );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Tomahawk::plentry_ptr> playlistEntries() const;
|
QList<Tomahawk::plentry_ptr> playlistEntries() const;
|
||||||
|
|
||||||
Tomahawk::playlist_ptr m_playlist;
|
Tomahawk::playlist_ptr m_playlist;
|
||||||
bool m_waitForUpdate;
|
bool m_waitForUpdate;
|
||||||
|
QList< Tomahawk::Query* > m_waitingForResolved;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLAYLISTMODEL_H
|
#endif // PLAYLISTMODEL_H
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -58,6 +58,7 @@ PlaylistView::setModel( PlaylistModel* model )
|
|||||||
setGuid( "playlistview" );
|
setGuid( "playlistview" );
|
||||||
|
|
||||||
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
|
connect( model, SIGNAL( playlistDeleted() ), SLOT( onDeleted() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -154,3 +155,12 @@ PlaylistView::jumpToCurrentTrack()
|
|||||||
scrollTo( proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
scrollTo( proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistView::onDeleted()
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
emit destroyed( widget() );
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -50,6 +50,9 @@ public:
|
|||||||
|
|
||||||
virtual bool jumpToCurrentTrack();
|
virtual bool jumpToCurrentTrack();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void destroyed( QWidget* widget );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent( QKeyEvent* event );
|
void keyPressEvent( QKeyEvent* event );
|
||||||
|
|
||||||
@@ -60,6 +63,8 @@ private slots:
|
|||||||
void addItemsToPlaylist();
|
void addItemsToPlaylist();
|
||||||
void deleteItems();
|
void deleteItems();
|
||||||
|
|
||||||
|
void onDeleted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupMenus();
|
void setupMenus();
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -33,7 +33,7 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
TrackModel::TrackModel( QObject* parent )
|
TrackModel::TrackModel( QObject* parent )
|
||||||
: QAbstractItemModel( parent )
|
: QAbstractItemModel( parent )
|
||||||
, m_rootItem( new PlItem( 0, this ) )
|
, m_rootItem( new TrackModelItem( 0, this ) )
|
||||||
, m_readOnly( true )
|
, m_readOnly( true )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
@@ -45,7 +45,7 @@ TrackModel::TrackModel( QObject* parent )
|
|||||||
|
|
||||||
TrackModel::~TrackModel()
|
TrackModel::~TrackModel()
|
||||||
{
|
{
|
||||||
delete m_rootItem;
|
// delete m_rootItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -55,8 +55,8 @@ TrackModel::index( int row, int column, const QModelIndex& parent ) const
|
|||||||
if ( !m_rootItem || row < 0 || column < 0 )
|
if ( !m_rootItem || row < 0 || column < 0 )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* parentItem = itemFromIndex( parent );
|
TrackModelItem* parentItem = itemFromIndex( parent );
|
||||||
PlItem* childItem = parentItem->children.value( row );
|
TrackModelItem* childItem = parentItem->children.value( row );
|
||||||
if ( !childItem )
|
if ( !childItem )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ TrackModel::rowCount( const QModelIndex& parent ) const
|
|||||||
if ( parent.column() > 0 )
|
if ( parent.column() > 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
PlItem* parentItem = itemFromIndex( parent );
|
TrackModelItem* parentItem = itemFromIndex( parent );
|
||||||
if ( !parentItem )
|
if ( !parentItem )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -88,15 +88,15 @@ TrackModel::columnCount( const QModelIndex& parent ) const
|
|||||||
QModelIndex
|
QModelIndex
|
||||||
TrackModel::parent( const QModelIndex& child ) const
|
TrackModel::parent( const QModelIndex& child ) const
|
||||||
{
|
{
|
||||||
PlItem* entry = itemFromIndex( child );
|
TrackModelItem* entry = itemFromIndex( child );
|
||||||
if ( !entry )
|
if ( !entry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* parentEntry = entry->parent;
|
TrackModelItem* parentEntry = entry->parent;
|
||||||
if ( !parentEntry )
|
if ( !parentEntry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* grandparentEntry = parentEntry->parent;
|
TrackModelItem* grandparentEntry = parentEntry->parent;
|
||||||
if ( !grandparentEntry )
|
if ( !grandparentEntry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ TrackModel::parent( const QModelIndex& child ) const
|
|||||||
QVariant
|
QVariant
|
||||||
TrackModel::data( const QModelIndex& index, int role ) const
|
TrackModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
PlItem* entry = itemFromIndex( index );
|
TrackModelItem* entry = itemFromIndex( index );
|
||||||
if ( !entry )
|
if ( !entry )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@@ -222,13 +222,13 @@ void
|
|||||||
TrackModel::setCurrentItem( const QModelIndex& index )
|
TrackModel::setCurrentItem( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
PlItem* oldEntry = itemFromIndex( m_currentIndex );
|
TrackModelItem* oldEntry = itemFromIndex( m_currentIndex );
|
||||||
if ( oldEntry )
|
if ( oldEntry )
|
||||||
{
|
{
|
||||||
oldEntry->setIsPlaying( false );
|
oldEntry->setIsPlaying( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
PlItem* entry = itemFromIndex( index );
|
TrackModelItem* entry = itemFromIndex( index );
|
||||||
if ( entry )
|
if ( entry )
|
||||||
{
|
{
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
@@ -283,7 +283,7 @@ TrackModel::mimeData( const QModelIndexList &indexes ) const
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
QModelIndex idx = index( i.row(), 0, i.parent() );
|
QModelIndex idx = index( i.row(), 0, i.parent() );
|
||||||
PlItem* item = itemFromIndex( idx );
|
TrackModelItem* item = itemFromIndex( idx );
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
const query_ptr& query = item->query();
|
const query_ptr& query = item->query();
|
||||||
@@ -315,7 +315,7 @@ TrackModel::removeIndex( const QModelIndex& index, bool moreToCome )
|
|||||||
if ( index.column() > 0 )
|
if ( index.column() > 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlItem* item = itemFromIndex( index );
|
TrackModelItem* item = itemFromIndex( index );
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
emit beginRemoveRows( index.parent(), index.row(), index.row() );
|
emit beginRemoveRows( index.parent(), index.row(), index.row() );
|
||||||
@@ -337,11 +337,11 @@ TrackModel::removeIndexes( const QList<QModelIndex>& indexes )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem*
|
TrackModelItem*
|
||||||
TrackModel::itemFromIndex( const QModelIndex& index ) const
|
TrackModel::itemFromIndex( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
if ( index.isValid() )
|
if ( index.isValid() )
|
||||||
return static_cast<PlItem*>( index.internalPointer() );
|
return static_cast<TrackModelItem*>( index.internalPointer() );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_rootItem;
|
return m_rootItem;
|
||||||
@@ -352,7 +352,7 @@ TrackModel::itemFromIndex( const QModelIndex& index ) const
|
|||||||
void
|
void
|
||||||
TrackModel::onPlaybackFinished( const Tomahawk::result_ptr& result )
|
TrackModel::onPlaybackFinished( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
PlItem* oldEntry = itemFromIndex( m_currentIndex );
|
TrackModelItem* oldEntry = itemFromIndex( m_currentIndex );
|
||||||
if ( oldEntry && !oldEntry->query().isNull() && oldEntry->query()->results().contains( result ) )
|
if ( oldEntry && !oldEntry->query().isNull() && oldEntry->query()->results().contains( result ) )
|
||||||
{
|
{
|
||||||
oldEntry->setIsPlaying( false );
|
oldEntry->setIsPlaying( false );
|
||||||
@@ -363,7 +363,7 @@ TrackModel::onPlaybackFinished( const Tomahawk::result_ptr& result )
|
|||||||
void
|
void
|
||||||
TrackModel::onPlaybackStopped()
|
TrackModel::onPlaybackStopped()
|
||||||
{
|
{
|
||||||
PlItem* oldEntry = itemFromIndex( m_currentIndex );
|
TrackModelItem* oldEntry = itemFromIndex( m_currentIndex );
|
||||||
if ( oldEntry )
|
if ( oldEntry )
|
||||||
{
|
{
|
||||||
oldEntry->setIsPlaying( false );
|
oldEntry->setIsPlaying( false );
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
#include "playlist/plitem.h"
|
#include "trackmodelitem.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
@@ -80,9 +80,9 @@ public:
|
|||||||
|
|
||||||
virtual void append( const Tomahawk::query_ptr& query ) = 0;
|
virtual void append( const Tomahawk::query_ptr& query ) = 0;
|
||||||
|
|
||||||
PlItem* itemFromIndex( const QModelIndex& index ) const;
|
TrackModelItem* itemFromIndex( const QModelIndex& index ) const;
|
||||||
|
|
||||||
PlItem* m_rootItem;
|
TrackModelItem* m_rootItem;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "plitem.h"
|
#include "trackmodelitem.h"
|
||||||
|
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
PlItem::~PlItem()
|
TrackModelItem::~TrackModelItem()
|
||||||
{
|
{
|
||||||
// Don't use qDeleteAll here! The children will remove themselves
|
// Don't use qDeleteAll here! The children will remove themselves
|
||||||
// from the list when they get deleted and the qDeleteAll iterator
|
// from the list when they get deleted and the qDeleteAll iterator
|
||||||
@@ -42,7 +42,7 @@ PlItem::~PlItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem::PlItem( PlItem* parent, QAbstractItemModel* model )
|
TrackModelItem::TrackModelItem( TrackModelItem* parent, QAbstractItemModel* model )
|
||||||
{
|
{
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
this->model = model;
|
this->model = model;
|
||||||
@@ -56,7 +56,7 @@ PlItem::PlItem( PlItem* parent, QAbstractItemModel* model )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem::PlItem( const QString& caption, PlItem* parent )
|
TrackModelItem::TrackModelItem( const QString& caption, TrackModelItem* parent )
|
||||||
{
|
{
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
this->caption = caption;
|
this->caption = caption;
|
||||||
@@ -72,35 +72,35 @@ PlItem::PlItem( const QString& caption, PlItem* parent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem::PlItem( const Tomahawk::query_ptr& query, PlItem* parent, int row )
|
TrackModelItem::TrackModelItem( const Tomahawk::query_ptr& query, TrackModelItem* parent, int row )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
{
|
{
|
||||||
setupItem( query, parent, row );
|
setupItem( query, parent, row );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem::PlItem( const Tomahawk::plentry_ptr& entry, PlItem* parent, int row )
|
TrackModelItem::TrackModelItem( const Tomahawk::plentry_ptr& entry, TrackModelItem* parent, int row )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_entry( entry )
|
, m_entry( entry )
|
||||||
{
|
{
|
||||||
setupItem( entry->query(), parent, row );
|
setupItem( entry->query(), parent, row );
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tomahawk::plentry_ptr&
|
const Tomahawk::plentry_ptr&
|
||||||
PlItem::entry() const
|
TrackModelItem::entry() const
|
||||||
{
|
{
|
||||||
return m_entry;
|
return m_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tomahawk::query_ptr&
|
const Tomahawk::query_ptr&
|
||||||
PlItem::query() const
|
TrackModelItem::query() const
|
||||||
{
|
{
|
||||||
if ( !m_entry.isNull() ) return m_entry->query(); else return m_query;
|
if ( !m_entry.isNull() ) return m_entry->query(); else return m_query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlItem::setupItem( const Tomahawk::query_ptr& query, PlItem* parent, int row )
|
TrackModelItem::setupItem( const Tomahawk::query_ptr& query, TrackModelItem* parent, int row )
|
||||||
{
|
{
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
if ( parent )
|
if ( parent )
|
||||||
@@ -132,7 +132,7 @@ PlItem::setupItem( const Tomahawk::query_ptr& query, PlItem* parent, int row )
|
|||||||
|
|
||||||
connect( query.data(), SIGNAL( resultsRemoved( Tomahawk::result_ptr ) ),
|
connect( query.data(), SIGNAL( resultsRemoved( Tomahawk::result_ptr ) ),
|
||||||
SIGNAL( dataChanged() ) );
|
SIGNAL( dataChanged() ) );
|
||||||
|
|
||||||
connect( query.data(), SIGNAL( resultsChanged() ),
|
connect( query.data(), SIGNAL( resultsChanged() ),
|
||||||
SIGNAL( dataChanged() ) );
|
SIGNAL( dataChanged() ) );
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -29,17 +29,17 @@
|
|||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
class DLLEXPORT PlItem : public QObject
|
class DLLEXPORT TrackModelItem : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~PlItem();
|
virtual ~TrackModelItem();
|
||||||
|
|
||||||
explicit PlItem( PlItem* parent = 0, QAbstractItemModel* model = 0 );
|
explicit TrackModelItem( TrackModelItem* parent = 0, QAbstractItemModel* model = 0 );
|
||||||
explicit PlItem( const QString& caption, PlItem* parent = 0 );
|
explicit TrackModelItem( const QString& caption, TrackModelItem* parent = 0 );
|
||||||
explicit PlItem( const Tomahawk::query_ptr& query, PlItem* parent = 0, int row = -1 );
|
explicit TrackModelItem( const Tomahawk::query_ptr& query, TrackModelItem* parent = 0, int row = -1 );
|
||||||
explicit PlItem( const Tomahawk::plentry_ptr& entry, PlItem* parent = 0, int row = -1 );
|
explicit TrackModelItem( const Tomahawk::plentry_ptr& entry, TrackModelItem* parent = 0, int row = -1 );
|
||||||
|
|
||||||
const Tomahawk::plentry_ptr& entry() const;
|
const Tomahawk::plentry_ptr& entry() const;
|
||||||
const Tomahawk::query_ptr& query() const;
|
const Tomahawk::query_ptr& query() const;
|
||||||
@@ -47,9 +47,9 @@ public:
|
|||||||
bool isPlaying() { return m_isPlaying; }
|
bool isPlaying() { return m_isPlaying; }
|
||||||
void setIsPlaying( bool b ) { m_isPlaying = b; emit dataChanged(); }
|
void setIsPlaying( bool b ) { m_isPlaying = b; emit dataChanged(); }
|
||||||
|
|
||||||
PlItem* parent;
|
TrackModelItem* parent;
|
||||||
QVector<PlItem*> children;
|
QVector<TrackModelItem*> children;
|
||||||
QHash<QString, PlItem*> hash;
|
QHash<QString, TrackModelItem*> hash;
|
||||||
QString caption;
|
QString caption;
|
||||||
int childCount;
|
int childCount;
|
||||||
QPersistentModelIndex index;
|
QPersistentModelIndex index;
|
||||||
@@ -60,7 +60,7 @@ signals:
|
|||||||
void dataChanged();
|
void dataChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupItem( const Tomahawk::query_ptr& query, PlItem* parent, int row = -1 );
|
void setupItem( const Tomahawk::query_ptr& query, TrackModelItem* parent, int row = -1 );
|
||||||
|
|
||||||
Tomahawk::plentry_ptr m_entry;
|
Tomahawk::plentry_ptr m_entry;
|
||||||
Tomahawk::query_ptr m_query;
|
Tomahawk::query_ptr m_query;
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -76,7 +76,7 @@ TrackProxyModel::tracks()
|
|||||||
|
|
||||||
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
|
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
|
||||||
{
|
{
|
||||||
PlItem* item = itemFromIndex( mapToSource( index( i, 0 ) ) );
|
TrackModelItem* item = itemFromIndex( mapToSource( index( i, 0 ) ) );
|
||||||
if ( item )
|
if ( item )
|
||||||
queries << item->query();
|
queries << item->query();
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ TrackProxyModel::siblingItem( int itemsAway )
|
|||||||
// Try to find the next available PlaylistItem (with results)
|
// Try to find the next available PlaylistItem (with results)
|
||||||
if ( idx.isValid() ) do
|
if ( idx.isValid() ) do
|
||||||
{
|
{
|
||||||
PlItem* item = itemFromIndex( mapToSource( idx ) );
|
TrackModelItem* item = itemFromIndex( mapToSource( idx ) );
|
||||||
qDebug() << item->query()->toString();
|
qDebug() << item->query()->toString();
|
||||||
if ( item && item->query()->playable() )
|
if ( item && item->query()->playable() )
|
||||||
{
|
{
|
||||||
@@ -156,14 +156,14 @@ TrackProxyModel::siblingItem( int itemsAway )
|
|||||||
bool
|
bool
|
||||||
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
PlItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
TrackModelItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
||||||
if ( !pi )
|
if ( !pi )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Tomahawk::query_ptr& q = pi->query();
|
const Tomahawk::query_ptr& q = pi->query();
|
||||||
if( q.isNull() ) // uh oh? filter out invalid queries i guess
|
if( q.isNull() ) // uh oh? filter out invalid queries i guess
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Tomahawk::result_ptr r;
|
Tomahawk::result_ptr r;
|
||||||
if ( q->numResults() )
|
if ( q->numResults() )
|
||||||
r = q->results().first();
|
r = q->results().first();
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
bool showOfflineResults() const { return m_showOfflineResults; }
|
bool showOfflineResults() const { return m_showOfflineResults; }
|
||||||
void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
|
void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
|
||||||
|
|
||||||
PlItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
TrackModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -69,12 +69,12 @@ TrackView::TrackView( QWidget* parent )
|
|||||||
f.setPointSize( f.pointSize() - 1 );
|
f.setPointSize( f.pointSize() - 1 );
|
||||||
setFont( f );
|
setFont( f );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
f.setPointSize( f.pointSize() - 2 );
|
f.setPointSize( f.pointSize() - 2 );
|
||||||
setFont( f );
|
setFont( f );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ TrackView::setModel( TrackModel* model )
|
|||||||
connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
|
connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
|
||||||
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
|
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
|
||||||
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
|
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
|
||||||
|
|
||||||
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||||
|
|
||||||
setAcceptDrops( true );
|
setAcceptDrops( true );
|
||||||
@@ -129,7 +129,7 @@ TrackView::setModel( TrackModel* model )
|
|||||||
void
|
void
|
||||||
TrackView::onItemActivated( const QModelIndex& index )
|
TrackView::onItemActivated( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
PlItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
TrackModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
||||||
if ( item && item->query()->numResults() )
|
if ( item && item->query()->numResults() )
|
||||||
{
|
{
|
||||||
qDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
qDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
||||||
@@ -178,7 +178,7 @@ TrackView::addItemsToQueue()
|
|||||||
if ( idx.column() )
|
if ( idx.column() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PlItem* item = model()->itemFromIndex( proxyModel()->mapToSource( idx ) );
|
TrackModelItem* item = model()->itemFromIndex( proxyModel()->mapToSource( idx ) );
|
||||||
if ( item && item->query()->numResults() )
|
if ( item && item->query()->numResults() )
|
||||||
{
|
{
|
||||||
PlaylistManager::instance()->queue()->model()->append( item->query() );
|
PlaylistManager::instance()->queue()->model()->append( item->query() );
|
||||||
|
@@ -45,6 +45,7 @@ Query::get( const QString& artist, const QString& track, const QString& album, c
|
|||||||
Query::Query( const QString& artist, const QString& track, const QString& album, const QID& qid )
|
Query::Query( const QString& artist, const QString& track, const QString& album, const QID& qid )
|
||||||
: m_solved( false )
|
: m_solved( false )
|
||||||
, m_playable( false )
|
, m_playable( false )
|
||||||
|
, m_resolveFinished( false )
|
||||||
, m_qid( qid )
|
, m_qid( qid )
|
||||||
, m_artist( artist )
|
, m_artist( artist )
|
||||||
, m_album( album )
|
, m_album( album )
|
||||||
@@ -61,7 +62,6 @@ Query::Query( const QString& artist, const QString& track, const QString& album,
|
|||||||
void
|
void
|
||||||
Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
|
Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
|
||||||
{
|
{
|
||||||
bool becameSolved = false;
|
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mutex );
|
QMutexLocker lock( &m_mutex );
|
||||||
m_results.append( newresults );
|
m_results.append( newresults );
|
||||||
@@ -114,6 +114,7 @@ void
|
|||||||
Query::onResolvingFinished()
|
Query::onResolvingFinished()
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO << "Finished resolving." << toString();
|
// qDebug() << Q_FUNC_INFO << "Finished resolving." << toString();
|
||||||
|
m_resolveFinished = true;
|
||||||
emit resolvingFinished( m_solved );
|
emit resolvingFinished( m_solved );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,6 +64,8 @@ public:
|
|||||||
/// true when any result has been found (score may be less than 1.0)
|
/// true when any result has been found (score may be less than 1.0)
|
||||||
bool playable() const { return m_playable; }
|
bool playable() const { return m_playable; }
|
||||||
|
|
||||||
|
bool resolvingFinished() const { return m_resolveFinished; }
|
||||||
|
|
||||||
unsigned int lastPipelineWeight() const { return m_lastpipelineweight; }
|
unsigned int lastPipelineWeight() const { return m_lastpipelineweight; }
|
||||||
void setLastPipelineWeight( unsigned int w ) { m_lastpipelineweight = w; }
|
void setLastPipelineWeight( unsigned int w ) { m_lastpipelineweight = w; }
|
||||||
|
|
||||||
@@ -72,7 +74,8 @@ public:
|
|||||||
void setTrack( const QString& track ) { m_track = track; }
|
void setTrack( const QString& track ) { m_track = track; }
|
||||||
void setResultHint( const QString& resultHint ) { m_resultHint = resultHint; }
|
void setResultHint( const QString& resultHint ) { m_resultHint = resultHint; }
|
||||||
void setDuration( int duration ) { m_duration = duration; }
|
void setDuration( int duration ) { m_duration = duration; }
|
||||||
|
void setResolveFinished( bool resolved ) { m_resolveFinished = resolved; }
|
||||||
|
|
||||||
QVariant toVariant() const;
|
QVariant toVariant() const;
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
|
|
||||||
@@ -108,6 +111,7 @@ private:
|
|||||||
QList< Tomahawk::result_ptr > m_results;
|
QList< Tomahawk::result_ptr > m_results;
|
||||||
bool m_solved;
|
bool m_solved;
|
||||||
bool m_playable;
|
bool m_playable;
|
||||||
|
bool m_resolveFinished;
|
||||||
mutable QID m_qid;
|
mutable QID m_qid;
|
||||||
unsigned int m_lastpipelineweight;
|
unsigned int m_lastpipelineweight;
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
class DLLEXPORT ViewPage
|
class DLLEXPORT ViewPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -45,12 +45,18 @@ public:
|
|||||||
virtual bool showStatsBar() const { return true; }
|
virtual bool showStatsBar() const { return true; }
|
||||||
virtual bool showModes() const { return false; }
|
virtual bool showModes() const { return false; }
|
||||||
virtual bool queueVisible() const { return true; }
|
virtual bool queueVisible() const { return true; }
|
||||||
|
|
||||||
virtual bool jumpToCurrentTrack() = 0;
|
virtual bool jumpToCurrentTrack() = 0;
|
||||||
|
|
||||||
|
/** subclasses implementing ViewPage can emit the following signals:
|
||||||
|
* descriptionChanged( const QString& )
|
||||||
|
* destroyed( QWidget* widget );
|
||||||
|
*
|
||||||
|
* See DynamicWidget for an example
|
||||||
|
*/
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // ns
|
}; // ns
|
||||||
|
|
||||||
#endif //VIEWPAGE_H
|
#endif //VIEWPAGE_H
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
virtual QWidget* widget() { return this; }
|
virtual QWidget* widget() { return this; }
|
||||||
virtual PlaylistInterface* playlistInterface() const { return 0; }
|
virtual PlaylistInterface* playlistInterface() const { return 0; }
|
||||||
|
|
||||||
virtual QString title() const { return tr( "Create a new playlist" ); }
|
virtual QString title() const { return tr( "Create a new playlist" ); }
|
||||||
virtual QString description() const { return QString(); }
|
virtual QString description() const { return QString(); }
|
||||||
|
|
||||||
|
@@ -265,6 +265,19 @@ TwitterPlugin::connectTimerFired()
|
|||||||
foreach( QString screenName, peerlist )
|
foreach( QString screenName, peerlist )
|
||||||
{
|
{
|
||||||
QHash< QString, QVariant > peerData = m_cachedPeers[screenName].toHash();
|
QHash< QString, QVariant > peerData = m_cachedPeers[screenName].toHash();
|
||||||
|
|
||||||
|
if ( Servent::instance()->connectedToSession( peerData["node"].toString() ) )
|
||||||
|
{
|
||||||
|
peerData["lastseen"] = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
m_cachedPeers[screenName] = peerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( QDateTime::currentMSecsSinceEpoch() - peerData["lastseen"].toLongLong() > 1209600000 ) // 2 weeks
|
||||||
|
{
|
||||||
|
qDebug() << "Aging peer " << screenName << " out of cache";
|
||||||
|
m_cachedPeers.remove( screenName );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) )
|
if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) )
|
||||||
{
|
{
|
||||||
@@ -529,11 +542,14 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q
|
|||||||
_peerData.remove( "resend" );
|
_peerData.remove( "resend" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !_peerData.contains( "okey" ) )
|
if ( !_peerData.contains( "okey" ) ||
|
||||||
|
!_peerData.contains( "onod" ) ||
|
||||||
|
( _peerData.contains( "onod" ) && _peerData["onod"] != Database::instance()->dbid() ) )
|
||||||
{
|
{
|
||||||
QString okey = QUuid::createUuid().toString().split( '-' ).last();
|
QString okey = QUuid::createUuid().toString().split( '-' ).last();
|
||||||
okey.chop( 1 );
|
okey.chop( 1 );
|
||||||
_peerData["okey"] = QVariant::fromValue< QString >( okey );
|
_peerData["okey"] = QVariant::fromValue< QString >( okey );
|
||||||
|
_peerData["onod"] = QVariant::fromValue< QString >( Database::instance()->dbid() );
|
||||||
peersChanged = true;
|
peersChanged = true;
|
||||||
needToAddToCache = true;
|
needToAddToCache = true;
|
||||||
needToSend = true;
|
needToSend = true;
|
||||||
@@ -568,6 +584,7 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q
|
|||||||
|
|
||||||
if ( peersChanged )
|
if ( peersChanged )
|
||||||
{
|
{
|
||||||
|
_peerData["lastseen"] = QString::number( QDateTime::currentMSecsSinceEpoch() );
|
||||||
m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData );
|
m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData );
|
||||||
TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers );
|
TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers );
|
||||||
}
|
}
|
||||||
@@ -595,7 +612,8 @@ void
|
|||||||
TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerData )
|
TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerData )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) || !peerData.contains( "node" ) )
|
if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) || !peerData.contains( "node" ) ||
|
||||||
|
peerData["host"].toString().isEmpty() || peerData["port"].toString().isEmpty() || peerData["pkey"].toString().isEmpty() || peerData["node"].toString().isEmpty() )
|
||||||
{
|
{
|
||||||
qDebug() << "TwitterPlugin could not find host and/or port and/or pkey and/or node for peer " << screenName;
|
qDebug() << "TwitterPlugin could not find host and/or port and/or pkey and/or node for peer " << screenName;
|
||||||
return;
|
return;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -81,7 +81,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
|||||||
setUniformRowHeights( false );
|
setUniformRowHeights( false );
|
||||||
setIndentation( 16 );
|
setIndentation( 16 );
|
||||||
setAnimated( true );
|
setAnimated( true );
|
||||||
|
|
||||||
setItemDelegate( new SourceDelegate( this ) );
|
setItemDelegate( new SourceDelegate( this ) );
|
||||||
|
|
||||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||||
@@ -132,10 +132,10 @@ SourceTreeView::setupMenus()
|
|||||||
if ( type == SourcesModel::PlaylistSource || type == SourcesModel::DynamicPlaylistSource )
|
if ( type == SourcesModel::PlaylistSource || type == SourcesModel::DynamicPlaylistSource )
|
||||||
{
|
{
|
||||||
playlist_ptr playlist = SourcesModel::indexToDynamicPlaylist( m_contextMenuIndex );
|
playlist_ptr playlist = SourcesModel::indexToDynamicPlaylist( m_contextMenuIndex );
|
||||||
if( playlist.isNull() )
|
if ( playlist.isNull() )
|
||||||
{
|
{
|
||||||
playlist = SourcesModel::indexToPlaylist( m_contextMenuIndex );
|
playlist = SourcesModel::indexToPlaylist( m_contextMenuIndex );
|
||||||
}
|
}
|
||||||
if ( !playlist.isNull() )
|
if ( !playlist.isNull() )
|
||||||
{
|
{
|
||||||
readonly = !playlist->author()->isLocal();
|
readonly = !playlist->author()->isLocal();
|
||||||
@@ -263,7 +263,7 @@ SourceTreeView::onItemActivated( const QModelIndex& index )
|
|||||||
if ( !playlist.isNull() )
|
if ( !playlist.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "Dynamic Playlist activated:" << playlist->title();
|
qDebug() << "Dynamic Playlist activated:" << playlist->title();
|
||||||
|
|
||||||
PlaylistManager::instance()->show( playlist );
|
PlaylistManager::instance()->show( playlist );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,13 +298,16 @@ SourceTreeView::deletePlaylist()
|
|||||||
playlist_ptr playlist = SourcesModel::indexToPlaylist( idx );
|
playlist_ptr playlist = SourcesModel::indexToPlaylist( idx );
|
||||||
if ( !playlist.isNull() )
|
if ( !playlist.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "Playlist about to be deleted:" << playlist->title();
|
|
||||||
Playlist::remove( playlist );
|
Playlist::remove( playlist );
|
||||||
}
|
}
|
||||||
} else if( type == SourcesModel::DynamicPlaylistSource ) {
|
}
|
||||||
dynplaylist_ptr playlist = SourcesModel::indexToDynamicPlaylist( idx );
|
else if ( type == SourcesModel::DynamicPlaylistSource )
|
||||||
|
{
|
||||||
|
dynplaylist_ptr playlist = SourcesModel::indexToDynamicPlaylist( idx );
|
||||||
if( !playlist.isNull() )
|
if( !playlist.isNull() )
|
||||||
|
{
|
||||||
DynamicPlaylist::remove( playlist );
|
DynamicPlaylist::remove( playlist );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,7 +508,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
painter->setFont( smaller );
|
painter->setFont( smaller );
|
||||||
o.font = smaller;
|
o.font = smaller;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( ( option.state & QStyle::State_Enabled ) == QStyle::State_Enabled )
|
if ( ( option.state & QStyle::State_Enabled ) == QStyle::State_Enabled )
|
||||||
{
|
{
|
||||||
o.state = QStyle::State_Enabled;
|
o.state = QStyle::State_Enabled;
|
||||||
@@ -515,13 +518,13 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
o.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) );
|
o.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStyleOptionViewItemV4 o3 = option;
|
QStyleOptionViewItemV4 o3 = option;
|
||||||
if ( index.data( SourceTreeItem::Type ) != SourcesModel::CollectionSource )
|
if ( index.data( SourceTreeItem::Type ) != SourcesModel::CollectionSource )
|
||||||
o3.rect.setX( 0 );
|
o3.rect.setX( 0 );
|
||||||
|
|
||||||
QApplication::style()->drawControl( QStyle::CE_ItemViewItem, &o3, painter );
|
QApplication::style()->drawControl( QStyle::CE_ItemViewItem, &o3, painter );
|
||||||
|
|
||||||
if ( index.data( SourceTreeItem::Type ) == SourcesModel::CollectionSource )
|
if ( index.data( SourceTreeItem::Type ) == SourcesModel::CollectionSource )
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
@@ -529,7 +532,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
QFont normal = painter->font();
|
QFont normal = painter->font();
|
||||||
QFont bold = painter->font();
|
QFont bold = painter->font();
|
||||||
bold.setBold( true );
|
bold.setBold( true );
|
||||||
|
|
||||||
SourceTreeItem* sti = SourcesModel::indexToTreeItem( index );
|
SourceTreeItem* sti = SourcesModel::indexToTreeItem( index );
|
||||||
bool status = !( !sti || sti->source().isNull() || !sti->source()->isOnline() );
|
bool status = !( !sti || sti->source().isNull() || !sti->source()->isOnline() );
|
||||||
QString tracks;
|
QString tracks;
|
||||||
@@ -548,7 +551,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
{
|
{
|
||||||
painter->setPen( o.palette.color( QPalette::HighlightedText ) );
|
painter->setPen( o.palette.color( QPalette::HighlightedText ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect textRect = option.rect.adjusted( iconRect.width() + 8, 6, -figWidth - 24, 0 );
|
QRect textRect = option.rect.adjusted( iconRect.width() + 8, 6, -figWidth - 24, 0 );
|
||||||
if ( status || sti->source().isNull() )
|
if ( status || sti->source().isNull() )
|
||||||
painter->setFont( bold );
|
painter->setFont( bold );
|
||||||
@@ -608,8 +611,8 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
{
|
{
|
||||||
QStyledItemDelegate::paint( painter, o, index );
|
QStyledItemDelegate::paint( painter, o, index );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
painter->setFont( savedFont );
|
painter->setFont( savedFont );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -299,7 +299,7 @@ TomahawkApp::~TomahawkApp()
|
|||||||
delete m_mainwindow;
|
delete m_mainwindow;
|
||||||
delete m_audioEngine;
|
delete m_audioEngine;
|
||||||
#endif
|
#endif
|
||||||
|
delete m_infoSystem;
|
||||||
delete m_database;
|
delete m_database;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,6 +348,8 @@ TomahawkApp::registerMetaTypes()
|
|||||||
qRegisterMetaType< Tomahawk::query_ptr >("Tomahawk::query_ptr");
|
qRegisterMetaType< Tomahawk::query_ptr >("Tomahawk::query_ptr");
|
||||||
qRegisterMetaType< Tomahawk::source_ptr >("Tomahawk::source_ptr");
|
qRegisterMetaType< Tomahawk::source_ptr >("Tomahawk::source_ptr");
|
||||||
qRegisterMetaType< Tomahawk::dyncontrol_ptr >("Tomahawk::dyncontrol_ptr");
|
qRegisterMetaType< Tomahawk::dyncontrol_ptr >("Tomahawk::dyncontrol_ptr");
|
||||||
|
qRegisterMetaType< Tomahawk::playlist_ptr >("Tomahawk::playlist_ptr");
|
||||||
|
qRegisterMetaType< Tomahawk::dynplaylist_ptr >("Tomahawk::dynplaylist_ptr");
|
||||||
qRegisterMetaType< Tomahawk::geninterface_ptr >("Tomahawk::geninterface_ptr");
|
qRegisterMetaType< Tomahawk::geninterface_ptr >("Tomahawk::geninterface_ptr");
|
||||||
qRegisterMetaType< QList<Tomahawk::playlist_ptr> >("QList<Tomahawk::playlist_ptr>");
|
qRegisterMetaType< QList<Tomahawk::playlist_ptr> >("QList<Tomahawk::playlist_ptr>");
|
||||||
qRegisterMetaType< QList<Tomahawk::dynplaylist_ptr> >("QList<Tomahawk::dynplaylist_ptr>");
|
qRegisterMetaType< QList<Tomahawk::dynplaylist_ptr> >("QList<Tomahawk::dynplaylist_ptr>");
|
||||||
|