3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
17 #include "ControlInclude.h"
21 #include "QIncludeDialog.h"
25 #include <qlineedit.h>
26 #include <qpushbutton.h>
27 #include <qcheckbox.h>
28 #include <qcombobox.h>
30 typedef Qt2CB<ControlInclude, Qt2DB<QIncludeDialog> > base_class;
33 : base_class(_("Include"))
38 void QInclude::build_dialog()
40 dialog_.reset(new QIncludeDialog(this));
42 bc().setOK(dialog_->okPB);
43 bc().setCancel(dialog_->closePB);
44 bc().addReadOnly(dialog_->filenameED);
45 bc().addReadOnly(dialog_->browsePB);
46 bc().addReadOnly(dialog_->visiblespaceCB);
47 bc().addReadOnly(dialog_->typeCO);
51 void QInclude::update_contents()
53 dialog_->filenameED->setText(controller().params().cparams.getContents().c_str());
55 string const cmdname = controller().params().cparams.getCmdName();
57 dialog_->visiblespaceCB->setChecked(false);
58 dialog_->visiblespaceCB->setEnabled(false);
60 if (cmdname == "input")
61 dialog_->typeCO->setCurrentItem(0);
62 else if (!cmdname.empty()) {
63 dialog_->typeCO->setCurrentItem(2);
64 dialog_->visiblespaceCB->setChecked(cmdname == "verbatiminput*");
65 dialog_->visiblespaceCB->setEnabled(true);
67 dialog_->typeCO->setCurrentItem(1);
72 void QInclude::apply()
74 controller().params().cparams.
75 setContents(dialog_->filenameED->text().latin1());
77 int const item = dialog_->typeCO->currentItem();
79 controller().params().flag = InsetInclude::INPUT;
81 controller().params().flag = InsetInclude::INCLUDE;
83 if (dialog_->visiblespaceCB->isChecked())
84 controller().params().flag = InsetInclude::VERBAST;
86 controller().params().flag = InsetInclude::VERB;
91 void QInclude::browse()
93 ControlInclude::Type type;
95 int const item = dialog_->typeCO->currentItem();
97 type = ControlInclude::INPUT;
99 type = ControlInclude::INCLUDE;
101 type = ControlInclude::VERBATIM;
103 string const & name = controller().Browse(dialog_->filenameED->text().latin1(), type);
105 dialog_->filenameED->setText(name.c_str());
109 void QInclude::load()
112 string const file(dialog_->filenameED->text().latin1());
114 controller().load(file);
119 bool QInclude::isValid()
121 return !string(dialog_->filenameED->text().latin1()).empty();