Skip to content
Permalink
Browse files

[fix #19868] fix paste style

  • Loading branch information
3nids committed Sep 17, 2018
1 parent 84d2376 commit 0296c272de7f449e6d0e6a3dd46af3909a428311
Showing with 8 additions and 4 deletions.
  1. +1 −1 src/app/qgsapplayertreeviewmenuprovider.cpp
  2. +7 −3 src/app/qgsmaplayerstylecategoriesmodel.cpp
@@ -363,7 +363,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
QIcon icon = model->data( index, Qt::DecorationRole ).value<QIcon>();
QAction *copyAction = new QAction( icon, name, pasteStyleMenu );
copyAction->setToolTip( tooltip );
connect( copyAction, &QAction::triggered, this, [ = ]() {app->copyStyle( layer, category );} );
connect( copyAction, &QAction::triggered, this, [ = ]() {app->pasteStyle( layer, category );} );
pasteStyleMenu->addAction( copyAction );
if ( category == QgsMapLayer::AllStyleCategories )
pasteStyleMenu->addSeparator();
@@ -63,12 +63,16 @@ QVariant QgsMapLayerStyleCategoriesModel::data( const QModelIndex &index, int ro
if ( !index.isValid() || index.row() >= rowCount() )
return QVariant();

QgsMapLayer::StyleCategory category = mCategoryList.at( index.row() );
QgsMapLayer::StyleCategory category = mCategoryList.at( index.row() + ( mShowAllCategories ? 0 : 1 ) );

if ( role == Qt::UserRole )
{
return category;
}
if ( role == Qt::CheckStateRole )
{
return mCategories.testFlag( category ) ? Qt::Checked : Qt::Unchecked;
}

switch ( category )
{
@@ -226,7 +230,7 @@ bool QgsMapLayerStyleCategoriesModel::setData( const QModelIndex &index, const Q

if ( role == Qt::CheckStateRole )
{
QgsMapLayer::StyleCategory category = mCategoryList.at( index.row() );
QgsMapLayer::StyleCategory category = data( index, Qt::UserRole ).value<QgsMapLayer::StyleCategory>();
if ( value.value<Qt::CheckState>() == Qt::Checked )
{
mCategories |= category;
@@ -246,5 +250,5 @@ bool QgsMapLayerStyleCategoriesModel::setData( const QModelIndex &index, const Q

Qt::ItemFlags QgsMapLayerStyleCategoriesModel::flags( const QModelIndex & ) const
{
return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsUserCheckable;
}

0 comments on commit 0296c27

Please sign in to comment.
You can’t perform that action at this time.