Beispiel #1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QModelIndex BookmarksModel::index(int row, int column, const QModelIndex& parent) const
{
  if (parent.isValid() && parent.column() != 0)
  { return QModelIndex(); }

  BookmarksItem* parentItem = getItem(parent);

  BookmarksItem* childItem = parentItem->child(row);
  if (childItem)
  { return createIndex(row, column, childItem); }
  else
  { return QModelIndex(); }
}
int BookmarksItem::index()
{
    BookmarksItem * parent = qobject_cast<BookmarksItem *>(this->parent());
    if(parent)
    {
        for(int i = 0; i < parent->childrenCount(); i++)
        {
            if(parent->child(i) == this)
            {
                return i;
            }
        }
    }
    return -1;
}