2010-09-07 11:28:57 +00:00
|
|
|
/**
|
|
|
|
* \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>
|
2012-06-28 18:52:20 +00:00
|
|
|
#include <support/debug.h>
|
2013-02-10 03:28:01 +00:00
|
|
|
#include <limits>
|
2010-09-07 11:28:57 +00:00
|
|
|
|
|
|
|
#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()));
|
2010-09-07 11:29:05 +00:00
|
|
|
}
|
2010-09-07 11:28:57 +00:00
|
|
|
|
2010-09-07 11:29:05 +00:00
|
|
|
bool GuiCompareHistory::initialiseParams(std::string const &)
|
|
|
|
{
|
|
|
|
string revstring = lyxview().currentBufferView()->buffer().lyxvc().revisionInfo(LyXVC::File);
|
2010-09-07 11:28:57 +00:00
|
|
|
int rev=0;
|
2010-09-07 11:29:07 +00:00
|
|
|
|
|
|
|
string tmp;
|
2013-02-10 03:28:01 +00:00
|
|
|
bool enableBetween = true;
|
|
|
|
// GIT case, hash is long
|
|
|
|
if (revstring.length() > 20) {
|
|
|
|
enableBetween = false;
|
|
|
|
rev = numeric_limits<int>::max();
|
|
|
|
} else {
|
|
|
|
// RCS case
|
|
|
|
if (!isStrInt(revstring))
|
|
|
|
revstring = rsplit(revstring, tmp , '.' );
|
|
|
|
// both SVN & RCS cases
|
|
|
|
if (isStrInt(revstring))
|
|
|
|
rev = convert<int>(revstring);
|
|
|
|
}
|
|
|
|
|
|
|
|
// later we can provide comparison between two hashes
|
|
|
|
betweenrevRB->setEnabled(enableBetween);
|
2010-09-07 11:28:57 +00:00
|
|
|
|
|
|
|
okPB->setEnabled(rev);
|
|
|
|
rev1SB->setMaximum(rev);
|
|
|
|
rev2SB->setMaximum(rev);
|
2010-09-07 11:29:09 +00:00
|
|
|
revbackSB->setMaximum(rev-1);
|
2010-09-07 11:28:57 +00:00
|
|
|
rev2SB->setValue(rev);
|
|
|
|
rev1SB->setValue(rev-1);
|
|
|
|
|
|
|
|
//bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
|
|
|
|
//bc().setOK(okPB);
|
|
|
|
//bc().setCancel(cancelPB);
|
|
|
|
enableControls();
|
2010-09-07 11:29:05 +00:00
|
|
|
return true;
|
2010-09-07 11:28:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
2010-09-07 11:58:42 +00:00
|
|
|
oldL->setEnabled(!rb);
|
|
|
|
newL->setEnabled(!rb);
|
2010-09-07 11:28:57 +00:00
|
|
|
rev1SB->setEnabled(!rb);
|
|
|
|
rev2SB->setEnabled(!rb);
|
2010-09-07 11:58:42 +00:00
|
|
|
rev2SB->setEnabled(!rb);
|
2010-09-07 11:28:57 +00:00
|
|
|
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"
|