diff --git a/src/audio/audioengine.cpp b/src/audio/audioengine.cpp index 7dd7b0a7e..d8b2d29d0 100644 --- a/src/audio/audioengine.cpp +++ b/src/audio/audioengine.cpp @@ -4,6 +4,9 @@ #include #include "playlistinterface.h" + +#include "database/database.h" +#include "database/databasecommand_logplayback.h" #include "network/servent.h" #include "madtranscode.h" @@ -20,6 +23,7 @@ AudioEngine::AudioEngine() , m_playlist( 0 ) , m_currentTrackPlaylist( 0 ) , m_queue( 0 ) + , m_timeElapsed( 0 ) , m_i( 0 ) { qDebug() << "Init AudioEngine"; @@ -155,7 +159,12 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result ) { m_lastTrack = m_currentTrack; if ( !m_lastTrack.isNull() ) + { + DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_lastTrack, m_timeElapsed ); + Database::instance()->enqueue( QSharedPointer(cmd) ); + emit finished( m_lastTrack ); + } m_currentTrack = result; io = Servent::instance()->getIODeviceForUrl( m_currentTrack ); @@ -321,6 +330,7 @@ AudioEngine::setStreamData( long sampleRate, int channels ) void AudioEngine::timerTriggered( unsigned int seconds ) { + m_timeElapsed = seconds; emit timerSeconds( seconds ); if ( m_currentTrack->duration() == 0 ) @@ -407,7 +417,6 @@ AudioEngine::loop() // are we cleanly at the end of a track, and ready for the next one? if ( !m_input.isNull() && m_input->atEnd() && -// m_input->isOpen() && !m_input->bytesAvailable() && !m_audio->haveData() && !m_audio->isPaused() ) diff --git a/src/audio/audioengine.h b/src/audio/audioengine.h index fdda5dd33..6a4c69252 100644 --- a/src/audio/audioengine.h +++ b/src/audio/audioengine.h @@ -100,6 +100,7 @@ private: PlaylistInterface* m_queue; QMutex m_mutex; + unsigned int m_timeElapsed; int m_i; }; diff --git a/src/infowidgets/sourceinfowidget.cpp b/src/infowidgets/sourceinfowidget.cpp index 6e0ed4852..f3a739330 100644 --- a/src/infowidgets/sourceinfowidget.cpp +++ b/src/infowidgets/sourceinfowidget.cpp @@ -7,6 +7,7 @@ #include "playlist/playlistmanager.h" #include "playlist/albummodel.h" #include "playlist/collectionflatmodel.h" +#include "playlist/playlistmodel.h" #include "database/databasecommand_alltracks.h" #include "database/databasecommand_allalbums.h" @@ -24,8 +25,17 @@ SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget* ui->recentCollectionView->setModel( m_recentCollectionModel ); m_recentCollectionModel->addFilteredCollection( source->collection(), 250, DatabaseCommand_AllTracks::ModificationTime ); -// ui->recentCollectionView->setColumnHidden( TrackModel::Bitrate, true ); -// ui->recentCollectionView->setColumnHidden( TrackModel::Origin, true ); + m_historyModel = new PlaylistModel( ui->historyView ); + ui->historyView->setModel( m_historyModel ); + m_historyModel->loadHistory( source ); + + ui->recentCollectionView->setColumnHidden( TrackModel::Bitrate, true ); + ui->recentCollectionView->setColumnHidden( TrackModel::Origin, true ); + ui->recentCollectionView->setColumnHidden( TrackModel::Filesize, true ); + + ui->historyView->setColumnHidden( TrackModel::Bitrate, true ); + ui->historyView->setColumnHidden( TrackModel::Origin, true ); + ui->historyView->setColumnHidden( TrackModel::Filesize, true ); m_recentAlbumModel = new AlbumModel( ui->recentAlbumView ); ui->recentAlbumView->setModel( m_recentAlbumModel ); diff --git a/src/infowidgets/sourceinfowidget.h b/src/infowidgets/sourceinfowidget.h index 0af88baa6..e3bb93047 100644 --- a/src/infowidgets/sourceinfowidget.h +++ b/src/infowidgets/sourceinfowidget.h @@ -9,6 +9,7 @@ class AlbumModel; class CollectionFlatModel; +class PlaylistModel; namespace Ui { @@ -30,6 +31,7 @@ private: Ui::SourceInfoWidget *ui; CollectionFlatModel* m_recentCollectionModel; + PlaylistModel* m_historyModel; AlbumModel* m_recentAlbumModel; }; diff --git a/src/infowidgets/sourceinfowidget.ui b/src/infowidgets/sourceinfowidget.ui index 599534a6a..1146b9fd9 100644 --- a/src/infowidgets/sourceinfowidget.ui +++ b/src/infowidgets/sourceinfowidget.ui @@ -10,7 +10,7 @@ 460 - + @@ -69,29 +69,59 @@ - + - - - - 13 - 75 - true - - - - Latest Additions to their Collection - - + + + + + + 13 + 75 + true + + + + Latest Additions to their Collection + + + + + + + - + + + + + + 13 + 75 + true + + + + Recently played Tracks + + + + + + + + + PlaylistView + QTreeView +
playlistview.h
+
CollectionView QTreeView diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index df324b8f6..5341f6d8a 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -42,11 +42,13 @@ set( libSources database/databasecommand_addfiles.cpp database/databasecommand_dirmtimes.cpp database/databasecommand_loadfile.cpp + database/databasecommand_logplayback.cpp database/databasecommand_addsource.cpp database/databasecommand_sourceoffline.cpp database/databasecommand_collectionstats.cpp database/databasecommand_loadplaylistentries.cpp database/databasecommand_modifyplaylist.cpp + database/databasecommand_playbackhistory.cpp database/databasecommand_setplaylistrevision.cpp database/databasecommand_loadallplaylists.cpp database/databasecommand_createplaylist.cpp @@ -96,11 +98,13 @@ set( libHeaders database/databasecommand_addfiles.h database/databasecommand_dirmtimes.h database/databasecommand_loadfile.h + database/databasecommand_logplayback.h database/databasecommand_addsource.h database/databasecommand_sourceoffline.h database/databasecommand_collectionstats.h database/databasecommand_loadplaylistentries.h database/databasecommand_modifyplaylist.h + database/databasecommand_playbackhistory.h database/databasecommand_setplaylistrevision.h database/databasecommand_loadallplaylists.h database/databasecommand_createplaylist.h diff --git a/src/libtomahawk/database/databasecommand_alltracks.cpp b/src/libtomahawk/database/databasecommand_alltracks.cpp index a71039bff..df5f07e6c 100644 --- a/src/libtomahawk/database/databasecommand_alltracks.cpp +++ b/src/libtomahawk/database/databasecommand_alltracks.cpp @@ -74,10 +74,10 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi ) t["mtime"] = query.value( 9 ).toInt(); t["mimetype"] = query.value( 10 ).toString(); t["albumpos"] = query.value( 11 ).toUInt(); - unsigned int trkid = query.value( 14 ).toInt(); + t["trackid"] = query.value( 14 ).toUInt(); attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" ); - attrQuery.bindValue( 0, trkid ); + attrQuery.bindValue( 0, t["trackid"] ); attrQuery.exec(); while ( attrQuery.next() ) { diff --git a/src/libtomahawk/database/databasecommand_logplayback.cpp b/src/libtomahawk/database/databasecommand_logplayback.cpp new file mode 100644 index 000000000..2c4932972 --- /dev/null +++ b/src/libtomahawk/database/databasecommand_logplayback.cpp @@ -0,0 +1,54 @@ +#include "databasecommand_logplayback.h" + +#include + +#include "collection.h" +#include "database/database.h" +#include "databaseimpl.h" +#include "network/servent.h" + +using namespace Tomahawk; + + +// After changing a collection, we need to tell other bits of the system: +void +DatabaseCommand_LogPlayback::postCommitHook() +{ + qDebug() << Q_FUNC_INFO; + + if( source()->isLocal() ) + Servent::instance()->triggerDBSync(); +} + + +void +DatabaseCommand_LogPlayback::exec( DatabaseImpl* dbi ) +{ + qDebug() << Q_FUNC_INFO; + Q_ASSERT( !source().isNull() ); + + TomahawkSqlQuery query = dbi->newquery(); + query.prepare( "INSERT INTO playback_log(source,track,playtime,secs_played) " + "VALUES (?, ?, ?, ?)" ); + + QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id(); + + qDebug() << "Logging playback of" << m_artist << "-" << m_track << "for source" << srcid; + + query.bindValue( 0, srcid ); + + bool isnew; + int artid = dbi->artistId( m_artist, isnew ); + if( artid < 1 ) + return; + + int trkid = dbi->trackId( artid, m_track, isnew ); + if( trkid < 1 ) + return; + + query.bindValue( 1, trkid ); + query.bindValue( 2, m_playtime ); + query.bindValue( 3, m_secsPlayed ); + + query.exec(); +} diff --git a/src/libtomahawk/database/databasecommand_logplayback.h b/src/libtomahawk/database/databasecommand_logplayback.h new file mode 100644 index 000000000..bcf2f4e5e --- /dev/null +++ b/src/libtomahawk/database/databasecommand_logplayback.h @@ -0,0 +1,63 @@ +#ifndef DATABASECOMMAND_LOGPLAYBACK_H +#define DATABASECOMMAND_LOGPLAYBACK_H + +#include +#include + +#include "database/databasecommandloggable.h" +#include "sourcelist.h" +#include "typedefs.h" + +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_LogPlayback : public DatabaseCommandLoggable +{ +Q_OBJECT +Q_PROPERTY( QString artist READ artist WRITE setArtist ) +Q_PROPERTY( QString track READ track WRITE setTrack ) +Q_PROPERTY( unsigned int playtime READ playtime WRITE setPlaytime ) +Q_PROPERTY( unsigned int secsPlayed READ secsPlayed WRITE setSecsPlayed ) + +public: + explicit DatabaseCommand_LogPlayback( QObject* parent = 0 ) + : DatabaseCommandLoggable( parent ) + {} + + explicit DatabaseCommand_LogPlayback( const Tomahawk::result_ptr& result, unsigned int secsPlayed, QObject* parent = 0 ) + : DatabaseCommandLoggable( parent ), m_result( result ), m_secsPlayed( secsPlayed ) + { + m_playtime = QDateTime::currentDateTimeUtc().toTime_t(); + setSource( SourceList::instance()->getLocal() ); + + setArtist( result->artist()->name() ); + setTrack( result->track() ); + } + + virtual QString commandname() const { return "logplayback"; } + + virtual void exec( DatabaseImpl* ); + virtual bool doesMutates() const { return true; } + virtual void postCommitHook(); + + QString artist() const { return m_artist; } + void setArtist( const QString& s ) { m_artist = s; } + + QString track() const { return m_track; } + void setTrack( const QString& s ) { m_track = s; } + + unsigned int playtime() const { return m_playtime; } + void setPlaytime( unsigned int i ) { m_playtime = i; } + + unsigned int secsPlayed() const { return m_secsPlayed; } + void setSecsPlayed( unsigned int i ) { m_secsPlayed = i; } + +private: + Tomahawk::result_ptr m_result; + + QString m_artist; + QString m_track; + unsigned int m_playtime; + unsigned int m_secsPlayed; +}; + +#endif // DATABASECOMMAND_LOGPLAYBACK_H diff --git a/src/libtomahawk/database/databasecommand_playbackhistory.cpp b/src/libtomahawk/database/databasecommand_playbackhistory.cpp new file mode 100644 index 000000000..75f97848c --- /dev/null +++ b/src/libtomahawk/database/databasecommand_playbackhistory.cpp @@ -0,0 +1,61 @@ +#include "databasecommand_playbackhistory.h" + +#include + +#include "databaseimpl.h" +#include "pipeline.h" + +void +DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi ) +{ + TomahawkSqlQuery query = dbi->newquery(); + QList ql; + + QString whereToken; + if ( !source().isNull() ) + { + whereToken = QString( "WHERE source %1" ).arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ); + } + + QString sql = QString( + "SELECT track, playtime, secs_played " + "FROM playback_log " + "%1" ).arg( whereToken ); + + query.prepare( sql ); + query.exec(); + + while( query.next() ) + { + TomahawkSqlQuery query_track = dbi->newquery(); + + QString sql = QString( + "SELECT track.name, artist.name " + "FROM track, artist " + "WHERE artist.id = track.artist " + "AND track.id = %1 " + ).arg( query.value( 0 ).toUInt() ); + + query_track.prepare( sql ); + query_track.exec(); + + if ( query_track.next() ) + { + QVariantMap m; + m.insert( "track", query_track.value( 0 ).toString() ); + m.insert( "artist", query_track.value( 1 ).toString() ); + m.insert( "qid", uuid() ); + + Tomahawk::query_ptr q( new Tomahawk::Query( m ) ); + ql << q; + } + } + + qDebug() << Q_FUNC_INFO << ql.length(); + + if ( ql.count() ) + { + Tomahawk::Pipeline::instance()->add( ql ); + emit tracks( ql ); + } +} diff --git a/src/libtomahawk/database/databasecommand_playbackhistory.h b/src/libtomahawk/database/databasecommand_playbackhistory.h new file mode 100644 index 000000000..e3e414d59 --- /dev/null +++ b/src/libtomahawk/database/databasecommand_playbackhistory.h @@ -0,0 +1,34 @@ +#ifndef DATABASECOMMAND_PLAYBACKHISTORY_H +#define DATABASECOMMAND_PLAYBACKHISTORY_H + +#include +#include + +#include "databasecommand.h" +#include "source.h" +#include "typedefs.h" + +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_PlaybackHistory : public DatabaseCommand +{ +Q_OBJECT +public: + explicit DatabaseCommand_PlaybackHistory( const Tomahawk::source_ptr& source, QObject* parent = 0 ) + : DatabaseCommand( parent ) + { + setSource( source ); + } + + virtual void exec( DatabaseImpl* ); + + virtual bool doesMutates() const { return false; } + virtual QString commandname() const { return "playbackhistory"; } + +signals: + void tracks( const QList& queries ); + +private: +}; + +#endif // DATABASECOMMAND_PLAYBACKHISTORY_H diff --git a/src/libtomahawk/database/databaseimpl.cpp b/src/libtomahawk/database/databaseimpl.cpp index 48382f454..fcc55c4d2 100644 --- a/src/libtomahawk/database/databaseimpl.cpp +++ b/src/libtomahawk/database/databaseimpl.cpp @@ -10,12 +10,12 @@ #include "databasecommand_updatesearchindex.h" /* !!!! You need to manually generate schema.sql.h when the schema changes: - cd src/database + cd src/libtomahawk/database ./gen_schema.h.sh ./schema.sql tomahawk > schema.sql.h */ #include "schema.sql.h" -#define CURRENT_SCHEMA_VERSION 14 +#define CURRENT_SCHEMA_VERSION 15 DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent ) diff --git a/src/libtomahawk/database/schema.sql b/src/libtomahawk/database/schema.sql index efaaf45bc..8130d52fa 100644 --- a/src/libtomahawk/database/schema.sql +++ b/src/libtomahawk/database/schema.sql @@ -97,8 +97,6 @@ CREATE TABLE IF NOT EXISTS playlist_revision ( previous_revision TEXT REFERENCES playlist_revision(guid) DEFERRABLE INITIALLY DEFERRED ); ---INSERT INTO playlist_revision(guid, playlist, entries) --- VALUES('revisionguid-1', 'playlistguid-1', '["itemguid-2","itemguid-1","itemguid-3"]'); -- the trigram search indexes @@ -209,10 +207,25 @@ CREATE TABLE IF NOT EXISTS track_attributes ( CREATE INDEX track_attrib_id ON track_attributes(id); CREATE INDEX track_attrib_k ON track_attributes(k); + +-- playback history + +-- if source=null, file is local to this machine +CREATE TABLE IF NOT EXISTS playback_log ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + source INTEGER REFERENCES source(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED, + track INTEGER REFERENCES track(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED, + playtime INTEGER NOT NULL, -- when playback finished (timestamp) + secs_played INTEGER NOT NULL +); +CREATE INDEX playback_log_source ON playback_log(source); +CREATE INDEX playback_log_track ON playback_log(track); + + -- Schema version, and misc tomahawk settings relating to the collection db CREATE TABLE IF NOT EXISTS settings ( k TEXT NOT NULL PRIMARY KEY, v TEXT NOT NULL DEFAULT '' ); -INSERT INTO settings(k,v) VALUES('schema_version', '14'); +INSERT INTO settings(k,v) VALUES('schema_version', '15'); diff --git a/src/libtomahawk/database/schema.sql.h b/src/libtomahawk/database/schema.sql.h index fd3127304..84f941cb9 100644 --- a/src/libtomahawk/database/schema.sql.h +++ b/src/libtomahawk/database/schema.sql.h @@ -1,5 +1,5 @@ /* - This file was automatically generated from schema.sql on Tue Jul 13 12:23:44 CEST 2010. + This file was automatically generated from schema.sql on Tue Jan 4 06:55:23 CET 2011. */ static const char * tomahawk_schema_sql = @@ -148,11 +148,20 @@ static const char * tomahawk_schema_sql = ");" "CREATE INDEX track_attrib_id ON track_attributes(id);" "CREATE INDEX track_attrib_k ON track_attributes(k);" +"CREATE TABLE IF NOT EXISTS playback_log (" +" id INTEGER PRIMARY KEY AUTOINCREMENT," +" source INTEGER REFERENCES source(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED," +" track INTEGER REFERENCES track(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED," +" playtime INTEGER NOT NULL, " +" secs_played INTEGER NOT NULL" +");" +"CREATE INDEX playback_log_source ON playback_log(source);" +"CREATE INDEX playback_log_track ON playback_log(track);" "CREATE TABLE IF NOT EXISTS settings (" " k TEXT NOT NULL PRIMARY KEY," " v TEXT NOT NULL DEFAULT ''" ");" -"INSERT INTO settings(k,v) VALUES('schema_version', '14');" +"INSERT INTO settings(k,v) VALUES('schema_version', '15');" ; const char * get_tomahawk_sql() diff --git a/src/musicscanner.cpp b/src/musicscanner.cpp index 3652059bf..4e8b5ced8 100644 --- a/src/musicscanner.cpp +++ b/src/musicscanner.cpp @@ -50,7 +50,7 @@ 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& ) ), - SLOT( setMtimes( const QMap& ) ), Qt::DirectConnection ); + SLOT( setMtimes( const QMap& ) ), Qt::DirectConnection ); connect( cmd, SIGNAL( done( const QMap& ) ), SLOT( scan() ), Qt::DirectConnection ); @@ -81,7 +81,7 @@ MusicScanner::scan() // queued, so will only fire after all dirs have been scanned: connect( lister, SIGNAL( finished( const QMap& ) ), - SLOT( listerFinished( const QMap& ) ), Qt::QueuedConnection ); + SLOT( listerFinished( const QMap& ) ), Qt::QueuedConnection ); connect( lister, SIGNAL( finished() ), lister, SLOT( deleteLater() ) ); diff --git a/src/playlist/playlistmodel.cpp b/src/playlist/playlistmodel.cpp index 256c88caf..1ad542222 100644 --- a/src/playlist/playlistmodel.cpp +++ b/src/playlist/playlistmodel.cpp @@ -6,6 +6,9 @@ #include "album.h" +#include "database/database.h" +#include "database/databasecommand_playbackhistory.h" + using namespace Tomahawk; @@ -115,6 +118,29 @@ PlaylistModel::loadAlbum( const Tomahawk::album_ptr& album ) } +void +PlaylistModel::loadHistory( const Tomahawk::source_ptr& source, unsigned int amount ) +{ + if ( rowCount( QModelIndex() ) ) + { + emit beginRemoveRows( QModelIndex(), 0, rowCount( QModelIndex() ) - 1 ); + delete m_rootItem; + emit endRemoveRows(); + m_rootItem = new PlItem( 0, this ); + } + + m_playlist.clear(); + setReadOnly( true ); + + DatabaseCommand_PlaybackHistory* cmd = new DatabaseCommand_PlaybackHistory( source ); + + connect( cmd, SIGNAL( tracks( QList ) ), + SLOT( onTracksAdded( QList ) ), Qt::QueuedConnection ); + + Database::instance()->enqueue( QSharedPointer( cmd ) ); +} + + void PlaylistModel::appendTrack( const Tomahawk::query_ptr& query ) { diff --git a/src/playlist/playlistmodel.h b/src/playlist/playlistmodel.h index 5fce18b96..1019d94de 100644 --- a/src/playlist/playlistmodel.h +++ b/src/playlist/playlistmodel.h @@ -32,6 +32,7 @@ public: void loadPlaylist( const Tomahawk::playlist_ptr& playlist ); void loadAlbum( const Tomahawk::album_ptr& album ); + void loadHistory( const Tomahawk::source_ptr& source, unsigned int amount = 100 ); void appendTrack( const Tomahawk::query_ptr& query ); diff --git a/src/playlist/trackheader.cpp b/src/playlist/trackheader.cpp index ae30f5b9c..60cbb6d4e 100644 --- a/src/playlist/trackheader.cpp +++ b/src/playlist/trackheader.cpp @@ -24,7 +24,7 @@ TrackHeader::TrackHeader( TrackView* parent ) setMinimumSectionSize( 60 ); setDefaultAlignment( Qt::AlignLeft ); setMovable( true ); - setCascadingSectionResizes( true ); +// setCascadingSectionResizes( true ); m_menu->addAction( tr( "Resize columns to fit window" ), this, SLOT( onToggleResizeColumns() ) ); m_menu->addSeparator(); @@ -72,7 +72,8 @@ TrackHeader::onResized() if ( sectionSize( x ) ) { // not hidden - resizeSection( x, int( (double)width * m_columnWeights[x] ) ); + double nw = (double)width * m_columnWeights[x]; + resizeSection( x, qMax( minimumSectionSize(), int( nw ) ) ); } } diff --git a/src/playlist/trackview.cpp b/src/playlist/trackview.cpp index 81037e561..c6ebd3173 100644 --- a/src/playlist/trackview.cpp +++ b/src/playlist/trackview.cpp @@ -36,7 +36,7 @@ TrackView::TrackView( QWidget* parent ) setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); setRootIsDecorated( false ); setUniformRowHeights( true ); - setMinimumWidth( 700 ); + setMinimumWidth( 300 ); setHeader( m_header ); diff --git a/src/scrobbler.cpp b/src/scrobbler.cpp index 67dc21cf8..0cfb0bf3f 100644 --- a/src/scrobbler.cpp +++ b/src/scrobbler.cpp @@ -50,10 +50,10 @@ Scrobbler::Scrobbler( QObject* parent ) } connect( TomahawkApp::instance(), SIGNAL( settingsChanged() ), - SLOT( settingsChanged() ), Qt::QueuedConnection ); + SLOT( settingsChanged() ), Qt::QueuedConnection ); connect( TomahawkApp::instance()->audioEngine(), SIGNAL( timerSeconds( unsigned int ) ), - SLOT( engineTick( unsigned int ) ), Qt::QueuedConnection ); + SLOT( engineTick( unsigned int ) ), Qt::QueuedConnection ); } diff --git a/src/widgets/welcomewidget.cpp b/src/widgets/welcomewidget.cpp index e2416600b..dd9015044 100644 --- a/src/widgets/welcomewidget.cpp +++ b/src/widgets/welcomewidget.cpp @@ -22,6 +22,10 @@ WelcomeWidget::WelcomeWidget( QWidget* parent ) ui->setupUi( this ); ui->playlistWidget->setItemDelegate( new PlaylistDelegate() ); + m_tracksModel = new PlaylistModel( ui->tracksView ); + ui->tracksView->setModel( m_tracksModel ); + m_tracksModel->loadHistory( Tomahawk::source_ptr() ); + connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); connect( ui->playlistWidget, SIGNAL( itemActivated( QListWidgetItem* ) ), SLOT( onPlaylistActivated( QListWidgetItem* ) ) ); diff --git a/src/widgets/welcomewidget.h b/src/widgets/welcomewidget.h index ed5bd48f8..6f8514c48 100644 --- a/src/widgets/welcomewidget.h +++ b/src/widgets/welcomewidget.h @@ -80,6 +80,8 @@ private slots: private: Ui::WelcomeWidget *ui; + + PlaylistModel* m_tracksModel; }; #endif // WELCOMEWIDGET_H diff --git a/src/widgets/welcomewidget.ui b/src/widgets/welcomewidget.ui index 7fc27e6b6..789b748d3 100644 --- a/src/widgets/welcomewidget.ui +++ b/src/widgets/welcomewidget.ui @@ -43,8 +43,30 @@ + + + + + 14 + + + + Recently played tracks: + + + + + + + + + PlaylistView + QTreeView +
playlistview.h
+
+