+ model_->blockSignals(true);
+ model_->insertColumns(0, 1);
+ maxdepth_ = 0;
+ mindepth_ = INT_MAX;
+
+ size_t end = toc_->size();
+ for (unsigned int index = 0; index != end; ++index) {
+ TocItem const & item = (*toc_)[index];
+ maxdepth_ = max(maxdepth_, item.depth());
+ mindepth_ = min(mindepth_, item.depth());
+ int current_row = model_->rowCount();
+ model_->insertRows(current_row, 1);
+ QModelIndex top_level_item = model_->index(current_row, 0);
+ model_->setData(top_level_item, toqstr(item.str()), Qt::DisplayRole);
+ model_->setData(top_level_item, index, Qt::UserRole);
+
+ LYXERR(Debug::GUI, "Toc: at depth " << item.depth()
+ << ", added item " << item.str());
+
+ populate(index, top_level_item);
+ if (index >= end)
+ break;
+ }
+
+ model_->setHeaderData(0, Qt::Horizontal, QVariant("title"), Qt::DisplayRole);
+ if (is_sorted_)
+ sorted_model_->sort(0);
+ model_->blockSignals(false);
+ reset();