mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 17:14:00 +02:00
* Some more scanner fixes.
* Update collections without having to restart the app. * Rescan collection is now more like "update collection", doesn't ask for a path anymore. * Scrobbler picks up setting changes correctly again.
This commit is contained in:
@@ -75,9 +75,6 @@ public:
|
||||
virtual void activate();
|
||||
virtual bool loadUrl( const QString& url );
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
private slots:
|
||||
void setupSIP();
|
||||
void messageReceived( const QString& );
|
||||
|
@@ -31,12 +31,14 @@ Collection::name() const
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
const
|
||||
source_ptr& Collection::source() const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Collection::addPlaylist( const Tomahawk::playlist_ptr& p )
|
||||
{
|
||||
@@ -51,6 +53,7 @@ Collection::addPlaylist( const Tomahawk::playlist_ptr& p )
|
||||
emit playlistsAdded( toadd );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Collection::addDynamicPlaylist( const Tomahawk::dynplaylist_ptr& p )
|
||||
{
|
||||
@@ -80,6 +83,7 @@ Collection::deletePlaylist( const Tomahawk::playlist_ptr& p )
|
||||
emit playlistsDeleted( todelete );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Collection::deleteDynamicPlaylist( const Tomahawk::dynplaylist_ptr& p )
|
||||
{
|
||||
@@ -137,6 +141,7 @@ Collection::setPlaylists( const QList<Tomahawk::playlist_ptr>& plists )
|
||||
emit playlistsAdded( plists );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Collection::setDynamicPlaylists( const QList< Tomahawk::dynplaylist_ptr >& plists )
|
||||
{
|
||||
@@ -146,6 +151,7 @@ Collection::setDynamicPlaylists( const QList< Tomahawk::dynplaylist_ptr >& plist
|
||||
emit dynamicPlaylistsAdded( plists );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Collection::setTracks( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::collection_ptr collection )
|
||||
{
|
||||
|
@@ -72,6 +72,7 @@ public slots:
|
||||
void setPlaylists( const QList<Tomahawk::playlist_ptr>& plists );
|
||||
void setDynamicPlaylists( const QList< Tomahawk::dynplaylist_ptr >& dynplists );
|
||||
void setTracks( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::collection_ptr collection );
|
||||
|
||||
protected:
|
||||
QString m_name;
|
||||
unsigned int m_lastmodified; // unix time of last change to collection
|
||||
|
@@ -27,6 +27,7 @@ DatabaseCollection::loadPlaylists()
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DatabaseCollection::loadDynamicPlaylists()
|
||||
{
|
||||
@@ -34,23 +35,20 @@ DatabaseCollection::loadDynamicPlaylists()
|
||||
DatabaseCommand_LoadAllDynamicPlaylists* cmd = new DatabaseCommand_LoadAllDynamicPlaylists( source() );
|
||||
|
||||
connect( cmd, SIGNAL( playlistLoaded( Tomahawk::source_ptr, QVariantList ) ),
|
||||
this, SLOT( dynamicPlaylistCreated( const Tomahawk::source_ptr&, const QVariantList& ) ) );
|
||||
SLOT( dynamicPlaylistCreated( const Tomahawk::source_ptr&, const QVariantList& ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
DatabaseCollection::loadTracks()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << source()->userName();
|
||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( source()->collection() );
|
||||
|
||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||
SLOT( setTracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
||||
/* connect( cmd, SIGNAL( done( Tomahawk::collection_ptr ) ),
|
||||
SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ) );*/
|
||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||
SLOT( setTracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
@@ -90,6 +88,7 @@ DatabaseCollection::playlists()
|
||||
return Collection::playlists();
|
||||
}
|
||||
|
||||
|
||||
QList< dynplaylist_ptr > DatabaseCollection::dynamicPlaylists()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
@@ -103,7 +102,6 @@ QList< dynplaylist_ptr > DatabaseCollection::dynamicPlaylists()
|
||||
}
|
||||
|
||||
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
DatabaseCollection::tracks()
|
||||
{
|
||||
@@ -117,6 +115,7 @@ DatabaseCollection::tracks()
|
||||
return Collection::tracks();
|
||||
}
|
||||
|
||||
|
||||
void DatabaseCollection::dynamicPlaylistCreated( const source_ptr& source, const QVariantList& data )
|
||||
{
|
||||
dynplaylist_ptr p( new DynamicPlaylist( source, //src
|
||||
|
@@ -38,11 +38,11 @@ DatabaseCommand_AddFiles::postCommitHook()
|
||||
// collection browser will update/fade in etc.
|
||||
Collection* coll = source()->collection().data();
|
||||
|
||||
connect( this, SIGNAL( notify( QList<QVariant>, Tomahawk::collection_ptr ) ),
|
||||
coll, SIGNAL( setTracks( QList<QVariant>, Tomahawk::collection_ptr ) ),
|
||||
connect( this, SIGNAL( notify( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||
coll, SLOT( setTracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||
Qt::QueuedConnection );
|
||||
// do it like this so it gets called in the right thread:
|
||||
emit notify( m_files, source()->collection() );
|
||||
|
||||
emit notify( m_queries, source()->collection() );
|
||||
|
||||
// also re-calc the collection stats, to updates the "X tracks" in the sidebar etc:
|
||||
DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( source() );
|
||||
@@ -68,7 +68,7 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
|
||||
|
||||
query_file.prepare( "INSERT INTO file(source, url, size, mtime, md5, mimetype, duration, bitrate) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)" );
|
||||
query_filejoin.prepare( "INSERT INTO file_join(file, artist ,album, track, albumpos) "
|
||||
query_filejoin.prepare( "INSERT INTO file_join(file, artist, album, track, albumpos) "
|
||||
"VALUES (?,?,?,?,?)" );
|
||||
query_trackattr.prepare( "INSERT INTO track_attributes(id, k, v) "
|
||||
"VALUES (?,?,?)" );
|
||||
@@ -88,7 +88,7 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
|
||||
QVariantMap m = v.toMap();
|
||||
|
||||
QString url = m.value( "url" ).toString();
|
||||
int mtime = m.value( "lastmodified" ).toInt();
|
||||
int mtime = m.value( "mtime" ).toInt();
|
||||
int size = m.value( "size" ).toInt();
|
||||
QString hash = m.value( "hash" ).toString();
|
||||
QString mimetype = m.value( "mimetype" ).toString();
|
||||
@@ -137,19 +137,19 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
|
||||
v = m;
|
||||
|
||||
bool isnew;
|
||||
int artid = dbi->artistId( artist, isnew );
|
||||
if( artid < 1 ) continue;
|
||||
m["artistid"] = dbi->artistId( artist, isnew );
|
||||
if( m["artistid"].toInt() < 1 ) continue;
|
||||
|
||||
int trkid = dbi->trackId( artid, track, isnew );
|
||||
if( trkid < 1 ) continue;
|
||||
m["trackid"] = dbi->trackId( m["artistid"].toInt(), track, isnew );
|
||||
if( m["trackid"].toInt() < 1 ) continue;
|
||||
|
||||
int albid = dbi->albumId( artid, album, isnew );
|
||||
m["albumid"] = dbi->albumId( m["artistid"].toInt(), album, isnew );
|
||||
|
||||
// Now add the association
|
||||
query_filejoin.bindValue( 0, fileid );
|
||||
query_filejoin.bindValue( 1, artid );
|
||||
query_filejoin.bindValue( 2, albid > 0 ? albid : QVariant( QVariant::Int ) );
|
||||
query_filejoin.bindValue( 3, trkid );
|
||||
query_filejoin.bindValue( 1, m["artistid"].toInt() );
|
||||
query_filejoin.bindValue( 2, m["albumid"].toInt() > 0 ? m["albumid"].toInt() : QVariant( QVariant::Int ) );
|
||||
query_filejoin.bindValue( 3, m["trackid"].toInt() );
|
||||
query_filejoin.bindValue( 4, albumpos );
|
||||
if( !query_filejoin.exec() )
|
||||
{
|
||||
@@ -157,11 +157,25 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
|
||||
continue;
|
||||
}
|
||||
|
||||
query_trackattr.bindValue( 0, trkid );
|
||||
query_trackattr.bindValue( 0, m["trackid"].toInt() );
|
||||
query_trackattr.bindValue( 1, "releaseyear" );
|
||||
query_trackattr.bindValue( 2, year );
|
||||
query_trackattr.exec();
|
||||
|
||||
QVariantMap attr;
|
||||
Tomahawk::query_ptr query = Tomahawk::Query::get( m, false );
|
||||
m["score"] = 1.0;
|
||||
attr["releaseyear"] = m.value( "year" );
|
||||
|
||||
Tomahawk::result_ptr result = Tomahawk::result_ptr( new Tomahawk::Result( m, source()->collection() ) );
|
||||
result->setAttributes( attr );
|
||||
|
||||
QList<Tomahawk::result_ptr> results;
|
||||
results << result;
|
||||
query->addResults( results );
|
||||
|
||||
m_queries << query;
|
||||
|
||||
added++;
|
||||
}
|
||||
qDebug() << "Inserted" << added;
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "database/databasecommandloggable.h"
|
||||
#include "typedefs.h"
|
||||
#include "query.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
@@ -36,10 +37,11 @@ public:
|
||||
|
||||
signals:
|
||||
void done( const QList<QVariant>&, Tomahawk::collection_ptr );
|
||||
void notify( const QList<QVariant>&, Tomahawk::collection_ptr );
|
||||
void notify( const QList<Tomahawk::query_ptr>&, Tomahawk::collection_ptr );
|
||||
|
||||
private:
|
||||
QVariantList m_files;
|
||||
QList<Tomahawk::query_ptr> m_queries;
|
||||
};
|
||||
|
||||
#endif // DATABASECOMMAND_ADDFILES_H
|
||||
|
@@ -51,8 +51,8 @@ DatabaseCommand_LogPlayback::exec( DatabaseImpl* dbi )
|
||||
return;
|
||||
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
query.prepare( "INSERT INTO playback_log(source,track,playtime,secs_played) "
|
||||
"VALUES (?, ?, ?, ?)" );
|
||||
query.prepare( "INSERT INTO playback_log(source, track, playtime, secs_played) "
|
||||
"VALUES (?, ?, ?, ?)" );
|
||||
|
||||
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
|
||||
|
||||
|
@@ -184,7 +184,7 @@ CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, co
|
||||
emit endInsertRows();
|
||||
|
||||
emit trackCountChanged( rowCount( QModelIndex() ) );
|
||||
qDebug() << rowCount( QModelIndex() );
|
||||
qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -42,9 +42,9 @@ MusicScanner::startScan()
|
||||
// trigger the scan once we've loaded old mtimes for dirs below our path
|
||||
DatabaseCommand_DirMtimes* cmd = new DatabaseCommand_DirMtimes( m_dir );
|
||||
connect( cmd, SIGNAL( done( const QMap<QString, unsigned int>& ) ),
|
||||
SLOT( setMtimes( const QMap<QString, unsigned int>& ) ), Qt::DirectConnection );
|
||||
SLOT( setMtimes( const QMap<QString, unsigned int>& ) ) );
|
||||
connect( cmd, SIGNAL( done( const QMap<QString,unsigned int>& ) ),
|
||||
SLOT( scan() ), Qt::DirectConnection );
|
||||
SLOT( scan() ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
}
|
||||
@@ -97,7 +97,7 @@ MusicScanner::listerFinished( const QMap<QString, unsigned int>& newmtimes )
|
||||
|
||||
// save mtimes, then quit thread
|
||||
DatabaseCommand_DirMtimes* cmd = new DatabaseCommand_DirMtimes( newmtimes );
|
||||
connect( cmd, SIGNAL( finished() ), SLOT( quit() ) );
|
||||
connect( cmd, SIGNAL( finished() ), SLOT( deleteLater() ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
|
||||
qDebug() << "Scanning complete, saving to database. "
|
||||
@@ -108,7 +108,6 @@ MusicScanner::listerFinished( const QMap<QString, unsigned int>& newmtimes )
|
||||
qDebug() << s;
|
||||
|
||||
m_dirLister->deleteLater();
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +211,7 @@ MusicScanner::readFile( const QFileInfo& fi )
|
||||
|
||||
QVariantMap m;
|
||||
m["url"] = url.arg( fi.absoluteFilePath() );
|
||||
m["lastmodified"] = fi.lastModified().toUTC().toTime_t();
|
||||
m["mtime"] = fi.lastModified().toUTC().toTime_t();
|
||||
m["size"] = (unsigned int)fi.size();
|
||||
m["hash"] = ""; // TODO
|
||||
m["mimetype"] = mimetype;
|
||||
|
@@ -57,8 +57,8 @@ Scrobbler::Scrobbler( QObject* parent )
|
||||
ldir.mkpath( lpath );
|
||||
}
|
||||
|
||||
connect( TomahawkApp::instance(), SIGNAL( settingsChanged() ),
|
||||
SLOT( settingsChanged() ), Qt::QueuedConnection );
|
||||
connect( TomahawkSettings::instance(), SIGNAL( settingsChanged() ),
|
||||
SLOT( settingsChanged() ), Qt::QueuedConnection );
|
||||
|
||||
connect( AudioEngine::instance(), SIGNAL( timerSeconds( unsigned int ) ),
|
||||
SLOT( engineTick( unsigned int ) ), Qt::QueuedConnection );
|
||||
|
@@ -234,7 +234,6 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
||||
m_mainwindow = new TomahawkWindow();
|
||||
m_mainwindow->setWindowTitle( "Tomahawk" );
|
||||
m_mainwindow->show();
|
||||
connect( m_mainwindow, SIGNAL( settingsChanged() ), SIGNAL( settingsChanged() ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -178,7 +178,7 @@ TomahawkWindow::setupSignals()
|
||||
connect( ui->actionToggleConnect, SIGNAL( triggered() ), APP->sipHandler(), SLOT( toggleConnect() ) );
|
||||
connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
||||
connect( ui->actionAddFriendManually, SIGNAL( triggered() ), SLOT( addFriendManually() ) );
|
||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
|
||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||
connect( ui->actionCreateAutomaticPlaylist, SIGNAL( triggered() ), SLOT( createAutomaticPlaylist() ));
|
||||
@@ -238,18 +238,11 @@ TomahawkWindow::showSettingsDialog()
|
||||
}
|
||||
|
||||
|
||||
/// scan stuff
|
||||
void
|
||||
TomahawkWindow::rescanCollectionManually()
|
||||
TomahawkWindow::updateCollectionManually()
|
||||
{
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
bool ok;
|
||||
QString path = QInputDialog::getText( this, tr( "Enter path to music dir:" ),
|
||||
tr( "Path pls" ), QLineEdit::Normal,
|
||||
s->scannerPath(), &ok );
|
||||
s->setValue( "scannerpath", path );
|
||||
if ( ok && !path.isEmpty() )
|
||||
ScanManager::instance()->runManualScan( path );
|
||||
if ( TomahawkSettings::instance()->hasScannerPath() )
|
||||
ScanManager::instance()->runManualScan( TomahawkSettings::instance()->scannerPath() );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -44,7 +44,7 @@ public slots:
|
||||
void createPlaylist();
|
||||
void loadSpiff();
|
||||
void showSettingsDialog();
|
||||
void rescanCollectionManually();
|
||||
void updateCollectionManually();
|
||||
|
||||
private slots:
|
||||
void onSipConnected();
|
||||
|
Reference in New Issue
Block a user