Use AssDialogue::Row more places

This commit is contained in:
Thomas Goyne 2014-04-17 17:30:06 -07:00
parent e729d38164
commit 27c1522622
4 changed files with 4 additions and 11 deletions

View File

@ -88,7 +88,7 @@ std::vector<std::string> AudioPlayerFactory::GetClasses() {
} }
std::unique_ptr<AudioPlayer> AudioPlayerFactory::GetAudioPlayer(AudioProvider *provider, wxWindow *window) { std::unique_ptr<AudioPlayer> AudioPlayerFactory::GetAudioPlayer(AudioProvider *provider, wxWindow *window) {
if (std::distance(std::begin(factories), std::end(factories)) == 0) if (std::begin(factories) == std::end(factories))
throw agi::NoAudioPlayersError("No audio players are available.", nullptr); throw agi::NoAudioPlayersError("No audio players are available.", nullptr);
auto preferred = OPT_GET("Audio/Player")->GetString(); auto preferred = OPT_GET("Audio/Player")->GetString();

View File

@ -65,7 +65,6 @@ DialogTranslation::DialogTranslation(agi::Context *c)
, active_line_connection(c->selectionController->AddActiveLineListener(&DialogTranslation::OnActiveLineChanged, this)) , active_line_connection(c->selectionController->AddActiveLineListener(&DialogTranslation::OnActiveLineChanged, this))
, active_line(c->selectionController->GetActiveLine()) , active_line(c->selectionController->GetActiveLine())
, line_count(c->ass->Events.size()) , line_count(c->ass->Events.size())
, line_number(std::distance(c->ass->Events.begin(), c->ass->iterator_to(*active_line)) + 1)
{ {
SetIcon(GETICON(translation_toolbutton_16)); SetIcon(GETICON(translation_toolbutton_16));
@ -173,7 +172,6 @@ void DialogTranslation::OnActiveLineChanged(AssDialogue *new_line) {
active_line = new_line; active_line = new_line;
blocks = active_line->ParseTags(); blocks = active_line->ParseTags();
cur_block = 0; cur_block = 0;
line_number = std::distance(c->ass->Events.begin(), c->ass->iterator_to(*new_line)) + 1;
if (bad_block(blocks[cur_block]) && !NextBlock()) { if (bad_block(blocks[cur_block]) && !NextBlock()) {
wxMessageBox(_("No more lines to translate.")); wxMessageBox(_("No more lines to translate."));
@ -184,7 +182,7 @@ void DialogTranslation::OnActiveLineChanged(AssDialogue *new_line) {
void DialogTranslation::OnExternalCommit(int commit_type) { void DialogTranslation::OnExternalCommit(int commit_type) {
if (commit_type == AssFile::COMMIT_NEW || commit_type & AssFile::COMMIT_DIAG_ADDREM) { if (commit_type == AssFile::COMMIT_NEW || commit_type & AssFile::COMMIT_DIAG_ADDREM) {
line_count = c->ass->Events.size(); line_count = c->ass->Events.size();
line_number_display->SetLabel(wxString::Format(_("Current line: %d/%d"), (int)line_number, (int)line_count)); line_number_display->SetLabel(wxString::Format(_("Current line: %d/%d"), active_line->Row + 1, (int)line_count));
} }
if (commit_type & AssFile::COMMIT_DIAG_TEXT) if (commit_type & AssFile::COMMIT_DIAG_TEXT)
@ -202,7 +200,6 @@ bool DialogTranslation::NextBlock() {
active_line = new_line; active_line = new_line;
blocks = active_line->ParseTags(); blocks = active_line->ParseTags();
cur_block = 0; cur_block = 0;
++line_number;
} }
else else
++cur_block; ++cur_block;
@ -224,7 +221,6 @@ bool DialogTranslation::PrevBlock() {
active_line = new_line; active_line = new_line;
blocks = active_line->ParseTags(); blocks = active_line->ParseTags();
cur_block = blocks.size() - 1; cur_block = blocks.size() - 1;
--line_number;
} }
else else
--cur_block; --cur_block;
@ -236,7 +232,7 @@ bool DialogTranslation::PrevBlock() {
} }
void DialogTranslation::UpdateDisplay() { void DialogTranslation::UpdateDisplay() {
line_number_display->SetLabel(wxString::Format(_("Current line: %d/%d"), (int)line_number, (int)line_count)); line_number_display->SetLabel(wxString::Format(_("Current line: %d/%d"), active_line->Row, (int)line_count));
original_text->SetReadOnly(false); original_text->SetReadOnly(false);
original_text->ClearAll(); original_text->ClearAll();

View File

@ -50,8 +50,6 @@ class DialogTranslation final : public wxDialog {
/// Total number of dialogue lines in the file /// Total number of dialogue lines in the file
size_t line_count; size_t line_count;
/// Line number of the currently active line
size_t line_number;
/// Should active line change announcements be ignored? /// Should active line change announcements be ignored?
bool switching_lines = false; bool switching_lines = false;

View File

@ -45,8 +45,7 @@ void SelectionController::OnSubtitlesOpen() {
void SelectionController::OnSubtitlesSave() { void SelectionController::OnSubtitlesSave() {
if (active_line) if (active_line)
context->ass->SaveUIState("Active Line", std::to_string(std::distance( context->ass->SaveUIState("Active Line", std::to_string(active_line->Row));
context->ass->Events.begin(), context->ass->iterator_to(*active_line))));
} }
void SelectionController::SetSelectedSet(Selection new_selection) { void SelectionController::SetSelectedSet(Selection new_selection) {