X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiChanges.cpp;h=63268ae24e808d3dc3f89428c7649ffd3c5455b7;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=99e4b4b6514cc36ece837ef99fbf9a2168ae0403;hpb=94e61a3bc9c136554afd8f23fd4d49c2f4e394ba;p=lyx.git diff --git a/src/frontends/qt4/GuiChanges.cpp b/src/frontends/qt4/GuiChanges.cpp index 99e4b4b651..63268ae24e 100644 --- a/src/frontends/qt4/GuiChanges.cpp +++ b/src/frontends/qt4/GuiChanges.cpp @@ -12,32 +12,39 @@ #include #include "GuiChanges.h" -#include "ControlChanges.h" #include "qt_helpers.h" +#include "support/gettext.h" #include "support/lstrings.h" +#include "support/lyxtime.h" -#include -#include +#include "Author.h" +#include "Buffer.h" +#include "BufferParams.h" +#include "BufferView.h" +#include "Changes.h" +#include "FuncRequest.h" +#include "LyXRC.h" -using lyx::support::bformat; +#include namespace lyx { namespace frontend { -GuiChangesDialog::GuiChangesDialog(LyXView & lv) - : GuiDialog(lv, "changes") +using support::bformat; + +GuiChanges::GuiChanges(GuiView & lv) + : GuiDialog(lv, "changes", qt_("Merge Changes")) { setupUi(this); - setController(new ControlChanges(*this)); - setViewTitle(_("Merge Changes")); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); - connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed())); - connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectPressed())); - connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptPressed())); + connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange())); + connect(previousPB, SIGNAL(clicked()), this, SLOT(previousChange())); + connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange())); + connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange())); bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); bc().setCancel(closePB); @@ -46,52 +53,79 @@ GuiChangesDialog::GuiChangesDialog(LyXView & lv) } -ControlChanges & GuiChangesDialog::controller() const +void GuiChanges::updateContents() { - return static_cast(GuiDialog::controller()); + docstring text; + docstring author = changeAuthor(); + docstring date = changeDate(); + + if (!author.empty()) + text += bformat(_("Change by %1$s\n\n"), author); + if (!date.empty()) + text += bformat(_("Change made at %1$s\n"), date); + + changeTB->setPlainText(toqstr(text)); } -void GuiChangesDialog::closeEvent(QCloseEvent *e) +void GuiChanges::nextChange() { - slotWMHide(); - e->accept(); + dispatch(FuncRequest(LFUN_CHANGE_NEXT)); } -void GuiChangesDialog::update_contents() +void GuiChanges::previousChange() { - docstring text; - docstring author = controller().getChangeAuthor(); - docstring date = controller().getChangeDate(); + dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS)); +} - if (!author.empty()) - text += bformat(_("Change by %1$s\n\n"), author); - if (!date.empty()) - text += bformat(_("Change made at %1$s\n"), date); - changeTB->setPlainText(toqstr(text)); +docstring GuiChanges::changeDate() const +{ + Change const & c = bufferview()->getCurrentChange(); + if (c.type == Change::UNCHANGED) + return docstring(); + + // FIXME UNICODE + return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format)); } -void GuiChangesDialog::nextPressed() +docstring GuiChanges::changeAuthor() const { - controller().next(); + Change const & c = bufferview()->getCurrentChange(); + if (c.type == Change::UNCHANGED) + return docstring(); + + Author const & a = buffer().params().authors().get(c.author); + + docstring author = a.name(); + + if (!a.email().empty()) + author += " (" + a.email() + ")"; + + return author; } -void GuiChangesDialog::acceptPressed() +void GuiChanges::acceptChange() { - controller().accept(); + dispatch(FuncRequest(LFUN_CHANGE_ACCEPT)); + nextChange(); } -void GuiChangesDialog::rejectPressed() +void GuiChanges::rejectChange() { - controller().reject(); + dispatch(FuncRequest(LFUN_CHANGE_REJECT)); + nextChange(); } + +Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); } + + } // namespace frontend } // namespace lyx -#include "GuiChanges_moc.cpp" +#include "moc_GuiChanges.cpp"