本文整理汇总了C++中TaskItem::childAt方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskItem::childAt方法的具体用法?C++ TaskItem::childAt怎么用?C++ TaskItem::childAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskItem
的用法示例。
在下文中一共展示了TaskItem::childAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cut
QModelIndex TreeModel::cut(const QModelIndex &index)
{
if (!index.isValid())
return index;
delete cutItem;
cutItem = itemForIndex(index);
Q_ASSERT(cutItem);
TaskItem *parent = cutItem->parent();
Q_ASSERT(parent);
int row = parent->rowOfChild(cutItem);
Q_ASSERT(row == index.row());
beginRemoveRows(index.parent(), row, row);
TaskItem *child = parent->takeChild(row);
endRemoveRows();
Q_ASSERT(child == cutItem);
child = 0; // Silence compiler unused variable warning
if (row > 0) {
--row;
return createIndex(row, 0, parent->childAt(row));
}
if (parent != rootItem) {
TaskItem *grandParent = parent->parent();
Q_ASSERT(grandParent);
return createIndex(grandParent->rowOfChild(parent), 0, parent);
}
return QModelIndex();
}
示例2: index
QModelIndex TreeModel::index(int row, int column,
const QModelIndex &parent) const
{
if (!rootItem || row < 0 || column < 0 || column >= ColumnCount
|| (parent.isValid() && parent.column() != 0))
return QModelIndex();
TaskItem *parentItem = itemForIndex(parent);
Q_ASSERT(parentItem);
if (TaskItem *item = parentItem->childAt(row))
return createIndex(row, column, item);
return QModelIndex();
}
示例3: demote
QModelIndex TreeModel::demote(const QModelIndex &index)
{
if (!index.isValid())
return index;
TaskItem *item = itemForIndex(index);
Q_ASSERT(item);
TaskItem *parent = item->parent();
Q_ASSERT(parent);
int row = parent->rowOfChild(item);
if (row == 0)
return index; // No preceding sibling to move this under
TaskItem *child = parent->takeChild(row);
Q_ASSERT(child == item);
TaskItem *sibling = parent->childAt(row - 1);
Q_ASSERT(sibling);
sibling->addChild(child);
QModelIndex newIndex = createIndex(sibling->childCount() - 1, 0,
child);
emit dataChanged(newIndex, newIndex);
return newIndex;
}