]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCompareHistory.cpp
removed unused includes
[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
13 #include "GuiCompareHistory.h"
14
15 #include "Buffer.h"
16 #include "BufferView.h"
17 #include "FuncRequest.h"
18 #include "GuiView.h"
19 #include "LyXVC.h"
20
21 #include "support/convert.h"
22 #include "support/lstrings.h"
23
24
25
26 using namespace std;
27 using namespace lyx::support;
28
29 namespace lyx {
30 namespace frontend {
31
32
33 GuiCompareHistory::GuiCompareHistory(GuiView & lv)
34         : GuiDialog(lv, "comparehistory", qt_("Compare different revisions"))
35
36 {
37         setupUi(this);
38         setModal(Qt::WindowModal);
39
40         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
41         connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotCancel()));
42
43         connect(revbackRB, SIGNAL(clicked()), this, SLOT(selectRevback()));
44         connect(betweenrevRB, SIGNAL(clicked()), this, SLOT(selectBetweenrev()));
45 }
46
47 bool GuiCompareHistory::initialiseParams(std::string const &)
48 {
49         string revstring = lyxview().currentBufferView()->buffer().lyxvc().revisionInfo(LyXVC::File);
50         int rev=0;
51
52         string tmp;
53         // RCS case
54         if (!isStrInt(revstring))
55                 revstring = rsplit(revstring, tmp , '.' );
56         if (isStrInt(revstring))
57                 rev = convert<int>(revstring);
58
59         okPB->setEnabled(rev);
60         rev1SB->setMaximum(rev);
61         rev2SB->setMaximum(rev);
62         revbackSB->setMaximum(rev-1);
63         rev2SB->setValue(rev);
64         rev1SB->setValue(rev-1);
65
66         //bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
67         //bc().setOK(okPB);
68         //bc().setCancel(cancelPB);
69         enableControls();
70         return true;
71 }
72
73
74 void GuiCompareHistory::updateContents()
75 {
76         enableControls();
77 }
78
79
80 void GuiCompareHistory::selectRevback()
81 {
82         betweenrevRB->setChecked(false);
83         enableControls();
84 }
85
86
87 void GuiCompareHistory::selectBetweenrev()
88 {
89         revbackRB->setChecked(false);
90         enableControls();
91 }
92
93
94 void GuiCompareHistory::enableControls()
95 {
96         bool rb = revbackRB->isChecked();
97         oldL->setEnabled(!rb);
98         newL->setEnabled(!rb);
99         rev1SB->setEnabled(!rb);
100         rev2SB->setEnabled(!rb);
101         rev2SB->setEnabled(!rb);
102         betweenrevRB->setChecked(!rb);
103         revbackSB->setEnabled(rb);
104 }
105
106
107 void GuiCompareHistory::slotOK()
108 {
109         string param;
110         if (revbackRB->isChecked())
111                 param = "-" + convert<string>(revbackSB->value());
112         else
113                 param = convert<string>(rev1SB->value()) +
114                         + " " + convert<string>(rev2SB->value());
115
116         GuiDialog::slotClose();
117         dispatch(FuncRequest(LFUN_VC_COMPARE, param));
118 }
119
120
121 void GuiCompareHistory::slotCancel()
122 {
123         GuiDialog::slotClose();
124 }
125
126
127 Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }
128
129
130 } // namespace frontend
131 } // namespace lyx
132
133
134 #include "moc_GuiCompareHistory.cpp"