]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QExternal.C
Strip trailing whitespace.
[lyx.git] / src / frontends / qt2 / QExternal.C
1 /**
2  * \file QExternal.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13
14 #include "ControlExternal.h"
15 #include "qt_helpers.h"
16
17 #include <qlineedit.h>
18 #include <qpushbutton.h>
19 #include <qcombobox.h>
20 #include <qtextview.h>
21
22 #include "QExternalDialog.h"
23 #include "QExternal.h"
24 #include "Qt2BC.h"
25
26 #include <vector>
27
28 typedef Qt2CB<ControlExternal, Qt2DB<QExternalDialog> > base_class;
29
30
31 QExternal::QExternal()
32         : base_class(qt_("LyX: Insert External Material"))
33 {
34 }
35
36
37 void QExternal::build_dialog()
38 {
39         dialog_.reset(new QExternalDialog(this));
40
41         bc().setOK(dialog_->okPB);
42         bc().setApply(dialog_->applyPB);
43         bc().setCancel(dialog_->closePB);
44         bc().addReadOnly(dialog_->externalCO);
45         bc().addReadOnly(dialog_->fileED);
46         bc().addReadOnly(dialog_->browsePB);
47
48         std::vector<string> templates(controller().getTemplates());
49
50         for (std::vector<string>::const_iterator cit = templates.begin();
51                 cit != templates.end(); ++cit) {
52                 dialog_->externalCO->insertItem(toqstr(*cit), -1);
53         }
54 }
55
56
57 void QExternal::update_contents()
58 {
59         InsetExternal::Params const & params = controller().params();
60
61         dialog_->fileED->setText(toqstr(params.filename));
62         dialog_->paramsED->setText(toqstr(params.parameters));
63
64         dialog_->externalCO->setCurrentItem(controller().getTemplateNumber(params.templ.lyxName));
65         dialog_->externalTV->setText(toqstr(params.templ.helpText));
66         isValid();
67 }
68
69
70 string const & QExternal::helpText()
71 {
72         InsetExternal::Params & params = controller().params();
73
74         params.templ = controller().getTemplate(dialog_->externalCO->currentItem());
75         return params.templ.helpText;
76 }
77
78
79 void QExternal::apply()
80 {
81         InsetExternal::Params & params = controller().params();
82
83         params.filename = fromqstr(dialog_->fileED->text());
84         params.parameters = fromqstr(dialog_->paramsED->text());
85
86         params.templ = controller().getTemplate(dialog_->externalCO->currentItem());
87 }