Skip to content

Commit 7b2bf0f

Browse files
committed
Fix #20: update SelectionModel behavior to support a separated currentItem for each scope
1 parent c1b55c8 commit 7b2bf0f

File tree

8 files changed

+25
-7
lines changed

8 files changed

+25
-7
lines changed

src/libs/application/dspxmodel/src/selectionmodel/SelectionModel.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,22 +167,22 @@ namespace dspx {
167167
if (targetSelectionType != d->selectionType) {
168168
switch (d->selectionType) {
169169
case ST_AnchorNode:
170-
// d->anchorNodeSelectionModel->d_func()->clearAll();
170+
// d->anchorNodeSelectionModel->d_func()->select(nullptr, command);
171171
break;
172172
case ST_Clip:
173-
d->clipSelectionModel->d_func()->clearAll();
173+
d->clipSelectionModel->d_func()->select(nullptr, command);
174174
break;
175175
case ST_Label:
176-
d->labelSelectionModel->d_func()->clearAll();
176+
d->labelSelectionModel->d_func()->select(nullptr, command);
177177
break;
178178
case ST_Note:
179-
d->noteSelectionModel->d_func()->clearAll();
179+
d->noteSelectionModel->d_func()->select(nullptr, command);
180180
break;
181181
case ST_Tempo:
182-
d->tempoSelectionModel->d_func()->clearAll();
182+
d->tempoSelectionModel->d_func()->select(nullptr, command);
183183
break;
184184
case ST_Track:
185-
d->trackSelectionModel->d_func()->clearAll();
185+
d->trackSelectionModel->d_func()->select(nullptr, command);
186186
break;
187187
default:
188188
break;

src/plugins/visualeditor/core/selectioncontrollers/LabelSelectionController.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace VisualEditor {
3131
selectionModel = q->windowHandle()->projectDocumentContext()->document()->selectionModel();
3232
labelSelectionModel = q->windowHandle()->projectDocumentContext()->document()->selectionModel()->labelSelectionModel();
3333
connect(labelSelectionModel, &dspx::LabelSelectionModel::currentItemChanged, this, &SelectionController::currentItemChanged);
34+
connect(selectionModel, &dspx::SelectionModel::selectionTypeChanged, this, &SelectionController::editScopeFocusedChanged);
3435
}
3536

3637
LabelSelectionController::~LabelSelectionController() = default;
@@ -88,4 +89,8 @@ namespace VisualEditor {
8889
return q->getLabelViewItemFromDocumentItem(labelSelectionModel->currentItem());
8990
}
9091

92+
bool LabelSelectionController::editScopeFocused() const {
93+
return selectionModel->selectionType() == dspx::SelectionModel::ST_Label;
94+
}
95+
9196
}

src/plugins/visualeditor/core/selectioncontrollers/LabelSelectionController_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace VisualEditor {
2626
QObjectList getItemsBetween(QObject *startItem, QObject *endItem) const override;
2727
void select(QObject *item, SelectionCommand command) override;
2828
QObject *currentItem() const override;
29+
bool editScopeFocused() const override;
2930

3031
private:
3132
ProjectViewModelContext *q;

src/plugins/visualeditor/core/selectioncontrollers/TempoSelectionController.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace VisualEditor {
3131
selectionModel = q->windowHandle()->projectDocumentContext()->document()->selectionModel();
3232
tempoSelectionModel = q->windowHandle()->projectDocumentContext()->document()->selectionModel()->tempoSelectionModel();
3333
connect(tempoSelectionModel, &dspx::TempoSelectionModel::currentItemChanged, this, &SelectionController::currentItemChanged);
34+
connect(selectionModel, &dspx::SelectionModel::selectionTypeChanged, this, &SelectionController::editScopeFocusedChanged);
3435
}
3536

3637
TempoSelectionController::~TempoSelectionController() = default;
@@ -88,4 +89,8 @@ namespace VisualEditor {
8889
return q->getTempoViewItemFromDocumentItem(tempoSelectionModel->currentItem());
8990
}
9091

92+
bool TempoSelectionController::editScopeFocused() const {
93+
return selectionModel->selectionType() == dspx::SelectionModel::ST_Tempo;
94+
}
95+
9196
}

src/plugins/visualeditor/core/selectioncontrollers/TempoSelectionController_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace VisualEditor {
2626
QObjectList getItemsBetween(QObject *startItem, QObject *endItem) const override;
2727
void select(QObject *item, SelectionCommand command) override;
2828
QObject *currentItem() const override;
29+
bool editScopeFocused() const override;
2930

3031
private:
3132
ProjectViewModelContext *q;

src/plugins/visualeditor/core/selectioncontrollers/TrackSelectionController.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace VisualEditor {
3030
selectionModel = q->windowHandle()->projectDocumentContext()->document()->selectionModel();
3131
trackSelectionModel = selectionModel->trackSelectionModel();
3232
connect(trackSelectionModel, &dspx::TrackSelectionModel::currentItemChanged, this, &SelectionController::currentItemChanged);
33+
connect(selectionModel, &dspx::SelectionModel::selectionTypeChanged, this, &SelectionController::editScopeFocusedChanged);
3334
}
3435

3536
TrackSelectionController::~TrackSelectionController() = default;
@@ -90,4 +91,8 @@ namespace VisualEditor {
9091
return q->getTrackViewItemFromDocumentItem(trackSelectionModel->currentItem());
9192
}
9293

94+
bool TrackSelectionController::editScopeFocused() const {
95+
return selectionModel->selectionType() == dspx::SelectionModel::ST_Track;
96+
}
97+
9398
}

src/plugins/visualeditor/core/selectioncontrollers/TrackSelectionController_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace VisualEditor {
2424
QObjectList getItemsBetween(QObject *startItem, QObject *endItem) const override;
2525
void select(QObject *item, SelectionCommand command) override;
2626
QObject *currentItem() const override;
27+
bool editScopeFocused() const override;
2728

2829
private:
2930
ProjectViewModelContext *q;

0 commit comments

Comments
 (0)