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(LyXView & lv)
40 : GuiDialog(lv, "changes"), Controller(this)
43 setController(this, false);
44 setViewTitle(_("Merge Changes"));
46 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
47 connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
48 connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange()));
49 connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange()));
51 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
52 bc().setCancel(closePB);
53 bc().addReadOnly(acceptPB);
54 bc().addReadOnly(rejectPB);
58 void GuiChanges::closeEvent(QCloseEvent *e)
65 void GuiChanges::updateContents()
68 docstring author = changeAuthor();
69 docstring date = changeDate();
72 text += bformat(_("Change by %1$s\n\n"), author);
74 text += bformat(_("Change made at %1$s\n"), date);
76 changeTB->setPlainText(toqstr(text));
80 void GuiChanges::nextChange()
82 dispatch(FuncRequest(LFUN_CHANGE_NEXT));
86 docstring GuiChanges::changeDate() const
88 Change const & c = bufferview()->getCurrentChange();
89 if (c.type == Change::UNCHANGED)
93 return from_utf8(formatted_time(c.changetime, lyxrc.date_insert_format));
97 docstring GuiChanges::changeAuthor() const
99 Change const & c = bufferview()->getCurrentChange();
100 if (c.type == Change::UNCHANGED)
103 Author const & a = buffer().params().authors().get(c.author);
105 docstring author = a.name();
107 if (!a.email().empty())
108 author += " (" + a.email() + ")";
114 void GuiChanges::acceptChange()
116 dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
121 void GuiChanges::rejectChange()
123 dispatch(FuncRequest(LFUN_CHANGE_REJECT));
128 Dialog * createGuiChanges(LyXView & lv) { return new GuiChanges(lv); }
131 } // namespace frontend
134 #include "GuiChanges_moc.cpp"