On Mon, Apr 17, 2006 at 07:54:04PM +0200, Abdelrazak Younes wrote:
> +void TocModel::populate(toc::Toc const & toc_list)
> +{
> +     clear();
> +
> +     if (toc_list.empty())
> +             return;
> +
> +     int current_row;
> +     QModelIndex top_level_item;
> +
> +     toc::Toc::const_iterator iter = toc_list.begin();
> +     toc::Toc::const_iterator end = toc_list.end();
> +
> +    insertColumns(0, 1);

Indentation.

> +void TocModel::populate(toc::Toc::const_iterator & iter,
> +                                             toc::Toc::const_iterator const 
> & end,
> +                                             QModelIndex const & parent)
> +{
> +     int curdepth = iter->depth + 1;
> +     int current_row;
> +     QModelIndex child_item;
> +
> +    insertColumns(0, 1, parent);

And here.

> +             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);
> +             item_map_.insert(make_pair(child_item, *iter));
> +             index_map_.insert(make_pair(
> +                     iter->str.substr(iter->str.find(' ') + 1), child_item));

I'd find 

+               index_map_[iter->str.substr(iter->str.find(' ') + 1)] = 
child_item;

more readable.

Apart from that I never completely understood what invalidates a
QModelIndex. All I know that it is very prudent not to rely on
its stability, so maybe that's not the best approach.

Andre'

Reply via email to