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(buttonBox, SIGNAL(clicked(QAbstractButton *)),
44 this, SLOT(slotButtonBox(QAbstractButton *)));
45 connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
46 connect(previousPB, SIGNAL(clicked()), this, SLOT(previousChange()));
47 connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange()));
48 connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange()));
50 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
51 bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
52 bc().addReadOnly(acceptPB);
53 bc().addReadOnly(rejectPB);
57 void GuiChanges::updateContents()
59 bool const changesPresent = buffer().areChangesPresent();
60 nextPB->setEnabled(changesPresent);
61 previousPB->setEnabled(changesPresent);
62 changeTB->setEnabled(changesPresent);
64 Change const & c = bufferview()->getCurrentChange();
65 bool const changePresent = c.type != Change::UNCHANGED;
66 rejectPB->setEnabled(changePresent);
67 acceptPB->setEnabled(changePresent);
71 QString const author =
72 toqstr(buffer().params().authors().get(c.author).nameAndEmail());
73 if (!author.isEmpty())
74 text += qt_("Changed by %1\n\n").arg(author);
76 QString const date = QDateTime::fromTime_t(c.changetime)
77 .toString(Qt::DefaultLocaleLongDate);
79 text += qt_("Change made on %1\n").arg(date);
81 changeTB->setPlainText(text);
85 void GuiChanges::nextChange()
87 dispatch(FuncRequest(LFUN_CHANGE_NEXT));
91 void GuiChanges::previousChange()
93 dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS));
97 void GuiChanges::acceptChange()
99 dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
104 void GuiChanges::rejectChange()
106 dispatch(FuncRequest(LFUN_CHANGE_REJECT));
111 Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); }
114 } // namespace frontend
117 #include "moc_GuiChanges.cpp"