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()));
46 string revstring = lv.currentBufferView()->buffer().lyxvc().revisionInfo(LyXVC::File);
48 if (prefixIs(revstring, "r"))
49 revstring = ltrim(revstring,"r");
50 if (isStrInt(revstring))
51 rev = convert<int>(revstring);
53 okPB->setEnabled(rev);
54 rev1SB->setMaximum(rev);
55 rev2SB->setMaximum(rev);
56 revbackSB->setMaximum(rev);
57 rev2SB->setValue(rev);
58 rev1SB->setValue(rev-1);
60 //bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
62 //bc().setCancel(cancelPB);
67 void GuiCompareHistory::updateContents()
73 void GuiCompareHistory::selectRevback()
75 betweenrevRB->setChecked(false);
80 void GuiCompareHistory::selectBetweenrev()
82 revbackRB->setChecked(false);
87 void GuiCompareHistory::enableControls()
89 bool rb = revbackRB->isChecked();
90 rev1SB->setEnabled(!rb);
91 rev2SB->setEnabled(!rb);
92 betweenrevRB->setChecked(!rb);
93 revbackSB->setEnabled(rb);
97 void GuiCompareHistory::slotOK()
100 if (revbackRB->isChecked())
101 param = "-" + convert<string>(revbackSB->value());
103 param = convert<string>(rev1SB->value()) +
104 + " " + convert<string>(rev2SB->value());
106 GuiDialog::slotClose();
107 dispatch(FuncRequest(LFUN_VC_COMPARE, param));
111 void GuiCompareHistory::slotCancel()
113 GuiDialog::slotClose();
117 Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }
120 } // namespace frontend
124 #include "moc_GuiCompareHistory.cpp"