X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiInclude.cpp;h=b02fd9181f0384e52e7f31fe8ed7a9c22062c297;hb=161f7b7f62cb33dab681add6c5b5b68a887e2ea1;hp=6e15b2666a6ba2f96f60d512c5c6988abcb93d9f;hpb=1458cd52b7b26243a524f4de86aa4596372748a8;p=lyx.git diff --git a/src/frontends/qt4/GuiInclude.cpp b/src/frontends/qt4/GuiInclude.cpp index 6e15b2666a..b02fd9181f 100644 --- a/src/frontends/qt4/GuiInclude.cpp +++ b/src/frontends/qt4/GuiInclude.cpp @@ -64,9 +64,9 @@ GuiInclude::GuiInclude(GuiView & lv) 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(set_listings_msg())); + connect(bypassCB, SIGNAL(clicked()), this, SLOT(setListingsMsg())); setFocusProxy(filenameED); @@ -91,25 +91,16 @@ void GuiInclude::change_adaptor() docstring GuiInclude::validate_listings_params() { - // use a cache here to avoid repeated validation - // of the same parameters - static string param_cache = string(); - static docstring msg_cache = docstring(); - if (typeCO->currentIndex() != 3 || bypassCB->isChecked()) return docstring(); - string params = fromqstr(listingsED->toPlainText()); - if (params != param_cache) { - param_cache = params; - msg_cache = InsetListingsParams(params).validate(); - } - return msg_cache; + return InsetListingsParams(params).validate(); } -void GuiInclude::set_listings_msg() +void GuiInclude::setListingsMsg() { + // FIXME THREAD static bool isOK = true; docstring msg = validate_listings_params(); if (msg.empty()) { @@ -166,7 +157,7 @@ void GuiInclude::typeChanged(int v) } -void GuiInclude::updateContents() +void GuiInclude::paramsToDialog(InsetCommandParams const & params_) { filenameED->setText(toqstr(params_["filename"])); @@ -232,6 +223,10 @@ void GuiInclude::updateContents() string extra = getStringFromVector(pars); listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams())); } + + // Make sure that the bc is in the INITIAL state + if (bc().policy().buttonStatus(ButtonPolicy::OKAY)) + bc().restore(); } @@ -256,7 +251,7 @@ void GuiInclude::applyView() if (!label.empty()) par.addParam("label", "{" + label + "}"); string const listparams = par.params(); - params_["lstparams"] = from_ascii(listparams); + params_["lstparams"] = from_utf8(listparams); } else { if (visiblespaceCB->isChecked()) params_.setCmdName("verbatiminput*"); @@ -290,9 +285,11 @@ void GuiInclude::edit() { if (!isValid()) return; - string const file = fromqstr(filenameED->text()); - slotOK(); - applyView(); + if (bc().policy().buttonStatus(ButtonPolicy::OKAY)) { + slotOK(); + applyView(); + } else + hideView(); dispatch(FuncRequest(LFUN_INSET_EDIT)); } @@ -316,26 +313,28 @@ QString GuiInclude::browse(QString const & in_name, Type in_type) const break; case VERBATIM: case LISTINGS: + filters = fileFilters(QString()); break; } QString const docpath = toqstr(support::onlyPath(buffer().absFileName())); - return browseRelFile(in_name, docpath, title, filters, false, + 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("include", data, params_); + InsetCommand::string2params(data, params_); + paramsToDialog(params_); return true; } void GuiInclude::dispatchParams() { - std::string const lfun = InsetCommand::params2string("include", params_); + std::string const lfun = InsetCommand::params2string(params_); dispatch(FuncRequest(getLfun(), lfun)); } @@ -346,4 +345,4 @@ Dialog * createGuiInclude(GuiView & lv) { return new GuiInclude(lv); } } // namespace frontend } // namespace lyx -#include "GuiInclude_moc.cpp" +#include "moc_GuiInclude.cpp"