本文整理汇总了C++中QAbstractItemModel::hasChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemModel::hasChildren方法的具体用法?C++ QAbstractItemModel::hasChildren怎么用?C++ QAbstractItemModel::hasChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractItemModel
的用法示例。
在下文中一共展示了QAbstractItemModel::hasChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: model
QModelIndexList
PartitionLabelsView::getIndexesToDraw( const QModelIndex& parent ) const
{
QModelIndexList list;
QAbstractItemModel* modl = model();
if ( !modl )
return list;
for ( int row = 0; row < modl->rowCount( parent ); ++row )
{
QModelIndex index = modl->index( row, 0, parent );
//HACK: horrible special casing follows.
// To save vertical space, we choose to hide short instances of free space.
// Arbitrary limit: 10MB.
const qint64 maxHiddenB = 10000000;
if ( index.data( PartitionModel::IsFreeSpaceRole ).toBool() &&
index.data( PartitionModel::SizeRole ).toLongLong() < maxHiddenB )
continue;
if ( !modl->hasChildren( index ) || !m_extendedPartitionHidden )
list.append( index );
if ( modl->hasChildren( index ) )
list.append( getIndexesToDraw( index ) );
}
return list;
}
示例2: expandAllGroups
void PropertyBrowser::expandAllGroups()
{
QAbstractItemModel * model = this->model();
QModelIndexList indexes = model->match(model->index(0,0), Qt::DisplayRole, "*", -1, Qt::MatchWildcard|Qt::MatchRecursive);
for (QModelIndex index : indexes)
{
if (!index.isValid())
continue;
AbstractProperty * property = retrieveProperty(index);
if (property->isGroup() && model->hasChildren(index))
expand(index);
}
}
示例3: onRowsInserted
void PropertyBrowser::onRowsInserted(const QModelIndex & parentIndex, int first, int last)
{
QAbstractItemModel * model = this->model();
for (int i = first; i <= last; ++i)
{
QModelIndex index = model->index(i, 0, parentIndex);
if (!index.isValid())
continue;
AbstractProperty * property = retrieveProperty(index);
if (property->isGroup() && model->hasChildren(index))
expand(index);
}
}