void PlaylistView::SetPlaylist(Playlist* playlist) {
  if (playlist_) {
    disconnect(playlist_, SIGNAL(CurrentSongChanged(Song)),
               this, SLOT(MaybeAutoscroll()));
    disconnect(playlist_, SIGNAL(DynamicModeChanged(bool)),
               this, SLOT(DynamicModeChanged(bool)));
    disconnect(playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed()));

    disconnect(dynamic_controls_, SIGNAL(Repopulate()),
               playlist_, SLOT(RepopulateDynamicPlaylist()));
    disconnect(dynamic_controls_, SIGNAL(TurnOff()),
               playlist_, SLOT(TurnOffDynamicPlaylist()));
  }

  playlist_ = playlist;
  LoadGeometry();
  ReloadSettings();
  DynamicModeChanged(playlist->is_dynamic());
  setFocus();
  read_only_settings_ = false;

  connect(playlist_, SIGNAL(RestoreFinished()), SLOT(JumpToLastPlayedTrack()));

  connect(playlist_, SIGNAL(CurrentSongChanged(Song)), SLOT(MaybeAutoscroll()));
  connect(playlist_, SIGNAL(DynamicModeChanged(bool)), SLOT(DynamicModeChanged(bool)));
  connect(playlist_, SIGNAL(destroyed()), SLOT(PlaylistDestroyed()));
  connect(dynamic_controls_, SIGNAL(Repopulate()), playlist_, SLOT(RepopulateDynamicPlaylist()));
  connect(dynamic_controls_, SIGNAL(TurnOff()), playlist_, SLOT(TurnOffDynamicPlaylist()));
}
예제 #2
0
void QueueManager::CurrentPlaylistChanged(Playlist* playlist) {
  if (current_playlist_) {
    disconnect(current_playlist_->queue(),
               SIGNAL(rowsInserted(QModelIndex, int, int)), this,
               SLOT(UpdateButtonState()));
    disconnect(current_playlist_->queue(),
               SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
               SLOT(UpdateButtonState()));
    disconnect(current_playlist_->queue(), SIGNAL(layoutChanged()), this,
               SLOT(UpdateButtonState()));
    disconnect(current_playlist_, SIGNAL(destroyed()), this,
               SLOT(PlaylistDestroyed()));
  }

  current_playlist_ = playlist;

  connect(current_playlist_->queue(),
          SIGNAL(rowsInserted(QModelIndex, int, int)), this,
          SLOT(UpdateButtonState()));
  connect(current_playlist_->queue(),
          SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
          SLOT(UpdateButtonState()));
  connect(current_playlist_->queue(), SIGNAL(layoutChanged()), this,
          SLOT(UpdateButtonState()));
  connect(current_playlist_, SIGNAL(destroyed()), this,
          SLOT(PlaylistDestroyed()));

  ui_->list->setModel(current_playlist_->queue());

  connect(ui_->list->selectionModel(),
          SIGNAL(currentChanged(QModelIndex, QModelIndex)),
          SLOT(UpdateButtonState()));
}