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.
12 #include <support/debug.h>
14 #include "GuiCompareHistory.h"
17 #include "BufferView.h"
18 #include "FuncRequest.h"
22 #include "support/convert.h"
23 #include "support/lstrings.h"
28 using namespace lyx::support;
34 GuiCompareHistory::GuiCompareHistory(GuiView & lv)
35 : GuiDialog(lv, "comparehistory", qt_("Compare different revisions"))
39 setModal(Qt::WindowModal);
41 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
42 connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotCancel()));
44 connect(revbackRB, SIGNAL(clicked()), this, SLOT(selectRevback()));
45 connect(betweenrevRB, SIGNAL(clicked()), this, SLOT(selectBetweenrev()));
48 bool GuiCompareHistory::initialiseParams(std::string const &)
50 string revstring = lyxview().currentBufferView()->buffer().lyxvc().revisionInfo(LyXVC::File);
55 if (!isStrInt(revstring))
56 revstring = rsplit(revstring, tmp , '.' );
57 if (isStrInt(revstring))
58 rev = convert<int>(revstring);
60 okPB->setEnabled(rev);
61 rev1SB->setMaximum(rev);
62 rev2SB->setMaximum(rev);
63 revbackSB->setMaximum(rev-1);
64 rev2SB->setValue(rev);
65 rev1SB->setValue(rev-1);
67 //bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
69 //bc().setCancel(cancelPB);
75 void GuiCompareHistory::updateContents()
81 void GuiCompareHistory::selectRevback()
83 betweenrevRB->setChecked(false);
88 void GuiCompareHistory::selectBetweenrev()
90 revbackRB->setChecked(false);
95 void GuiCompareHistory::enableControls()
97 bool rb = revbackRB->isChecked();
98 oldL->setEnabled(!rb);
99 newL->setEnabled(!rb);
100 rev1SB->setEnabled(!rb);
101 rev2SB->setEnabled(!rb);
102 rev2SB->setEnabled(!rb);
103 betweenrevRB->setChecked(!rb);
104 revbackSB->setEnabled(rb);
108 void GuiCompareHistory::slotOK()
111 if (revbackRB->isChecked())
112 param = "-" + convert<string>(revbackSB->value());
114 param = convert<string>(rev1SB->value()) +
115 + " " + convert<string>(rev2SB->value());
117 GuiDialog::slotClose();
118 dispatch(FuncRequest(LFUN_VC_COMPARE, param));
122 void GuiCompareHistory::slotCancel()
124 GuiDialog::slotClose();
128 Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }
131 } // namespace frontend
135 #include "moc_GuiCompareHistory.cpp"