+///////////////////////////////////////////////////////////////////////////////
+//
+// TocTypeModel
+//
+///////////////////////////////////////////////////////////////////////////////
+
+TocTypeModel::TocTypeModel(QObject * parent)
+ : QStandardItemModel(parent)
+{
+}
+
+
+void TocTypeModel::reset()
+{
+ QStandardItemModel::reset();
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// TocModel
+//
+///////////////////////////////////////////////////////////////////////////////
+
+TocModel::TocModel(QObject * parent)
+ : model_(new TocTypeModel(parent)),
+ sorted_model_(new QSortFilterProxyModel(parent)),
+ is_sorted_(false), maxdepth_(0), mindepth_(0)
+{
+#if QT_VERSION >= 0x040300
+ sorted_model_->setSortLocaleAware(true);
+#endif
+ sorted_model_->setSourceModel(model_);
+}
+
+
+QAbstractItemModel * TocModel::model()
+{
+ if (is_sorted_)
+ return sorted_model_;
+ return model_;
+}
+
+
+QAbstractItemModel const * TocModel::model() const
+{
+ if (is_sorted_)
+ return sorted_model_;
+ return model_;
+}
+
+
+void TocModel::clear()
+{
+ model_->blockSignals(true);
+ model_->clear();
+ model_->blockSignals(false);
+}
+
+
+void TocModel::sort(bool sort_it)
+{
+ is_sorted_ = sort_it;
+ if (is_sorted_)
+ sorted_model_->sort(0);
+}
+