Skip to content

Commit

Permalink
Merge pull request #4468 from ronso0/effects-pref-fixes
Browse files Browse the repository at this point in the history
Effects preferences fixes
  • Loading branch information
Be-ing authored Oct 22, 2021
2 parents 4757242 + d09fd60 commit f6ef330
Showing 1 changed file with 23 additions and 4 deletions.
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

0 comments on commit f6ef330

Please sign in to comment.