本文整理汇总了C++中ItemData::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemData::insert方法的具体用法?C++ ItemData::insert怎么用?C++ ItemData::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemData
的用法示例。
在下文中一共展示了ItemData::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/** Maps to what groups the source row belongs by returning the data of those groups.
*
* @returns a list of data for the rows the argument belongs to. In common cases this list will
* contain only one entry. An empty list means that the source item will be placed in the root of
* this proxyModel. There is no support for hiding source items.
*
* Group data can be pre-loaded in the return value so it's added to the cache maintained by this
* class. This is required if you want to have data that is not present in the source model.
*/
QList<RowData>
QtGroupingProxy::belongsTo( const QModelIndex &idx )
{
//qDebug() << __FILE__ << __FUNCTION__;
QList<RowData> rowDataList;
//get all the data for this index from the model
ItemData itemData = sourceModel()->itemData( idx );
QMapIterator<int, QVariant> i( itemData );
while( i.hasNext() )
{
i.next();
int role = i.key();
QVariant variant = i.value();
// qDebug() << "role " << role << " : (" << variant.typeName() << ") : "<< variant;
if( variant.type() == QVariant::List )
{
//a list of variants get's expanded to multiple rows
QVariantList list = variant.toList();
for( int i = 0; i < list.length(); i++ )
{
//take an existing row data or create a new one
RowData rowData = (rowDataList.count() > i) ? rowDataList.takeAt( i )
: RowData();
//we only gather data for the first column
ItemData indexData = rowData.contains( 0 ) ? rowData.take( 0 ) : ItemData();
indexData.insert( role, list.value( i ) );
rowData.insert( 0, indexData );
//for the grouped column the data should not be gathered from the children
//this will allow filtering on the content of this column with a
//QSortFilterProxyModel
rowData.insert( m_groupedColumn, indexData );
rowDataList.insert( i, rowData );
}
}
else if( !variant.isNull() )
{
//it's just a normal item. Copy all the data and break this loop.
RowData rowData;
rowData.insert( 0, itemData );
rowDataList << rowData;
break;
}
}
return rowDataList;
}