本文整理汇总了C++中TaskItem::rowOfChild方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskItem::rowOfChild方法的具体用法?C++ TaskItem::rowOfChild怎么用?C++ TaskItem::rowOfChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskItem
的用法示例。
在下文中一共展示了TaskItem::rowOfChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: promote
QModelIndex TreeModel::promote(const QModelIndex &index)
{
if (!index.isValid())
return index;
TaskItem *item = itemForIndex(index);
Q_ASSERT(item);
TaskItem *parent = item->parent();
Q_ASSERT(parent);
if (parent == rootItem)
return index; // Already a top-level item
int row = parent->rowOfChild(item);
TaskItem *child = parent->takeChild(row);
Q_ASSERT(child == item);
TaskItem *grandParent = parent->parent();
Q_ASSERT(grandParent);
row = grandParent->rowOfChild(parent) + 1;
grandParent->insertChild(row, child);
QModelIndex newIndex = createIndex(row, 0, child);
emit dataChanged(newIndex, newIndex);
return newIndex;
}
示例3: announceItemChanged
void TreeModel::announceItemChanged(TaskItem *item)
{
if (item == rootItem)
return;
TaskItem *parent = item->parent();
Q_ASSERT(parent);
int row = parent->rowOfChild(item);
QModelIndex startIndex = createIndex(row, static_cast<int>(Name),
item);
QModelIndex endIndex = createIndex(row, static_cast<int>(Total),
item);
emit dataChanged(startIndex, endIndex);
// Update the parent & parent's parent etc too
announceItemChanged(parent);
}
示例4: paste
QModelIndex TreeModel::paste(const QModelIndex &index)
{
if (!index.isValid() || !cutItem)
return index;
TaskItem *sibling = itemForIndex(index);
Q_ASSERT(sibling);
TaskItem *parent = sibling->parent();
Q_ASSERT(parent);
int row = parent->rowOfChild(sibling) + 1;
beginInsertRows(index.parent(), row, row);
parent->insertChild(row, cutItem);
TaskItem *child = cutItem;
cutItem = 0;
endInsertRows();
return createIndex(row, 0, child);
}
示例5: 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;
}