mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-29 08:40:40 +02:00
* Added ViewPage, ViewPage-history and more consistent sidebar behaviour.
This commit is contained in:
BIN
data/images/back.png
Normal file
BIN
data/images/back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
BIN
data/images/forward.png
Normal file
BIN
data/images/forward.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
@@ -71,6 +71,8 @@
|
|||||||
<file>./data/images/echonest_logo.png</file>
|
<file>./data/images/echonest_logo.png</file>
|
||||||
<file>./data/images/loading-animation.gif</file>
|
<file>./data/images/loading-animation.gif</file>
|
||||||
<file>./data/images/home.png</file>
|
<file>./data/images/home.png</file>
|
||||||
|
<file>./data/images/back.png</file>
|
||||||
|
<file>./data/images/forward.png</file>
|
||||||
<file>./data/topbar-radiobuttons.css</file>
|
<file>./data/topbar-radiobuttons.css</file>
|
||||||
<file>./data/icons/tomahawk-icon-16x16.png</file>
|
<file>./data/icons/tomahawk-icon-16x16.png</file>
|
||||||
<file>./data/icons/tomahawk-icon-32x32.png</file>
|
<file>./data/icons/tomahawk-icon-32x32.png</file>
|
||||||
|
@@ -24,10 +24,10 @@ set( libSources
|
|||||||
query.cpp
|
query.cpp
|
||||||
result.cpp
|
result.cpp
|
||||||
source.cpp
|
source.cpp
|
||||||
|
viewpage.cpp
|
||||||
|
|
||||||
sip/SipPlugin.cpp
|
sip/SipPlugin.cpp
|
||||||
|
|
||||||
|
|
||||||
audio/madtranscode.cpp
|
audio/madtranscode.cpp
|
||||||
audio/vorbistranscode.cpp
|
audio/vorbistranscode.cpp
|
||||||
audio/flactranscode.cpp
|
audio/flactranscode.cpp
|
||||||
@@ -161,6 +161,7 @@ set( libHeaders
|
|||||||
resolver.h
|
resolver.h
|
||||||
result.h
|
result.h
|
||||||
source.h
|
source.h
|
||||||
|
viewpage.h
|
||||||
|
|
||||||
artist.h
|
artist.h
|
||||||
album.h
|
album.h
|
||||||
|
@@ -225,6 +225,8 @@ AlbumModel::addCollection( const collection_ptr& collection )
|
|||||||
SLOT( onAlbumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::collection_ptr ) ) );
|
SLOT( onAlbumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::collection_ptr ) ) );
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
|
|
||||||
|
m_title = tr( "All albums from %1" ).arg( collection->source()->friendlyName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -245,6 +247,8 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in
|
|||||||
SLOT( onAlbumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::collection_ptr ) ) );
|
SLOT( onAlbumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::collection_ptr ) ) );
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
|
|
||||||
|
m_title = tr( "All albums by %1" ).arg( collection->source()->friendlyName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -40,9 +40,6 @@ public:
|
|||||||
virtual void removeIndex( const QModelIndex& index );
|
virtual void removeIndex( const QModelIndex& index );
|
||||||
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
||||||
|
|
||||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
|
||||||
virtual bool shuffled() const { return false; }
|
|
||||||
|
|
||||||
virtual QMimeData* mimeData( const QModelIndexList& indexes ) const;
|
virtual QMimeData* mimeData( const QModelIndexList& indexes ) const;
|
||||||
virtual QStringList mimeTypes() const;
|
virtual QStringList mimeTypes() const;
|
||||||
virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
|
virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
|
||||||
@@ -50,6 +47,11 @@ public:
|
|||||||
void addCollection( const Tomahawk::collection_ptr& collection );
|
void addCollection( const Tomahawk::collection_ptr& collection );
|
||||||
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order );
|
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order );
|
||||||
|
|
||||||
|
virtual QString title() const { return m_title; }
|
||||||
|
virtual QString description() const { return m_description; }
|
||||||
|
virtual void setTitle( const QString& title ) { m_title = title; }
|
||||||
|
virtual void setDescription( const QString& description ) { m_description = description; }
|
||||||
|
|
||||||
AlbumItem* itemFromIndex( const QModelIndex& index ) const
|
AlbumItem* itemFromIndex( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
if ( index.isValid() )
|
if ( index.isValid() )
|
||||||
@@ -81,6 +83,9 @@ private:
|
|||||||
QPersistentModelIndex m_currentIndex;
|
QPersistentModelIndex m_currentIndex;
|
||||||
AlbumItem* m_rootItem;
|
AlbumItem* m_rootItem;
|
||||||
QPixmap m_defaultCover;
|
QPixmap m_defaultCover;
|
||||||
|
|
||||||
|
QString m_title;
|
||||||
|
QString m_description;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ALBUMMODEL_H
|
#endif // ALBUMMODEL_H
|
||||||
|
@@ -33,7 +33,8 @@ public:
|
|||||||
|
|
||||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||||
virtual bool shuffled() const { return m_shuffled; }
|
virtual bool shuffled() const { return m_shuffled; }
|
||||||
|
virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Album; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
|
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
#include "albumitemdelegate.h"
|
#include "albumitemdelegate.h"
|
||||||
#include "albummodel.h"
|
|
||||||
#include "albumproxymodel.h"
|
|
||||||
#include "playlistmanager.h"
|
#include "playlistmanager.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
@@ -4,12 +4,13 @@
|
|||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
#include "albummodel.h"
|
||||||
|
#include "albumproxymodel.h"
|
||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
class AlbumModel;
|
class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage
|
||||||
class AlbumProxyModel;
|
|
||||||
|
|
||||||
class DLLEXPORT AlbumView : public QListView
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -19,12 +20,22 @@ public:
|
|||||||
|
|
||||||
void setProxyModel( AlbumProxyModel* model );
|
void setProxyModel( AlbumProxyModel* model );
|
||||||
|
|
||||||
AlbumModel* model() { return m_model; }
|
AlbumModel* model() const { return m_model; }
|
||||||
AlbumProxyModel* proxyModel() { return m_proxyModel; }
|
AlbumProxyModel* proxyModel() const { return m_proxyModel; }
|
||||||
// PlaylistItemDelegate* delegate() { return m_delegate; }
|
// PlaylistItemDelegate* delegate() { return m_delegate; }
|
||||||
|
|
||||||
void setModel( AlbumModel* model );
|
void setModel( AlbumModel* model );
|
||||||
|
|
||||||
|
virtual QWidget* widget() { return this; }
|
||||||
|
virtual PlaylistInterface* playlistInterface() const { return proxyModel(); }
|
||||||
|
|
||||||
|
virtual QString title() const { return m_model->title(); }
|
||||||
|
virtual QString description() const { return m_model->description(); }
|
||||||
|
|
||||||
|
virtual bool showModes() const { return true; }
|
||||||
|
|
||||||
|
virtual bool jumpToCurrentTrack() { return false; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onItemActivated( const QModelIndex& index );
|
void onItemActivated( const QModelIndex& index );
|
||||||
|
|
||||||
|
@@ -60,6 +60,11 @@ CollectionFlatModel::addCollection( const collection_ptr& collection )
|
|||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
||||||
connect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
|
connect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
|
||||||
SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
|
SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
|
||||||
|
|
||||||
|
if ( collection->source()->isLocal() )
|
||||||
|
setTitle( tr( "Your Collection" ) );
|
||||||
|
else
|
||||||
|
setTitle( tr( "Collection of %1" ).arg( collection->source()->friendlyName() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -12,6 +12,8 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
explicit CollectionProxyModel( QObject* parent = 0 );
|
explicit CollectionProxyModel( QObject* parent = 0 );
|
||||||
|
|
||||||
|
virtual PlaylistInterface::ViewMode viewMode() const { return PlaylistInterface::Flat; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
||||||
};
|
};
|
||||||
|
@@ -45,7 +45,6 @@ CollectionView::setModel( TrackModel* model )
|
|||||||
void
|
void
|
||||||
CollectionView::dragEnterEvent( QDragEnterEvent* event )
|
CollectionView::dragEnterEvent( QDragEnterEvent* event )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,3 +93,10 @@ CollectionView::onTrackCountChanged( unsigned int tracks )
|
|||||||
else
|
else
|
||||||
overlay()->hide();
|
overlay()->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
CollectionView::jumpToCurrentTrack()
|
||||||
|
{
|
||||||
|
scrollTo( proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
||||||
|
}
|
||||||
|
@@ -3,11 +3,14 @@
|
|||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
#include "trackproxymodel.h"
|
||||||
|
#include "trackmodel.h"
|
||||||
#include "trackview.h"
|
#include "trackview.h"
|
||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
class DLLEXPORT CollectionView : public TrackView
|
class DLLEXPORT CollectionView : public TrackView, public Tomahawk::ViewPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -17,6 +20,16 @@ public:
|
|||||||
|
|
||||||
virtual void setModel( TrackModel* model );
|
virtual void setModel( TrackModel* model );
|
||||||
|
|
||||||
|
virtual QWidget* widget() { return this; }
|
||||||
|
virtual PlaylistInterface* playlistInterface() const { return proxyModel(); }
|
||||||
|
|
||||||
|
virtual QString title() const { return model()->title(); }
|
||||||
|
virtual QString description() const { return model()->description(); }
|
||||||
|
|
||||||
|
virtual bool showModes() const { return true; }
|
||||||
|
|
||||||
|
virtual bool jumpToCurrentTrack();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCustomContextMenu( const QPoint& pos );
|
void onCustomContextMenu( const QPoint& pos );
|
||||||
void onTrackCountChanged( unsigned int tracks );
|
void onTrackCountChanged( unsigned int tracks );
|
||||||
|
@@ -45,7 +45,7 @@ public:
|
|||||||
|
|
||||||
void setDynamicWorking( bool working );
|
void setDynamicWorking( bool working );
|
||||||
|
|
||||||
virtual void paintEvent(QPaintEvent* event);
|
virtual void paintEvent( QPaintEvent* event );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showMessageTimeout( const QString& title, const QString& body );
|
void showMessageTimeout( const QString& title, const QString& body );
|
||||||
|
@@ -386,3 +386,9 @@ DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qre
|
|||||||
p.setPen( pen );
|
p.setPen( pen );
|
||||||
p.drawRoundedRect( r, 10, 10 );
|
p.drawRoundedRect( r, 10, 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
DynamicWidget::jumpToCurrentTrack()
|
||||||
|
{
|
||||||
|
m_view->scrollTo( m_view->proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
||||||
|
}
|
||||||
|
@@ -20,8 +20,11 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
#include "dynamic/DynamicPlaylist.h"
|
#include "dynamic/DynamicPlaylist.h"
|
||||||
#include "dynamic/DynamicControl.h"
|
#include "dynamic/DynamicControl.h"
|
||||||
|
#include "dynamic/DynamicModel.h"
|
||||||
|
|
||||||
class LoadingSpinner;
|
class LoadingSpinner;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
@@ -43,20 +46,15 @@ namespace Tomahawk
|
|||||||
|
|
||||||
class DynamicSetupWidget;
|
class DynamicSetupWidget;
|
||||||
|
|
||||||
|
|
||||||
class DynamicModel;
|
|
||||||
|
|
||||||
|
|
||||||
class DynamicView;
|
class DynamicView;
|
||||||
|
|
||||||
|
|
||||||
class CollapsibleControls;
|
class CollapsibleControls;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains the dynamic playlist config and the playlist view itself
|
* This class contains the dynamic playlist config and the playlist view itself
|
||||||
*/
|
*/
|
||||||
class DynamicWidget : public QWidget
|
class DynamicWidget : public QWidget, public Tomahawk::ViewPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -65,7 +63,7 @@ public:
|
|||||||
|
|
||||||
void loadDynamicPlaylist( const dynplaylist_ptr& playlist );
|
void loadDynamicPlaylist( const dynplaylist_ptr& playlist );
|
||||||
|
|
||||||
PlaylistInterface* playlistInterface() const;
|
virtual PlaylistInterface* playlistInterface() const;
|
||||||
|
|
||||||
virtual QSize sizeHint() const;
|
virtual QSize sizeHint() const;
|
||||||
virtual void resizeEvent( QResizeEvent* );
|
virtual void resizeEvent( QResizeEvent* );
|
||||||
@@ -73,6 +71,14 @@ public:
|
|||||||
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 QString title() const { return m_model->title(); }
|
||||||
|
virtual QString description() const { return m_model->description(); }
|
||||||
|
|
||||||
|
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);
|
||||||
@@ -94,6 +100,7 @@ private slots:
|
|||||||
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
|
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
|
||||||
|
|
||||||
void layoutFloatingWidgets();
|
void layoutFloatingWidgets();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
dynplaylist_ptr m_playlist;
|
dynplaylist_ptr m_playlist;
|
||||||
QVBoxLayout* m_layout;
|
QVBoxLayout* m_layout;
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#define FILTER_TIMEOUT 280
|
#define FILTER_TIMEOUT 280
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
||||||
PlaylistManager* PlaylistManager::s_instance = 0;
|
PlaylistManager* PlaylistManager::s_instance = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -44,14 +46,12 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
|||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_widget( new QWidget() )
|
, m_widget( new QWidget() )
|
||||||
, m_welcomeWidget( new WelcomeWidget() )
|
, m_welcomeWidget( new WelcomeWidget() )
|
||||||
, m_currentInterface( 0 )
|
|
||||||
, m_currentMode( 0 )
|
, m_currentMode( 0 )
|
||||||
, m_superCollectionVisible( true )
|
, m_superCollectionVisible( true )
|
||||||
, m_statsAvailable( false )
|
|
||||||
, m_modesAvailable( false )
|
|
||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
|
||||||
|
setHistoryPosition( -1 );
|
||||||
m_widget->setLayout( new QVBoxLayout() );
|
m_widget->setLayout( new QVBoxLayout() );
|
||||||
|
|
||||||
m_topbar = new TopBar();
|
m_topbar = new TopBar();
|
||||||
@@ -91,11 +91,8 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
|||||||
m_superAlbumView = new AlbumView();
|
m_superAlbumView = new AlbumView();
|
||||||
m_superAlbumModel = new AlbumModel( m_superAlbumView );
|
m_superAlbumModel = new AlbumModel( m_superAlbumView );
|
||||||
m_superAlbumView->setModel( m_superAlbumModel );
|
m_superAlbumView->setModel( m_superAlbumModel );
|
||||||
|
m_superAlbumView->setFrameShape( QFrame::NoFrame );
|
||||||
m_stack->addWidget( m_superCollectionView );
|
m_superAlbumView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
m_stack->addWidget( m_superAlbumView );
|
|
||||||
|
|
||||||
m_currentInterface = m_superCollectionView->proxyModel();
|
|
||||||
|
|
||||||
m_stack->setContentsMargins( 0, 0, 0, 0 );
|
m_stack->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
||||||
@@ -106,34 +103,16 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
|||||||
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
||||||
|
|
||||||
connect( m_topbar, SIGNAL( filterTextChanged( QString ) ),
|
connect( m_topbar, SIGNAL( filterTextChanged( QString ) ),
|
||||||
this, SLOT( setFilter( QString ) ) );
|
SLOT( setFilter( QString ) ) );
|
||||||
|
|
||||||
connect( this, SIGNAL( numSourcesChanged( unsigned int ) ),
|
|
||||||
m_topbar, SLOT( setNumSources( unsigned int ) ) );
|
|
||||||
|
|
||||||
connect( this, SIGNAL( numTracksChanged( unsigned int ) ),
|
|
||||||
m_topbar, SLOT( setNumTracks( unsigned int ) ) );
|
|
||||||
|
|
||||||
connect( this, SIGNAL( numArtistsChanged( unsigned int ) ),
|
|
||||||
m_topbar, SLOT( setNumArtists( unsigned int ) ) );
|
|
||||||
|
|
||||||
connect( this, SIGNAL( numShownChanged( unsigned int ) ),
|
|
||||||
m_topbar, SLOT( setNumShown( unsigned int ) ) );
|
|
||||||
|
|
||||||
connect( m_topbar, SIGNAL( flatMode() ),
|
connect( m_topbar, SIGNAL( flatMode() ),
|
||||||
this, SLOT( setTableMode() ) );
|
SLOT( setTableMode() ) );
|
||||||
|
|
||||||
connect( m_topbar, SIGNAL( artistMode() ),
|
connect( m_topbar, SIGNAL( artistMode() ),
|
||||||
this, SLOT( setTreeMode() ) );
|
SLOT( setTreeMode() ) );
|
||||||
|
|
||||||
connect( m_topbar, SIGNAL( albumMode() ),
|
connect( m_topbar, SIGNAL( albumMode() ),
|
||||||
this, SLOT( setAlbumMode() ) );
|
SLOT( setAlbumMode() ) );
|
||||||
|
|
||||||
connect( this, SIGNAL( statsAvailable( bool ) ),
|
|
||||||
m_topbar, SLOT( setStatsVisible( bool ) ) );
|
|
||||||
|
|
||||||
connect( this, SIGNAL( modesAvailable( bool ) ),
|
|
||||||
m_topbar, SLOT( setModesVisible( bool ) ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -153,11 +132,10 @@ PlaylistManager::queue() const
|
|||||||
bool
|
bool
|
||||||
PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
||||||
{
|
{
|
||||||
unlinkPlaylist();
|
PlaylistView* view;
|
||||||
|
|
||||||
if ( !m_playlistViews.contains( playlist ) )
|
if ( !m_playlistViews.contains( playlist ) )
|
||||||
{
|
{
|
||||||
PlaylistView* view = new PlaylistView();
|
view = new PlaylistView();
|
||||||
PlaylistModel* model = new PlaylistModel();
|
PlaylistModel* model = new PlaylistModel();
|
||||||
view->setModel( model );
|
view->setModel( model );
|
||||||
view->setFrameShape( QFrame::NoFrame );
|
view->setFrameShape( QFrame::NoFrame );
|
||||||
@@ -165,27 +143,15 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
|||||||
model->loadPlaylist( playlist );
|
model->loadPlaylist( playlist );
|
||||||
playlist->resolve();
|
playlist->resolve();
|
||||||
|
|
||||||
m_currentInterface = view->proxyModel();
|
|
||||||
m_playlistViews.insert( playlist, view );
|
m_playlistViews.insert( playlist, view );
|
||||||
|
|
||||||
m_stack->addWidget( view );
|
|
||||||
m_stack->setCurrentWidget( view );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlaylistView* view = m_playlistViews.value( playlist );
|
view = m_playlistViews.value( playlist );
|
||||||
m_stack->setCurrentWidget( view );
|
|
||||||
m_currentInterface = view->proxyModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_queueView->show();
|
setPage( view );
|
||||||
m_infobar->setCaption( playlist->title() );
|
|
||||||
m_infobar->setDescription( tr( "A playlist by %1" ).arg( playlist->author()->isLocal() ? tr( "you" ) : playlist->author()->friendlyName() ) );
|
|
||||||
|
|
||||||
m_superCollectionVisible = false;
|
m_superCollectionVisible = false;
|
||||||
m_statsAvailable = true;
|
|
||||||
m_modesAvailable = false;
|
|
||||||
linkPlaylist();
|
|
||||||
|
|
||||||
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
||||||
|
|
||||||
@@ -197,34 +163,25 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
|||||||
bool
|
bool
|
||||||
PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
||||||
{
|
{
|
||||||
unlinkPlaylist();
|
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 );
|
||||||
m_stack->addWidget( m_dynamicWidgets[ playlist ] );
|
|
||||||
playlist->resolve();
|
playlist->resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_stack->setCurrentWidget( m_dynamicWidgets.value( playlist ) );
|
setPage( m_dynamicWidgets.value( playlist ) );
|
||||||
m_currentInterface = m_dynamicWidgets.value( playlist )->playlistInterface();
|
|
||||||
|
|
||||||
m_infobar->setCaption( playlist->title() );
|
if ( playlist->mode() == Tomahawk::OnDemand )
|
||||||
m_infobar->setDescription( tr( "A playlist by %1" ).arg( playlist->author()->isLocal() ? tr( "you" ) : playlist->author()->friendlyName() ) );
|
|
||||||
|
|
||||||
if( playlist->mode() == Tomahawk::OnDemand )
|
|
||||||
m_queueView->hide();
|
m_queueView->hide();
|
||||||
|
else
|
||||||
|
m_queueView->show();
|
||||||
|
|
||||||
m_superCollectionVisible = false;
|
m_superCollectionVisible = false;
|
||||||
m_statsAvailable = true;
|
|
||||||
m_modesAvailable = false;
|
|
||||||
linkPlaylist();
|
|
||||||
|
|
||||||
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
|
||||||
|
|
||||||
emit numSourcesChanged( SourceList::instance()->count() );
|
emit numSourcesChanged( SourceList::instance()->count() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,39 +189,26 @@ PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
|||||||
bool
|
bool
|
||||||
PlaylistManager::show( const Tomahawk::artist_ptr& artist )
|
PlaylistManager::show( const Tomahawk::artist_ptr& artist )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << &artist << artist.data();
|
PlaylistView* view;
|
||||||
unlinkPlaylist();
|
|
||||||
|
|
||||||
if ( !m_artistViews.contains( artist ) )
|
if ( !m_artistViews.contains( artist ) )
|
||||||
{
|
{
|
||||||
PlaylistView* view = new PlaylistView();
|
view = new PlaylistView();
|
||||||
PlaylistModel* model = new PlaylistModel();
|
PlaylistModel* model = new PlaylistModel();
|
||||||
view->setModel( model );
|
view->setModel( model );
|
||||||
view->setFrameShape( QFrame::NoFrame );
|
view->setFrameShape( QFrame::NoFrame );
|
||||||
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
model->append( artist );
|
model->append( artist );
|
||||||
|
|
||||||
m_currentInterface = view->proxyModel();
|
|
||||||
m_artistViews.insert( artist, view );
|
m_artistViews.insert( artist, view );
|
||||||
|
|
||||||
m_stack->addWidget( view );
|
|
||||||
m_stack->setCurrentWidget( view );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlaylistView* view = m_artistViews.value( artist );
|
view = m_artistViews.value( artist );
|
||||||
m_stack->setCurrentWidget( view );
|
|
||||||
m_currentInterface = view->proxyModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_queueView->show();
|
setPage( view );
|
||||||
m_infobar->setCaption( tr( "All tracks by %1" ).arg( artist->name() ) );
|
|
||||||
m_infobar->setDescription( "" );
|
|
||||||
|
|
||||||
m_superCollectionVisible = false;
|
m_superCollectionVisible = false;
|
||||||
m_statsAvailable = false;
|
|
||||||
m_modesAvailable = false;
|
|
||||||
linkPlaylist();
|
|
||||||
|
|
||||||
emit numSourcesChanged( 1 );
|
emit numSourcesChanged( 1 );
|
||||||
return true;
|
return true;
|
||||||
@@ -274,39 +218,25 @@ PlaylistManager::show( const Tomahawk::artist_ptr& artist )
|
|||||||
bool
|
bool
|
||||||
PlaylistManager::show( const Tomahawk::album_ptr& album )
|
PlaylistManager::show( const Tomahawk::album_ptr& album )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << &album << album.data();
|
PlaylistView* view;
|
||||||
unlinkPlaylist();
|
|
||||||
|
|
||||||
if ( !m_albumViews.contains( album ) )
|
if ( !m_albumViews.contains( album ) )
|
||||||
{
|
{
|
||||||
PlaylistView* view = new PlaylistView();
|
view = new PlaylistView();
|
||||||
PlaylistModel* model = new PlaylistModel();
|
PlaylistModel* model = new PlaylistModel();
|
||||||
view->setModel( model );
|
view->setModel( model );
|
||||||
view->setFrameShape( QFrame::NoFrame );
|
view->setFrameShape( QFrame::NoFrame );
|
||||||
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
model->append( album );
|
model->append( album );
|
||||||
|
|
||||||
m_currentInterface = view->proxyModel();
|
|
||||||
m_albumViews.insert( album, view );
|
m_albumViews.insert( album, view );
|
||||||
|
|
||||||
m_stack->addWidget( view );
|
|
||||||
m_stack->setCurrentWidget( view );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlaylistView* view = m_albumViews.value( album );
|
view = m_albumViews.value( album );
|
||||||
m_stack->setCurrentWidget( view );
|
|
||||||
m_currentInterface = view->proxyModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_queueView->show();
|
setPage( view );
|
||||||
m_infobar->setCaption( tr( "All tracks on %1 by %2" ).arg( album->name() ).arg( album->artist()->name() ) );
|
|
||||||
m_infobar->setDescription( "" );
|
|
||||||
|
|
||||||
m_superCollectionVisible = false;
|
m_superCollectionVisible = false;
|
||||||
m_statsAvailable = false;
|
|
||||||
m_modesAvailable = false;
|
|
||||||
linkPlaylist();
|
|
||||||
|
|
||||||
emit numSourcesChanged( 1 );
|
emit numSourcesChanged( 1 );
|
||||||
return true;
|
return true;
|
||||||
@@ -316,70 +246,52 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
|
|||||||
bool
|
bool
|
||||||
PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
||||||
{
|
{
|
||||||
unlinkPlaylist();
|
|
||||||
|
|
||||||
m_currentCollection = collection;
|
m_currentCollection = collection;
|
||||||
if ( m_currentMode == 0 )
|
if ( m_currentMode == 0 )
|
||||||
{
|
{
|
||||||
|
CollectionView* view;
|
||||||
if ( !m_collectionViews.contains( collection ) )
|
if ( !m_collectionViews.contains( collection ) )
|
||||||
{
|
{
|
||||||
CollectionView* view = new CollectionView();
|
view = new CollectionView();
|
||||||
CollectionFlatModel* model = new CollectionFlatModel();
|
CollectionFlatModel* model = new CollectionFlatModel();
|
||||||
view->setModel( model );
|
view->setModel( model );
|
||||||
view->setFrameShape( QFrame::NoFrame );
|
view->setFrameShape( QFrame::NoFrame );
|
||||||
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
model->addCollection( collection );
|
model->addCollection( collection );
|
||||||
|
|
||||||
m_currentInterface = view->proxyModel();
|
|
||||||
m_collectionViews.insert( collection, view );
|
m_collectionViews.insert( collection, view );
|
||||||
|
|
||||||
m_stack->addWidget( view );
|
|
||||||
m_stack->setCurrentWidget( view );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CollectionView* view = m_collectionViews.value( collection );
|
view = m_collectionViews.value( collection );
|
||||||
m_stack->setCurrentWidget( view );
|
|
||||||
m_currentInterface = view->proxyModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setPage( view );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_currentMode == 2 )
|
if ( m_currentMode == 2 )
|
||||||
{
|
{
|
||||||
|
AlbumView* aview;
|
||||||
if ( !m_collectionAlbumViews.contains( collection ) )
|
if ( !m_collectionAlbumViews.contains( collection ) )
|
||||||
{
|
{
|
||||||
AlbumView* aview = new AlbumView();
|
aview = new AlbumView();
|
||||||
AlbumModel* amodel = new AlbumModel( aview );
|
AlbumModel* amodel = new AlbumModel( aview );
|
||||||
aview->setModel( amodel );
|
aview->setModel( amodel );
|
||||||
aview->setFrameShape( QFrame::NoFrame );
|
aview->setFrameShape( QFrame::NoFrame );
|
||||||
aview->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
aview->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
amodel->addCollection( collection );
|
amodel->addCollection( collection );
|
||||||
|
|
||||||
m_currentInterface = aview->proxyModel();
|
|
||||||
m_collectionAlbumViews.insert( collection, aview );
|
m_collectionAlbumViews.insert( collection, aview );
|
||||||
|
|
||||||
m_stack->addWidget( aview );
|
|
||||||
m_stack->setCurrentWidget( aview );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AlbumView* view = m_collectionAlbumViews.value( collection );
|
aview = m_collectionAlbumViews.value( collection );
|
||||||
m_stack->setCurrentWidget( view );
|
|
||||||
m_currentInterface = view->proxyModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setPage( aview );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_infobar->setDescription( "" );
|
|
||||||
if ( collection->source()->isLocal() )
|
|
||||||
m_infobar->setCaption( tr( "Your Collection" ) );
|
|
||||||
else
|
|
||||||
m_infobar->setCaption( tr( "Collection of %1" ).arg( collection->source()->friendlyName() ) );
|
|
||||||
|
|
||||||
m_queueView->show();
|
|
||||||
m_superCollectionVisible = false;
|
m_superCollectionVisible = false;
|
||||||
m_statsAvailable = ( m_currentMode == 0 );
|
|
||||||
m_modesAvailable = true;
|
|
||||||
linkPlaylist();
|
|
||||||
|
|
||||||
emit numSourcesChanged( 1 );
|
emit numSourcesChanged( 1 );
|
||||||
return true;
|
return true;
|
||||||
@@ -389,32 +301,19 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection )
|
|||||||
bool
|
bool
|
||||||
PlaylistManager::show( const Tomahawk::source_ptr& source )
|
PlaylistManager::show( const Tomahawk::source_ptr& source )
|
||||||
{
|
{
|
||||||
unlinkPlaylist();
|
SourceInfoWidget* swidget;
|
||||||
|
|
||||||
m_currentInterface = 0;
|
|
||||||
|
|
||||||
if ( !m_sourceViews.contains( source ) )
|
if ( !m_sourceViews.contains( source ) )
|
||||||
{
|
{
|
||||||
SourceInfoWidget* swidget = new SourceInfoWidget( source );
|
swidget = new SourceInfoWidget( source );
|
||||||
m_currentInfoWidget = swidget;
|
|
||||||
m_stack->addWidget( m_currentInfoWidget );
|
|
||||||
m_sourceViews.insert( source, swidget );
|
m_sourceViews.insert( source, swidget );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_currentInfoWidget = m_sourceViews.value( source );
|
swidget = m_sourceViews.value( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_infobar->setCaption( tr( "Info about %1" ).arg( source->isLocal() ? tr( "Your Collection" ) : source->friendlyName() ) );
|
setPage( swidget );
|
||||||
m_infobar->setDescription( "" );
|
|
||||||
|
|
||||||
m_queueView->show();
|
|
||||||
m_stack->setCurrentWidget( m_currentInfoWidget );
|
|
||||||
m_superCollectionVisible = false;
|
m_superCollectionVisible = false;
|
||||||
m_statsAvailable = false;
|
|
||||||
m_modesAvailable = false;
|
|
||||||
|
|
||||||
linkPlaylist();
|
|
||||||
|
|
||||||
emit numSourcesChanged( 1 );
|
emit numSourcesChanged( 1 );
|
||||||
return true;
|
return true;
|
||||||
@@ -422,28 +321,15 @@ PlaylistManager::show( const Tomahawk::source_ptr& source )
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PlaylistManager::show( QWidget* widget, const QString& title, const QString& desc, const QPixmap& pixmap )
|
PlaylistManager::show( ViewPage* page )
|
||||||
{
|
{
|
||||||
unlinkPlaylist();
|
if ( m_stack->indexOf( page->widget() ) < 0 )
|
||||||
|
|
||||||
if ( m_stack->indexOf( widget ) < 0 )
|
|
||||||
{
|
{
|
||||||
connect( widget, SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ) );
|
connect( page->widget(), SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ) );
|
||||||
m_stack->addWidget( widget );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_stack->setCurrentWidget( widget );
|
setPage( page );
|
||||||
m_infobar->setCaption( title );
|
|
||||||
m_infobar->setDescription( desc );
|
|
||||||
m_infobar->setPixmap( pixmap.isNull() ? QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ) : pixmap );
|
|
||||||
|
|
||||||
m_queueView->show();
|
|
||||||
m_superCollectionVisible = false;
|
m_superCollectionVisible = false;
|
||||||
m_statsAvailable = false;
|
|
||||||
m_modesAvailable = false;
|
|
||||||
m_currentInterface = 0;
|
|
||||||
|
|
||||||
linkPlaylist();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -460,27 +346,21 @@ PlaylistManager::showSuperCollection()
|
|||||||
m_superCollectionFlatModel->addCollection( source->collection() );
|
m_superCollectionFlatModel->addCollection( source->collection() );
|
||||||
m_superAlbumModel->addCollection( source->collection() );
|
m_superAlbumModel->addCollection( source->collection() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_superCollectionFlatModel->setTitle( tr( "All available tracks" ) );
|
||||||
|
m_superAlbumModel->setTitle( tr( "All available albums" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_currentMode == 0 )
|
if ( m_currentMode == 0 )
|
||||||
{
|
{
|
||||||
m_stack->setCurrentWidget( m_superCollectionView );
|
setPage( m_superCollectionView );
|
||||||
m_currentInterface = m_superCollectionView->proxyModel();
|
|
||||||
}
|
}
|
||||||
else if ( m_currentMode == 2 )
|
else if ( m_currentMode == 2 )
|
||||||
{
|
{
|
||||||
m_stack->setCurrentWidget( m_superAlbumView );
|
setPage( m_superAlbumView );
|
||||||
m_currentInterface = m_superAlbumView->proxyModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_infobar->setCaption( tr( "Super Collection" ) );
|
|
||||||
m_infobar->setDescription( tr( "All available tracks" ) );
|
|
||||||
|
|
||||||
m_queueView->show();
|
|
||||||
m_superCollectionVisible = true;
|
m_superCollectionVisible = true;
|
||||||
m_statsAvailable = ( m_currentMode == 0 );
|
|
||||||
m_modesAvailable = true;
|
|
||||||
linkPlaylist();
|
|
||||||
|
|
||||||
emit numSourcesChanged( m_superCollections.count() );
|
emit numSourcesChanged( m_superCollections.count() );
|
||||||
return true;
|
return true;
|
||||||
@@ -490,8 +370,7 @@ PlaylistManager::showSuperCollection()
|
|||||||
void
|
void
|
||||||
PlaylistManager::showWelcomePage()
|
PlaylistManager::showWelcomePage()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
show( m_welcomeWidget );
|
||||||
show( m_welcomeWidget, tr( "Welcome to Tomahawk!" ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -545,8 +424,7 @@ PlaylistManager::showQueue()
|
|||||||
if ( QThread::currentThread() != thread() )
|
if ( QThread::currentThread() != thread() )
|
||||||
{
|
{
|
||||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||||
QMetaObject::invokeMethod( this, "showQueue",
|
QMetaObject::invokeMethod( this, "showQueue", Qt::QueuedConnection );
|
||||||
Qt::QueuedConnection );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,8 +438,7 @@ PlaylistManager::hideQueue()
|
|||||||
if ( QThread::currentThread() != thread() )
|
if ( QThread::currentThread() != thread() )
|
||||||
{
|
{
|
||||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||||
QMetaObject::invokeMethod( this, "hideQueue",
|
QMetaObject::invokeMethod( this, "hideQueue", Qt::QueuedConnection );
|
||||||
Qt::QueuedConnection );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,6 +446,42 @@ PlaylistManager::hideQueue()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistManager::historyBack()
|
||||||
|
{
|
||||||
|
if ( m_historyPosition < 1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
showHistory( m_historyPosition - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistManager::historyForward()
|
||||||
|
{
|
||||||
|
if ( m_historyPosition >= m_pageHistory.count() - 1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
showHistory( m_historyPosition + 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistManager::showHistory( int historyPosition )
|
||||||
|
{
|
||||||
|
if ( historyPosition < 0 || historyPosition >= m_pageHistory.count() )
|
||||||
|
{
|
||||||
|
qDebug() << "History position out of bounds!" << historyPosition << m_pageHistory.count();
|
||||||
|
Q_ASSERT( false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setHistoryPosition( historyPosition );
|
||||||
|
ViewPage* page = m_pageHistory.at( historyPosition );
|
||||||
|
setPage( page, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistManager::setFilter( const QString& filter )
|
PlaylistManager::setFilter( const QString& filter )
|
||||||
{
|
{
|
||||||
@@ -586,67 +499,111 @@ PlaylistManager::applyFilter()
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
if ( m_currentInterface && m_currentInterface->filter() != m_filter )
|
if ( currentPlaylistInterface() && currentPlaylistInterface()->filter() != m_filter )
|
||||||
m_currentInterface->setFilter( m_filter );
|
currentPlaylistInterface()->setFilter( m_filter );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistManager::setPage( ViewPage* page, bool trackHistory )
|
||||||
|
{
|
||||||
|
unlinkPlaylist();
|
||||||
|
|
||||||
|
if ( !m_pageHistory.contains( page ) )
|
||||||
|
{
|
||||||
|
m_stack->addWidget( page->widget() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( trackHistory )
|
||||||
|
m_pageHistory.removeAll( page );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( trackHistory )
|
||||||
|
{
|
||||||
|
m_pageHistory << page;
|
||||||
|
setHistoryPosition( m_pageHistory.count() - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( playlistForInterface( currentPlaylistInterface() ) )
|
||||||
|
emit playlistActivated( playlistForInterface( currentPlaylistInterface() ) );
|
||||||
|
if ( dynamicPlaylistForInterface( currentPlaylistInterface() ) )
|
||||||
|
emit dynamicPlaylistActivated( dynamicPlaylistForInterface( currentPlaylistInterface() ) );
|
||||||
|
if ( collectionForInterface( currentPlaylistInterface() ) )
|
||||||
|
emit collectionActivated( collectionForInterface( currentPlaylistInterface() ) );
|
||||||
|
if ( !currentPlaylistInterface() )
|
||||||
|
emit tempPageActivated();
|
||||||
|
|
||||||
|
m_stack->setCurrentWidget( page->widget() );
|
||||||
|
updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistManager::unlinkPlaylist()
|
PlaylistManager::unlinkPlaylist()
|
||||||
{
|
{
|
||||||
if ( m_currentInterface )
|
if ( currentPlaylistInterface() )
|
||||||
{
|
{
|
||||||
disconnect( m_currentInterface->object(), SIGNAL( sourceTrackCountChanged( unsigned int ) ),
|
disconnect( currentPlaylistInterface()->object(), SIGNAL( sourceTrackCountChanged( unsigned int ) ),
|
||||||
this, SIGNAL( numTracksChanged( unsigned int ) ) );
|
this, SIGNAL( numTracksChanged( unsigned int ) ) );
|
||||||
|
|
||||||
disconnect( m_currentInterface->object(), SIGNAL( trackCountChanged( unsigned int ) ),
|
disconnect( currentPlaylistInterface()->object(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||||
this, SIGNAL( numShownChanged( unsigned int ) ) );
|
this, SIGNAL( numShownChanged( unsigned int ) ) );
|
||||||
|
|
||||||
disconnect( m_currentInterface->object(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
disconnect( currentPlaylistInterface()->object(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||||
this, SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
this, SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
||||||
|
|
||||||
disconnect( m_currentInterface->object(), SIGNAL( shuffleModeChanged( bool ) ),
|
disconnect( currentPlaylistInterface()->object(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||||
this, SIGNAL( shuffleModeChanged( bool ) ) );
|
this, SIGNAL( shuffleModeChanged( bool ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistManager::linkPlaylist()
|
PlaylistManager::updateView()
|
||||||
{
|
{
|
||||||
if ( m_currentInterface )
|
if ( currentPlaylistInterface() )
|
||||||
{
|
{
|
||||||
connect( m_currentInterface->object(), SIGNAL( sourceTrackCountChanged( unsigned int ) ),
|
connect( currentPlaylistInterface()->object(), SIGNAL( sourceTrackCountChanged( unsigned int ) ),
|
||||||
this, SIGNAL( numTracksChanged( unsigned int ) ) );
|
SIGNAL( numTracksChanged( unsigned int ) ) );
|
||||||
|
|
||||||
connect( m_currentInterface->object(), SIGNAL( trackCountChanged( unsigned int ) ),
|
connect( currentPlaylistInterface()->object(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||||
this, SIGNAL( numShownChanged( unsigned int ) ) );
|
SIGNAL( numShownChanged( unsigned int ) ) );
|
||||||
|
|
||||||
connect( m_currentInterface->object(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
connect( currentPlaylistInterface()->object(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||||
this, SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ) );
|
||||||
|
|
||||||
connect( m_currentInterface->object(), SIGNAL( shuffleModeChanged( bool ) ),
|
connect( currentPlaylistInterface()->object(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||||
this, SIGNAL( shuffleModeChanged( bool ) ) );
|
SIGNAL( shuffleModeChanged( bool ) ) );
|
||||||
|
|
||||||
m_interfaceHistory.removeAll( m_currentInterface );
|
m_topbar->setFilter( currentPlaylistInterface()->filter() );
|
||||||
m_interfaceHistory << m_currentInterface;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEngine::instance()->setPlaylist( m_currentInterface );
|
if ( currentPage()->showStatsBar() && currentPlaylistInterface() )
|
||||||
|
|
||||||
if ( m_currentInterface && m_statsAvailable )
|
|
||||||
{
|
{
|
||||||
m_topbar->setFilter( m_currentInterface->filter() );
|
emit numTracksChanged( currentPlaylistInterface()->unfilteredTrackCount() );
|
||||||
|
emit numShownChanged( currentPlaylistInterface()->trackCount() );
|
||||||
emit numTracksChanged( m_currentInterface->unfilteredTrackCount() );
|
emit repeatModeChanged( currentPlaylistInterface()->repeatMode() );
|
||||||
emit numShownChanged( m_currentInterface->trackCount() );
|
emit shuffleModeChanged( currentPlaylistInterface()->shuffled() );
|
||||||
emit repeatModeChanged( m_currentInterface->repeatMode() );
|
emit modeChanged( currentPlaylistInterface()->viewMode() );
|
||||||
emit shuffleModeChanged( m_currentInterface->shuffled() );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit statsAvailable( m_statsAvailable );
|
if ( currentPage()->queueVisible() )
|
||||||
emit modesAvailable( m_modesAvailable );
|
m_queueView->show();
|
||||||
|
else
|
||||||
|
m_queueView->hide();
|
||||||
|
|
||||||
|
emit statsAvailable( currentPage()->showStatsBar() );
|
||||||
|
emit modesAvailable( currentPage()->showModes() );
|
||||||
|
|
||||||
|
if ( !currentPage()->showStatsBar() && !currentPage()->showModes() )
|
||||||
|
m_topbar->setVisible( false );
|
||||||
|
else
|
||||||
|
m_topbar->setVisible( true );
|
||||||
|
|
||||||
|
m_infobar->setCaption( currentPage()->title() );
|
||||||
|
m_infobar->setDescription( currentPage()->description() );
|
||||||
|
m_infobar->setPixmap( currentPage()->pixmap() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -658,17 +615,20 @@ PlaylistManager::onWidgetDestroyed( QWidget* widget )
|
|||||||
bool resetWidget = ( m_stack->currentWidget() == widget );
|
bool resetWidget = ( m_stack->currentWidget() == widget );
|
||||||
m_stack->removeWidget( widget );
|
m_stack->removeWidget( widget );
|
||||||
|
|
||||||
if ( resetWidget && m_interfaceHistory.count() )
|
for ( int i = 0; i < m_pageHistory.count(); i++ )
|
||||||
{
|
{
|
||||||
unlinkPlaylist();
|
ViewPage* page = m_pageHistory.at( i );
|
||||||
|
if ( page->widget() == widget )
|
||||||
|
{
|
||||||
|
m_pageHistory.removeAt( i );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_currentInterface = m_interfaceHistory.last();
|
if ( resetWidget )
|
||||||
qDebug() << "Last interface:" << m_currentInterface << m_currentInterface->widget();
|
{
|
||||||
|
if ( m_pageHistory.count() )
|
||||||
if ( m_currentInterface->widget() )
|
showHistory( m_pageHistory.count() - 1 );
|
||||||
m_stack->setCurrentWidget( m_currentInterface->widget() );
|
|
||||||
|
|
||||||
linkPlaylist();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -676,16 +636,16 @@ PlaylistManager::onWidgetDestroyed( QWidget* widget )
|
|||||||
void
|
void
|
||||||
PlaylistManager::setRepeatMode( PlaylistInterface::RepeatMode mode )
|
PlaylistManager::setRepeatMode( PlaylistInterface::RepeatMode mode )
|
||||||
{
|
{
|
||||||
if ( m_currentInterface )
|
if ( currentPlaylistInterface() )
|
||||||
m_currentInterface->setRepeatMode( mode );
|
currentPlaylistInterface()->setRepeatMode( mode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistManager::setShuffled( bool enabled )
|
PlaylistManager::setShuffled( bool enabled )
|
||||||
{
|
{
|
||||||
if ( m_currentInterface )
|
if ( currentPlaylistInterface() )
|
||||||
m_currentInterface->setShuffled( enabled );
|
currentPlaylistInterface()->setShuffled( enabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -709,20 +669,120 @@ PlaylistManager::createDynamicPlaylist( const Tomahawk::source_ptr& src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ViewPage*
|
||||||
|
PlaylistManager::pageForInterface( PlaylistInterface* interface ) const
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < m_pageHistory.count(); i++ )
|
||||||
|
{
|
||||||
|
ViewPage* page = m_pageHistory.at( i );
|
||||||
|
if ( page->playlistInterface() == interface )
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
PlaylistManager::positionInHistory( ViewPage* page ) const
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < m_pageHistory.count(); i++ )
|
||||||
|
{
|
||||||
|
if ( page == m_pageHistory.at( i ) )
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PlaylistInterface*
|
||||||
|
PlaylistManager::currentPlaylistInterface() const
|
||||||
|
{
|
||||||
|
if ( currentPage() )
|
||||||
|
return currentPage()->playlistInterface();
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::ViewPage*
|
||||||
|
PlaylistManager::currentPage() const
|
||||||
|
{
|
||||||
|
if ( m_historyPosition >= 0 )
|
||||||
|
return m_pageHistory.at( m_historyPosition );
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistManager::setHistoryPosition( int position )
|
||||||
|
{
|
||||||
|
m_historyPosition = position;
|
||||||
|
|
||||||
|
emit historyBackAvailable( m_historyPosition > 0 );
|
||||||
|
emit historyForwardAvailable( m_historyPosition < m_pageHistory.count() - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::playlist_ptr
|
||||||
|
PlaylistManager::playlistForInterface( PlaylistInterface* interface ) const
|
||||||
|
{
|
||||||
|
foreach ( PlaylistView* view, m_playlistViews.values() )
|
||||||
|
{
|
||||||
|
if ( view->playlistInterface() == interface )
|
||||||
|
{
|
||||||
|
return m_playlistViews.key( view );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return playlist_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::dynplaylist_ptr
|
||||||
|
PlaylistManager::dynamicPlaylistForInterface( PlaylistInterface* interface ) const
|
||||||
|
{
|
||||||
|
foreach ( DynamicWidget* view, m_dynamicWidgets.values() )
|
||||||
|
{
|
||||||
|
if ( view->playlistInterface() == interface )
|
||||||
|
{
|
||||||
|
return m_dynamicWidgets.key( view );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dynplaylist_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::collection_ptr
|
||||||
|
PlaylistManager::collectionForInterface( PlaylistInterface* interface ) const
|
||||||
|
{
|
||||||
|
foreach ( CollectionView* view, m_collectionViews.values() )
|
||||||
|
{
|
||||||
|
if ( view->playlistInterface() == interface )
|
||||||
|
{
|
||||||
|
return m_collectionViews.key( view );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ( AlbumView* view, m_collectionAlbumViews.values() )
|
||||||
|
{
|
||||||
|
if ( view->playlistInterface() == interface )
|
||||||
|
{
|
||||||
|
return m_collectionAlbumViews.key( view );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return collection_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistManager::showCurrentTrack()
|
PlaylistManager::showCurrentTrack()
|
||||||
{
|
{
|
||||||
unlinkPlaylist();
|
ViewPage* page = pageForInterface( AudioEngine::instance()->currentTrackPlaylist() );
|
||||||
|
setPage( page );
|
||||||
m_currentInterface = AudioEngine::instance()->currentTrackPlaylist();
|
|
||||||
|
|
||||||
if ( m_currentInterface->widget() )
|
|
||||||
m_stack->setCurrentWidget( m_currentInterface->widget() );
|
|
||||||
|
|
||||||
linkPlaylist();
|
|
||||||
|
|
||||||
/* if ( m_currentView && m_currentProxyModel )
|
|
||||||
m_currentView->scrollTo( m_currentProxyModel->currentItem(), QAbstractItemView::PositionAtCenter );*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -737,4 +797,4 @@ void
|
|||||||
PlaylistManager::onPauseClicked()
|
PlaylistManager::onPauseClicked()
|
||||||
{
|
{
|
||||||
emit pauseClicked();
|
emit pauseClicked();
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
@@ -27,7 +28,8 @@ class InfoBar;
|
|||||||
class TopBar;
|
class TopBar;
|
||||||
class WelcomeWidget;
|
class WelcomeWidget;
|
||||||
|
|
||||||
namespace Tomahawk {
|
namespace Tomahawk
|
||||||
|
{
|
||||||
class DynamicWidget;
|
class DynamicWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +48,10 @@ public:
|
|||||||
|
|
||||||
bool isSuperCollectionVisible() const { return true; }
|
bool isSuperCollectionVisible() const { return true; }
|
||||||
|
|
||||||
PlaylistInterface* currentPlaylistInterface() const { return m_currentInterface; }
|
PlaylistInterface* currentPlaylistInterface() const;
|
||||||
|
Tomahawk::ViewPage* currentPage() const;
|
||||||
|
Tomahawk::ViewPage* pageForInterface( PlaylistInterface* interface ) const;
|
||||||
|
int positionInHistory( Tomahawk::ViewPage* page ) const;
|
||||||
|
|
||||||
bool show( const Tomahawk::playlist_ptr& playlist );
|
bool show( const Tomahawk::playlist_ptr& playlist );
|
||||||
bool show( const Tomahawk::dynplaylist_ptr& playlist );
|
bool show( const Tomahawk::dynplaylist_ptr& playlist );
|
||||||
@@ -55,7 +60,7 @@ public:
|
|||||||
bool show( const Tomahawk::collection_ptr& collection );
|
bool show( const Tomahawk::collection_ptr& collection );
|
||||||
bool show( const Tomahawk::source_ptr& source );
|
bool show( const Tomahawk::source_ptr& source );
|
||||||
|
|
||||||
bool show( QWidget* widget, const QString& title = QString(), const QString& desc = QString(), const QPixmap& pixmap = QPixmap() );
|
bool show( Tomahawk::ViewPage* page );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void numSourcesChanged( unsigned int sources );
|
void numSourcesChanged( unsigned int sources );
|
||||||
@@ -68,15 +73,29 @@ signals:
|
|||||||
|
|
||||||
void statsAvailable( bool b );
|
void statsAvailable( bool b );
|
||||||
void modesAvailable( bool b );
|
void modesAvailable( bool b );
|
||||||
|
void modeChanged( PlaylistInterface::ViewMode mode );
|
||||||
|
|
||||||
void playClicked();
|
void playClicked();
|
||||||
void pauseClicked();
|
void pauseClicked();
|
||||||
|
|
||||||
|
void historyBackAvailable( bool avail );
|
||||||
|
void historyForwardAvailable( bool avail );
|
||||||
|
|
||||||
|
void tempPageActivated();
|
||||||
|
void superCollectionActivated();
|
||||||
|
void collectionActivated( const Tomahawk::collection_ptr& collection );
|
||||||
|
void playlistActivated( const Tomahawk::playlist_ptr& playlist );
|
||||||
|
void dynamicPlaylistActivated( const Tomahawk::dynplaylist_ptr& playlist );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool showSuperCollection();
|
bool showSuperCollection();
|
||||||
void showWelcomePage();
|
void showWelcomePage();
|
||||||
void showCurrentTrack();
|
void showCurrentTrack();
|
||||||
|
|
||||||
|
void historyBack();
|
||||||
|
void historyForward();
|
||||||
|
void showHistory( int historyPosition );
|
||||||
|
|
||||||
void setTreeMode();
|
void setTreeMode();
|
||||||
void setTableMode();
|
void setTableMode();
|
||||||
void setAlbumMode();
|
void setAlbumMode();
|
||||||
@@ -103,9 +122,15 @@ private slots:
|
|||||||
void onWidgetDestroyed( QWidget* widget );
|
void onWidgetDestroyed( QWidget* widget );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setHistoryPosition( int position );
|
||||||
|
void setPage( Tomahawk::ViewPage* page, bool trackHistory = true );
|
||||||
|
void updateView();
|
||||||
void unlinkPlaylist();
|
void unlinkPlaylist();
|
||||||
void linkPlaylist();
|
|
||||||
|
|
||||||
|
Tomahawk::playlist_ptr playlistForInterface( PlaylistInterface* interface ) const;
|
||||||
|
Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( 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;
|
||||||
@@ -130,19 +155,15 @@ 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;
|
||||||
|
|
||||||
PlaylistInterface* m_currentInterface;
|
QList<Tomahawk::ViewPage*> m_pageHistory;
|
||||||
QList<PlaylistInterface*> m_interfaceHistory;
|
int m_historyPosition;
|
||||||
|
|
||||||
QWidget* m_currentInfoWidget;
|
|
||||||
|
|
||||||
Tomahawk::collection_ptr m_currentCollection;
|
Tomahawk::collection_ptr m_currentCollection;
|
||||||
|
|
||||||
int m_currentMode;
|
int m_currentMode;
|
||||||
bool m_superCollectionVisible;
|
bool m_superCollectionVisible;
|
||||||
bool m_statsAvailable;
|
|
||||||
bool m_modesAvailable;
|
|
||||||
|
|
||||||
QTimer m_filterTimer;
|
QTimer m_filterTimer;
|
||||||
QString m_filter;
|
QString m_filter;
|
||||||
|
|
||||||
|
@@ -67,8 +67,10 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
||||||
|
|
||||||
setReadOnly( !m_playlist->author()->isLocal() );
|
setReadOnly( !m_playlist->author()->isLocal() );
|
||||||
|
setTitle( playlist->title() );
|
||||||
|
setDescription( tr( "A playlist by %1" ).arg( playlist->author()->isLocal() ? tr( "you" ) : playlist->author()->friendlyName() ) );
|
||||||
|
|
||||||
if( !loadEntries )
|
if ( !loadEntries )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlItem* plitem;
|
PlItem* plitem;
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include "playlist/playlistmodel.h"
|
|
||||||
#include "playlist/playlistproxymodel.h"
|
#include "playlist/playlistproxymodel.h"
|
||||||
#include "widgets/overlaywidget.h"
|
#include "widgets/overlaywidget.h"
|
||||||
|
|
||||||
@@ -129,3 +128,10 @@ PlaylistView::onTrackCountChanged( unsigned int tracks )
|
|||||||
else
|
else
|
||||||
overlay()->hide();
|
overlay()->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
PlaylistView::jumpToCurrentTrack()
|
||||||
|
{
|
||||||
|
scrollTo( proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
||||||
|
}
|
||||||
|
@@ -3,13 +3,16 @@
|
|||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
#include "playlist/trackproxymodel.h"
|
||||||
|
#include "playlist/playlistmodel.h"
|
||||||
#include "trackview.h"
|
#include "trackview.h"
|
||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
class PlaylistModel;
|
class PlaylistModel;
|
||||||
|
|
||||||
class DLLEXPORT PlaylistView : public TrackView
|
class DLLEXPORT PlaylistView : public TrackView, public Tomahawk::ViewPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -20,6 +23,14 @@ public:
|
|||||||
PlaylistModel* playlistModel() const { return m_model; }
|
PlaylistModel* playlistModel() const { return m_model; }
|
||||||
virtual void setModel( PlaylistModel* model );
|
virtual void setModel( PlaylistModel* model );
|
||||||
|
|
||||||
|
virtual QWidget* widget() { return this; }
|
||||||
|
virtual PlaylistInterface* playlistInterface() const { return proxyModel(); }
|
||||||
|
|
||||||
|
virtual QString title() const { return playlistModel()->title(); }
|
||||||
|
virtual QString description() const { return m_model->description(); }
|
||||||
|
|
||||||
|
virtual bool jumpToCurrentTrack();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent( QKeyEvent* event );
|
void keyPressEvent( QKeyEvent* event );
|
||||||
|
|
||||||
|
@@ -65,7 +65,28 @@ TopBar::TopBar( QWidget* parent )
|
|||||||
setNumArtists( 0 );
|
setNumArtists( 0 );
|
||||||
setNumShown( 0 );
|
setNumShown( 0 );
|
||||||
|
|
||||||
ui->radioNormal->setChecked( true );
|
onFlatMode();
|
||||||
|
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( numSourcesChanged( unsigned int ) ),
|
||||||
|
SLOT( setNumSources( unsigned int ) ) );
|
||||||
|
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( numTracksChanged( unsigned int ) ),
|
||||||
|
SLOT( setNumTracks( unsigned int ) ) );
|
||||||
|
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( numArtistsChanged( unsigned int ) ),
|
||||||
|
SLOT( setNumArtists( unsigned int ) ) );
|
||||||
|
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( numShownChanged( unsigned int ) ),
|
||||||
|
SLOT( setNumShown( unsigned int ) ) );
|
||||||
|
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( statsAvailable( bool ) ),
|
||||||
|
SLOT( setStatsVisible( bool ) ) );
|
||||||
|
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( modesAvailable( bool ) ),
|
||||||
|
SLOT( setModesVisible( bool ) ) );
|
||||||
|
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( modeChanged( PlaylistInterface::ViewMode ) ),
|
||||||
|
SLOT( onModeChanged( PlaylistInterface::ViewMode ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -238,3 +259,48 @@ TopBar::setFilter( const QString& filter )
|
|||||||
{
|
{
|
||||||
ui->filterEdit->setText( filter );
|
ui->filterEdit->setText( filter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TopBar::onModeChanged( PlaylistInterface::ViewMode mode )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << mode;
|
||||||
|
switch ( mode )
|
||||||
|
{
|
||||||
|
case PlaylistInterface::Flat:
|
||||||
|
onFlatMode();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PlaylistInterface::Tree:
|
||||||
|
onArtistMode();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PlaylistInterface::Album:
|
||||||
|
onAlbumMode();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TopBar::onFlatMode()
|
||||||
|
{
|
||||||
|
ui->radioNormal->setChecked( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TopBar::onArtistMode()
|
||||||
|
{
|
||||||
|
ui->radioDetailed->setChecked( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TopBar::onAlbumMode()
|
||||||
|
{
|
||||||
|
ui->radioCloud->setChecked( true );
|
||||||
|
}
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
#include "playlist/playlistmanager.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
@@ -42,6 +43,12 @@ public slots:
|
|||||||
|
|
||||||
void setFilter( const QString& filter );
|
void setFilter( const QString& filter );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onModeChanged( PlaylistInterface::ViewMode mode );
|
||||||
|
void onFlatMode();
|
||||||
|
void onArtistMode();
|
||||||
|
void onAlbumMode();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent( QEvent* e );
|
void changeEvent( QEvent* e );
|
||||||
void resizeEvent( QResizeEvent* e );
|
void resizeEvent( QResizeEvent* e );
|
||||||
|
@@ -35,6 +35,11 @@ public:
|
|||||||
|
|
||||||
virtual bool isReadOnly() const { return m_readOnly; }
|
virtual bool isReadOnly() const { return m_readOnly; }
|
||||||
|
|
||||||
|
virtual QString title() const { return m_title; }
|
||||||
|
virtual void setTitle( const QString& title ) { m_title = title; }
|
||||||
|
virtual QString description() const { return m_description; }
|
||||||
|
virtual void setDescription( const QString& description ) { m_description = description; }
|
||||||
|
|
||||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||||
|
|
||||||
virtual int rowCount( const QModelIndex& parent ) const;
|
virtual int rowCount( const QModelIndex& parent ) const;
|
||||||
@@ -84,6 +89,9 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
QPersistentModelIndex m_currentIndex;
|
QPersistentModelIndex m_currentIndex;
|
||||||
bool m_readOnly;
|
bool m_readOnly;
|
||||||
|
|
||||||
|
QString m_title;
|
||||||
|
QString m_description;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACKMODEL_H
|
#endif // TRACKMODEL_H
|
||||||
|
@@ -73,7 +73,6 @@ void
|
|||||||
TrackView::setProxyModel( TrackProxyModel* model )
|
TrackView::setProxyModel( TrackProxyModel* model )
|
||||||
{
|
{
|
||||||
m_proxyModel = model;
|
m_proxyModel = model;
|
||||||
m_proxyModel->setWidget( this );
|
|
||||||
|
|
||||||
m_delegate = new PlaylistItemDelegate( this, m_proxyModel );
|
m_delegate = new PlaylistItemDelegate( this, m_proxyModel );
|
||||||
setItemDelegate( m_delegate );
|
setItemDelegate( m_delegate );
|
||||||
|
@@ -13,8 +13,9 @@ class DLLEXPORT PlaylistInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
||||||
|
enum ViewMode { Unknown, Flat, Tree, Album };
|
||||||
PlaylistInterface( QObject* parent = 0 ) : m_widget( 0 ), m_object( parent ) {}
|
|
||||||
|
PlaylistInterface( QObject* parent = 0 ) : m_object( parent ) {}
|
||||||
virtual ~PlaylistInterface() {}
|
virtual ~PlaylistInterface() {}
|
||||||
|
|
||||||
virtual QList< Tomahawk::query_ptr > tracks() = 0;
|
virtual QList< Tomahawk::query_ptr > tracks() = 0;
|
||||||
@@ -28,13 +29,11 @@ public:
|
|||||||
|
|
||||||
virtual PlaylistInterface::RepeatMode repeatMode() const = 0;
|
virtual PlaylistInterface::RepeatMode repeatMode() const = 0;
|
||||||
virtual bool shuffled() const = 0;
|
virtual bool shuffled() const = 0;
|
||||||
|
virtual PlaylistInterface::ViewMode viewMode() const { return Unknown; }
|
||||||
|
|
||||||
virtual QString filter() const { return m_filter; }
|
virtual QString filter() const { return m_filter; }
|
||||||
virtual void setFilter( const QString& pattern ) { m_filter = pattern; }
|
virtual void setFilter( const QString& pattern ) { m_filter = pattern; }
|
||||||
|
|
||||||
QWidget* widget() const { return m_widget; }
|
|
||||||
void setWidget( QWidget* widget ) { m_widget = widget; }
|
|
||||||
|
|
||||||
QObject* object() const { return m_object; }
|
QObject* object() const { return m_object; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -48,7 +47,6 @@ signals:
|
|||||||
virtual void sourceTrackCountChanged( unsigned int tracks ) = 0;
|
virtual void sourceTrackCountChanged( unsigned int tracks ) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* m_widget;
|
|
||||||
QObject* m_object;
|
QObject* m_object;
|
||||||
|
|
||||||
QString m_filter;
|
QString m_filter;
|
||||||
|
6
src/libtomahawk/viewpage.cpp
Normal file
6
src/libtomahawk/viewpage.cpp
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
38
src/libtomahawk/viewpage.h
Normal file
38
src/libtomahawk/viewpage.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef VIEWPAGE_H
|
||||||
|
#define VIEWPAGE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "typedefs.h"
|
||||||
|
#include "playlistinterface.h"
|
||||||
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class DLLEXPORT ViewPage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ViewPage() {}
|
||||||
|
|
||||||
|
virtual QWidget* widget() = 0;
|
||||||
|
virtual PlaylistInterface* playlistInterface() const = 0;
|
||||||
|
|
||||||
|
virtual QString title() const = 0;
|
||||||
|
virtual QString description() const = 0;
|
||||||
|
virtual QPixmap pixmap() const { return QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ); }
|
||||||
|
|
||||||
|
virtual bool showStatsBar() const { return true; }
|
||||||
|
virtual bool showModes() const { return false; }
|
||||||
|
virtual bool queueVisible() const { return true; }
|
||||||
|
|
||||||
|
virtual bool jumpToCurrentTrack() = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // ns
|
||||||
|
|
||||||
|
#endif //VIEWPAGE_H
|
@@ -43,6 +43,8 @@ SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget*
|
|||||||
m_recentAlbumModel = new AlbumModel( ui->recentAlbumView );
|
m_recentAlbumModel = new AlbumModel( ui->recentAlbumView );
|
||||||
ui->recentAlbumView->setModel( m_recentAlbumModel );
|
ui->recentAlbumView->setModel( m_recentAlbumModel );
|
||||||
m_recentAlbumModel->addFilteredCollection( source->collection(), 20, DatabaseCommand_AllAlbums::ModificationTime );
|
m_recentAlbumModel->addFilteredCollection( source->collection(), 20, DatabaseCommand_AllAlbums::ModificationTime );
|
||||||
|
|
||||||
|
m_title = tr( "Info about %1" ).arg( source->isLocal() ? tr( "Your Collection" ) : source->friendlyName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#include "album.h"
|
#include "album.h"
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ namespace Ui
|
|||||||
class SourceInfoWidget;
|
class SourceInfoWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DLLEXPORT SourceInfoWidget : public QWidget
|
class DLLEXPORT SourceInfoWidget : public QWidget, public Tomahawk::ViewPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -26,6 +27,16 @@ public:
|
|||||||
SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget* parent = 0 );
|
SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget* parent = 0 );
|
||||||
~SourceInfoWidget();
|
~SourceInfoWidget();
|
||||||
|
|
||||||
|
virtual QWidget* widget() { return this; }
|
||||||
|
virtual PlaylistInterface* playlistInterface() const { return 0; }
|
||||||
|
|
||||||
|
virtual QString title() const { return m_title; }
|
||||||
|
virtual QString description() const { return m_description; }
|
||||||
|
|
||||||
|
virtual bool showStatsBar() const { return false; }
|
||||||
|
|
||||||
|
virtual bool jumpToCurrentTrack() { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent( QEvent* e );
|
void changeEvent( QEvent* e );
|
||||||
|
|
||||||
@@ -38,6 +49,9 @@ private:
|
|||||||
CollectionFlatModel* m_recentCollectionModel;
|
CollectionFlatModel* m_recentCollectionModel;
|
||||||
PlaylistModel* m_historyModel;
|
PlaylistModel* m_historyModel;
|
||||||
AlbumModel* m_recentAlbumModel;
|
AlbumModel* m_recentAlbumModel;
|
||||||
|
|
||||||
|
QString m_title;
|
||||||
|
QString m_description;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SOURCEINFOWIDGET_H
|
#endif // SOURCEINFOWIDGET_H
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#include "album.h"
|
#include "album.h"
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ namespace Ui
|
|||||||
class NewPlaylistWidget;
|
class NewPlaylistWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DLLEXPORT NewPlaylistWidget : public QWidget
|
class DLLEXPORT NewPlaylistWidget : public QWidget, public Tomahawk::ViewPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -26,6 +27,16 @@ public:
|
|||||||
NewPlaylistWidget( QWidget* parent = 0 );
|
NewPlaylistWidget( QWidget* parent = 0 );
|
||||||
~NewPlaylistWidget();
|
~NewPlaylistWidget();
|
||||||
|
|
||||||
|
virtual QWidget* widget() { return this; }
|
||||||
|
virtual PlaylistInterface* playlistInterface() const { return 0; }
|
||||||
|
|
||||||
|
virtual QString title() const { return tr( "Create a new playlist" ); }
|
||||||
|
virtual QString description() const { return QString(); }
|
||||||
|
|
||||||
|
virtual bool showStatsBar() const { return false; }
|
||||||
|
|
||||||
|
virtual bool jumpToCurrentTrack() { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent( QEvent* e );
|
void changeEvent( QEvent* e );
|
||||||
|
|
||||||
|
@@ -11,28 +11,11 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="captionLabel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>20</pointsize>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Create A New Playlist</string>
|
|
||||||
</property>
|
|
||||||
<property name="scaledContents">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>13</pointsize>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -54,7 +37,7 @@
|
|||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>13</pointsize>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -69,7 +52,7 @@
|
|||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>13</pointsize>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT WelcomeWidget : public QWidget
|
class DLLEXPORT WelcomeWidget : public QWidget, public Tomahawk::ViewPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -81,6 +82,16 @@ public:
|
|||||||
WelcomeWidget( QWidget* parent = 0 );
|
WelcomeWidget( QWidget* parent = 0 );
|
||||||
~WelcomeWidget();
|
~WelcomeWidget();
|
||||||
|
|
||||||
|
virtual QWidget* widget() { return this; }
|
||||||
|
virtual PlaylistInterface* playlistInterface() const { return 0; }
|
||||||
|
|
||||||
|
virtual QString title() const { return tr( "Welcome to Tomahawk" ); }
|
||||||
|
virtual QString description() const { return QString(); }
|
||||||
|
|
||||||
|
virtual bool showStatsBar() const { return false; }
|
||||||
|
|
||||||
|
virtual bool jumpToCurrentTrack() { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent( QEvent* e );
|
void changeEvent( QEvent* e );
|
||||||
|
|
||||||
|
@@ -526,7 +526,7 @@ Jabber_p::handleRosterPresence( const RosterItem& item, const std::string& resou
|
|||||||
// convert to QString to get proper regex support
|
// convert to QString to get proper regex support
|
||||||
QString res( jid.resource().c_str() );
|
QString res( jid.resource().c_str() );
|
||||||
QRegExp regex( "tomahawk\\d+" );
|
QRegExp regex( "tomahawk\\d+" );
|
||||||
if( res != "tomahawk-tomahawk" && !res.contains( regex ) )
|
if( res != "tomahawk-tomahawk" && !res.startsWith( "tomahawk" ) )
|
||||||
{
|
{
|
||||||
//qDebug() << "not considering resource of" << res;
|
//qDebug() << "not considering resource of" << res;
|
||||||
// Disco them to check if they are tomahawk-capable
|
// Disco them to check if they are tomahawk-capable
|
||||||
|
@@ -58,7 +58,8 @@ SourcesModel::flags( const QModelIndex& index ) const
|
|||||||
playlist_ptr playlist = indexToPlaylist( index );
|
playlist_ptr playlist = indexToPlaylist( index );
|
||||||
if ( !playlist.isNull() && playlist->author()->isLocal() )
|
if ( !playlist.isNull() && playlist->author()->isLocal() )
|
||||||
defaultFlags |= Qt::ItemIsEditable;
|
defaultFlags |= Qt::ItemIsEditable;
|
||||||
} else if ( indexType( index ) == DynamicPlaylistSource )
|
}
|
||||||
|
else if ( indexType( index ) == DynamicPlaylistSource )
|
||||||
{
|
{
|
||||||
dynplaylist_ptr playlist = indexToDynamicPlaylist( index );
|
dynplaylist_ptr playlist = indexToDynamicPlaylist( index );
|
||||||
if ( !playlist.isNull() && playlist->author()->isLocal() )
|
if ( !playlist.isNull() && playlist->author()->isLocal() )
|
||||||
@@ -261,6 +262,75 @@ SourcesModel::indexToTreeItem( const QModelIndex& index )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QModelIndex
|
||||||
|
SourcesModel::playlistToIndex( const Tomahawk::playlist_ptr& playlist )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < rowCount(); i++ )
|
||||||
|
{
|
||||||
|
QModelIndex pidx = index( i, 0 );
|
||||||
|
|
||||||
|
for ( int j = 0; j < rowCount( pidx ); j++ )
|
||||||
|
{
|
||||||
|
QModelIndex idx = index( j, 0, pidx );
|
||||||
|
SourcesModel::SourceType type = SourcesModel::indexType( idx );
|
||||||
|
|
||||||
|
if ( type == SourcesModel::PlaylistSource )
|
||||||
|
{
|
||||||
|
playlist_ptr p = SourcesModel::indexToPlaylist( idx );
|
||||||
|
if ( playlist.data() == p.data() )
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QModelIndex
|
||||||
|
SourcesModel::dynamicPlaylistToIndex( const Tomahawk::dynplaylist_ptr& playlist )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < rowCount(); i++ )
|
||||||
|
{
|
||||||
|
QModelIndex pidx = index( i, 0 );
|
||||||
|
|
||||||
|
for ( int j = 0; j < rowCount( pidx ); j++ )
|
||||||
|
{
|
||||||
|
QModelIndex idx = index( j, 0, pidx );
|
||||||
|
SourcesModel::SourceType type = SourcesModel::indexType( idx );
|
||||||
|
|
||||||
|
if ( type == SourcesModel::DynamicPlaylistSource )
|
||||||
|
{
|
||||||
|
playlist_ptr p = SourcesModel::indexToDynamicPlaylist( idx );
|
||||||
|
if ( playlist.data() == p.data() )
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QModelIndex
|
||||||
|
SourcesModel::collectionToIndex( const Tomahawk::collection_ptr& collection )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < rowCount(); i++ )
|
||||||
|
{
|
||||||
|
QModelIndex idx = index( i, 0 );
|
||||||
|
SourcesModel::SourceType type = SourcesModel::indexType( idx );
|
||||||
|
if ( type == SourcesModel::CollectionSource )
|
||||||
|
{
|
||||||
|
SourceTreeItem* sti = SourcesModel::indexToTreeItem( idx );
|
||||||
|
if ( sti && !sti->source().isNull() && sti->source()->collection().data() == collection.data() )
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SourcesModel::setData( const QModelIndex& index, const QVariant& value, int role )
|
SourcesModel::setData( const QModelIndex& index, const QVariant& value, int role )
|
||||||
{
|
{
|
||||||
|
@@ -37,6 +37,10 @@ public:
|
|||||||
static Tomahawk::dynplaylist_ptr indexToDynamicPlaylist( const QModelIndex& index );
|
static Tomahawk::dynplaylist_ptr indexToDynamicPlaylist( const QModelIndex& index );
|
||||||
static SourceTreeItem* indexToTreeItem( const QModelIndex& index );
|
static SourceTreeItem* indexToTreeItem( const QModelIndex& index );
|
||||||
|
|
||||||
|
QModelIndex playlistToIndex( const Tomahawk::playlist_ptr& playlist );
|
||||||
|
QModelIndex dynamicPlaylistToIndex( const Tomahawk::dynplaylist_ptr& playlist );
|
||||||
|
QModelIndex collectionToIndex( const Tomahawk::collection_ptr& collection );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked( const QModelIndex& );
|
void clicked( const QModelIndex& );
|
||||||
|
|
||||||
|
@@ -237,8 +237,8 @@ void SourceTreeItem::playlistAddedInternal( qlonglong ptr, const Tomahawk::playl
|
|||||||
subitem->setData( (qlonglong)this, SourceItemPointer );
|
subitem->setData( (qlonglong)this, SourceItemPointer );
|
||||||
|
|
||||||
m_columns.at( 0 )->appendRow( subitem );
|
m_columns.at( 0 )->appendRow( subitem );
|
||||||
Q_ASSERT( qobject_cast<QTreeView*>((parent()->parent()) ) );
|
// Q_ASSERT( qobject_cast<QTreeView*>((parent()->parent()) ) );
|
||||||
qobject_cast<QTreeView*>((parent()->parent()))->expandAll();
|
// qobject_cast<QTreeView*>((parent()->parent()))->expandAll();
|
||||||
|
|
||||||
p->loadRevision();
|
p->loadRevision();
|
||||||
}
|
}
|
||||||
|
@@ -67,7 +67,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
|||||||
setItemDelegate( new SourceDelegate( this ) );
|
setItemDelegate( new SourceDelegate( this ) );
|
||||||
|
|
||||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||||
connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( onCustomContextMenu( const QPoint& ) ) );
|
connect( this, SIGNAL( customContextMenuRequested( QPoint ) ), SLOT( onCustomContextMenu( QPoint ) ) );
|
||||||
|
|
||||||
m_model = new SourcesModel( this );
|
m_model = new SourcesModel( this );
|
||||||
m_proxyModel = new SourcesProxyModel( m_model, this );
|
m_proxyModel = new SourcesProxyModel( m_model, this );
|
||||||
@@ -77,14 +77,25 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
|||||||
header()->setResizeMode( 0, QHeaderView::Stretch );
|
header()->setResizeMode( 0, QHeaderView::Stretch );
|
||||||
|
|
||||||
connect( m_model, SIGNAL( clicked( QModelIndex ) ), SIGNAL( clicked( QModelIndex ) ) );
|
connect( m_model, SIGNAL( clicked( QModelIndex ) ), SIGNAL( clicked( QModelIndex ) ) );
|
||||||
connect( this, SIGNAL( clicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
connect( this, SIGNAL( clicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
||||||
|
|
||||||
connect( selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), SLOT( onSelectionChanged() ) );
|
connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onSelectionChanged() ) );
|
||||||
connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) );
|
connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) );
|
||||||
|
|
||||||
m_model->appendItem( source_ptr() );
|
m_model->appendItem( source_ptr() );
|
||||||
|
|
||||||
hideOfflineSources();
|
hideOfflineSources();
|
||||||
|
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( playlistActivated( Tomahawk::playlist_ptr ) ),
|
||||||
|
SLOT( onPlaylistActivated( Tomahawk::playlist_ptr ) ) );
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( dynamicPlaylistActivated( Tomahawk::dynplaylist_ptr ) ),
|
||||||
|
SLOT( onDynamicPlaylistActivated( Tomahawk::dynplaylist_ptr ) ) );
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( collectionActivated( Tomahawk::collection_ptr ) ),
|
||||||
|
SLOT( onCollectionActivated( Tomahawk::collection_ptr ) ) );
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( superCollectionActivated() ),
|
||||||
|
SLOT( onSuperCollectionActivated() ) );
|
||||||
|
connect( PlaylistManager::instance(), SIGNAL( tempPageActivated() ),
|
||||||
|
SLOT( onTempPageActivated() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,6 +154,57 @@ SourceTreeView::onSourceOffline( Tomahawk::source_ptr src )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::onPlaylistActivated( const Tomahawk::playlist_ptr& playlist )
|
||||||
|
{
|
||||||
|
QModelIndex idx = m_proxyModel->mapFromSource( m_model->playlistToIndex( playlist ) );
|
||||||
|
if ( idx.isValid() )
|
||||||
|
{
|
||||||
|
setCurrentIndex( idx );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::onDynamicPlaylistActivated( const Tomahawk::dynplaylist_ptr& playlist )
|
||||||
|
{
|
||||||
|
QModelIndex idx = m_proxyModel->mapFromSource( m_model->dynamicPlaylistToIndex( playlist ) );
|
||||||
|
if ( idx.isValid() )
|
||||||
|
{
|
||||||
|
setCurrentIndex( idx );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::onCollectionActivated( const Tomahawk::collection_ptr& collection )
|
||||||
|
{
|
||||||
|
QModelIndex idx = m_proxyModel->mapFromSource( m_model->collectionToIndex( collection ) );
|
||||||
|
if ( idx.isValid() )
|
||||||
|
{
|
||||||
|
setCurrentIndex( idx );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::onSuperCollectionActivated()
|
||||||
|
{
|
||||||
|
QModelIndex idx = m_proxyModel->index( 0, 0 );
|
||||||
|
if ( idx.isValid() )
|
||||||
|
{
|
||||||
|
setCurrentIndex( idx );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::onTempPageActivated()
|
||||||
|
{
|
||||||
|
clearSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreeView::onItemActivated( const QModelIndex& index )
|
SourceTreeView::onItemActivated( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
|
@@ -27,6 +27,12 @@ signals:
|
|||||||
void onOffline( const QModelIndex& index );
|
void onOffline( const QModelIndex& index );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void onPlaylistActivated( const Tomahawk::playlist_ptr& playlist );
|
||||||
|
void onDynamicPlaylistActivated( const Tomahawk::dynplaylist_ptr& playlist );
|
||||||
|
void onCollectionActivated( const Tomahawk::collection_ptr& collection );
|
||||||
|
void onSuperCollectionActivated();
|
||||||
|
void onTempPageActivated();
|
||||||
|
|
||||||
void onItemActivated( const QModelIndex& index );
|
void onItemActivated( const QModelIndex& index );
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
|
|
||||||
|
@@ -56,6 +56,8 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
PlaylistManager* pm = new PlaylistManager( this );
|
PlaylistManager* pm = new PlaylistManager( this );
|
||||||
|
connect( pm, SIGNAL( historyBackAvailable( bool ) ), SLOT( onHistoryBackAvailable( bool ) ) );
|
||||||
|
connect( pm, SIGNAL( historyForwardAvailable( bool ) ), SLOT( onHistoryForwardAvailable( bool ) ) );
|
||||||
|
|
||||||
connect( m_audioControls, SIGNAL( playPressed() ), pm, SLOT( onPlayClicked() ) );
|
connect( m_audioControls, SIGNAL( playPressed() ), pm, SLOT( onPlayClicked() ) );
|
||||||
connect( m_audioControls, SIGNAL( pausePressed() ), pm, SLOT( onPauseClicked() ) );
|
connect( m_audioControls, SIGNAL( pausePressed() ), pm, SLOT( onPauseClicked() ) );
|
||||||
@@ -119,9 +121,11 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
|||||||
toolbar->setMovable( false );
|
toolbar->setMovable( false );
|
||||||
toolbar->setFloatable( false );
|
toolbar->setFloatable( false );
|
||||||
toolbar->setIconSize( QSize( 32, 32 ) );
|
toolbar->setIconSize( QSize( 32, 32 ) );
|
||||||
toolbar->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
toolbar->setToolButtonStyle( Qt::ToolButtonFollowStyle );
|
||||||
toolbar->installEventFilter( new WidgetDragFilter( toolbar ) );
|
toolbar->installEventFilter( new WidgetDragFilter( toolbar ) );
|
||||||
|
|
||||||
|
m_backAvailable = toolbar->addAction( QIcon( RESPATH "images/back.png" ), tr( "Back" ), PlaylistManager::instance(), SLOT( historyBack() ) );
|
||||||
|
m_forwardAvailable = toolbar->addAction( QIcon( RESPATH "images/forward.png" ), tr( "Forward" ), PlaylistManager::instance(), SLOT( historyForward() ) );
|
||||||
toolbar->addAction( QIcon( RESPATH "images/home.png" ), tr( "Home" ), PlaylistManager::instance(), SLOT( showWelcomePage() ) );
|
toolbar->addAction( QIcon( RESPATH "images/home.png" ), tr( "Home" ), PlaylistManager::instance(), SLOT( showWelcomePage() ) );
|
||||||
|
|
||||||
statusBar()->addPermanentWidget( m_audioControls, 1 );
|
statusBar()->addPermanentWidget( m_audioControls, 1 );
|
||||||
@@ -355,6 +359,20 @@ TomahawkWindow::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkWindow::onHistoryBackAvailable( bool avail )
|
||||||
|
{
|
||||||
|
m_backAvailable->setEnabled( avail );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkWindow::onHistoryForwardAvailable( bool avail )
|
||||||
|
{
|
||||||
|
m_forwardAvailable->setEnabled( avail );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::onSipConnected()
|
TomahawkWindow::onSipConnected()
|
||||||
{
|
{
|
||||||
|
@@ -54,7 +54,9 @@ private slots:
|
|||||||
void addPeerManually();
|
void addPeerManually();
|
||||||
|
|
||||||
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
||||||
|
void onHistoryBackAvailable( bool avail );
|
||||||
|
void onHistoryForwardAvailable( bool avail );
|
||||||
|
|
||||||
void showAboutTomahawk();
|
void showAboutTomahawk();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -68,6 +70,9 @@ private:
|
|||||||
QNetworkAccessManager m_nam;
|
QNetworkAccessManager m_nam;
|
||||||
QPushButton* m_statusButton;
|
QPushButton* m_statusButton;
|
||||||
|
|
||||||
|
QAction* m_backAvailable;
|
||||||
|
QAction* m_forwardAvailable;
|
||||||
|
|
||||||
Tomahawk::result_ptr m_currentTrack;
|
Tomahawk::result_ptr m_currentTrack;
|
||||||
QString m_windowTitle;
|
QString m_windowTitle;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user