Skip to content

Commit

Permalink
sort embedded layer by drawing order (fixes #7673)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Sep 4, 2013
1 parent 7120b1c commit e6a4f2f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
10 changes: 8 additions & 2 deletions scripts/update_ts_files.sh
Expand Up @@ -52,8 +52,6 @@ cleanup() {
trap "" EXIT
}

trap cleanup EXIT

PATH=$QTDIR/bin:$PATH

if type qmake-qt4 >/dev/null 2>&1; then
Expand All @@ -62,6 +60,11 @@ else
QMAKE=qmake
fi

if ! type pylupdate4 >/dev/null 2>&1; then
echo "pylupdate4 not found"
exit 1
fi

if type lupdate-qt4 >/dev/null 2>&1; then
LUPDATE=lupdate-qt4
else
Expand Down Expand Up @@ -93,10 +96,13 @@ while (( $# > 0 )); do
fi
done

trap cleanup EXIT

if [ -n "$exclude" -o -n "$add" ]; then
echo Saving excluded translations
tar $fast -cf i18n/qgis_ts.tar i18n/qgis_*.ts$exclude
fi

echo Updating python translations
cd python
pylupdate4 utils.py {console,pyplugin_installer}/*.{py,ui} -ts python-i18n.ts
Expand Down
19 changes: 18 additions & 1 deletion src/app/legend/qgslegend.cpp
Expand Up @@ -830,7 +830,8 @@ void QgsLegend::handleRightClickEvent( QTreeWidgetItem* item, const QPoint& posi

// properties goes on bottom of menu for consistency with normal ui standards
// e.g. kde stuff
theMenu.addAction( tr( "&Properties" ), QgisApp::instance(), SLOT( layerProperties() ) );
if ( lyr->layer() && QgsProject::instance()->layerIsEmbedded( lyr->layer()->id() ).isEmpty() )
theMenu.addAction( tr( "&Properties" ), QgisApp::instance(), SLOT( layerProperties() ) );

if ( li->parent() && !parentGroupEmbedded( li ) )
{
Expand Down Expand Up @@ -1383,6 +1384,14 @@ QList<QgsMapLayer *> QgsLegend::layers()
return ls;
}

static bool inReverseDrawingOrder( QgsLegendLayer *a, QgsLegendLayer *b )
{
if ( !a || !b )
return false;

return a->drawingOrder() > b->drawingOrder();
}

QList<QgsMapCanvasLayer> QgsLegend::canvasLayers()
{
QMap<int, QgsMapCanvasLayer> layers;
Expand Down Expand Up @@ -1412,6 +1421,10 @@ QList<QgsMapCanvasLayer> QgsLegend::canvasLayers()
{
int groupDrawingOrder = lgroup->drawingOrder();
QList<QgsLegendLayer*> groupLayers = lgroup->legendLayers();
if ( !mUpdateDrawingOrder )
{
qSort( groupLayers.begin(), groupLayers.end(), inReverseDrawingOrder );
}
for ( int i = groupLayers.size() - 1; i >= 0; --i )
{
QgsLegendLayer* ll = groupLayers.at( i );
Expand Down Expand Up @@ -1471,6 +1484,10 @@ void QgsLegend::setDrawingOrder( const QList<DrawingOrderInfo> &order )
{
group->setDrawingOrder( i );
QList<QgsLegendLayer*> groupLayers = group->legendLayers();
if ( !mUpdateDrawingOrder )
{
qSort( groupLayers.begin(), groupLayers.end(), inReverseDrawingOrder );
}
QList<QgsLegendLayer*>::iterator groupIt = groupLayers.begin();
for ( ; groupIt != groupLayers.end(); ++groupIt )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -8073,7 +8073,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
return;
}

mActionLayerProperties->setEnabled( true );
mActionLayerProperties->setEnabled( QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() );
mActionAddToOverview->setEnabled( true );
mActionZoomToLayer->setEnabled( true );

Expand Down
5 changes: 4 additions & 1 deletion src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -30,6 +30,7 @@
#include "qgsfeatureaction.h"
#include "qgslogger.h"
#include "qgsnetworkaccessmanager.h"
#include "qgsproject.h"

#include <QCloseEvent>
#include <QLabel>
Expand Down Expand Up @@ -687,6 +688,7 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
if ( !item )
return;

QgsMapLayer *layer = vectorLayer( item );
QgsVectorLayer *vlayer = vectorLayer( item );
QgsRasterLayer *rlayer = rasterLayer( item );
if ( vlayer == 0 && rlayer == 0 )
Expand Down Expand Up @@ -745,7 +747,8 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
mActionPopup->addAction( tr( "Clear highlights" ), this, SLOT( clearHighlights() ) );
mActionPopup->addAction( tr( "Highlight all" ), this, SLOT( highlightAll() ) );
mActionPopup->addAction( tr( "Highlight layer" ), this, SLOT( highlightLayer() ) );
mActionPopup->addAction( tr( "Layer properties..." ), this, SLOT( layerProperties() ) );
if ( layer && QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() )
mActionPopup->addAction( tr( "Layer properties..." ), this, SLOT( layerProperties() ) );
mActionPopup->addSeparator();
mActionPopup->addAction( tr( "Expand all" ), this, SLOT( expandAll() ) );
mActionPopup->addAction( tr( "Collapse all" ), this, SLOT( collapseAll() ) );
Expand Down

0 comments on commit e6a4f2f

Please sign in to comment.