Skip to content

Commit

Permalink
effects preferences: allow only single selection in each tab
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Oct 22, 2021
1 parent e918be0 commit d09fd60
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 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 Down Expand Up @@ -287,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 d09fd60

Please sign in to comment.