]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/InsetDialog.cpp
Transfer LyXfunc code to GuiApplication::dispatch() and getStatus(). Now
[lyx.git] / src / frontends / qt4 / InsetDialog.cpp
1 /**\r
2  * \file InsetDialog.cpp\r
3  * This file is part of LyX, the document processor.\r
4  * Licence details can be found in the file COPYING.\r
5  *\r
6  * \author Abdelrazak Younes\r
7  *\r
8  * Full author contact details are available in file CREDITS.\r
9  */\r
10 \r
11 #include <config.h>\r
12 \r
13 #include "InsetDialog.h"\r
14 \r
15 #include "qt_helpers.h"\r
16 \r
17 #include "Buffer.h"\r
18 #include "buffer_funcs.h"\r
19 #include "BufferParams.h"\r
20 #include "BufferView.h"\r
21 #include "Cursor.h"\r
22 #include "FuncRequest.h"\r
23 \r
24 #include "support/debug.h"\r
25 #include "support/lstrings.h"\r
26 \r
27 using namespace std;\r
28 using namespace lyx::support;\r
29 \r
30 namespace lyx {\r
31 namespace frontend {\r
32 \r
33 /////////////////////////////////////////////////////////////////\r
34 //\r
35 // InsetDialog::Private\r
36 //\r
37 /////////////////////////////////////////////////////////////////\r
38 \r
39 struct InsetDialog::Private\r
40 {\r
41         Private(InsetCode code, FuncCode creation_code)\r
42                 : inset_code_(code), creation_code_(creation_code)\r
43         {\r
44         }\r
45 \r
46         ///\r
47         InsetCode inset_code_;\r
48         ///\r
49         FuncCode creation_code_;\r
50 };\r
51 \r
52 /////////////////////////////////////////////////////////////////\r
53 //\r
54 // InsetDialog\r
55 //\r
56 /////////////////////////////////////////////////////////////////\r
57 \r
58 InsetDialog::InsetDialog(GuiView & lv, InsetCode code, FuncCode creation_code,\r
59                 char const * name, char const * display_name)\r
60         : DialogView(lv, name, qt_(display_name)), d(new Private(code, creation_code))\r
61 {\r
62 }\r
63 \r
64 \r
65 void InsetDialog::on_closePB_clicked()\r
66 {\r
67         hide();\r
68 }\r
69 \r
70 \r
71 void InsetDialog::on_newPB_clicked()\r
72 {\r
73         docstring const argument = dialogToParams();\r
74         dispatch(FuncRequest(d->creation_code_, argument));\r
75 }\r
76 \r
77 \r
78 void InsetDialog::applyView()\r
79 {\r
80         if (!checkWidgets())\r
81                 return;\r
82 \r
83         Inset const * i = inset(d->inset_code_);\r
84         if (!i)\r
85                 return;\r
86         \r
87         docstring const argument = dialogToParams();\r
88         if (!i->validateModifyArgument(argument))\r
89                 return;\r
90 \r
91         dispatch(FuncRequest(LFUN_INSET_MODIFY, argument));\r
92 }\r
93 \r
94 \r
95 void InsetDialog::updateView()\r
96 {\r
97         Inset const * i = inset(d->inset_code_);\r
98         if (i)\r
99                 paramsToDialog(i);\r
100         else\r
101                 enableView(false);\r
102 \r
103         //FIXME: the newPB push button cannot be accessed here and so cannot be\r
104         // disabled...\r
105         /*\r
106         docstring const argument = dialogToParams();\r
107         newPB->setEnabled(\r
108                 getStatus(FuncRequest(LFUN_INSET_MODIFY, argument).enabled());\r
109         */\r
110 }\r
111 \r
112 } // namespace frontend\r
113 } // namespace lyx\r
114 \r
115 #include "moc_InsetDialog.cpp"\r