]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiToc.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiToc.cpp
index 2d746d80c1ab98d9d8797776876d621f3d38ff7c..73bd3d751eb4200f8d36a17a003ff5ff7207d355 100644 (file)
@@ -17,6 +17,7 @@
 #include "DockView.h"
 #include "TocWidget.h"
 #include "FuncRequest.h"
+
 #include "insets/InsetCommand.h"
 
 #include "TocModel.h"
 #include "Buffer.h"
 #include "BufferView.h"
 #include "BufferParams.h"
-#include "support/debug.h"
 #include "FloatList.h"
 #include "FuncRequest.h"
-#include "support/gettext.h"
 #include "TextClass.h"
 
 #include "support/convert.h"
+#include "support/debug.h"
+#include "support/gettext.h"
+
+#include "support/assert.h"
 
 #include <algorithm>
 
@@ -41,9 +44,9 @@ namespace lyx {
 namespace frontend {
 
 GuiToc::GuiToc(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
-       : DockView(parent, "toc", qt_("Outline"), area, flags), params_(TOC_CODE)
+       : DockView(parent, "toc", qt_("Outline"), area, flags)
 {
-       widget_ = new TocWidget(*this);
+       widget_ = new TocWidget(*this, &parent);
        setWidget(widget_);
 }
 
@@ -86,7 +89,7 @@ QStandardItemModel * GuiToc::tocModel(int type)
        LYXERR(Debug::GUI, "GuiToc: type " << type
                << "  toc_models_.size() " << toc_models_.size());
 
-       BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
+       LASSERT(type >= 0 && type < int(toc_models_.size()), /**/);
        return toc_models_[type];
 }
 
@@ -96,12 +99,6 @@ QModelIndex GuiToc::currentIndex(int type) const
        if (type < 0)
                return QModelIndex();
 
-       // FIXME: The TocBackend infrastructure is not ready for LOF and LOT
-       // This is because a proper ParConstIterator is not constructed in
-       // InsetCaption::addToToc()
-       if(!canOutline(type))
-               return QModelIndex();
-
        return toc_models_[type]->modelIndex(currentTocItem(type));
 }
 
@@ -114,7 +111,7 @@ void GuiToc::goTo(int type, QModelIndex const & index)
                return;
        }
 
-       BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
+       LASSERT(type >= 0 && type < int(toc_models_.size()), /**/);
 
        TocIterator const it = toc_models_[type]->tocIterator(index);
 
@@ -139,7 +136,24 @@ TocList const & GuiToc::tocs() const
 
 bool GuiToc::initialiseParams(string const & data)
 {
-       InsetCommandMailer::string2params("toc", data, params_);
+       LYXERR(Debug::GUI, data);
+       QString str = toqstr(data);
+       QString new_type;
+       if (str.contains("tableofcontents")) {
+               new_type = "tableofcontents";
+       } else if (str.contains("floatlist")) {
+               if (str.contains("\"figure"))
+                       new_type = "figure";
+               else if (str.contains("\"table"))
+                       new_type = "table";
+               else if (str.contains("\"algorithm"))
+                       new_type = "algorithm";
+       } else if (!str.isEmpty()) {
+               new_type = str;
+       } else {
+               // Default to Outliner.
+               new_type = "tableofcontents";
+       }
 
        types_.clear();
        type_names_.clear();
@@ -148,25 +162,13 @@ bool GuiToc::initialiseParams(string const & data)
        TocList::const_iterator it = tocs.begin();
        TocList::const_iterator end = tocs.end();
        for (; it != end; ++it) {
-               types_.push_back(it->first);
-               type_names_.push_back(guiName(it->first));
+               types_.push_back(toqstr(it->first));
+               type_names_.push_back(toqstr(guiName(it->first)));
                toc_models_.push_back(new TocModel(it->second));
        }
 
-       string selected_type ;
-       if (params_["type"].empty()) //Then plain toc...
-               selected_type = params_.getCmdName();
-       else
-               selected_type = to_ascii(params_["type"]);
-       selected_type_ = -1;
-       for (size_t i = 0;  i != types_.size(); ++i) {
-               if (selected_type == types_[i]) {
-                       selected_type_ = i;
-                       break;
-               }
-       }
+       widget_->updateGui(types_.indexOf(new_type));
 
-       modelReset();
        return true;
 }
 
@@ -210,9 +212,9 @@ void GuiToc::updateBackend()
 
 TocIterator GuiToc::currentTocItem(int type) const
 {
-       BOOST_ASSERT(bufferview());
+       LASSERT(bufferview(), /**/);
        ParConstIterator it(bufferview()->cursor());
-       return buffer().masterBuffer()->tocBackend().item(types_[type], it);
+       return buffer().masterBuffer()->tocBackend().item(fromqstr(types_[type]), it);
 }
 
 
@@ -220,14 +222,28 @@ docstring GuiToc::guiName(string const & type) const
 {
        if (type == "tableofcontents")
                return _("Table of Contents");
-
+       if (type == "child")
+               return _("Child Documents");
+       if (type == "graphics")
+               return _("List of Graphics");
+       if (type == "equation")
+               return _("List of Equations");
        if (type == "footnote")
                return _("List of Foot notes");
-
+       if (type == "listing")
+               return _("List of Listings");
+       if (type == "index")
+               return _("List of Indexes");
+       if (type == "marginalnote")
+               return _("List of Marginal notes");
        if (type == "note")
                return _("List of Notes");
+       if (type == "citation")
+               return _("List of Citations");
+       if (type == "label")
+               return _("Labels and References");
 
-       FloatList const & floats = buffer().params().getTextClass().floats();
+       FloatList const & floats = buffer().params().documentClass().floats();
        if (floats.typeExist(type))
                return _(floats.getType(type).listName());
 
@@ -237,9 +253,6 @@ docstring GuiToc::guiName(string const & type) const
 
 void GuiToc::dispatchParams()
 {
-       string const lfun = 
-               InsetCommandMailer::params2string("toc", params_);
-       dispatch(FuncRequest(getLfun(), lfun));
 }