]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCompareHistory.cpp
Fix the tab ordering of GuiDocument components.
[lyx.git] / src / frontends / qt4 / GuiCompareHistory.cpp
1 /**
2  * \file GuiCompareHistory.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Pavel Sanda
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12 #include <support/debug.h>
13
14 #include "GuiCompareHistory.h"
15
16 #include "Buffer.h"
17 #include "BufferView.h"
18 #include "FuncRequest.h"
19 #include "GuiView.h"
20 #include "LyXVC.h"
21
22 #include "support/convert.h"
23 #include "support/lstrings.h"
24
25
26
27 using namespace std;
28 using namespace lyx::support;
29
30 namespace lyx {
31 namespace frontend {
32
33
34 GuiCompareHistory::GuiCompareHistory(GuiView & lv)
35         : GuiDialog(lv, "comparehistory", qt_("Compare different revisions"))
36
37 {
38         setupUi(this);
39         setModal(Qt::WindowModal);
40
41         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
42         connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotCancel()));
43
44         connect(revbackRB, SIGNAL(clicked()), this, SLOT(selectRevback()));
45         connect(betweenrevRB, SIGNAL(clicked()), this, SLOT(selectBetweenrev()));
46 }
47
48 bool GuiCompareHistory::initialiseParams(std::string const &)
49 {
50         string revstring = lyxview().currentBufferView()->buffer().lyxvc().revisionInfo(LyXVC::File);
51         int rev=0;
52
53         string tmp;
54         // RCS case
55         if (!isStrInt(revstring))
56                 revstring = rsplit(revstring, tmp , '.' );
57         if (isStrInt(revstring))
58                 rev = convert<int>(revstring);
59
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);
66
67         //bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
68         //bc().setOK(okPB);
69         //bc().setCancel(cancelPB);
70         enableControls();
71         return true;
72 }
73
74
75 void GuiCompareHistory::updateContents()
76 {
77         enableControls();
78 }
79
80
81 void GuiCompareHistory::selectRevback()
82 {
83         betweenrevRB->setChecked(false);
84         enableControls();
85 }
86
87
88 void GuiCompareHistory::selectBetweenrev()
89 {
90         revbackRB->setChecked(false);
91         enableControls();
92 }
93
94
95 void GuiCompareHistory::enableControls()
96 {
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);
105 }
106
107
108 void GuiCompareHistory::slotOK()
109 {
110         string param;
111         if (revbackRB->isChecked())
112                 param = "-" + convert<string>(revbackSB->value());
113         else
114                 param = convert<string>(rev1SB->value()) +
115                         + " " + convert<string>(rev2SB->value());
116
117         GuiDialog::slotClose();
118         dispatch(FuncRequest(LFUN_VC_COMPARE, param));
119 }
120
121
122 void GuiCompareHistory::slotCancel()
123 {
124         GuiDialog::slotClose();
125 }
126
127
128 Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }
129
130
131 } // namespace frontend
132 } // namespace lyx
133
134
135 #include "moc_GuiCompareHistory.cpp"