]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialog.cpp
getting rid of superfluous lyx::support:: statements.
[lyx.git] / src / frontends / qt4 / GuiDialog.cpp
1 /**
2  * \file Dialog.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiDialog.h"
14 #include "GuiView.h"
15 #include "qt_helpers.h"
16
17 #include "support/debug.h"
18
19 #include <QCloseEvent>
20 #include <QMainWindow>
21 #include <QSettings>
22 #include <QShowEvent>
23
24 using namespace std;
25
26 namespace lyx {
27 namespace frontend {
28
29 GuiDialog::GuiDialog(GuiView & lv, string const & name)
30         : DialogView(lv, name), is_closing_(false)
31 {}
32
33
34 void GuiDialog::setButtonsValid(bool valid)
35 {
36         bc().setValid(valid);
37 }
38
39
40 void GuiDialog::slotApply()
41 {
42         apply();
43         bc().apply();
44 }
45
46
47 void GuiDialog::slotOK()
48 {
49         is_closing_ = true;
50         apply();
51         is_closing_ = false;
52         QDialog::hide();
53         bc().ok();
54 }
55
56
57 void GuiDialog::slotClose()
58 {
59         QDialog::hide();
60         bc().cancel();
61 }
62
63
64 void GuiDialog::slotRestore()
65 {
66         // Tell the controller that a request to refresh the dialog's contents
67         // has been received. It's up to the controller to supply the necessary
68         // info by calling GuiDialog::updateView().
69         updateDialog();
70         bc().restore();
71 }
72
73
74 void GuiDialog::changed()
75 {
76         if (updating_)
77                 return;
78         bc().setValid(isValid());
79 }
80
81
82 void GuiDialog::enableView(bool enable)
83 {
84         bc().setReadOnly(!enable);
85         bc().setValid(enable);
86         DialogView::enableView(enable);
87 }
88
89
90 void GuiDialog::updateView()
91 {
92         setUpdatesEnabled(false);
93
94         bc().setReadOnly(isBufferReadonly());
95         // protect the BC from unwarranted state transitions
96         updating_ = true;
97         updateContents();
98         updating_ = false;
99         // The widgets may not be valid, so refresh the button controller
100         bc().refresh();
101
102         setUpdatesEnabled(true);
103 }
104
105 } // namespace frontend
106 } // namespace lyx
107
108
109 /////////////////////////////////////////////////////////////////////
110 //
111 // Command based dialogs
112 //
113 /////////////////////////////////////////////////////////////////////
114
115 #include "FuncRequest.h"
116 #include "insets/InsetCommand.h"
117
118 using namespace std;
119
120 namespace lyx {
121 namespace frontend {
122
123 GuiCommand::GuiCommand(GuiView & lv, string const & name)
124         : GuiDialog(lv, name), params_(insetCode(name)), lfun_name_(name)
125 {
126 }
127
128
129 bool GuiCommand::initialiseParams(string const & data)
130 {
131         // The name passed with LFUN_INSET_APPLY is also the name
132         // used to identify the mailer.
133         InsetCommandMailer::string2params(lfun_name_, data, params_);
134         return true;
135 }
136
137
138 void GuiCommand::dispatchParams()
139 {
140         if (lfun_name_.empty())
141                 return;
142
143         string const lfun = 
144                 InsetCommandMailer::params2string(lfun_name_, params_);
145         dispatch(FuncRequest(getLfun(), lfun));
146 }
147
148 } // namespace frontend
149 } // namespace lyx
150
151 #include "GuiDialog_moc.cpp"