1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

* Added a few overlay info messages.

This commit is contained in:
Christian Muehlhaeuser
2011-11-26 09:59:27 +01:00
parent 7b96505d27
commit b86c0f5c5e
12 changed files with 68 additions and 19 deletions

View File

@@ -226,6 +226,8 @@ AlbumModel::removeIndex( const QModelIndex& index )
delete item; delete item;
emit endRemoveRows(); emit endRemoveRows();
} }
emit itemCountChanged( rowCount( QModelIndex() ) );
} }
@@ -259,7 +261,7 @@ AlbumModel::addCollection( const collection_ptr& collection, bool overwrite )
if ( collection.isNull() ) if ( collection.isNull() )
{ {
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::UniqueConnection );
QList<Tomahawk::source_ptr> sources = SourceList::instance()->sources(); QList<Tomahawk::source_ptr> sources = SourceList::instance()->sources();
foreach ( const source_ptr& source, sources ) foreach ( const source_ptr& source, sources )
@@ -289,6 +291,7 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in
cmd->setSortOrder( order ); cmd->setSortOrder( order );
cmd->setSortDescending( true ); cmd->setSortDescending( true );
m_overwriteOnAdd = overwrite; m_overwriteOnAdd = overwrite;
m_collection = collection;
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ), connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
SLOT( addAlbums( QList<Tomahawk::album_ptr> ) ) ); SLOT( addAlbums( QList<Tomahawk::album_ptr> ) ) );
@@ -313,7 +316,10 @@ AlbumModel::addAlbums( const QList<Tomahawk::album_ptr>& albums )
clear(); clear();
if ( !albums.count() ) if ( !albums.count() )
{
emit itemCountChanged( rowCount( QModelIndex() ) );
return; return;
}
int c = rowCount( QModelIndex() ); int c = rowCount( QModelIndex() );
QPair< int, int > crows; QPair< int, int > crows;
@@ -332,6 +338,7 @@ AlbumModel::addAlbums( const QList<Tomahawk::album_ptr>& albums )
} }
emit endInsertRows(); emit endInsertRows();
emit itemCountChanged( rowCount( QModelIndex() ) );
} }
@@ -345,10 +352,7 @@ AlbumModel::onSourceAdded( const Tomahawk::source_ptr& source )
void void
AlbumModel::onCollectionChanged() AlbumModel::onCollectionChanged()
{ {
if ( m_collection ) addCollection( m_collection, true );
addCollection( m_collection, true );
else
addCollection( m_collection, true );
} }
@@ -395,7 +399,6 @@ AlbumModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, Q
if ( requestData.caller != s_tmInfoIdentifier || if ( requestData.caller != s_tmInfoIdentifier ||
( requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt && requestData.type != Tomahawk::InfoSystem::InfoArtistImages ) ) ( requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt && requestData.type != Tomahawk::InfoSystem::InfoArtistImages ) )
{ {
// qDebug() << "Info of wrong type or not with our identifier";
return; return;
} }

View File

@@ -61,6 +61,8 @@ public:
virtual QStringList mimeTypes() const; virtual QStringList mimeTypes() const;
virtual Qt::ItemFlags flags( const QModelIndex& index ) const; virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
Tomahawk::collection_ptr collection() const { return m_collection; }
void clear(); void clear();
void addCollection( const Tomahawk::collection_ptr& collection, bool overwrite = false ); void addCollection( const Tomahawk::collection_ptr& collection, bool overwrite = false );
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order, bool overwrite = false ); void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order, bool overwrite = false );
@@ -92,7 +94,7 @@ signals:
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
void shuffleModeChanged( bool enabled ); void shuffleModeChanged( bool enabled );
void trackCountChanged( unsigned int tracks ); void itemCountChanged( unsigned int items );
void loadingStarted(); void loadingStarted();
void loadingFinished(); void loadingFinished();

View File

