Nice typedefs.

This commit is contained in:
John Maguire 2010-08-03 19:40:54 +00:00
parent 36264e0b2b
commit 16d50b29d8
2 changed files with 9 additions and 6 deletions

View File

@ -880,6 +880,10 @@ void Playlist::Save() const {
backend_->SavePlaylistAsync(id_, items_, last_played_index()); backend_->SavePlaylistAsync(id_, items_, last_played_index());
} }
namespace {
typedef QFutureWatcher<shared_ptr<PlaylistItem> > PlaylistItemFutureWatcher;
}
void Playlist::Restore() { void Playlist::Restore() {
if (!backend_) if (!backend_)
return; return;
@ -888,16 +892,14 @@ void Playlist::Restore() {
virtual_items_.clear(); virtual_items_.clear();
library_items_by_id_.clear(); library_items_by_id_.clear();
QFuture<shared_ptr<PlaylistItem> > future = backend_->GetPlaylistItems(id_); PlaylistBackend::PlaylistItemFuture future = backend_->GetPlaylistItems(id_);
QFutureWatcher<shared_ptr<PlaylistItem> >* watcher = PlaylistItemFutureWatcher* watcher = new PlaylistItemFutureWatcher(this);
new QFutureWatcher<shared_ptr<PlaylistItem> >(this);
watcher->setFuture(future); watcher->setFuture(future);
connect(watcher, SIGNAL(finished()), SLOT(ItemsLoaded())); connect(watcher, SIGNAL(finished()), SLOT(ItemsLoaded()));
} }
void Playlist::ItemsLoaded() { void Playlist::ItemsLoaded() {
QFutureWatcher<shared_ptr<PlaylistItem> >* watcher = PlaylistItemFutureWatcher* watcher = static_cast<PlaylistItemFutureWatcher*>(sender());
static_cast<QFutureWatcher<shared_ptr<PlaylistItem> >*>(sender());
watcher->deleteLater(); watcher->deleteLater();
items_ = watcher->future().results(); items_ = watcher->future().results();

View File

@ -40,10 +40,11 @@ class PlaylistBackend : public QObject {
int last_played; int last_played;
}; };
typedef QList<Playlist> PlaylistList; typedef QList<Playlist> PlaylistList;
typedef QFuture<boost::shared_ptr<PlaylistItem> > PlaylistItemFuture;
PlaylistList GetAllPlaylists(); PlaylistList GetAllPlaylists();
Playlist GetPlaylist(int id); Playlist GetPlaylist(int id);
QFuture<boost::shared_ptr<PlaylistItem> > GetPlaylistItems(int playlist); PlaylistItemFuture GetPlaylistItems(int playlist);
void SavePlaylistAsync(int playlist, const PlaylistItemList& items, void SavePlaylistAsync(int playlist, const PlaylistItemList& items,
int last_played); int last_played);
void SetPlaylistOrder(const QList<int>& ids); void SetPlaylistOrder(const QList<int>& ids);