X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiChanges.cpp;h=c168d3591bf2f43f2e6446cbd10376705b4d3d1a;hb=c0a1893008bd13650d470afff16f56720b65c87c;hp=63b3533885e5846d261fd56bbec696b4f6bf74b7;hpb=6bb94129d8a5e087642458eb098c09c54c3c425e;p=lyx.git diff --git a/src/frontends/qt4/GuiChanges.cpp b/src/frontends/qt4/GuiChanges.cpp index 63b3533885..c168d3591b 100644 --- a/src/frontends/qt4/GuiChanges.cpp +++ b/src/frontends/qt4/GuiChanges.cpp @@ -25,17 +25,15 @@ #include "BufferView.h" #include "Changes.h" #include "FuncRequest.h" -#include "lyxfind.h" #include "LyXRC.h" -#include +#include #include namespace lyx { namespace frontend { -using support::bformat; GuiChanges::GuiChanges(GuiView & lv) : GuiDialog(lv, "changes", qt_("Merge Changes")) @@ -44,6 +42,7 @@ GuiChanges::GuiChanges(GuiView & lv) connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); 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())); @@ -54,25 +53,31 @@ GuiChanges::GuiChanges(GuiView & lv) } -void GuiChanges::closeEvent(QCloseEvent *e) -{ - slotClose(); - e->accept(); -} - - void GuiChanges::updateContents() { - 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); + bool const changesPresent = buffer().areChangesPresent(); + nextPB->setEnabled(changesPresent); + previousPB->setEnabled(changesPresent); + changeTB->setEnabled(changesPresent); - changeTB->setPlainText(toqstr(text)); + 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); } @@ -82,31 +87,9 @@ void GuiChanges::nextChange() } -docstring GuiChanges::changeDate() const +void GuiChanges::previousChange() { - 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)); -} - - -docstring GuiChanges::changeAuthor() const -{ - 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; + dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS)); } @@ -130,4 +113,4 @@ Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); } } // namespace frontend } // namespace lyx -#include "GuiChanges_moc.cpp" +#include "moc_GuiChanges.cpp"