]> git.lyx.org Git - features.git/commitdiff
Try to restore current selected type in case of a toc reset.
authorAbdelrazak Younes <younes@lyx.org>
Tue, 12 Feb 2008 15:33:01 +0000 (15:33 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 12 Feb 2008 15:33:01 +0000 (15:33 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22963 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiToc.cpp
src/frontends/qt4/TocWidget.cpp

index 2c041e9a86168c12596d3388ded818a3d2dd2025..7d96dfca83b3b2a74d288f190bd02d3862ceaa7e 100644 (file)
@@ -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"))
index 0a1131469b0de9dd7b634b6e2c04b06c77e2c17d..c51740bab54a0c84068251e5ac97fcf959000924 100644 (file)
@@ -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());