2 * \file GuiCompareHistory.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "GuiCompareHistory.h"
16 #include "BufferView.h"
17 #include "FuncRequest.h"
21 #include "support/convert.h"
22 #include "support/lstrings.h"
27 using namespace lyx::support;
33 GuiCompareHistory::GuiCompareHistory(GuiView & lv)
34 : GuiDialog(lv, "comparehistory", qt_("Compare different revisions"))
38 setModal(Qt::WindowModal);
40 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
41 connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotCancel()));
43 connect(revbackRB, SIGNAL(clicked()), this, SLOT(selectRevback()));
44 connect(betweenrevRB, SIGNAL(clicked()), this, SLOT(selectBetweenrev()));
47 bool GuiCompareHistory::initialiseParams(std::string const &)
49 string revstring = lyxview().currentBufferView()->buffer().lyxvc().revisionInfo(LyXVC::File);
54 if (!isStrInt(revstring))
55 revstring = rsplit(revstring, tmp , '.' );
56 if (isStrInt(revstring))
57 rev = convert<int>(revstring);
59 okPB->setEnabled(rev);
60 rev1SB->setMaximum(rev);
61 rev2SB->setMaximum(rev);
62 revbackSB->setMaximum(rev-1);
63 rev2SB->setValue(rev);
64 rev1SB->setValue(rev-1);
66 //bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
68 //bc().setCancel(cancelPB);
74 void GuiCompareHistory::updateContents()
80 void GuiCompareHistory::selectRevback()
82 betweenrevRB->setChecked(false);
87 void GuiCompareHistory::selectBetweenrev()
89 revbackRB->setChecked(false);
94 void GuiCompareHistory::enableControls()
96 bool rb = revbackRB->isChecked();
97 oldL->setEnabled(!rb);
98 newL->setEnabled(!rb);
99 rev1SB->setEnabled(!rb);
100 rev2SB->setEnabled(!rb);
101 rev2SB->setEnabled(!rb);
102 betweenrevRB->setChecked(!rb);
103 revbackSB->setEnabled(rb);
107 void GuiCompareHistory::slotOK()
110 if (revbackRB->isChecked())
111 param = "-" + convert<string>(revbackSB->value());
113 param = convert<string>(rev1SB->value()) +
114 + " " + convert<string>(rev2SB->value());
116 GuiDialog::slotClose();
117 dispatch(FuncRequest(LFUN_VC_COMPARE, param));
121 void GuiCompareHistory::slotCancel()
123 GuiDialog::slotClose();
127 Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }
130 } // namespace frontend
134 #include "moc_GuiCompareHistory.cpp"