Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effects preferences fixes #4468

Merged
merged 2 commits into from
Oct 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/preferences/dialog/dlgprefeffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent,
hiddenEffectsTableView->setModel(m_pHiddenEffectsModel);
setupManifestTableView(hiddenEffectsTableView);

// Allow selection only in either of the effects lists at a time to clarify
// which effect/chain the info below refers to.
// Upon selection change, deselect items in the adjacent list (reset doesn't
// emit dataChanged() signal.
connect(visibleEffectsTableView->selectionModel(),
&QItemSelectionModel::currentRowChanged,
hiddenEffectsTableView->selectionModel(),
&QItemSelectionModel::reset);
connect(hiddenEffectsTableView->selectionModel(),
&QItemSelectionModel::currentRowChanged,
visibleEffectsTableView->selectionModel(),
&QItemSelectionModel::reset);

setupChainListView(chainListView);
setupChainListView(quickEffectListView);

Expand Down Expand Up @@ -66,7 +79,7 @@ void DlgPrefEffects::setupManifestTableView(QTableView* pTableView) {
// QTableView won't remove dragged items without this??
pTableView->setDragDropOverwriteMode(false);
pTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
pTableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
pTableView->setSelectionMode(QAbstractItemView::SingleSelection);
connect(pTableView->selectionModel(),
&QItemSelectionModel::currentRowChanged,
this,
Expand All @@ -78,11 +91,11 @@ void DlgPrefEffects::setupChainListView(QListView* pListView) {
pListView->setModel(pModel);
pListView->setDropIndicatorShown(true);
pListView->setDragDropMode(QAbstractItemView::DragDrop);
pListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
pListView->setSelectionMode(QAbstractItemView::SingleSelection);
//TODO: prevent drops of duplicate items
pListView->setDefaultDropAction(Qt::CopyAction);
connect(pListView,
&QAbstractItemView::clicked,
connect(pListView->selectionModel(),
&QItemSelectionModel::currentRowChanged,
this,
&DlgPrefEffects::slotChainPresetSelected);
pListView->installEventFilter(this);
Expand All @@ -91,6 +104,11 @@ void DlgPrefEffects::setupChainListView(QListView* pListView) {
void DlgPrefEffects::slotUpdate() {
clear();

// Prevent emission of dataChanged() when clearing the effects lists to not
// call effectsTableItemSelected() with a selection that has no model.
visibleEffectsTableView->selectionModel()->reset();
hiddenEffectsTableView->selectionModel()->reset();

const QList<EffectManifestPointer> visibleEffects = m_pVisibleEffectsList->getList();
m_pVisibleEffectsModel->setList(visibleEffects);

Expand Down Expand Up @@ -282,6 +300,7 @@ bool DlgPrefEffects::eventFilter(QObject* pChainList, QEvent* event) {
return false;
}
m_pFocusedChainList = pListView;
unfocusedChainList()->selectionModel()->reset();
}
return false;
}
Expand Down