Exemplo n.º 1
0
void EditTagDialog::SetSongsFinished() {
  QFutureWatcher<QList<Data> >* watcher =
      dynamic_cast<QFutureWatcher<QList<Data> >*>(sender());
  if (!watcher) return;
  watcher->deleteLater();

  if (!SetLoading(QString())) return;

  data_ = watcher->result();
  if (data_.count() == 0) {
    // If there were no valid songs, disable everything
    ui_->song_list->setEnabled(false);
    ui_->tab_widget->setEnabled(false);

    // Show a summary with empty information
    UpdateSummaryTab(Song());
    ui_->tab_widget->setCurrentWidget(ui_->summary_tab);

    SetSongListVisibility(false);
    return;
  }

  // Add the filenames to the list
  for (const Data& data : data_) {
    ui_->song_list->addItem(data.current_.basefilename());
  }

  // Select all
  ui_->song_list->setCurrentRow(0);
  ui_->song_list->selectAll();

  // Hide the list if there's only one song in it
  SetSongListVisibility(data_.count() != 1);
}
Exemplo n.º 2
0
void EditTagDialog::SelectionChanged() {
  const QModelIndexList sel =
      ui_->song_list->selectionModel()->selectedIndexes();
  if (sel.isEmpty()) return;

  // Set the editable fields
  UpdateUI(sel);

  // If we're editing multiple songs then we have to disable certain tabs
  const bool multiple = sel.count() > 1;
  ui_->tab_widget->setTabEnabled(ui_->tab_widget->indexOf(ui_->summary_tab),
                                 !multiple);

  if (!multiple) {
    const Song& song = data_[sel.first().row()].original_;
    UpdateSummaryTab(song);
    UpdateStatisticsTab(song);
  }
}
Exemplo n.º 3
0
void EditTagDialog::UpdateCoverOf(const Song& selected,
                                  const QModelIndexList& sel,
                                  const QString& cover) {
  if (!selected.is_valid() || selected.id() == -1) return;

  UpdateSummaryTab(selected);

  // Now check if we have any other songs cached that share that artist and
  // album (and would therefore be changed as well)
  for (int i = 0; i < data_.count(); ++i) {
    if (i == sel.first().row())  // Already changed this one
      continue;

    Song* other_song = &data_[i].original_;
    if (selected.artist() == other_song->artist() &&
        selected.album() == other_song->album()) {
      other_song->set_art_manual(cover);
    }
  }
}