QgsSymbolV2SelectorWidget::QgsSymbolV2SelectorWidget( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent ) : QgsPanelWidget( parent ) , mAdvancedMenu( nullptr ) , mVectorLayer( vl ) , mMapCanvas( nullptr ) { #ifdef Q_OS_MAC setWindowModality( Qt::WindowModal ); #endif mStyle = style; mSymbol = symbol; mPresentWidget = nullptr; setupUi( this ); // setup icons btnAddLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) ); btnRemoveLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) ); QIcon iconLock; iconLock.addFile( QgsApplication::iconPath( "locked.svg" ), QSize(), QIcon::Normal, QIcon::On ); iconLock.addFile( QgsApplication::iconPath( "locked.svg" ), QSize(), QIcon::Active, QIcon::On ); iconLock.addFile( QgsApplication::iconPath( "unlocked.svg" ), QSize(), QIcon::Normal, QIcon::Off ); iconLock.addFile( QgsApplication::iconPath( "unlocked.svg" ), QSize(), QIcon::Active, QIcon::Off ); btnLock->setIcon( iconLock ); btnDuplicate->setIcon( QIcon( QgsApplication::iconPath( "mActionDuplicateLayer.svg" ) ) ); btnUp->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) ); btnDown->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) ); model = new QStandardItemModel( layersTree ); // Set the symbol layersTree->setModel( model ); layersTree->setHeaderHidden( true ); QItemSelectionModel* selModel = layersTree->selectionModel(); connect( selModel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( layerChanged() ) ); loadSymbol( symbol, static_cast<SymbolLayerItem*>( model->invisibleRootItem() ) ); updatePreview(); connect( btnUp, SIGNAL( clicked() ), this, SLOT( moveLayerUp() ) ); connect( btnDown, SIGNAL( clicked() ), this, SLOT( moveLayerDown() ) ); connect( btnAddLayer, SIGNAL( clicked() ), this, SLOT( addLayer() ) ); connect( btnRemoveLayer, SIGNAL( clicked() ), this, SLOT( removeLayer() ) ); connect( btnLock, SIGNAL( clicked() ), this, SLOT( lockLayer() ) ); connect( btnDuplicate, SIGNAL( clicked() ), this, SLOT( duplicateLayer() ) ); connect( this, SIGNAL( symbolModified() ), this, SIGNAL( widgetChanged() ) ); updateUi(); // set symbol as active item in the tree QModelIndex newIndex = layersTree->model()->index( 0, 0 ); layersTree->setCurrentIndex( newIndex ); setPanelTitle( tr( "Symbol selector" ) ); }
void LayerTableView::createActions() { LayerManager* pManager = LayerManager::getInstance(); deleteAct = new QAction(tr("Delete"), contextMenu); connect(deleteAct, SIGNAL(triggered()), pManager, SLOT(deleteLayer())); contextMenu->addAction(deleteAct); duplicateAct = new QAction(tr("Duplicate"), contextMenu); connect(duplicateAct, SIGNAL(triggered()), pManager, SLOT(duplicateLayer())); contextMenu->addAction(duplicateAct); }