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;
37 using support::formatted_time;
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(previousPB, SIGNAL(clicked()), this, SLOT(previousChange()));
47 connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange()));
48 connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange()));
50 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
51 bc().setCancel(closePB);
52 bc().addReadOnly(acceptPB);
53 bc().addReadOnly(rejectPB);
57 void GuiChanges::updateContents()
60 docstring author = changeAuthor();
61 docstring date = changeDate();
64 text += bformat(_("Change by %1$s\n\n"), author);
66 text += bformat(_("Change made at %1$s\n"), date);
68 changeTB->setPlainText(toqstr(text));
72 void GuiChanges::nextChange()
74 dispatch(FuncRequest(LFUN_CHANGE_NEXT));
78 void GuiChanges::previousChange()
80 dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS));
84 docstring GuiChanges::changeDate() const
86 Change const & c = bufferview()->getCurrentChange();
87 if (c.type == Change::UNCHANGED)
91 return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
95 docstring GuiChanges::changeAuthor() const
97 Change const & c = bufferview()->getCurrentChange();
98 if (c.type == Change::UNCHANGED)
101 Author const & a = buffer().params().authors().get(c.author);
103 docstring author = a.name();
105 if (!a.email().empty())
106 author += " (" + a.email() + ")";
112 void GuiChanges::acceptChange()
114 dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
119 void GuiChanges::rejectChange()
121 dispatch(FuncRequest(LFUN_CHANGE_REJECT));
126 Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
129 } // namespace frontend
132 #include "moc_GuiChanges.cpp"