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(previousPB, SIGNAL(clicked()), this, SLOT(previousChange()));
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 void GuiChanges::previousChange()
79 dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS));
83 docstring GuiChanges::changeDate() const
85 Change const & c = bufferview()->getCurrentChange();
86 if (c.type == Change::UNCHANGED)
90 return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
94 docstring GuiChanges::changeAuthor() const
96 Change const & c = bufferview()->getCurrentChange();
97 if (c.type == Change::UNCHANGED)
100 Author const & a = buffer().params().authors().get(c.author);
102 docstring author = a.name();
104 if (!a.email().empty())
105 author += " (" + a.email() + ")";
111 void GuiChanges::acceptChange()
113 dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
118 void GuiChanges::rejectChange()
120 dispatch(FuncRequest(LFUN_CHANGE_REJECT));
125 Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
128 } // namespace frontend
131 #include "moc_GuiChanges.cpp"