@@ -45,6 +45,7 @@ AlbumView::AlbumView( QWidget* parent )
, m_proxyModel( 0 ) , m_proxyModel( 0 )
, m_delegate( 0 ) , m_delegate( 0 )
, m_loadingSpinner( new LoadingSpinner( this ) ) , m_loadingSpinner( new LoadingSpinner( this ) )
, m_overlay( new OverlayWidget( this ) )
{ {
setDragEnabled( true ); setDragEnabled( true );
setDropIndicatorShown( false ); setDropIndicatorShown( false );
@@ -111,6 +112,7 @@ AlbumView::setAlbumModel( AlbumModel* model )
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) ); connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) ); connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) );
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() ) );
@@ -143,6 +145,23 @@ AlbumView::onViewChanged()
} }
void
AlbumView::onItemCountChanged( unsigned int items )
{
if ( items == 0 )
{
if ( m_model->collection().isNull() || ( !m_model->collection().isNull() && m_model->collection()->source()->isLocal() ) )
m_overlay->setText( tr( "After you have scanned your music collection you will find your latest album additions right here." ) );
else
m_overlay->setText( tr( "This collection doesn't have any recent albums." ) );
m_overlay->show();
}
else
m_overlay->hide();
}
void void
AlbumView::onScrollTimeout() AlbumView::onScrollTimeout()
{ {

View File

@@ -24,8 +24,9 @@
#include <QTimer> #include <QTimer>
#include "viewpage.h" #include "viewpage.h"
#include "dllmacro.h"
#include "albumproxymodel.h" #include "albumproxymodel.h"
#include "widgets/overlaywidget.h"
#include "dllmacro.h"
class AlbumModel; class AlbumModel;
class LoadingSpinner; class LoadingSpinner;
@@ -68,6 +69,8 @@ protected:
void resizeEvent( QResizeEvent* event ); void resizeEvent( QResizeEvent* event );
private slots: private slots:
void onItemCountChanged( unsigned int items );
void onFilterChanged( const QString& filter ); void onFilterChanged( const QString& filter );
void onViewChanged(); void onViewChanged();
@@ -78,6 +81,7 @@ private:
AlbumProxyModel* m_proxyModel; AlbumProxyModel* m_proxyModel;
AlbumItemDelegate* m_delegate; AlbumItemDelegate* m_delegate;
LoadingSpinner* m_loadingSpinner; LoadingSpinner* m_loadingSpinner;
OverlayWidget* m_overlay;
QTimer m_timer; QTimer m_timer;
}; };

View File

