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