Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot rename layers in composer legend #17241

Closed
qgib opened this issue Aug 15, 2013 · 16 comments
Closed

Cannot rename layers in composer legend #17241

qgib opened this issue Aug 15, 2013 · 16 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks
Milestone

Comments

@qgib
Copy link
Contributor

qgib commented Aug 15, 2013

Author Name: Giovanni Manghi (@gioman)
Original Redmine Issue: 8473
Affected QGIS version: master
Redmine category:map_composer/printing
Assignee: Marco Hugentobler


It seems a regression: in the print composer legend the name of rasters/wms layers cannot be changed. The dialog shows, it allows enter a new name but the operation has no effect. Works ok on 1.8.


@qgib
Copy link
Contributor Author

qgib commented Aug 15, 2013

Author Name: Giovanni Manghi (@gioman)


I see another issue, this time only on Linux. See Attached screenshots.

On Windows if in the composer legend there is vector with "single symbol" symbology, then the (one) symbology class has no text associated, but this can be edited.

On Linux in the same situation, the (one) symbology class is given the layer name by default, and this cannot be edited.


  • 6163 was configured as 12.png
  • 6164 was configured as 22.png
  • 6165 was configured as 11.png

@qgib
Copy link
Contributor Author

qgib commented Aug 16, 2013

Author Name: Salvatore Larosa (@slarosa)


I am not fairly sure but this patch has worked for me (please anyone who knows better the composer code might reviews it ?):

diff --git a/src/app/composer/qgscomposerlegendwidget.cpp b/src/app/composer/qgscomposerlegendwidget.cpp
index 613d394..5032ab7 100644
--- a/src/app/composer/qgscomposerlegendwidget.cpp
+++ b/src/app/composer/qgscomposerlegendwidget.cpp
@@ -740,8 +740,8 @@ void QgsComposerLegendWidget::on_mEditPushButton_clicked()
   QgsComposerLegendItemDialog itemDialog( currentItem );
   if ( itemDialog.exec() == QDialog::Accepted )
   {
-    currentItem->setUserText( itemDialog.itemText() );
-    mLegend->model()->updateItemText( currentItem );
+    currentItem->setText( itemDialog.itemText() );
+    //mLegend->model()->updateItemText( currentItem );
   }
 
   mLegend->beginCommand( tr( "Legend item edited" ) );

@qgib
Copy link
Contributor Author

qgib commented Aug 16, 2013

Author Name: Giovanni Manghi (@gioman)


  • pull_request_patch_supplied was changed from 0 to 1

@qgib
Copy link
Contributor Author

qgib commented Aug 18, 2013

Author Name: Anita Graser (@anitagraser)


For me, this issue is not limited to raster layers. (Using today's OSGeo4W nightly - code rev 4408a8b.)

In a project with only one polygon layer, I can only rename the upper level item in the print composer legend - but not the sub-level item.


  • subject was changed from Cannot rename raster layers in composer legend to Cannot rename (raster) layers in composer legend

@qgib
Copy link
Contributor Author

qgib commented Aug 19, 2013

Author Name: Giovanni Manghi (@gioman)


  • subject was changed from Cannot rename (raster) layers in composer legend to Cannot rename layers in composer legend

@qgib
Copy link
Contributor Author

qgib commented Aug 19, 2013

Author Name: René-Luc ReLuc (@rldhont)


Thanks Salvatore for your patch, but it changes the way to manage text for all the layers and not only for raster layers.

I proposed this patch :

index 29b86f5..d958676 100644
--- a/src/core/composer/qgslegendmodel.cpp
+++ b/src/core/composer/qgslegendmodel.cpp
@@ -380,10 +380,9 @@ void QgsLegendModel::updateLayer( QStandardItem* layerItem )
     QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance()->mapLayer( lItem->layerID() );
     if ( mapLayer )
     {
-      QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
-
       updateLayerItemText( lItem );
 
+      QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
       if ( vLayer )
       {
         addVectorLayerItemsV2( lItem, vLayer );
@@ -406,11 +405,9 @@ void QgsLegendModel::updateLayerItemText( QStandardItem* layerItem )
   QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance()->mapLayer( lItem->layerID() );
   if ( !mapLayer ) return;
 
-  QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
-  if ( !vLayer ) return;
-
   QString label = lItem->userText().isEmpty() ? mapLayer->name() : lItem->userText();
 
+  QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
   if ( vLayer && lItem->showFeatureCount() )
   {
     label += QString( " [%1]" ).arg( vLayer->featureCount() );


  • assigned_to_id was configured as René-Luc ReLuc

@qgib
Copy link
Contributor Author

qgib commented Aug 19, 2013

Author Name: Salvatore Larosa (@slarosa)


Hi René, sadly I am not a C++ expert :-( so my patch might not be correct.

Anyway, I did try your patch but renaming sub-level has not worked for me, I see the same issue as Anita.
For raster layers works fine!

Thanks.

@qgib
Copy link
Contributor Author

qgib commented Aug 20, 2013

Author Name: René-Luc ReLuc (@rldhont)


I have completed my patch and I proposed it through this pull request
#824


  • done_ratio was changed from 0 to 90

@qgib
Copy link
Contributor Author

qgib commented Aug 22, 2013

Author Name: René-Luc ReLuc (@rldhont)


Hi Radim,

I assigne this issue to you for reviewing my patch.
Marco wrote that you did a lot of work on composer legend.

Regards,


  • assigned_to_id was changed from René-Luc ReLuc to Radim Blazek

@qgib
Copy link
Contributor Author

qgib commented Aug 22, 2013

Author Name: Radim Blazek (@blazek)


I am offline until September 3, please ask someone else to apply the patch.

@qgib
Copy link
Contributor Author

qgib commented Aug 22, 2013

Author Name: Marco Hugentobler (@mhugent)


Ok, in that case the ticket is assigned to me.


  • assigned_to_id was changed from Radim Blazek to Marco Hugentobler

@qgib
Copy link
Contributor Author

qgib commented Aug 22, 2013

Author Name: Marco Hugentobler (@mhugent)


The changes are fine and the patch is applied in master branch. Thanks rldhont for fixing this issue!


  • status_id was changed from Open to Closed

@qgib
Copy link
Contributor Author

qgib commented Sep 3, 2013

Author Name: Lene Fischer (@LeneFischer)


I have just downloaded weekly (03-09-13) Still the same problem. Is the correction not in the weekly yet?
Regards
Lene Fischer

@qgib
Copy link
Contributor Author

qgib commented Sep 3, 2013

Author Name: Giovanni Manghi (@gioman)


Lene Fischer wrote:

I have just downloaded weekly (03-09-13) Still the same problem. Is the correction not in the weekly yet?
Regards
Lene Fischer

it works fine here on Linux.

@qgib
Copy link
Contributor Author

qgib commented Sep 3, 2013

Author Name: Salvatore Larosa (@slarosa)


Hi Lene,

Which is the revision code ?
The fix has been introduced in 7f8b259, so I think the last weekly should include that fix.

@qgib
Copy link
Contributor Author

qgib commented Sep 3, 2013

Author Name: René-Luc ReLuc (@rldhont)


I've tested a today compliation on Ubuntu, qgis is named fef175b, and it works.

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks labels May 24, 2019
@qgib qgib added this to the Version 2.0.0 milestone May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks
Projects
None yet
Development

No branches or pull requests

1 participant