From 21cc9c2795f559fa3f6d59dba3a7b1f5f4d84a79 Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Fri, 10 Mar 2006 16:53:24 +0000 Subject: [PATCH] fix bug 2212: First change is skipped in Merge changes... dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@13332 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 10 ++---- src/ChangeLog | 5 +++ src/frontends/controllers/ChangeLog | 5 +++ src/frontends/controllers/ControlChanges.C | 7 ++++ src/frontends/controllers/ControlChanges.h | 3 ++ src/frontends/gtk/ChangeLog | 5 +++ src/frontends/gtk/GChanges.C | 5 ++- src/frontends/qt2/ChangeLog | 5 +++ src/frontends/qt2/QChanges.C | 15 ++++---- src/frontends/xforms/ChangeLog | 5 +++ src/frontends/xforms/FormChanges.C | 41 ++++++++++------------ 11 files changed, 68 insertions(+), 38 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 87bc17b337..af88feffe9 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -907,12 +907,7 @@ void BufferView::Pimpl::trackChanges() buffer_->undostack().clear(); } else { cursor_.setCursor(doc_iterator_begin(buffer_->inset())); - bool const found = lyx::find::findNextChange(bv_); - if (found) { - // We reset the cursor to the start of the - // document, since the Changes Dialog is going - // to search for the next change anyway. - cursor_.setCursor(doc_iterator_begin(buffer_->inset())); + if (lyx::find::findNextChange(bv_)) { owner_->getDialogs().show("changes"); return; } @@ -1213,7 +1208,8 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd) } case LFUN_MERGE_CHANGES: - owner_->getDialogs().show("changes"); + if (lyx::find::findNextChange(bv_)) + owner_->getDialogs().show("changes"); break; case LFUN_ACCEPT_ALL_CHANGES: { diff --git a/src/ChangeLog b/src/ChangeLog index 626a72ae73..a143c46f20 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -4142,6 +4142,11 @@ 2004-02-06 André Pönitz + * BufferView_pimpl.C: fix bug 2212: First change is skipped is + "Merge changes..." dialog + +2006-03-10 Martin Vermeer + * BufferView.[Ch]: * BufferView_pimpl.[Ch]: * text3.C: move some text specific LFUN handling diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 796fb85b10..19a6edb4da 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2006-03-10 Martin Vermeer + + * ControlChanges.C: fix bug 2212: First change is skipped in + "Merge changes..." dialog + 2005-12-12 Jürgen Spitzmüller * ControlPrefs.[Ch]: new helper functions toPaperSize and diff --git a/src/frontends/controllers/ControlChanges.C b/src/frontends/controllers/ControlChanges.C index ea6b8909cf..c03ec98457 100644 --- a/src/frontends/controllers/ControlChanges.C +++ b/src/frontends/controllers/ControlChanges.C @@ -39,6 +39,13 @@ bool ControlChanges::find() } +bool ControlChanges::changed() +{ + Change c(kernel().bufferview()->getCurrentChange()); + return c.type != Change::UNCHANGED; +} + + string const ControlChanges::getChangeDate() { Change c(kernel().bufferview()->getCurrentChange()); diff --git a/src/frontends/controllers/ControlChanges.h b/src/frontends/controllers/ControlChanges.h index f146befa45..d0425fb576 100644 --- a/src/frontends/controllers/ControlChanges.h +++ b/src/frontends/controllers/ControlChanges.h @@ -38,6 +38,9 @@ public: /// find the next merge chunk and highlight it bool find(); + /// Are there changes to be merged at current location? + bool changed(); + /// return date of change std::string const getChangeDate(); diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 30b7eadc67..3cf01d0a62 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,8 @@ +2006-03-10 Martin Vermeer + + * GChanges.C: fix bug 2212: First change is skipped in + "Merge changes..." dialog + 2006-02-20 John Spray * glade/documents.glade: change "page style" to "page numbering" in UI. diff --git a/src/frontends/gtk/GChanges.C b/src/frontends/gtk/GChanges.C index a518b75980..771ac148e0 100644 --- a/src/frontends/gtk/GChanges.C +++ b/src/frontends/gtk/GChanges.C @@ -63,7 +63,10 @@ void GChanges::doBuild() void GChanges::update() { - onNext(); + if (controller().changed()) + promptChange(); + else + promptDismiss(); } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 8894d0e635..e840732efb 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2006-03-10 Martin Vermeer + + * QChanges.C: fix bug 2212: First change is skipped in + "Merge changes..." dialog + 2006-03-10 Georg Baum * QWorkArea.C (getClipboard): convert MAC to UNIX line endings on OSX diff --git a/src/frontends/qt2/QChanges.C b/src/frontends/qt2/QChanges.C index 654566e5a3..16a2c1c230 100644 --- a/src/frontends/qt2/QChanges.C +++ b/src/frontends/qt2/QChanges.C @@ -50,14 +50,6 @@ void QChanges::build_dialog() void QChanges::update_contents() { - next(); -} - - -void QChanges::next() -{ - controller().find(); - string text; string author(controller().getChangeAuthor()); string date(controller().getChangeDate()); @@ -71,6 +63,13 @@ void QChanges::next() } +void QChanges::next() +{ + controller().find(); + update_contents(); +} + + void QChanges::accept() { controller().accept(); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 762f8f11a3..1277726d49 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2006-03-10 Martin Vermeer + + * FormChanges.C: fix bug 2212: First change is skipped in + "Merge changes..." dialog + 2006-02-15 Jürgen Spitzmüller * FormCitation.C (input): get rid of the iterator. diff --git a/src/frontends/xforms/FormChanges.C b/src/frontends/xforms/FormChanges.C index 284ed5e717..ef275e91d7 100644 --- a/src/frontends/xforms/FormChanges.C +++ b/src/frontends/xforms/FormChanges.C @@ -48,35 +48,32 @@ void FormChanges::build() void FormChanges::update() { - input(dialog_->button_next, 0); + if (!dialog_.get()) return; + bool exist = controller().changed(); + setEnabled(dialog_->button_accept, exist); + setEnabled(dialog_->button_reject, exist); + setEnabled(dialog_->button_next, exist); + + string const author = exist ? controller().getChangeAuthor() : ""; + fl_set_object_label(dialog_->text_author, author.c_str()); + + string const date = exist ? controller().getChangeDate() : ""; + fl_set_object_label(dialog_->text_date, date.c_str()); + + // Yes, this is needed. + fl_redraw_form(form()); } ButtonPolicy::SMInput FormChanges::input(FL_OBJECT * obj, long) { - if (obj == dialog_->button_accept) { + if (obj == dialog_->button_accept) controller().accept(); - - } else if (obj == dialog_->button_reject) { + else if (obj == dialog_->button_reject) controller().reject(); - - } else if (obj == dialog_->button_next) { - - bool const exist = controller().find(); - setEnabled(dialog_->button_accept, exist); - setEnabled(dialog_->button_reject, exist); - setEnabled(dialog_->button_next, exist); - - string const author = exist ? controller().getChangeAuthor() : ""; - fl_set_object_label(dialog_->text_author, author.c_str()); - - string const date = exist ? controller().getChangeDate() : ""; - fl_set_object_label(dialog_->text_date, date.c_str()); - - // Yes, this is needed. - fl_redraw_form(form()); - } - + else if (obj == dialog_->button_next) + controller().find(); + update(); return ButtonPolicy::SMI_VALID; }