* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
-GuiIncludeDialog::GuiIncludeDialog(LyXView & lv)
- : GuiDialog(lv, "include")
+
+GuiInclude::GuiInclude(GuiView & lv)
+ : GuiDialog(lv, "include", qt_("Child Document")),
+ params_(insetCode("include"))
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(visiblespaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(filenameED, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
connect(visiblespaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(filenameED, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
- connect(editPB, SIGNAL(clicked()), this, SLOT(editClicked()));
- connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
+ connect(editPB, SIGNAL(clicked()), this, SLOT(edit()));
+ connect(browsePB, SIGNAL(clicked()), this, SLOT(browse()));
connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
connect(previewCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(captionLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(labelLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(listingsED, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
connect(previewCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(captionLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(labelLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(listingsED, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
- connect(listingsED, SIGNAL(textChanged()), this, SLOT(set_listings_msg()));
+ connect(listingsED, SIGNAL(textChanged()), this, SLOT(setListingsMsg()));
connect(bypassCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(bypassCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(bypassCB, SIGNAL(clicked()), this, SLOT(set_listings_msg()));
+ connect(bypassCB, SIGNAL(clicked()), this, SLOT(setListingsMsg()));
- if (params != param_cache) {
- param_cache = params;
- msg_cache = InsetListingsParams(params).validate();
- }
- return msg_cache;
+ InsetListingsParams lstparams(params);
+ lstparams.setMinted(buffer().params().use_minted);
+ return lstparams.validate();
listingsTB->setPlainText(
qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
listingsTB->setPlainText(
qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
if (cmdname != "include" &&
cmdname != "verbatiminput" &&
cmdname != "verbatiminput*" &&
if (cmdname != "include" &&
cmdname != "verbatiminput" &&
cmdname != "verbatiminput*" &&
} else if (cmdname == "input") {
typeCO->setCurrentIndex(1);
previewCB->setEnabled(true);
} else if (cmdname == "input") {
typeCO->setCurrentIndex(1);
previewCB->setEnabled(true);
typeCO->setCurrentIndex(3);
listingsGB->setEnabled(true);
listingsED->setEnabled(true);
typeCO->setCurrentIndex(3);
listingsGB->setEnabled(true);
listingsED->setEnabled(true);
// extract caption and label and put them into their respective editboxes
vector<string> pars = getVectorFromString(par.separatedParams(), "\n");
for (vector<string>::iterator it = pars.begin();
it != pars.end(); ++it) {
if (prefixIs(*it, "caption=")) {
string cap = it->substr(8);
// extract caption and label and put them into their respective editboxes
vector<string> pars = getVectorFromString(par.separatedParams(), "\n");
for (vector<string>::iterator it = pars.begin();
it != pars.end(); ++it) {
if (prefixIs(*it, "caption=")) {
string cap = it->substr(8);
- if (cap[0] == '{' && cap[cap.size()-1] == '}') {
- captionLE->setText(toqstr(cap.substr(1, cap.size()-2)));
+ if (cap[0] == '{' && cap[cap.size() - 1] == '}') {
+ captionLE->setText(toqstr(cap.substr(1, cap.size() - 2)));
} else if (prefixIs(*it, "label=")) {
string lbl = it->substr(6);
if (lbl[0] == '{' && lbl[lbl.size()-1] == '}') {
} else if (prefixIs(*it, "label=")) {
string lbl = it->substr(6);
if (lbl[0] == '{' && lbl[lbl.size()-1] == '}') {
string extra = getStringFromVector(pars);
listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
}
string extra = getStringFromVector(pars);
listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
}
- InsetCommandParams params = controller().params();
-
- params["filename"] = from_utf8(internal_path(fromqstr(filenameED->text())));
- params.preview(previewCB->isChecked());
+ params_["filename"] = from_utf8(internal_path(fromqstr(filenameED->text())));
+ params_.preview(previewCB->isChecked());
// the parameter string should have passed validation
InsetListingsParams par(fromqstr(listingsED->toPlainText()));
string caption = fromqstr(captionLE->text());
// the parameter string should have passed validation
InsetListingsParams par(fromqstr(listingsED->toPlainText()));
string caption = fromqstr(captionLE->text());
par.addParam("caption", "{" + caption + "}");
if (!label.empty())
par.addParam("label", "{" + label + "}");
par.addParam("caption", "{" + caption + "}");
if (!label.empty())
par.addParam("label", "{" + label + "}");
- docstring const & name =
- controller().browse(qstring_to_ucs4(filenameED->text()), type);
- if (!name.empty())
- filenameED->setText(toqstr(name));
+ QString name = browse(filenameED->text(), type);
+ if (!name.isEmpty())
+ filenameED->setText(name);
- controller().edit(file);
+ applyView();
+ } else
+ hideView();
+ dispatch(FuncRequest(LFUN_INSET_EDIT));
+}
+
+
+bool GuiInclude::isValid()
+{
+ return !filenameED->text().isEmpty() && validate_listings_params().empty();
+}
+
+
+QString GuiInclude::browse(QString const & in_name, Type in_type) const
+{
+ QString const title = qt_("Select document to include");
+
+ // input TeX, verbatim, or LyX file ?
+ QStringList filters;
+ switch (in_type) {
+ case INCLUDE:
+ case INPUT:
+ filters = fileFilters(qt_("LaTeX/LyX Documents (*.tex *.lyx)"));
+ break;
+ case VERBATIM:
+ case LISTINGS:
+ filters = fileFilters(QString());
+ break;
+
+ QString const docpath = toqstr(support::onlyPath(buffer().absFileName()));
+
+ return browseRelToParent(in_name, docpath, title, filters, false,
+ qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
+}
+
+
+bool GuiInclude::initialiseParams(std::string const & data)
+{
+ InsetCommand::string2params(data, params_);
+ paramsToDialog(params_);
+ return true;
- return !filenameED->text().isEmpty() &&
- validate_listings_params().empty();
+ std::string const lfun = InsetCommand::params2string(params_);
+ dispatch(FuncRequest(getLfun(), lfun));