#include <config.h>
#include <support/debug.h>
+#include <limits>
#include "GuiCompareHistory.h"
#include "support/convert.h"
#include "support/lstrings.h"
-
+#include <QDialogButtonBox>
+#include <QPushButton>
using namespace std;
using namespace lyx::support;
setupUi(this);
setModal(Qt::WindowModal);
- connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
- connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotCancel()));
+ connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
+ this, SLOT(slotButtonBox(QAbstractButton *)));
connect(revbackRB, SIGNAL(clicked()), this, SLOT(selectRevback()));
connect(betweenrevRB, SIGNAL(clicked()), this, SLOT(selectBetweenrev()));
bool GuiCompareHistory::initialiseParams(std::string const &)
{
string revstring = lyxview().currentBufferView()->buffer().lyxvc().revisionInfo(LyXVC::File);
- int rev=0;
+ int rev = 0;
string tmp;
- // RCS case
- if (!isStrInt(revstring))
- revstring = rsplit(revstring, tmp , '.' );
- if (isStrInt(revstring))
- rev = convert<int>(revstring);
-
- okPB->setEnabled(rev);
+ 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);
+
+ buttonBox->button(QDialogButtonBox::Ok)->setEnabled(rev);
rev1SB->setMaximum(rev);
rev2SB->setMaximum(rev);
revbackSB->setMaximum(rev-1);
}
+void GuiCompareHistory::slotButtonBox(QAbstractButton * button)
+{
+ switch (buttonBox->standardButton(button)) {
+ case QDialogButtonBox::Ok:
+ slotOK();
+ break;
+ case QDialogButtonBox::Cancel:
+ slotCancel();
+ break;
+ default:
+ break;
+ }
+}
+
+
Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }