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 <QCloseEvent>
32 #include <QTextBrowser>
38 using support::bformat;
40 GuiChanges::GuiChanges(GuiView & lv)
41 : GuiDialog(lv, "changes", qt_("Merge Changes"))
45 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
46 connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
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 docstring GuiChanges::changeDate() const
80 Change const & c = bufferview()->getCurrentChange();
81 if (c.type == Change::UNCHANGED)
85 return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
89 docstring GuiChanges::changeAuthor() const
91 Change const & c = bufferview()->getCurrentChange();
92 if (c.type == Change::UNCHANGED)
95 Author const & a = buffer().params().authors().get(c.author);
97 docstring author = a.name();
99 if (!a.email().empty())
100 author += " (" + a.email() + ")";
106 void GuiChanges::acceptChange()
108 dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
113 void GuiChanges::rejectChange()
115 dispatch(FuncRequest(LFUN_CHANGE_REJECT));
120 Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
123 } // namespace frontend
126 #include "GuiChanges_moc.cpp"