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 <QTextBrowser>
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()
58 bool const changesPresent = buffer().areChangesPresent();
59 nextPB->setEnabled(changesPresent);
60 previousPB->setEnabled(changesPresent);
61 changeTB->setEnabled(changesPresent);
63 Change const & c = bufferview()->getCurrentChange();
64 bool const changePresent = c.type != Change::UNCHANGED;
65 rejectPB->setEnabled(changePresent);
66 acceptPB->setEnabled(changePresent);
70 QString const author =
71 toqstr(buffer().params().authors().get(c.author).nameAndEmail());
72 if (!author.isEmpty())
73 text += qt_("Changed by %1\n\n").arg(author);
75 QString const date = QDateTime::fromTime_t(c.changetime)
76 .toString(Qt::DefaultLocaleLongDate);
78 text += qt_("Change made on %1\n").arg(date);
80 changeTB->setPlainText(text);
84 void GuiChanges::nextChange()
86 dispatch(FuncRequest(LFUN_CHANGE_NEXT));
90 void GuiChanges::previousChange()
92 dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS));
96 void GuiChanges::acceptChange()
98 dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
103 void GuiChanges::rejectChange()
105 dispatch(FuncRequest(LFUN_CHANGE_REJECT));
110 Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
113 } // namespace frontend
116 #include "moc_GuiChanges.cpp"