3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #include "GuiChanges.h"
16 #include "qt_helpers.h"
18 #include "support/gettext.h"
19 #include "support/lstrings.h"
20 #include "support/lyxtime.h"
24 #include "BufferParams.h"
25 #include "BufferView.h"
27 #include "FuncRequest.h"
31 #include <QTextBrowser>
37 using support::bformat;
39 GuiChanges::GuiChanges(GuiView & lv)
40 : GuiDialog(lv, "changes", qt_("Merge Changes"))
44 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
45 connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
46 connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange()));
47 connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange()));
49 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
50 bc().setCancel(closePB);
51 bc().addReadOnly(acceptPB);
52 bc().addReadOnly(rejectPB);
56 void GuiChanges::updateContents()
59 docstring author = changeAuthor();
60 docstring date = changeDate();
63 text += bformat(_("Change by %1$s\n\n"), author);
65 text += bformat(_("Change made at %1$s\n"), date);
67 changeTB->setPlainText(toqstr(text));
71 void GuiChanges::nextChange()
73 dispatch(FuncRequest(LFUN_CHANGE_NEXT));
77 docstring GuiChanges::changeDate() const
79 Change const & c = bufferview()->getCurrentChange();
80 if (c.type == Change::UNCHANGED)
84 return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
88 docstring GuiChanges::changeAuthor() const
90 Change const & c = bufferview()->getCurrentChange();
91 if (c.type == Change::UNCHANGED)
94 Author const & a = buffer().params().authors().get(c.author);
96 docstring author = a.name();
98 if (!a.email().empty())
99 author += " (" + a.email() + ")";
105 void GuiChanges::acceptChange()
107 dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
112 void GuiChanges::rejectChange()
114 dispatch(FuncRequest(LFUN_CHANGE_REJECT));
119 Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
122 } // namespace frontend
125 #include "GuiChanges_moc.cpp"