* Full author contact details are available in file CREDITS.
*/
+#include <config.h>
+
#include "TocModel.h"
#include "debug.h"
namespace lyx {
namespace frontend {
-\r
+
TocModel::TocModel(TocBackend::Toc const & toc)
{
populate(toc);
return *this;
}
-\r
+
TocIterator const TocModel::tocIterator(QModelIndex const & index) const
{
BOOST_ASSERT(map_it != toc_map_.end());
return map_it->second;
}
-\r
+
QModelIndex const TocModel::modelIndex(TocIterator const & it) const
{
return map_it->second;
}
-\r
+
void TocModel::clear()
{
TocIterator iter = toc.begin();
TocIterator end = toc.end();
- insertColumns(0, 1);
+ insertColumns(0, 1);
while (iter != end) {
- if (iter->depth() >= 0) {
+ if (iter->isValid()) {
current_row = rowCount();
insertRows(current_row, 1);
top_level_item = QStandardItemModel::index(current_row, 0);
//setData(top_level_item, toqstr(iter->str()));
setData(top_level_item, toqstr(iter->str()), Qt::DisplayRole);
- toc_map_.insert(make_pair(top_level_item, iter));
- model_map_.insert(make_pair(iter, top_level_item));
+ toc_map_[top_level_item] = iter;
+ model_map_[iter] = top_level_item;
lyxerr[Debug::GUI]
<< "Toc: at depth " << iter->depth()
int current_row;
QModelIndex child_item;
- insertColumns(0, 1, parent);
+ insertColumns(0, 1, parent);
while (iter != end) {
++iter;
--iter;
return;
}
-// if (iter->depth() > curdepth) {
-// return;
-// }
current_row = rowCount(parent);
insertRows(current_row, 1, parent);
child_item = QStandardItemModel::index(current_row, 0, parent);
//setData(child_item, toqstr(iter->str()));
setData(child_item, toqstr(iter->str()), Qt::DisplayRole);
- toc_map_.insert(make_pair(child_item, iter));
- model_map_.insert(make_pair(iter, child_item));
-
-// lyxerr[Debug::GUI]
-// << "Toc: at depth " << iter->depth()
-// << ", added item " << iter->str()
-// << endl;
-
+ toc_map_[child_item] = iter;
+ model_map_[iter] = child_item;
populate(iter, end, child_item);
}
}
-\r
+
} // namespace frontend
} // namespace lyx
+
+#include "TocModel_moc.cpp"