]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCompareHistory.cpp
These things need to be updated for each dialog opening
[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         if (prefixIs(revstring, "r"))
52                 revstring = ltrim(revstring,"r");
53         if (isStrInt(revstring))
54                 rev = convert<int>(revstring);
55
56         okPB->setEnabled(rev);
57         rev1SB->setMaximum(rev);
58         rev2SB->setMaximum(rev);
59         revbackSB->setMaximum(rev);
60         rev2SB->setValue(rev);
61         rev1SB->setValue(rev-1);
62
63         //bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
64         //bc().setOK(okPB);
65         //bc().setCancel(cancelPB);
66         enableControls();
67         return true;
68 }
69
70
71 void GuiCompareHistory::updateContents()
72 {
73         enableControls();
74 }
75
76
77 void GuiCompareHistory::selectRevback()
78 {
79         betweenrevRB->setChecked(false);
80         enableControls();
81 }
82
83
84 void GuiCompareHistory::selectBetweenrev()
85 {
86         revbackRB->setChecked(false);
87         enableControls();
88 }
89
90
91 void GuiCompareHistory::enableControls()
92 {
93         bool rb = revbackRB->isChecked();
94         rev1SB->setEnabled(!rb);
95         rev2SB->setEnabled(!rb);
96         betweenrevRB->setChecked(!rb);
97         revbackSB->setEnabled(rb);
98 }
99
100
101 void GuiCompareHistory::slotOK()
102 {
103         string param;
104         if (revbackRB->isChecked())
105                 param = "-" + convert<string>(revbackSB->value());
106         else
107                 param = convert<string>(rev1SB->value()) +
108                         + " " + convert<string>(rev2SB->value());
109
110         GuiDialog::slotClose();
111         dispatch(FuncRequest(LFUN_VC_COMPARE, param));
112 }
113
114
115 void GuiCompareHistory::slotCancel()
116 {
117         GuiDialog::slotClose();
118 }
119
120
121 Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); }
122
123
124 } // namespace frontend
125 } // namespace lyx
126
127
128 #include "moc_GuiCompareHistory.cpp"