From 6a877dfc1add3aa1a4bcde30140d43691b075087 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 12 Feb 2008 15:33:01 +0000 Subject: [PATCH] Try to restore current selected type in case of a toc reset. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22963 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiToc.cpp | 7 ++++--- src/frontends/qt4/TocWidget.cpp | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index 2c041e9a86..7d96dfca83 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -140,10 +140,11 @@ TocList const & GuiToc::tocs() const bool GuiToc::initialiseParams(string const & data) { LYXERR(Debug::GUI, data); - LYXERR0(data); QString str = QString::fromUtf8(data.c_str()); - string new_type = "tableofcontents"; - if (str.contains("floatlist")) { + 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")) diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index 0a1131469b..c51740bab5 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -221,7 +221,7 @@ void TocWidget::updateGui(int selected_type) return; } - QString current_text = typeCO->currentText(); + QString const current_text = typeCO->currentText(); typeCO->blockSignals(true); typeCO->clear(); for (size_t i = 0; i != type_names.size(); ++i) { @@ -230,6 +230,12 @@ void TocWidget::updateGui(int selected_type) } if (selected_type != -1) typeCO->setCurrentIndex(selected_type); + else { + int const new_index = typeCO->findText(current_text); + if (new_index != -1) + typeCO->setCurrentIndex(new_index); + } + typeCO->blockSignals(false); setTocModel(typeCO->currentIndex());