Slather on some std::moves when setting the selection
This commit is contained in:
parent
7c2363ee5b
commit
26c92453b8
8 changed files with 16 additions and 20 deletions
|
@ -317,5 +317,5 @@ void AssKaraoke::SplitLines(std::set<AssDialogue*> const& lines, agi::Context *c
|
||||||
AssDialogue *new_active = c->selectionController->GetActiveLine();
|
AssDialogue *new_active = c->selectionController->GetActiveLine();
|
||||||
if (!sel.count(c->selectionController->GetActiveLine()))
|
if (!sel.count(c->selectionController->GetActiveLine()))
|
||||||
new_active = *sel.begin();
|
new_active = *sel.begin();
|
||||||
c->selectionController->SetSelectionAndActive(sel, new_active);
|
c->selectionController->SetSelectionAndActive(std::move(sel), new_active);
|
||||||
}
|
}
|
||||||
|
|
|
@ -943,7 +943,7 @@ namespace Automation4 {
|
||||||
AssDialogue *new_active = c->selectionController->GetActiveLine();
|
AssDialogue *new_active = c->selectionController->GetActiveLine();
|
||||||
if (active_line && (active_idx > 0 || !sel.count(new_active)))
|
if (active_line && (active_idx > 0 || !sel.count(new_active)))
|
||||||
new_active = active_line;
|
new_active = active_line;
|
||||||
c->selectionController->SetSelectionAndActive(sel, new_active);
|
c->selectionController->SetSelectionAndActive(std::move(sel), new_active);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
|
@ -269,7 +269,7 @@ void BaseGrid::UpdateMaps() {
|
||||||
sorted.begin(), sorted.end(),
|
sorted.begin(), sorted.end(),
|
||||||
inserter(new_sel, new_sel.begin()));
|
inserter(new_sel, new_sel.begin()));
|
||||||
|
|
||||||
SetSelectedSet(new_sel);
|
SetSelectedSet(std::move(new_sel));
|
||||||
|
|
||||||
// The active line may have ceased to exist; pick a new one if so
|
// The active line may have ceased to exist; pick a new one if so
|
||||||
if (line_index_map.size() && !line_index_map.count(active_line))
|
if (line_index_map.size() && !line_index_map.count(active_line))
|
||||||
|
@ -321,7 +321,7 @@ void BaseGrid::SelectRow(int row, bool addToSelected, bool select) {
|
||||||
if (!addToSelected) {
|
if (!addToSelected) {
|
||||||
Selection sel;
|
Selection sel;
|
||||||
if (select) sel.insert(line);
|
if (select) sel.insert(line);
|
||||||
SetSelectedSet(sel);
|
SetSelectedSet(std::move(sel));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
||||||
if (ctrl) newsel = selection;
|
if (ctrl) newsel = selection;
|
||||||
for (int i = i1; i <= i2; i++)
|
for (int i = i1; i <= i2; i++)
|
||||||
newsel.insert(GetDialogue(i));
|
newsel.insert(GetDialogue(i));
|
||||||
SetSelectedSet(newsel);
|
SetSelectedSet(std::move(newsel));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,7 +940,7 @@ void BaseGrid::OnKeyDown(wxKeyEvent &event) {
|
||||||
for (int i = begin; i <= end; i++)
|
for (int i = begin; i <= end; i++)
|
||||||
newsel.insert(GetDialogue(i));
|
newsel.insert(GetDialogue(i));
|
||||||
|
|
||||||
SetSelectedSet(newsel);
|
SetSelectedSet(std::move(newsel));
|
||||||
|
|
||||||
MakeRowVisible(next);
|
MakeRowVisible(next);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -132,7 +132,7 @@ void paste_lines(agi::Context *c, bool paste_over, Paster&& paste_line) {
|
||||||
c->ass->Commit(_("paste"), paste_over ? AssFile::COMMIT_DIAG_FULL : AssFile::COMMIT_DIAG_ADDREM);
|
c->ass->Commit(_("paste"), paste_over ? AssFile::COMMIT_DIAG_FULL : AssFile::COMMIT_DIAG_ADDREM);
|
||||||
|
|
||||||
if (!paste_over)
|
if (!paste_over)
|
||||||
c->selectionController->SetSelectionAndActive(newsel, first);
|
c->selectionController->SetSelectionAndActive(std::move(newsel), first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ static void duplicate_lines(agi::Context *c, int shift) {
|
||||||
|
|
||||||
c->ass->Commit(shift ? _("split") : _("duplicate lines"), AssFile::COMMIT_DIAG_ADDREM);
|
c->ass->Commit(shift ? _("split") : _("duplicate lines"), AssFile::COMMIT_DIAG_ADDREM);
|
||||||
|
|
||||||
c->selectionController->SetSelectionAndActive(new_sel, new_active);
|
c->selectionController->SetSelectionAndActive(std::move(new_sel), new_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct edit_line_duplicate : public validate_sel_nonempty {
|
struct edit_line_duplicate : public validate_sel_nonempty {
|
||||||
|
@ -783,7 +783,7 @@ static bool try_paste_lines(agi::Context *c) {
|
||||||
auto pos = c->ass->Events.iterator_to(*c->selectionController->GetActiveLine());
|
auto pos = c->ass->Events.iterator_to(*c->selectionController->GetActiveLine());
|
||||||
c->ass->Events.splice(pos, parsed, parsed.begin(), parsed.end());
|
c->ass->Events.splice(pos, parsed, parsed.begin(), parsed.end());
|
||||||
c->ass->Commit(_("paste"), AssFile::COMMIT_DIAG_ADDREM);
|
c->ass->Commit(_("paste"), AssFile::COMMIT_DIAG_ADDREM);
|
||||||
c->selectionController->SetSelectionAndActive(new_selection, new_active);
|
c->selectionController->SetSelectionAndActive(std::move(new_selection), new_active);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -985,7 +985,7 @@ struct edit_line_recombine : public validate_sel_multiple {
|
||||||
// Restore selection
|
// Restore selection
|
||||||
if (!new_sel.count(active_line))
|
if (!new_sel.count(active_line))
|
||||||
active_line = *new_sel.begin();
|
active_line = *new_sel.begin();
|
||||||
c->selectionController->SetSelectionAndActive(new_sel, active_line);
|
c->selectionController->SetSelectionAndActive(std::move(new_sel), active_line);
|
||||||
|
|
||||||
c->ass->Commit(_("combining"), AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
|
c->ass->Commit(_("combining"), AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ struct subtitle_select_all : public Command {
|
||||||
void operator()(agi::Context *c) override {
|
void operator()(agi::Context *c) override {
|
||||||
SubtitleSelection sel;
|
SubtitleSelection sel;
|
||||||
boost::copy(c->ass->Events | agi::address_of, inserter(sel, sel.end()));
|
boost::copy(c->ass->Events | agi::address_of, inserter(sel, sel.end()));
|
||||||
c->selectionController->SetSelectedSet(sel);
|
c->selectionController->SetSelectedSet(std::move(sel));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ struct subtitle_select_visible : public Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c->selectionController->SetSelectedSet(new_selection);
|
c->selectionController->SetSelectedSet(std::move(new_selection));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Validate(const agi::Context *c) override {
|
bool Validate(const agi::Context *c) override {
|
||||||
|
|
|
@ -221,14 +221,10 @@ void DialogSelection::Process(wxCommandEvent&) {
|
||||||
else
|
else
|
||||||
StatusTimeout(message);
|
StatusTimeout(message);
|
||||||
|
|
||||||
if (new_sel.size() && !new_sel.count(con->selectionController->GetActiveLine()))
|
|
||||||
con->selectionController->SetActiveLine(*new_sel.begin());
|
|
||||||
con->selectionController->SetSelectedSet(new_sel);
|
|
||||||
|
|
||||||
AssDialogue *new_active = con->selectionController->GetActiveLine();
|
AssDialogue *new_active = con->selectionController->GetActiveLine();
|
||||||
if (new_sel.size() && !new_sel.count(new_active))
|
if (new_sel.size() && !new_sel.count(new_active))
|
||||||
new_active = *new_sel.begin();
|
new_active = *new_sel.begin();
|
||||||
con->selectionController->SetSelectionAndActive(new_sel, new_active);
|
con->selectionController->SetSelectionAndActive(std::move(new_sel), new_active);
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ struct SubsController::UndoInfo {
|
||||||
c->subsGrid->BeginBatch();
|
c->subsGrid->BeginBatch();
|
||||||
c->selectionController->SetSelectedSet(std::set<AssDialogue *>{});
|
c->selectionController->SetSelectedSet(std::set<AssDialogue *>{});
|
||||||
c->ass->Commit("", AssFile::COMMIT_NEW);
|
c->ass->Commit("", AssFile::COMMIT_NEW);
|
||||||
c->selectionController->SetSelectionAndActive(new_sel, active_line);
|
c->selectionController->SetSelectionAndActive(std::move(new_sel), active_line);
|
||||||
c->subsGrid->EndBatch();
|
c->subsGrid->EndBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ void VisualTool<FeatureType>::SetSelection(FeatureType *feat, bool clear) {
|
||||||
if (!clear)
|
if (!clear)
|
||||||
sel = c->selectionController->GetSelectedSet();
|
sel = c->selectionController->GetSelectedSet();
|
||||||
if (sel.insert(feat->line).second)
|
if (sel.insert(feat->line).second)
|
||||||
c->selectionController->SetSelectedSet(sel);
|
c->selectionController->SetSelectedSet(std::move(sel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ void VisualTool<FeatureType>::RemoveSelection(FeatureType *feat) {
|
||||||
if (feat->line == new_active)
|
if (feat->line == new_active)
|
||||||
new_active = *sel.begin();
|
new_active = *sel.begin();
|
||||||
|
|
||||||
c->selectionController->SetSelectionAndActive(sel, new_active);
|
c->selectionController->SetSelectionAndActive(std::move(sel), new_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////// PARSERS
|
//////// PARSERS
|
||||||
|
|
Loading…
Reference in a new issue