]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiInclude.cpp
Do not compute caret geometry when we are not ready to do so.
[lyx.git] / src / frontends / qt4 / GuiInclude.cpp
index 7f5c96bd1894ac0b2a4d5dd2c2917c1209d401a9..edbf7a19c42f96617fb991253ba3df1137368ce2 100644 (file)
@@ -15,6 +15,7 @@
 #include "GuiInclude.h"
 
 #include "Buffer.h"
+#include "BufferParams.h"
 #include "FuncRequest.h"
 #include "LyXRC.h"
 
@@ -30,9 +31,9 @@
 #include "insets/InsetListingsParams.h"
 #include "insets/InsetInclude.h"
 
-#include <QPushButton>
 #include <QCheckBox>
 #include <QLineEdit>
+#include <QPushButton>
 
 #include <utility>
 
@@ -91,25 +92,18 @@ 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;
+       InsetListingsParams lstparams(params);
+       lstparams.setMinted(buffer().params().use_minted);
+       return lstparams.validate();
 }
 
 
 void GuiInclude::setListingsMsg()
 {
+       // FIXME THREAD
        static bool isOK = true;
        docstring msg = validate_listings_params();
        if (msg.empty()) {
@@ -159,7 +153,7 @@ void GuiInclude::typeChanged(int v)
                        listingsGB->setEnabled(false);
                        break;
        }
-       //see this thread 
+       //see this thread
        //  http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg118471.html
        //for the reason this is here.
        okPB->setDefault(true);
@@ -185,7 +179,8 @@ void GuiInclude::paramsToDialog(InsetCommandParams const & params_)
        if (cmdname != "include" &&
            cmdname != "verbatiminput" &&
            cmdname != "verbatiminput*" &&
-               cmdname != "lstinputlisting")
+           cmdname != "lstinputlisting" &&
+           cmdname != "inputminted")
                cmdname = "input";
 
        if (cmdname == "include") {
@@ -205,7 +200,7 @@ void GuiInclude::paramsToDialog(InsetCommandParams const & params_)
                typeCO->setCurrentIndex(2);
                visiblespaceCB->setEnabled(true);
 
-       } else if (cmdname == "lstinputlisting") {
+       } else if (cmdname == "lstinputlisting" || cmdname == "inputminted") {
                typeCO->setCurrentIndex(3);
                listingsGB->setEnabled(true);
                listingsED->setEnabled(true);
@@ -219,7 +214,7 @@ void GuiInclude::paramsToDialog(InsetCommandParams const & params_)
                                if (cap[0] == '{' && cap[cap.size() - 1] == '}') {
                                        captionLE->setText(toqstr(cap.substr(1, cap.size() - 2)));
                                        *it = "";
-                               } 
+                               }
                        } else if (prefixIs(*it, "label=")) {
                                string lbl = it->substr(6);
                                if (lbl[0] == '{' && lbl[lbl.size()-1] == '}') {
@@ -250,7 +245,10 @@ void GuiInclude::applyView()
        } else if (item == 1) {
                params_.setCmdName("input");
        } else if (item == 3) {
-               params_.setCmdName("lstinputlisting");
+               if (buffer().params().use_minted)
+                       params_.setCmdName("inputminted");
+               else
+                       params_.setCmdName("lstinputlisting");
                // the parameter string should have passed validation
                InsetListingsParams par(fromqstr(listingsED->toPlainText()));
                string caption = fromqstr(captionLE->text());
@@ -294,7 +292,6 @@ void GuiInclude::edit()
 {
        if (!isValid())
                return;
-       string const file = fromqstr(filenameED->text());
        if (bc().policy().buttonStatus(ButtonPolicy::OKAY)) {
                slotOK();
                applyView();
@@ -323,6 +320,7 @@ QString GuiInclude::browse(QString const & in_name, Type in_type) const
                break;
        case VERBATIM:
        case LISTINGS:
+               filters = fileFilters(QString());
                break;
        }