]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialog.cpp
removed unused includes
[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
15 #include "GuiView.h"
16 #include "qt_helpers.h"
17
18 #include <QCloseEvent>
19
20 using namespace std;
21
22 namespace lyx {
23 namespace frontend {
24
25 GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
26         : QDialog(&lv), Dialog(lv, name, "LyX: " + title), updating_(false), 
27           is_closing_(false)
28 {}
29
30
31 void GuiDialog::closeEvent(QCloseEvent * ev)
32 {
33         slotClose();
34         ev->accept();
35 }
36
37
38 void GuiDialog::setButtonsValid(bool valid)
39 {
40         bc().setValid(valid);
41 }
42
43
44 void GuiDialog::slotApply()
45 {
46         apply();
47         bc().apply();
48 }
49
50
51 void GuiDialog::slotAutoApply()
52 {
53         apply();
54         bc().autoApply();
55 }
56
57
58 void GuiDialog::slotOK()
59 {
60         is_closing_ = true;
61         apply();
62         is_closing_ = false;
63         hideView();
64         bc().ok();
65 }
66
67
68 void GuiDialog::slotClose()
69 {
70         hideView();
71         bc().cancel();
72 }
73
74
75 void GuiDialog::slotRestore()
76 {
77         // Tell the controller that a request to refresh the dialog's contents
78         // has been received. It's up to the controller to supply the necessary
79         // info by calling GuiDialog::updateView().
80         updateDialog();
81         bc().restore();
82 }
83
84
85 void GuiDialog::changed()
86 {
87         if (updating_)
88                 return;
89         bc().setValid(isValid());
90 }
91
92
93 void GuiDialog::enableView(bool enable)
94 {
95         if (!enable) {
96                 bc().setReadOnly(true);
97                 bc().setValid(false);
98         }
99         Dialog::enableView(enable);
100 }
101
102
103 void GuiDialog::updateView()
104 {
105         setUpdatesEnabled(false);
106
107         bc().setReadOnly(isBufferReadonly());
108         // protect the BC from unwarranted state transitions
109         updating_ = true;
110         updateContents();
111         updating_ = false;
112         // The widgets may not be valid, so refresh the button controller
113         bc().refresh();
114
115         setUpdatesEnabled(true);
116 }
117
118 } // namespace frontend
119 } // namespace lyx
120
121 #include "moc_GuiDialog.cpp"