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"
30 #include <QTextBrowser>
36 using support::bformat;
38 GuiChanges::GuiChanges(GuiView & lv)
39 : GuiDialog(lv, "changes", qt_("Merge Changes"))
43 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
44 connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
45 connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange()));
46 connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange()));
48 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
49 bc().setCancel(closePB);
50 bc().addReadOnly(acceptPB);
51 bc().addReadOnly(rejectPB);
55 void GuiChanges::updateContents()
58 docstring author = changeAuthor();
59 docstring date = changeDate();
62 text += bformat(_("Change by %1$s\n\n"), author);
64 text += bformat(_("Change made at %1$s\n"), date);
66 changeTB->setPlainText(toqstr(text));
70 void GuiChanges::nextChange()
72 dispatch(FuncRequest(LFUN_CHANGE_NEXT));
76 docstring GuiChanges::changeDate() const
78 Change const & c = bufferview()->getCurrentChange();
79 if (c.type == Change::UNCHANGED)
83 return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
87 docstring GuiChanges::changeAuthor() const
89 Change const & c = bufferview()->getCurrentChange();
90 if (c.type == Change::UNCHANGED)
93 Author const & a = buffer().params().authors().get(c.author);
95 docstring author = a.name();
97 if (!a.email().empty())
98 author += " (" + a.email() + ")";
104 void GuiChanges::acceptChange()
106 dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
111 void GuiChanges::rejectChange()
113 dispatch(FuncRequest(LFUN_CHANGE_REJECT));
118 Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
121 } // namespace frontend
124 #include "moc_GuiChanges.cpp"