Following patch corrects some misbehavior in TOC dialog:
- When clicking on Toc insets, dialog switches to correct list. - cursor goes to correct entry when clicked.. - some other fixes.. There is one strange problem, though. After clicking table toc entries, cursor goes to correct table, but the last table inset is selected in tableview. This only happens in the table insets. Any idea?? This is no showstopper, in my opinion. Then, may I ask somebody commits, if there is no problem?? Ugras
Index: QToc.C =================================================================== --- QToc.C (revision 15933) +++ QToc.C (working copy) @@ -112,14 +112,24 @@ } +int QToc::getType() +{ + return type_; +} + + void QToc::update() { - toc_models_.clear(); + updateType(); + updateToc(); +} + +void QToc::updateType() +{ + QStringList type_list; - type_ = 0; - vector<string> const & types = getTypes(); if (types.empty()) { type_model_.setStringList(type_list); @@ -127,8 +137,11 @@ 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 @@ << "\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<string> const & types = getTypes(); + + for (size_t i = 0; i != types.size(); ++i) { + + toc_models_.push_back(new TocModel(getContents(types[i]))); + } + } Index: QToc.h =================================================================== --- QToc.h (revision 15933) +++ QToc.h (working copy) @@ -32,9 +32,11 @@ QToc(Dialog &); void update(); + /// + void updateToc(); + /// + void updateType(); - void updateToc(int type); - bool canOutline(); QStandardItemModel * tocModel(); @@ -47,6 +49,8 @@ QModelIndex const getCurrentIndex(); /// void goTo(QModelIndex const & index); + /// + int getType(); private: Index: QTocDialog.h =================================================================== --- QTocDialog.h (revision 15933) +++ QTocDialog.h (working copy) @@ -71,6 +71,8 @@ protected: /// void enableButtons(bool enable = true); + /// Reconnects the selection model change signal when TOC changed. + void reconnectSelectionModel(); private: Index: QTocDialog.C =================================================================== --- QTocDialog.C (revision 15933) +++ QTocDialog.C (working copy) @@ -79,7 +79,7 @@ void QTocDialog::on_updatePB_clicked() { - update(); + form_->update(); } @@ -105,6 +105,7 @@ { form_->setTocModel(value); tocTV->setModel(form_->tocModel()); + reconnectSelectionModel(); enableButtons(); } @@ -180,7 +181,7 @@ void QTocDialog::update() { - form_->update(); + form_->updateToc(); updateGui(); } @@ -197,6 +198,7 @@ } typeCO->setModel(type_model); + typeCO->setCurrentIndex(form_->getType()); if (form_->tocModel()) tocTV->setModel(form_->tocModel()); @@ -208,12 +210,7 @@ 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::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::show() { - update(); + form_->update(); QDialog::show(); }