lyx_mirror/src/frontends/qt4/GuiCompareHistory.cpp
Pavel Sanda e2c0424c17 Add decent UI for VC_COMPARE
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35306 a592a061-630c-0410-9148-cb99ea01b6c8
2010-09-07 11:28:57 +00:00

125 lines
2.4 KiB
C++

/**
* \file GuiCompareHistory.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Pavel Sanda
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "GuiCompareHistory.h"
#include "Buffer.h"
#include "BufferView.h"
#include "FuncRequest.h"
#include "GuiView.h"
#include "LyXVC.h"
#include "support/convert.h"
#include "support/lstrings.h"
using namespace std;
using namespace lyx::support;
namespace lyx {
namespace frontend {
GuiCompareHistory::GuiCompareHistory(GuiView & lv)
: GuiDialog(lv, "comparehistory", qt_("Compare different revisions"))
{
setupUi(this);
setModal(Qt::WindowModal);
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotCancel()));
connect(revbackRB, SIGNAL(clicked()), this, SLOT(selectRevback()));
connect(betweenrevRB, SIGNAL(clicked()), this, SLOT(selectBetweenrev()));
string revstring = lv.currentBufferView()->buffer().lyxvc().revisionInfo(LyXVC::File);
int rev=0;
if (prefixIs(revstring, "r"))
revstring = ltrim(revstring,"r");
if (isStrInt(revstring))
rev = convert<int>(revstring);
okPB->setEnabled(rev);
rev1SB->setMaximum(rev);
rev2SB->setMaximum(rev);
revbackSB->setMaximum(rev);
rev2SB->setValue(rev);
rev1SB->setValue(rev-1);
//bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
//bc().setOK(okPB);
//bc().setCancel(cancelPB);
enableControls();
}
void GuiCompareHistory::updateContents()
{
enableControls();
}
void GuiCompareHistory::selectRevback()
{
betweenrevRB->setChecked(false);
enableControls();
}
void GuiCompareHistory::selectBetweenrev()
{
revbackRB->setChecked(false);
enableControls();
}
void GuiCompareHistory::enableControls()
{
bool rb = revbackRB->isChecked();
rev1SB->setEnabled(!rb);
rev2SB->setEnabled(!rb);
betweenrevRB->setChecked(!rb);
revbackSB->setEnabled(rb);
}
void GuiCompareHistory::slotOK()
{
string param;
if (revbackRB->isChecked())
param = "-" + convert<string>(revbackSB->value());
else
param = convert<string>(rev1SB->value()) +
+ " " + convert<string>(rev2SB->value());
GuiDialog::slotClose();
dispatch(FuncRequest(LFUN_VC_COMPARE, param));
}
void GuiCompareHistory::slotCancel()
{
GuiDialog::slotClose();
}
Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }
} // namespace frontend
} // namespace lyx
#include "moc_GuiCompareHistory.cpp"