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);
setWidget(widget_);
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 = "tableofcontents";
+ if (str.contains("floatlist")) {
+ if (str.contains("figure"))
+ new_type = "figure";
+ else if (str.contains("table"))
+ new_type = "table";
+ }
types_.clear();
type_names_.clear();
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;
}
}
- modelReset();
+ widget_->updateGui(selected_type);
+
return true;
}
void GuiToc::dispatchParams()
{
- string const lfun =
- InsetCommandMailer::params2string("toc", params_);
- dispatch(FuncRequest(getLfun(), lfun));
}
std::vector<docstring> const & typeNames() const
{ return type_names_; }
- ///
- int selectedType() { return selected_type_; }
-
/// Return the first TocItem before the cursor
TocIterator currentTocItem(int type) const;
std::vector<std::string> types_;
std::vector<docstring> type_names_;
- int selected_type_;
/// Return the guiname from a given cmdName of the TOC param
docstring guiName(std::string const & type) const;
/// clean-up on hide.
- void clearParams() { params_.clear(); }
+ void clearParams() {}
///
void dispatchParams();
///
bool isBufferDependent() const { return true; }
-
-private:
- ///
- InsetCommandParams params_;
};
} // namespace frontend
{
setupUi(this);
- connect(&form_, SIGNAL(modelReset()), SLOT(updateGui()));
-
moveOutTB->setIcon(QIcon(":/images/promote.png"));
moveInTB->setIcon(QIcon(":/images/demote.png"));
moveUpTB->setIcon(QIcon(":/images/up.png"));
}
-void TocWidget::updateGui()
+void TocWidget::updateGui(int selected_type)
{
vector<docstring> const & type_names = form_.typeNames();
if (type_names.empty()) {
}
QString current_text = typeCO->currentText();
- //lyxerr << "current_text " << fromqstr(current_text) << endl;
typeCO->blockSignals(true);
typeCO->clear();
- int current_type = -1;
for (size_t i = 0; i != type_names.size(); ++i) {
QString item = toqstr(type_names[i]);
typeCO->addItem(item);
- if (item == current_text)
- current_type = i;
}
- if (current_type != -1)
- typeCO->setCurrentIndex(current_type);
- else
- typeCO->setCurrentIndex(form_.selectedType());
+ typeCO->setCurrentIndex(selected_type);
typeCO->blockSignals(false);
setTocModel(typeCO->currentIndex());
/// Update the display of the dialog whilst it is still visible.
void updateView();
-protected Q_SLOTS:
/// Update Gui of the display.
- void updateGui();
+ void updateGui(int selected_type);
+
+protected Q_SLOTS:
///
void setTocModel(size_t type);
///