]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrintindex.cpp
Avoid extra space in tooltips
[lyx.git] / src / frontends / qt4 / GuiPrintindex.cpp
index 53278497e0194b02ab6960ef3a1a9f4e8f6f9ddf..be8c0cd9b621b5c75a497870b315df42a06c1d6a 100644 (file)
 #include "FuncRequest.h"
 #include "IndicesList.h"
 
+#include "support/lstrings.h"
+
 #include "insets/InsetCommand.h"
 
 #include <QPushButton>
 
 using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 namespace frontend {
@@ -39,6 +42,8 @@ GuiPrintindex::GuiPrintindex(GuiView & lv)
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose()));
        connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+       connect(subindexCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+       connect(literalCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
 
        bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
        bc().setOK(okPB);
@@ -57,10 +62,14 @@ void GuiPrintindex::updateContents()
        typedef IndicesList::const_iterator const_iterator;
 
        IndicesList const & indiceslist = buffer().params().indiceslist();
-       docstring const cur_index = params_["type"];
+       docstring const cur_index = suffixIs(params_.getCmdName(), '*') ?
+               from_ascii("printall") : params_["type"];
 
        indicesCO->clear();
 
+       indicesCO->addItem(qt_("<All indexes>"),
+                       QVariant(QString("printall")));
+
        const_iterator const begin = indiceslist.begin();
        const_iterator const end = indiceslist.end();
        for (const_iterator it = begin; it != end; ++it)
@@ -69,6 +78,8 @@ void GuiPrintindex::updateContents()
 
        int const pos = indicesCO->findData(toqstr(cur_index));
        indicesCO->setCurrentIndex(pos);
+       subindexCB->setChecked(params_.getCmdName() == "printsubindex");
+       literalCB->setChecked(params_["literal"] == "true");
 }
 
 
@@ -76,14 +87,29 @@ void GuiPrintindex::applyView()
 {
        QString const index = indicesCO->itemData(
                indicesCO->currentIndex()).toString();
-       params_["type"] = qstring_to_ucs4(index);
+       string cmd = "printindex";
+       if (subindexCB->isChecked())
+               cmd = "printsubindex";
+       if (index == QString("printall"))
+               cmd += '*';
+       params_.setCmdName(cmd);
+       if (index == QString("printall"))
+               params_["type"] = docstring();
+       else
+               params_["type"] = qstring_to_ucs4(index);
+       params_["literal"] = literalCB->isChecked()
+                       ? from_ascii("true") : from_ascii("false");
 }
 
 
 void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
 {
-       int const pos = indicesCO->findData(toqstr(params_["type"]));
+       int const pos = suffixIs(params_.getCmdName(), '*') ?
+               indicesCO->findData(QString("printall")) :
+               indicesCO->findData(toqstr(params_["type"]));
+       subindexCB->setChecked(params_.getCmdName() == "printsubindex");
        indicesCO->setCurrentIndex(pos);
+       literalCB->setChecked(params_["literal"] == "true");
        bc().setValid(isValid());
 }
 
@@ -92,14 +118,15 @@ bool GuiPrintindex::initialiseParams(string const & data)
 {
        // The name passed with LFUN_INSET_APPLY is also the name
        // used to identify the mailer.
-       InsetCommand::string2params("index_print", data, params_);
+       InsetCommand::string2params(data, params_);
+       paramsToDialog(params_);
        return true;
 }
 
 
 void GuiPrintindex::dispatchParams()
 {
-       std::string const lfun = InsetCommand::params2string("index_print", params_);
+       std::string const lfun = InsetCommand::params2string(params_);
        dispatch(FuncRequest(getLfun(), lfun));
 }