@@ -130,6 +130,7 @@ ArtistView::setTreeModel( TreeModel* model )
connect( m_proxyModel, SIGNAL( filteringStarted() ), SLOT( onFilteringStarted() ) ); connect( m_proxyModel, SIGNAL( filteringStarted() ), SLOT( onFilteringStarted() ) );
connect( m_proxyModel, SIGNAL( filteringFinished() ), m_loadingSpinner, SLOT( fadeOut() ) ); connect( m_proxyModel, SIGNAL( filteringFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) );
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) ); connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) ); connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
@@ -167,6 +168,7 @@ ArtistView::onItemActivated( const QModelIndex& index )
} }
} }
void void
ArtistView::keyPressEvent( QKeyEvent* event ) ArtistView::keyPressEvent( QKeyEvent* event )
{ {
@@ -206,6 +208,23 @@ ArtistView::resizeEvent( QResizeEvent* event )
} }
void
ArtistView::onItemCountChanged( unsigned int items )
{
if ( items == 0 )
{
if ( m_model->collection().isNull() || ( !m_model->collection().isNull() && m_model->collection()->source()->isLocal() ) )
m_overlay->setText( tr( "After you have scanned your music collection you will find your tracks right here." ) );
else
m_overlay->setText( tr( "This collection is currently empty." ) );
m_overlay->show();
}
else
m_overlay->hide();
}
void void
ArtistView::onFilterChanged( const QString& ) ArtistView::onFilterChanged( const QString& )
{ {

View File

@@ -81,6 +81,7 @@ protected:
void keyPressEvent( QKeyEvent* event ); void keyPressEvent( QKeyEvent* event );
private slots: private slots:
void onItemCountChanged( unsigned int items );
void onFilterChanged( const QString& filter ); void onFilterChanged( const QString& filter );
void onFilteringStarted(); void onFilteringStarted();
void onViewChanged(); void onViewChanged();

View File

@@ -192,9 +192,6 @@ PlaylistModel::insert( const Tomahawk::query_ptr& query, int row )
void void
PlaylistModel::insert( const QList< Tomahawk::query_ptr >& queries, int row ) PlaylistModel::insert( const QList< Tomahawk::query_ptr >& queries, int row )
{ {
if ( !queries.count() )
return;
QList< Tomahawk::plentry_ptr > entries; QList< Tomahawk::plentry_ptr > entries;
foreach( const query_ptr& query, queries ) foreach( const query_ptr& query, queries )
{ {
@@ -221,7 +218,10 @@ void
PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row ) PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row )
{ {
if ( !entries.count() ) if ( !entries.count() )
{
emit trackCountChanged( rowCount( QModelIndex() ) );
return; return;
}
int c = row; int c = row;
QPair< int, int > crows; QPair< int, int > crows;

View File

@@ -81,7 +81,6 @@ PlaylistView::setPlaylistModel( PlaylistModel* model )
} }
void void
PlaylistView::keyPressEvent( QKeyEvent* event ) PlaylistView::keyPressEvent( QKeyEvent* event )
{ {

View File

@@ -52,7 +52,6 @@ public:
virtual bool jumpToCurrentTrack(); virtual bool jumpToCurrentTrack();
virtual bool isTemporaryPage() const; virtual bool isTemporaryPage() const;
signals: signals:
void nameChanged( const QString& title ); void nameChanged( const QString& title );
void destroyed( QWidget* widget ); void destroyed( QWidget* widget );
@@ -60,7 +59,6 @@ signals:
protected: protected:
void keyPressEvent( QKeyEvent* event ); void keyPressEvent( QKeyEvent* event );
private slots: private slots:
void onTrackCountChanged( unsigned int tracks ); void onTrackCountChanged( unsigned int tracks );
void onMenuTriggered( int action ); void onMenuTriggered( int action );
@@ -73,7 +71,6 @@ private:
PlaylistModel* m_model; PlaylistModel* m_model;
QString m_customTitle; QString m_customTitle;
QString m_customDescripton; QString m_customDescripton;
}; };
#endif // PLAYLISTVIEW_H #endif // PLAYLISTVIEW_H

View File

@@ -367,7 +367,10 @@ void
TrackModel::insert( const QList< Tomahawk::query_ptr >& queries, int row ) TrackModel::insert( const QList< Tomahawk::query_ptr >& queries, int row )
{ {
if ( !queries.count() ) if ( !queries.count() )
{
emit trackCountChanged( rowCount( QModelIndex() ) );
return; return;
}
int c = row; int c = row;
QPair< int, int > crows; QPair< int, int > crows;

View File

@@ -568,8 +568,6 @@ TreeModel::removeIndexes( const QList<QModelIndex>& indexes )
void void
TreeModel::addAllCollections() TreeModel::addAllCollections()
{ {
qDebug() << Q_FUNC_INFO;
emit loadingStarted(); emit loadingStarted();
DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists(); DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists();
@@ -578,7 +576,7 @@ TreeModel::addAllCollections()
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) ); Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::UniqueConnection );
QList<Tomahawk::source_ptr> sources = SourceList::instance()->sources(); QList<Tomahawk::source_ptr> sources = SourceList::instance()->sources();
foreach ( const source_ptr& source, sources ) foreach ( const source_ptr& source, sources )
@@ -753,7 +751,10 @@ TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
{ {
emit loadingFinished(); emit loadingFinished();
if ( !artists.count() ) if ( !artists.count() )
{
emit itemCountChanged( rowCount( QModelIndex() ) );
return; return;
}
int c = rowCount( QModelIndex() ); int c = rowCount( QModelIndex() );
QPair< int, int > crows; QPair< int, int > crows;
@@ -771,6 +772,7 @@ TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
} }
emit endInsertRows(); emit endInsertRows();
emit itemCountChanged( rowCount( QModelIndex() ) );
} }

View File

@@ -132,7 +132,7 @@ signals:
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode ); void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
void shuffleModeChanged( bool enabled ); void shuffleModeChanged( bool enabled );
void trackCountChanged( unsigned int tracks ); void itemCountChanged( unsigned int items );
void loadingStarted(); void loadingStarted();
void loadingFinished(); void loadingFinished();