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/lstrings.h"
19 #include "support/lyxtime.h"
23 #include "BufferParams.h"
24 #include "BufferView.h"
26 #include "FuncRequest.h"
30 #include <QCloseEvent>
31 #include <QTextBrowser>
37 using support::bformat;
39 GuiChanges::GuiChanges(GuiView & lv)
40 : GuiDialog(lv, "changes")
43 setViewTitle(_("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::closeEvent(QCloseEvent *e)
64 void GuiChanges::updateContents()
67 docstring author = changeAuthor();
68 docstring date = changeDate();
71 text += bformat(_("Change by %1$s\n\n"), author);
73 text += bformat(_("Change made at %1$s\n"), date);
75 changeTB->setPlainText(toqstr(text));
79 void GuiChanges::nextChange()
81 dispatch(FuncRequest(LFUN_CHANGE_NEXT));
85 docstring GuiChanges::changeDate() const
87 Change const & c = bufferview()->getCurrentChange();
88 if (c.type == Change::UNCHANGED)
92 return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
96 docstring GuiChanges::changeAuthor() const
98 Change const & c = bufferview()->getCurrentChange();
99 if (c.type == Change::UNCHANGED)
102 Author const & a = buffer().params().authors().get(c.author);
104 docstring author = a.name();
106 if (!a.email().empty())
107 author += " (" + a.email() + ")";
113 void GuiChanges::acceptChange()
115 dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
120 void GuiChanges::rejectChange()
122 dispatch(FuncRequest(LFUN_CHANGE_REJECT));
127 Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
130 } // namespace frontend
133 #include "GuiChanges_moc.cpp"