| 183 | } |
| 184 | |
| 185 | void DialogSelection::Process(wxCommandEvent& event) { |
| 186 | std::set<AssDialogue*> matches; |
| 187 | |
| 188 | try { |
| 189 | matches = process( |
| 190 | from_wx(match_text->GetValue()), case_sensitive->IsChecked(), |
| 191 | static_cast<Mode>(match_mode->GetSelection()), select_unmatching_lines->GetValue(), |
| 192 | apply_to_comments->IsChecked(), apply_to_dialogue->IsChecked(), |
| 193 | dialogue_field->GetSelection(), con->ass.get()); |
| 194 | } |
| 195 | catch (agi::Exception const&) { |
| 196 | if (event.GetId() == wxID_OK) Close(); |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | auto action = static_cast<Action>(selection_change_type->GetSelection()); |
| 201 | |
| 202 | Selection old_sel, new_sel; |
| 203 | if (action != Action::SET) |
| 204 | old_sel = con->selectionController->GetSelectedSet(); |
| 205 | |
| 206 | wxString message; |
| 207 | size_t count = 0; |
| 208 | switch (action) { |
| 209 | case Action::SET: |
| 210 | new_sel = std::move(matches); |
| 211 | message = (count = new_sel.size()) |
| 212 | ? fmt_plural(count, "Selection was set to one line", "Selection was set to %u lines", count) |
| 213 | : _("Selection was set to no lines"); |
| 214 | break; |
| 215 | |
| 216 | case Action::ADD: |
| 217 | boost::set_union(old_sel, matches, inserter(new_sel, new_sel.begin())); |
| 218 | message = (count = new_sel.size() - old_sel.size()) |
| 219 | ? fmt_plural(count, "One line was added to selection", "%u lines were added to selection", count) |
| 220 | : _("No lines were added to selection"); |
| 221 | break; |
| 222 | |
| 223 | case Action::SUB: |
| 224 | boost::set_difference(old_sel, matches, inserter(new_sel, new_sel.begin())); |
| 225 | goto sub_message; |
| 226 | |
| 227 | case Action::INTERSECT: |
| 228 | boost::set_intersection(old_sel, matches, inserter(new_sel, new_sel.begin())); |
| 229 | sub_message: |
| 230 | message = (count = old_sel.size() - new_sel.size()) |
| 231 | ? fmt_plural(count, "One line was removed from selection", "%u lines were removed from selection", count) |
| 232 | : _("No lines were removed from selection"); |
| 233 | break; |
| 234 | } |
| 235 | |
| 236 | if (count == 0) |
| 237 | wxMessageBox(message, _("Selection"), wxOK | wxCENTER, this); |
| 238 | else |
| 239 | con->frame->StatusTimeout(message); |
| 240 | |
| 241 | AssDialogue *new_active = con->selectionController->GetActiveLine(); |
| 242 | if (new_sel.size() && !new_sel.count(new_active)) |
nothing calls this directly
no test coverage detected