]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetIndex.cpp
Remove all BufferParam arguments in InsetXXX methods (since insets know about their...
[lyx.git] / src / insets / InsetIndex.cpp
index d18c407dc9b4013d75ca88cc8de250f428452ce6..e64685335b7af1bab160fd15216e641cc0da0f78 100644 (file)
@@ -171,6 +171,12 @@ int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
+docstring InsetIndex::xhtml(odocstream &, OutputParams const &) const
+{
+       return docstring();
+}
+
+
 bool InsetIndex::showInsetDialog(BufferView * bv) const
 {
        bv->showDialog("index", params2string(params_),
@@ -186,13 +192,13 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY: {
                if (cmd.getArg(0) == "changetype") {
                        params_.index = from_utf8(cmd.getArg(1));
-                       setLayout(cur.buffer()->params());
+                       setLayout();
                        break;
                }
                InsetIndexParams params;
                InsetIndex::string2params(to_utf8(cmd.argument()), params);
                params_.index = params.index;
-               setLayout(cur.buffer()->params());
+               setLayout();
                break;
        }
 
@@ -248,6 +254,18 @@ docstring const InsetIndex::buttonLabel(BufferView const & bv) const
 }
 
 
+ColorCode InsetIndex::labelColor() const
+{
+       if (params_.index.empty() || params_.index == from_ascii("idx"))
+               return InsetCollapsable::labelColor();
+       // FIXME UNICODE
+       ColorCode c = lcolor.getFromLyXName(to_utf8(params_.index));
+       if (c == Color_none)
+               c = InsetCollapsable::labelColor();
+       return c;
+}
+
+
 docstring InsetIndex::toolTip(BufferView const &, int, int) const
 {
        docstring tip = _("Index Entry");
@@ -267,10 +285,7 @@ docstring InsetIndex::toolTip(BufferView const &, int, int) const
        odocstringstream ods;
        InsetText::plaintext(ods, rp);
        tip += ods.str();
-       // shorten it if necessary
-       if (tip.size() > 200)
-               tip = tip.substr(0, 200) + "...";
-       return tip;
+       return wrapParas(tip);
 }
 
 
@@ -398,34 +413,53 @@ ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
 
 docstring InsetPrintIndex::screenLabel() const
 {
-       if ((!buffer().masterBuffer()->params().use_indices
+       bool const printall = suffixIs(getCmdName(), '*');
+       bool const multind = buffer().masterBuffer()->params().use_indices;
+       if ((!multind
             && getParam("type") == from_ascii("idx"))
-           || getParam("type").empty())
+           || (getParam("type").empty() && !printall))
                return _("Index");
        Buffer const & realbuffer = *buffer().masterBuffer();
        IndicesList const & indiceslist = realbuffer.params().indiceslist();
        Index const * index = indiceslist.findShortcut(getParam("type"));
-       if (!index)
+       if (!index && !printall)
                return _("Unknown index type!");
-       docstring res = index->index();
-       if (!buffer().masterBuffer()->params().use_indices)
+       docstring res = printall ? _("All indices") : index->index();
+       if (!multind)
                res += " (" + _("non-active") + ")";
-       else if (getCmdName() == "printsubindex")
+       else if (contains(getCmdName(), "printsubindex"))
                res += " (" + _("subindex") + ")";
        return res;
 }
 
 
+bool InsetPrintIndex::isCompatibleCommand(string const & s)
+{
+       return s == "printindex" || s == "printsubindex"
+               || s == "printindex*" || s == "printsubindex*";
+}
+
+
 void InsetPrintIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
                if (cmd.argument() == from_ascii("toggle-subindex")) {
-                       if (getCmdName() == "printindex")
-                               setCmdName("printsubindex");
+                       string cmd = getCmdName();
+                       if (contains(cmd, "printindex"))
+                               cmd = subst(cmd, "printindex", "printsubindex");
                        else
-                               setCmdName("printindex");
+                               cmd = subst(cmd, "printsubindex", "printindex");
+                       setCmdName(cmd);
+                       break;
+               } else if (cmd.argument() == from_ascii("check-printindex*")) {
+                       string cmd = getCmdName();
+                       if (suffixIs(cmd, '*'))
+                               break;
+                       cmd += '*';
+                       setParam("type", docstring());
+                       setCmdName(cmd);
                        break;
                }
                InsetCommandParams p(INDEX_PRINT_CODE);
@@ -455,13 +489,22 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_INSET_MODIFY: {
                if (cmd.argument() == from_ascii("toggle-subindex")) {
                        status.setEnabled(buffer().masterBuffer()->params().use_indices);
-                       status.setOnOff(getCmdName() == "printsubindex");
+                       status.setOnOff(contains(getCmdName(), "printsubindex"));
+                       return true;
+               } else if (cmd.argument() == from_ascii("check-printindex*")) {
+                       status.setEnabled(buffer().masterBuffer()->params().use_indices);
+                       status.setOnOff(suffixIs(getCmdName(), '*'));
                        return true;
                } if (cmd.getArg(0) == "index_print"
                    && cmd.getArg(1) == "CommandInset") {
                        InsetCommandParams p(INDEX_PRINT_CODE);
                        InsetCommand::string2params("index_print",
                                to_utf8(cmd.argument()), p);
+                       if (suffixIs(p.getCmdName(), '*')) {
+                               status.setEnabled(true);
+                               status.setOnOff(false);
+                               return true;
+                       }
                        Buffer const & realbuffer = *buffer().masterBuffer();
                        IndicesList const & indiceslist =
                                realbuffer.params().indiceslist();
@@ -516,5 +559,9 @@ bool InsetPrintIndex::hasSettings() const
        return buffer().masterBuffer()->params().use_indices;
 }
 
+docstring InsetPrintIndex::xhtml(odocstream &, OutputParams const &) const
+{
+       return docstring();
+}
 
 } // namespace lyx