diff --git a/src/frontends/qt4/QToc.C b/src/frontends/qt4/QToc.C index 22a3990c19..039d3980ce 100644 --- a/src/frontends/qt4/QToc.C +++ b/src/frontends/qt4/QToc.C @@ -112,14 +112,24 @@ void QToc::goTo(QModelIndex const & index) } +int QToc::getType() +{ + return type_; +} + + void QToc::update() { - toc_models_.clear(); + updateType(); + updateToc(); +} + + +void QToc::updateType() +{ QStringList type_list; - type_ = 0; - vector const & types = getTypes(); if (types.empty()) { type_model_.setStringList(type_list); @@ -127,8 +137,11 @@ void QToc::update() return; } - string const & selected_type = params().getCmdName(); - lyxerr[Debug::GUI] << "selected_type " << selected_type << endl; + string selected_type ; + if(params()["type"].empty()) //Then plain toc... + selected_type = params().getCmdName(); + else + selected_type = to_ascii(params()["type"]); QString gui_names_; for (size_t i = 0; i != types.size(); ++i) { @@ -142,15 +155,21 @@ void QToc::update() << "\ttoc_models_.size() " << toc_models_.size() << endl; - toc_models_.push_back(new TocModel(getContents(types[i]))); } type_model_.setStringList(type_list); } -void QToc::updateToc(int type) +void QToc::updateToc() { - toc_models_[type] = new TocModel(getContents(getTypes()[type])); + toc_models_.clear(); + vector const & types = getTypes(); + + for (size_t i = 0; i != types.size(); ++i) { + + toc_models_.push_back(new TocModel(getContents(types[i]))); + } + } diff --git a/src/frontends/qt4/QToc.h b/src/frontends/qt4/QToc.h index abee279bfb..15d65d590a 100644 --- a/src/frontends/qt4/QToc.h +++ b/src/frontends/qt4/QToc.h @@ -32,8 +32,10 @@ public: QToc(Dialog &); void update(); - - void updateToc(int type); + /// + void updateToc(); + /// + void updateType(); bool canOutline(); @@ -47,6 +49,8 @@ public: QModelIndex const getCurrentIndex(); /// void goTo(QModelIndex const & index); + /// + int getType(); private: diff --git a/src/frontends/qt4/QTocDialog.C b/src/frontends/qt4/QTocDialog.C index 64e752f198..be1160752e 100644 --- a/src/frontends/qt4/QTocDialog.C +++ b/src/frontends/qt4/QTocDialog.C @@ -79,7 +79,7 @@ void QTocDialog::on_closePB_clicked() void QTocDialog::on_updatePB_clicked() { - update(); + form_->update(); } @@ -105,6 +105,7 @@ void QTocDialog::on_typeCO_activated(int value) { form_->setTocModel(value); tocTV->setModel(form_->tocModel()); + reconnectSelectionModel(); enableButtons(); } @@ -180,7 +181,7 @@ void QTocDialog::enableButtons(bool enable) void QTocDialog::update() { - form_->update(); + form_->updateToc(); updateGui(); } @@ -197,6 +198,7 @@ void QTocDialog::updateGui() } typeCO->setModel(type_model); + typeCO->setCurrentIndex(form_->getType()); if (form_->tocModel()) tocTV->setModel(form_->tocModel()); @@ -208,12 +210,7 @@ void QTocDialog::updateGui() tocTV->header()->setVisible(false); enableButtons(); - connect(tocTV->selectionModel(), - SIGNAL(currentChanged(const QModelIndex &, - const QModelIndex &)), - this, SLOT(selectionChanged(const QModelIndex &, - const QModelIndex &))); - + reconnectSelectionModel(); select(form_->getCurrentIndex()); lyxerr[Debug::GUI] @@ -224,6 +221,16 @@ void QTocDialog::updateGui() } +void QTocDialog::reconnectSelectionModel() +{ + connect(tocTV->selectionModel(), + SIGNAL(currentChanged(const QModelIndex &, + const QModelIndex &)), + this, SLOT(selectionChanged(const QModelIndex &, + const QModelIndex &))); +} + + void QTocDialog::apply() { // Nothing to do here... for now. @@ -239,7 +246,7 @@ void QTocDialog::hide() void QTocDialog::show() { - update(); + form_->update(); QDialog::show(); } diff --git a/src/frontends/qt4/QTocDialog.h b/src/frontends/qt4/QTocDialog.h index df86647ebf..a006c3b4ad 100644 --- a/src/frontends/qt4/QTocDialog.h +++ b/src/frontends/qt4/QTocDialog.h @@ -71,6 +71,8 @@ protected Q_SLOTS: protected: /// void enableButtons(bool enable = true); + /// Reconnects the selection model change signal when TOC changed. + void reconnectSelectionModel(); private: