organise: Update the song preview when the selected destination's data changes

This will cause the file exensions to change when transcode options are changed.
This commit is contained in:
Jim Broadus 2020-06-06 21:40:07 -07:00 committed by John Maguire
parent 4dd3233976
commit c299c198de
2 changed files with 22 additions and 1 deletions

View File

@ -113,6 +113,13 @@ void OrganiseDialog::SetDestinationModel(QAbstractItemModel* model,
ui_->destination->setModel(model); ui_->destination->setModel(model);
ui_->eject_after->setVisible(devices); ui_->eject_after->setVisible(devices);
// In case this is called more than once, disconnect old model.
if (model_connection_) disconnect(model_connection_);
// If a device changes, transcoding options may have changed.
model_connection_ =
connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
SLOT(DestDataChanged(QModelIndex, QModelIndex)));
} }
bool OrganiseDialog::SetSongs(const SongList& songs) { bool OrganiseDialog::SetSongs(const SongList& songs) {
@ -306,6 +313,16 @@ void OrganiseDialog::UpdatePreviews() {
} }
} }
void OrganiseDialog::DestDataChanged(const QModelIndex& begin,
const QModelIndex& end) {
const QModelIndex destination =
ui_->destination->model()->index(ui_->destination->currentIndex(), 0);
if (QItemSelection(begin, end).contains(destination)) {
qLog(Debug) << "Destination data changed";
UpdatePreviews();
}
}
QSize OrganiseDialog::sizeHint() const { return QSize(650, 0); } QSize OrganiseDialog::sizeHint() const { return QSize(650, 0); }
void OrganiseDialog::Reset() { void OrganiseDialog::Reset() {

View File

@ -64,7 +64,7 @@ class OrganiseDialog : public QDialog {
void SetCopy(bool copy); void SetCopy(bool copy);
signals: signals:
void FileCopied(int); void FileCopied(int);
public slots: public slots:
@ -80,6 +80,8 @@ signals:
void InsertTag(const QString& tag); void InsertTag(const QString& tag);
void UpdatePreviews(); void UpdatePreviews();
void DestDataChanged(const QModelIndex& begin, const QModelIndex& end);
void OrganiseFinished(const QStringList& files_with_errors); void OrganiseFinished(const QStringList& files_with_errors);
private: private:
@ -93,6 +95,8 @@ signals:
TaskManager* task_manager_; TaskManager* task_manager_;
LibraryBackend* backend_; LibraryBackend* backend_;
QMetaObject::Connection model_connection_;
OrganiseFormat format_; OrganiseFormat format_;
QFuture<SongList> songs_future_; QFuture<SongList> songs_future_;