#include "Buffer.h"
#include "BufferView.h"
#include "BufferParams.h"
-#include "debug.h"
#include "FloatList.h"
#include "FuncRequest.h"
-#include "gettext.h"
#include "TextClass.h"
#include "support/convert.h"
+#include "support/debug.h"
+#include "support/gettext.h"
#include <algorithm>
-using std::endl;
-using std::string;
-
+using namespace std;
namespace lyx {
namespace frontend {
GuiToc::GuiToc(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
- : DockView(parent, "toc", area, flags), params_(TOC_CODE)
+ : DockView(parent, "toc", qt_("Outline"), area, flags)
{
- widget_ = new TocWidget(*this);
+ widget_ = new TocWidget(*this, &parent);
setWidget(widget_);
- setWindowTitle(widget_->windowTitle());
}
GuiToc::~GuiToc()
{
+ clearTocModels();
delete widget_;
}
+void GuiToc::clearTocModels()
+{
+ const unsigned int size = toc_models_.size();
+ for (unsigned int i = 0; i < size; ++i) {
+ delete toc_models_[i];
+ }
+ toc_models_.clear();
+}
+
+
int GuiToc::getTocDepth(int type)
{
if (type < 0)
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));
}
LYXERR(Debug::GUI, "GuiToc::goTo " << to_utf8(it->str()));
string const tmp = convert<string>(it->id());
- lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
+ dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
}
bool GuiToc::initialiseParams(string const & data)
{
- InsetCommandMailer::string2params("toc", data, params_);
+ LYXERR(Debug::GUI, data);
+ QString str = QString::fromUtf8(data.c_str());
+ string 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";
+ }
types_.clear();
type_names_.clear();
- toc_models_.clear();
+ clearTocModels();
TocList const & tocs = buffer().masterBuffer()->tocBackend().tocs();
TocList::const_iterator it = tocs.begin();
TocList::const_iterator end = tocs.end();
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;
+ int selected_type = -1;
for (size_t i = 0; i != types_.size(); ++i) {
- if (selected_type == types_[i]) {
- selected_type_ = i;
+ if (new_type == types_[i]) {
+ selected_type = i;
break;
}
}
+ widget_->updateGui(selected_type);
- modelReset();
return true;
}
{
if (type == "tableofcontents")
return _("Table of Contents");
-
- FloatList const & floats = buffer().params().getTextClass().floats();
+ 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().documentClass().floats();
if (floats.typeExist(type))
return _(floats.getType(type).listName());
void GuiToc::dispatchParams()
{
- string const lfun =
- InsetCommandMailer::params2string("toc", params_);
- dispatch(FuncRequest(getLfun(), lfun));
}