]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialog.cpp
renaming of some methods that hurt the eyes + removal of:
[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 "debug.h"
15
16
17 namespace lyx {
18 namespace frontend {
19
20 GuiDialog::GuiDialog(LyXView & lv, std::string const & name)
21         : Dialog(lv, name)
22 {}
23
24
25 void GuiDialog::setButtonsValid(bool valid)
26 {
27         bc().setValid(valid);
28 }
29
30
31 void GuiDialog::ApplyButton()
32 {
33         apply();
34         bc().apply();
35 }
36
37
38 void GuiDialog::OKButton()
39 {
40         is_closing_ = true;
41         apply();
42         is_closing_ = false;
43         hide();
44         bc().ok();
45 }
46
47
48 void GuiDialog::CancelButton()
49 {
50         hide();
51         bc().cancel();
52 }
53
54
55 void GuiDialog::RestoreButton()
56 {
57         // Tell the kernel that a request to refresh the dialog's contents
58         // has been received. It's up to the kernel to supply the necessary
59         // info by calling GuiDialog::updateView().
60         kernel().updateDialog(name_);
61         bc().restore();
62 }
63
64
65 void GuiDialog::preShow()
66 {
67         bc().setReadOnly(kernel().isBufferReadonly());
68 }
69
70
71 void GuiDialog::postShow()
72 {
73         // The widgets may not be valid, so refresh the button controller
74         bc().refresh();
75 }
76
77
78 void GuiDialog::preUpdate()
79 {
80         bc().setReadOnly(kernel().isBufferReadonly());
81 }
82
83
84 void GuiDialog::postUpdate()
85 {
86         // The widgets may not be valid, so refresh the button controller
87         bc().refresh();
88 }
89
90
91 void GuiDialog::checkStatus()
92 {
93         // buffer independant dialogs are always active.
94         // This check allows us leave canApply unimplemented for some dialogs.
95         if (!controller().isBufferDependent())
96                 return;
97
98         // deactivate the dialog if we have no buffer
99         if (!kernel().isBufferAvailable()) {
100                 bc().setReadOnly(true);
101                 return;
102         }
103
104         // check whether this dialog may be active
105         if (controller().canApply()) {
106                 bool const readonly = kernel().isBufferReadonly();
107                 bc().setReadOnly(readonly);
108                 // refreshReadOnly() is too generous in _enabling_ widgets
109                 // update dialog to disable disabled widgets again
110 /*
111  *      FIXME:
112                 if (!readonly || controller().canApplyToReadOnly())
113                         update();
114 */
115         } else {
116                 bc().setReadOnly(true);
117         }       
118 }
119
120 } // namespace frontend
121 } // namespace lyx