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);
51 if (prefixIs(revstring, "r"))
52 revstring = ltrim(revstring,"r");
53 if (isStrInt(revstring))
54 rev = convert<int>(revstring);
56 okPB->setEnabled(rev);
57 rev1SB->setMaximum(rev);
58 rev2SB->setMaximum(rev);
59 revbackSB->setMaximum(rev);
60 rev2SB->setValue(rev);
61 rev1SB->setValue(rev-1);
63 //bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
65 //bc().setCancel(cancelPB);
71 void GuiCompareHistory::updateContents()
77 void GuiCompareHistory::selectRevback()
79 betweenrevRB->setChecked(false);
84 void GuiCompareHistory::selectBetweenrev()
86 revbackRB->setChecked(false);
91 void GuiCompareHistory::enableControls()
93 bool rb = revbackRB->isChecked();
94 rev1SB->setEnabled(!rb);
95 rev2SB->setEnabled(!rb);
96 betweenrevRB->setChecked(!rb);
97 revbackSB->setEnabled(rb);
101 void GuiCompareHistory::slotOK()
104 if (revbackRB->isChecked())
105 param = "-" + convert<string>(revbackSB->value());
107 param = convert<string>(rev1SB->value()) +
108 + " " + convert<string>(rev2SB->value());
110 GuiDialog::slotClose();
111 dispatch(FuncRequest(LFUN_VC_COMPARE, param));
115 void GuiCompareHistory::slotCancel()
117 GuiDialog::slotClose();
121 Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }
124 } // namespace frontend
128 #include "moc_GuiCompareHistory.cpp"