mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
* Assert on empty friendlynames.
This commit is contained in:
parent
f6d377275b
commit
633ade23fc
@ -35,20 +35,21 @@ DatabaseCommand_addSource::DatabaseCommand_addSource( const QString& username, c
|
||||
void
|
||||
DatabaseCommand_addSource::exec( DatabaseImpl* dbi )
|
||||
{
|
||||
Q_ASSERT( !m_fname.isEmpty() );
|
||||
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
query.prepare( "SELECT id, friendlyname FROM source WHERE name = ?" );
|
||||
query.prepare( "SELECT id FROM source WHERE name = ?" );
|
||||
query.addBindValue( m_username );
|
||||
query.exec();
|
||||
|
||||
if ( query.next() )
|
||||
{
|
||||
unsigned int id = query.value( 0 ).toInt();
|
||||
QString fname = query.value( 1 ).toString();
|
||||
query.prepare( "UPDATE source SET isonline = 'true', friendlyname = ? WHERE id = ?" );
|
||||
query.addBindValue( m_fname );
|
||||
query.addBindValue( id );
|
||||
query.exec();
|
||||
emit done( id, fname );
|
||||
emit done( id, m_fname );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ DatabaseCommand_LoadDynamicPlaylistEntries::exec( DatabaseImpl* dbi )
|
||||
|
||||
if( mode == OnDemand )
|
||||
{
|
||||
Q_ASSERT( m_entrymap.isEmpty() ); // ondemand should have no entry
|
||||
// Q_ASSERT( m_entrymap.isEmpty() ); // ondemand should have no entry
|
||||
|
||||
emit done( revisionGuid(), m_islatest, type, controls, true );
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "artist.h"
|
||||
#include "albumitem.h"
|
||||
#include "source.h"
|
||||
#include "sourcelist.h"
|
||||
#include "database/database.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
@ -247,6 +248,7 @@ AlbumModel::addCollection( const collection_ptr& collection, bool overwrite )
|
||||
|
||||
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
|
||||
m_overwriteOnAdd = overwrite;
|
||||
m_collection = collection;
|
||||
|
||||
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
|
||||
SLOT( addAlbums( QList<Tomahawk::album_ptr> ) ) );
|
||||
@ -255,6 +257,21 @@ AlbumModel::addCollection( const collection_ptr& collection, bool overwrite )
|
||||
|
||||
m_title = tr( "All albums from %1" ).arg( collection->source()->friendlyName() );
|
||||
|
||||
if ( collection.isNull() )
|
||||
{
|
||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||
|
||||
QList<Tomahawk::source_ptr> sources = SourceList::instance()->sources();
|
||||
foreach ( const source_ptr& source, sources )
|
||||
{
|
||||
connect( source->collection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
connect( collection.data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
|
||||
}
|
||||
|
||||
emit loadingStarted();
|
||||
}
|
||||
|
||||
@ -318,6 +335,23 @@ AlbumModel::addAlbums( const QList<Tomahawk::album_ptr>& albums )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumModel::onSourceAdded( const Tomahawk::source_ptr& source )
|
||||
{
|
||||
connect( source->collection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumModel::onCollectionChanged()
|
||||
{
|
||||
if ( m_collection )
|
||||
addCollection( m_collection, true );
|
||||
else
|
||||
addCollection( m_collection, true );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumModel::clear()
|
||||
{
|
||||
|
@ -96,9 +96,13 @@ signals:
|
||||
|
||||
void loadingStarted();
|
||||
void loadingFinished();
|
||||
|
||||
private slots:
|
||||
void onDataChanged();
|
||||
|
||||
void onSourceAdded( const Tomahawk::source_ptr& source );
|
||||
void onCollectionChanged();
|
||||
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
@ -110,6 +114,8 @@ private:
|
||||
QString m_description;
|
||||
bool m_overwriteOnAdd;
|
||||
|
||||
Tomahawk::collection_ptr m_collection;
|
||||
|
||||
QHash<qlonglong, QPersistentModelIndex> m_coverHash;
|
||||
};
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "playlist/collectionflatmodel.h"
|
||||
#include "playlist/playlistmodel.h"
|
||||
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
#include "database/databasecommand_allalbums.h"
|
||||
|
||||
@ -38,6 +39,7 @@
|
||||
SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::SourceInfoWidget )
|
||||
, m_source( source )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
@ -56,7 +58,7 @@ SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget*
|
||||
m_recentCollectionModel->setStyle( TrackModel::Short );
|
||||
ui->recentCollectionView->setTrackModel( m_recentCollectionModel );
|
||||
ui->recentCollectionView->sortByColumn( TrackModel::Age, Qt::DescendingOrder );
|
||||
m_recentCollectionModel->addFilteredCollection( source->collection(), 250, DatabaseCommand_AllTracks::ModificationTime );
|
||||
loadTracks();
|
||||
|
||||
m_historyModel = new PlaylistModel( ui->historyView );
|
||||
m_historyModel->setStyle( TrackModel::Short );
|
||||
@ -90,6 +92,29 @@ SourceInfoWidget::~SourceInfoWidget()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceInfoWidget::loadTracks()
|
||||
{
|
||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_source->collection() );
|
||||
cmd->setLimit( 250 );
|
||||
cmd->setSortOrder( DatabaseCommand_AllTracks::ModificationTime );
|
||||
cmd->setSortDescending( true );
|
||||
|
||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
||||
SLOT( onLoadedTrackHistory( QList<Tomahawk::query_ptr> ) ), Qt::QueuedConnection );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceInfoWidget::onLoadedTrackHistory( const QList<Tomahawk::query_ptr>& queries )
|
||||
{
|
||||
m_recentCollectionModel->clear();
|
||||
m_recentCollectionModel->append( queries );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceInfoWidget::onPlaybackFinished( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
|
@ -60,6 +60,9 @@ protected:
|
||||
private slots:
|
||||
void onPlaybackFinished( const Tomahawk::query_ptr& query );
|
||||
|
||||
void loadTracks();
|
||||
void onLoadedTrackHistory( const QList<Tomahawk::query_ptr>& queries );
|
||||
|
||||
private:
|
||||
Ui::SourceInfoWidget *ui;
|
||||
|
||||
@ -67,6 +70,8 @@ private:
|
||||
PlaylistModel* m_historyModel;
|
||||
AlbumModel* m_recentAlbumModel;
|
||||
|
||||
Tomahawk::source_ptr m_source;
|
||||
|
||||
QString m_title;
|
||||
QString m_description;
|
||||
QPixmap m_pixmap;
|
||||
|
@ -21,9 +21,9 @@
|
||||
#include "whatshotwidget_p.h"
|
||||
#include "ui_whatshotwidget.h"
|
||||
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QtGui/QStandardItem>
|
||||
#include <QPainter>
|
||||
#include <QStandardItemModel>
|
||||
#include <QStandardItem>
|
||||
|
||||
#include "viewmanager.h"
|
||||
#include "sourcelist.h"
|
||||
@ -37,7 +37,7 @@
|
||||
#include "widgets/overlaywidget.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
#include <pipeline.h>
|
||||
#include "pipeline.h"
|
||||
|
||||
#define HISTORY_TRACK_ITEMS 25
|
||||
#define HISTORY_PLAYLIST_ITEMS 10
|
||||
@ -110,6 +110,7 @@ WhatsHotWidget::~WhatsHotWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
PlaylistInterface*
|
||||
WhatsHotWidget::playlistInterface() const
|
||||
{
|
||||
@ -129,6 +130,7 @@ WhatsHotWidget::isBeingPlayed() const
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
WhatsHotWidget::jumpToCurrentTrack()
|
||||
{
|
||||
@ -159,15 +161,13 @@ WhatsHotWidget::fetchData()
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot: requested InfoChartCapabilities";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
if ( requestData.caller != s_whatsHotIdentifier )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: got something...";
|
||||
if ( !output.canConvert< QVariantMap >() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: Could not parse output";
|
||||
@ -175,15 +175,11 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
}
|
||||
|
||||
QVariantMap returnedData = output.toMap();
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot::" << returnedData;
|
||||
switch ( requestData.type )
|
||||
{
|
||||
case InfoSystem::InfoChartCapabilities:
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot:: info chart capabilities";
|
||||
QStandardItem *rootItem= m_crumbModelLeft->invisibleRootItem();
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot:: " << returnedData.keys();
|
||||
|
||||
QVariantMap defaults;
|
||||
if ( returnedData.contains( "defaults" ) )
|
||||
defaults = returnedData.take( "defaults" ).toMap();
|
||||
@ -191,9 +187,7 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
|
||||
foreach ( const QString label, returnedData.keys() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot:: parsing " << label;
|
||||
QStandardItem *childItem = parseNode( rootItem, label, returnedData[label] );
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot:: appending" << childItem->text();
|
||||
rootItem->appendRow(childItem);
|
||||
}
|
||||
|
||||
@ -204,7 +198,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
QStandardItem* source = rootItem->child( i, 0 );
|
||||
if ( defaultSource.toLower() == source->text().toLower() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Setting DEFAULT SOURCE:" << source->text();
|
||||
source->setData( true, Breadcrumb::DefaultRole );
|
||||
}
|
||||
|
||||
@ -220,7 +213,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
{
|
||||
if ( cur->child( k, 0 )->text() == index )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Found DEFAULT ITEM:" << index;
|
||||
cur = cur->child( k, 0 ); // this is the default, drill down into the default to pick the next default
|
||||
cur->setData( true, Breadcrumb::DefaultRole );
|
||||
break;
|
||||
@ -235,6 +227,7 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
ui->breadCrumbLeft->setModel( m_sortedProxy );
|
||||
break;
|
||||
}
|
||||
|
||||
case InfoSystem::InfoChart:
|
||||
{
|
||||
if( !returnedData.contains("type") )
|
||||
@ -246,11 +239,9 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
const QString chartId = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >().value( "chart_id" );
|
||||
|
||||
m_queuedFetches.remove( chartId );
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: got chart! " << type << " on " << side;
|
||||
if( type == "artists" )
|
||||
{
|
||||
const QStringList artists = returnedData["artists"].toStringList();
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: got artists! " << artists.size();
|
||||
|
||||
TreeModel* artistsModel = new TreeModel( ui->artistsViewLeft );
|
||||
artistsModel->setColumnStyle( TreeModel::TrackOnly );
|
||||
@ -269,7 +260,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
{
|
||||
QList<album_ptr> al;
|
||||
const QList< Tomahawk::InfoSystem::InfoStringHash > albums = returnedData[ "albums" ].value< QList< Tomahawk::InfoSystem::InfoStringHash > >();
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: got albums! " << albums.size();
|
||||
|
||||
AlbumModel* albumModel = new AlbumModel( ui->additionsView );
|
||||
foreach ( const Tomahawk::InfoSystem::InfoStringHash& album, albums )
|
||||
@ -280,7 +270,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
al << albumPtr;
|
||||
|
||||
}
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Adding albums to model";
|
||||
albumModel->addAlbums( al );
|
||||
|
||||
m_albumModels[ chartId ] = albumModel;
|
||||
@ -291,7 +280,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
else if( type == "tracks" )
|
||||
{
|
||||
const QList< Tomahawk::InfoSystem::InfoStringHash > tracks = returnedData[ "tracks" ].value< QList< Tomahawk::InfoSystem::InfoStringHash > >();
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot: got tracks! " << tracks.size();
|
||||
|
||||
PlaylistModel* trackModel = new PlaylistModel( ui->tracksViewLeft );
|
||||
trackModel->setStyle( TrackModel::Short );
|
||||
|
Loading…
x
Reference in New Issue
Block a user