From: Abdelrazak Younes Date: Tue, 12 Feb 2008 07:47:16 +0000 (+0000) Subject: simplify GuiToc / TocWidget interaction. Much can still be simplified... X-Git-Tag: 1.6.10~6312 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8c73b3d2ce356e2720186f8cf5208614d124fdcf;p=features.git simplify GuiToc / TocWidget interaction. Much can still be simplified... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22953 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index 2d746d80c1..0d7643f869 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -41,7 +41,7 @@ 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); setWidget(widget_); @@ -139,7 +139,15 @@ TocList const & GuiToc::tocs() const 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(); @@ -153,20 +161,16 @@ bool GuiToc::initialiseParams(string const & data) 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; } @@ -237,9 +241,6 @@ docstring GuiToc::guiName(string const & type) const void GuiToc::dispatchParams() { - string const lfun = - InsetCommandMailer::params2string("toc", params_); - dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/frontends/qt4/GuiToc.h b/src/frontends/qt4/GuiToc.h index f73291f48f..99e0e6dba7 100644 --- a/src/frontends/qt4/GuiToc.h +++ b/src/frontends/qt4/GuiToc.h @@ -83,9 +83,6 @@ public: std::vector const & typeNames() const { return type_names_; } - /// - int selectedType() { return selected_type_; } - /// Return the first TocItem before the cursor TocIterator currentTocItem(int type) const; @@ -102,21 +99,16 @@ public: std::vector types_; std::vector 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 diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index e90b53aeaf..bdc968670b 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -32,8 +32,6 @@ TocWidget::TocWidget(GuiToc & form, QWidget * parent) { 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")); @@ -212,7 +210,7 @@ void TocWidget::updateView() } -void TocWidget::updateGui() +void TocWidget::updateGui(int selected_type) { vector const & type_names = form_.typeNames(); if (type_names.empty()) { @@ -224,20 +222,13 @@ void TocWidget::updateGui() } 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()); diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index a4a41c6f1e..bad9da2c08 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -32,9 +32,10 @@ public: /// 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); ///