Пример #1
0
ActivePlaylistView::ActivePlaylistView(DataStore* dataStore, QWidget* parent):
  QTableView(parent),
  dataStore(dataStore)
{
  setContextMenuPolicy(Qt::CustomContextMenu);
  setFocusPolicy(Qt::TabFocus);
  setEditTriggers(QAbstractItemView::NoEditTriggers);
  model = new ActivePlaylistModel(getDataQuery(), dataStore, this);
  horizontalHeader()->setStretchLastSection(true);
  createActions();
  setModel(model);
  setSelectionBehavior(QAbstractItemView::SelectRows);
  setSelectionMode(QAbstractItemView::ContiguousSelection);
  configureHeaders();
  connect(
    dataStore,
    SIGNAL(activePlaylistModified()),
    model,
    SLOT(refresh()));
  connect(
    this,
    SIGNAL(activated(const QModelIndex&)),
    this,
    SLOT(setCurrentSong(const QModelIndex&)));
  connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
    this, SLOT(handleContextMenuRequest(const QPoint&)));
  connect(
    selectionModel(),
    SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
    this,
    SLOT(handleSelectionChange(const QItemSelection&, const QItemSelection&)));
}
Пример #2
0
void ActivePlaylistView::handleSelectionChange(
  const QItemSelection& selected,
  const QItemSelection& /*deselected*/)
{
  if(selected.indexes().size() == 0){
    connect(
      dataStore,
      SIGNAL(activePlaylistModified()),
      model, 
      SLOT(refresh()));
  }
  else{
    disconnect(
      dataStore,
      SIGNAL(activePlaylistModified()),
      model, 
      SLOT(refresh()));
  }
}
Пример #3
0
PlaybackWidget::PlaybackWidget(DataStore *dataStore, QWidget *parent):
  QWidget(parent), dataStore(dataStore), currentPlaybackState(PLAYING)
{
  audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
  mediaObject = new Phonon::MediaObject(this);
  createActions();
  setupUi();

  mediaObject->setTickInterval(1000);
  connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
  connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
    this, SLOT(stateChanged(Phonon::State, Phonon::State)));
  connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)),
    this, SLOT(sourceChanged(Phonon::MediaSource)));
  connect(mediaObject, SIGNAL(finished()), this, SLOT(playNextSong()));
  connect(
    mediaObject,
    SIGNAL(metaDataChanged()),
    this,
    SLOT(metaDataChanged()));
  connect(
    dataStore,
    SIGNAL(manualSongChange(Phonon::MediaSource)),
    this,
    SLOT(setNewSource(Phonon::MediaSource)));

  connect(
    dataStore,
    SIGNAL(eventEnded()),
    this,
    SLOT(clearWidget()));

  connect(
    dataStore,
    SIGNAL(eventCreated()),
    this,
    SLOT(enablePlayback()));

  connect(
    dataStore,
    SIGNAL(eventEnded()),
    this,
    SLOT(disablePlayback()));

  connect(
    dataStore,
    SIGNAL(activePlaylistModified()),
    this,
    SLOT(handlePlaylistChange()));

  Phonon::createPath(mediaObject, audioOutput);
  dataStore->isCurrentlyHosting() ? setEnabled(true) : setEnabled(false);
  playNextSong();
}