本文整理汇总了C++中SymbolLayerItem::rowCount方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolLayerItem::rowCount方法的具体用法?C++ SymbolLayerItem::rowCount怎么用?C++ SymbolLayerItem::rowCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolLayerItem
的用法示例。
在下文中一共展示了SymbolLayerItem::rowCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveLayerByOffset
void QgsSymbolSelectorWidget::moveLayerByOffset( int offset )
{
SymbolLayerItem *item = currentLayerItem();
if ( !item )
return;
int row = item->row();
SymbolLayerItem *parent = static_cast<SymbolLayerItem *>( item->parent() );
QgsSymbol *parentSymbol = parent->symbol();
int layerIdx = parent->rowCount() - row - 1;
// switch layers
QgsSymbolLayer *tmpLayer = parentSymbol->takeSymbolLayer( layerIdx );
parentSymbol->insertSymbolLayer( layerIdx - offset, tmpLayer );
QList<QStandardItem *> rowItems = parent->takeRow( row );
parent->insertRows( row + offset, rowItems );
parent->updatePreview();
QModelIndex newIdx = rowItems[ 0 ]->index();
layersTree->setCurrentIndex( newIdx );
updatePreview();
updateUi();
}
示例2: addLayer
void QgsSymbolSelectorWidget::addLayer()
{
QModelIndex idx = layersTree->currentIndex();
if ( !idx.isValid() )
return;
int insertIdx = -1;
SymbolLayerItem *item = static_cast<SymbolLayerItem *>( model->itemFromIndex( idx ) );
if ( item->isLayer() )
{
insertIdx = item->row();
item = static_cast<SymbolLayerItem *>( item->parent() );
}
QgsSymbol *parentSymbol = item->symbol();
// save data-defined values at marker level
QgsProperty ddSize( parentSymbol->type() == QgsSymbol::Marker
? static_cast<QgsMarkerSymbol *>( parentSymbol )->dataDefinedSize()
: QgsProperty() );
QgsProperty ddAngle( parentSymbol->type() == QgsSymbol::Marker
? static_cast<QgsMarkerSymbol *>( parentSymbol )->dataDefinedAngle()
: QgsProperty() );
QgsProperty ddWidth( parentSymbol->type() == QgsSymbol::Line
? static_cast<QgsLineSymbol *>( parentSymbol )->dataDefinedWidth()
: QgsProperty() );
QgsSymbolLayer *newLayer = QgsApplication::symbolLayerRegistry()->defaultSymbolLayer( parentSymbol->type() );
if ( insertIdx == -1 )
parentSymbol->appendSymbolLayer( newLayer );
else
parentSymbol->insertSymbolLayer( item->rowCount() - insertIdx, newLayer );
// restore data-defined values at marker level
if ( ddSize )
static_cast<QgsMarkerSymbol *>( parentSymbol )->setDataDefinedSize( ddSize );
if ( ddAngle )
static_cast<QgsMarkerSymbol *>( parentSymbol )->setDataDefinedAngle( ddAngle );
if ( ddWidth )
static_cast<QgsLineSymbol *>( parentSymbol )->setDataDefinedWidth( ddWidth );
SymbolLayerItem *newLayerItem = new SymbolLayerItem( newLayer );
item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
item->updatePreview();
layersTree->setCurrentIndex( model->indexFromItem( newLayerItem ) );
updateUi();
updatePreview();
}
示例3: removeLayer
void QgsSymbolSelectorWidget::removeLayer()
{
SymbolLayerItem *item = currentLayerItem();
int row = item->row();
SymbolLayerItem *parent = static_cast<SymbolLayerItem *>( item->parent() );
int layerIdx = parent->rowCount() - row - 1; // IMPORTANT
QgsSymbol *parentSymbol = parent->symbol();
QgsSymbolLayer *tmpLayer = parentSymbol->takeSymbolLayer( layerIdx );
parent->removeRow( row );
parent->updatePreview();
QModelIndex newIdx = parent->child( 0 )->index();
layersTree->setCurrentIndex( newIdx );
updateUi();
updatePreview();
//finally delete the removed layer pointer
delete tmpLayer;
}
示例4: duplicateLayer
void QgsSymbolSelectorWidget::duplicateLayer()
{
QModelIndex idx = layersTree->currentIndex();
if ( !idx.isValid() )
return;
SymbolLayerItem *item = static_cast<SymbolLayerItem *>( model->itemFromIndex( idx ) );
if ( !item->isLayer() )
return;
QgsSymbolLayer *source = item->layer();
int insertIdx = item->row();
item = static_cast<SymbolLayerItem *>( item->parent() );
QgsSymbol *parentSymbol = item->symbol();
QgsSymbolLayer *newLayer = source->clone();
if ( insertIdx == -1 )
parentSymbol->appendSymbolLayer( newLayer );
else
parentSymbol->insertSymbolLayer( item->rowCount() - insertIdx, newLayer );
SymbolLayerItem *newLayerItem = new SymbolLayerItem( newLayer );
item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
if ( newLayer->subSymbol() )
{
loadSymbol( newLayer->subSymbol(), newLayerItem );
layersTree->setExpanded( newLayerItem->index(), true );
}
item->updatePreview();
layersTree->setCurrentIndex( model->indexFromItem( newLayerItem ) );
updateUi();
updatePreview();
}