X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiChanges.cpp;h=c168d3591bf2f43f2e6446cbd10376705b4d3d1a;hb=c0a1893008bd13650d470afff16f56720b65c87c;hp=e615c14a0f13470dbc71c0550dc97bb9673112a8;hpb=470aba2a0e552f27d55992372c09f15af9725fa8;p=lyx.git diff --git a/src/frontends/qt4/GuiChanges.cpp b/src/frontends/qt4/GuiChanges.cpp index e615c14a0f..c168d3591b 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 +#include namespace lyx { namespace frontend { -GuiChangesDialog::GuiChangesDialog(LyXView & lv) - : GuiDialog(lv, "changes") + +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,64 @@ GuiChangesDialog::GuiChangesDialog(LyXView & lv) } -ControlChanges & GuiChangesDialog::controller() +void GuiChanges::updateContents() { - return static_cast(GuiDialog::controller()); + bool const changesPresent = buffer().areChangesPresent(); + nextPB->setEnabled(changesPresent); + previousPB->setEnabled(changesPresent); + changeTB->setEnabled(changesPresent); + + Change const & c = bufferview()->getCurrentChange(); + bool const changePresent = c.type != Change::UNCHANGED; + rejectPB->setEnabled(changePresent); + acceptPB->setEnabled(changePresent); + + QString text; + if (changePresent) { + QString const author = + toqstr(buffer().params().authors().get(c.author).nameAndEmail()); + if (!author.isEmpty()) + text += qt_("Changed by %1\n\n").arg(author); + + QString const date = QDateTime::fromTime_t(c.changetime) + .toString(Qt::DefaultLocaleLongDate); + if (!date.isEmpty()) + text += qt_("Change made on %1\n").arg(date); + } + changeTB->setPlainText(text); } -void GuiChangesDialog::closeEvent(QCloseEvent *e) +void GuiChanges::nextChange() { - slotClose(); - e->accept(); + dispatch(FuncRequest(LFUN_CHANGE_NEXT)); } -void GuiChangesDialog::updateContents() +void GuiChanges::previousChange() { - docstring text; - docstring author = controller().getChangeAuthor(); - docstring date = controller().getChangeDate(); - - 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)); + dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS)); } -void GuiChangesDialog::nextPressed() +void GuiChanges::acceptChange() { - controller().next(); + dispatch(FuncRequest(LFUN_CHANGE_ACCEPT)); + nextChange(); } -void GuiChangesDialog::acceptPressed() +void GuiChanges::rejectChange() { - controller().accept(); + dispatch(FuncRequest(LFUN_CHANGE_REJECT)); + nextChange(); } -void GuiChangesDialog::rejectPressed() -{ - controller().reject(); -} +Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); } + } // namespace frontend } // namespace lyx -#include "GuiChanges_moc.cpp" +#include "moc_GuiChanges.cpp"