Skip to content

Commit

Permalink
[fix #19868] fix paste style
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Sep 17, 2018
1 parent 84d2376 commit 0296c27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/qgsapplayertreeviewmenuprovider.cpp
Expand Up @@ -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();
Expand Down
10 changes: 7 additions & 3 deletions src/app/qgsmaplayerstylecategoriesmodel.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
Expand All @@ -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.