Skip to content
Permalink
Browse files
Remove the legend from the application completely.
  • Loading branch information
wonder-sk committed May 21, 2014
1 parent d26bdf7 commit 55c4ae57559bbbfe90e0aeb201daf6f443a71386
@@ -31,7 +31,6 @@ class QgsGPSConnection;
class QgsGPSTrackerThread;
struct QgsGPSInformation;

class QgsLegend;
class QFile;
class QColor;

@@ -284,8 +284,8 @@ void QgsAppLegendInterface::onAddedChildren(QgsLayerTreeNode* node, int indexFro
emit itemAdded( mLayerTreeView->layerTreeModel()->node2index(child) );

// also notify about all children
if (QgsLayerTree::isGroup(child))
onAddedChildren(child, 0, child->children().count());
if (QgsLayerTree::isGroup(child) && child->children().count())
onAddedChildren(child, 0, child->children().count()-1);
}
}

@@ -113,6 +113,7 @@
#include "qgscredentialdialog.h"
#include "qgscursors.h"
#include "qgscustomization.h"
#include "qgscustomlayerorderwidget.h"
#include "qgscustomprojectiondialog.h"
#include "qgsdatasourceuri.h"
#include "qgsdatumtransformdialog.h"
@@ -142,10 +143,6 @@
#include "qgslayertreeutils.h"
#include "qgslayertreeview.h"
#include "qgslayertreeviewdefaultactions.h"
#include "qgslegend.h"
#include "qgslegendgroup.h"
#include "qgslayerorder.h"
#include "qgslegendlayer.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayer.h"
@@ -556,11 +553,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mMapCanvas->setFocus();

mLayerTreeView = new QgsLayerTreeView( this );

// "theMapLegend" used to find this canonical instance later
mMapLegend = new QgsLegend( mMapCanvas, this, "theMapLegend" );

mMapLayerOrder = new QgsLayerOrder( mMapLegend, this, "theMapLayerOrder" );
mLayerTreeView->setObjectName("theLayerTreeView"); // "theLayerTreeView" used to find this canonical instance later

// create undo widget
mUndoWidget = new QgsUndoWidget( NULL, mMapCanvas );
@@ -574,7 +567,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
createCanvasTools();
mMapCanvas->freeze();
initLayerTreeView();
initLegend();
createOverview();
createMapTips();
createDecorations();
@@ -822,7 +814,6 @@ QgisApp::QgisApp( )
mMapCanvas = new QgsMapCanvas();
mMapCanvas->freeze();
mLayerTreeView = new QgsLayerTreeView( this );
mMapLegend = new QgsLegend( mMapCanvas );
mUndoWidget = new QgsUndoWidget( NULL, mMapCanvas );
mInfoBar = new QgsMessageBar( centralWidget() );
// More tests may need more members to be initialized
@@ -2216,8 +2207,10 @@ QgsMessageBar* QgisApp::messageBar()

void QgisApp::initLayerTreeView()
{
mLayerTreeDock = new QDockWidget( tr( "Layers NEW" ), this );
mLayerTreeDock->setObjectName( "LayersNEW" );
mLayerTreeView->setWhatsThis( tr( "Map legend that displays all the layers currently on the map canvas. Click on the check box to turn a layer on or off. Double click on a layer in the legend to customize its appearance and set other properties." ) );

mLayerTreeDock = new QDockWidget( tr( "Layers" ), this );
mLayerTreeDock->setObjectName( "Layers" );
mLayerTreeDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );

QgsLayerTreeModel* model = new QgsLayerTreeModel( QgsProject::instance()->layerTreeRoot(), this );
@@ -2233,8 +2226,28 @@ void QgisApp::initLayerTreeView()
mLayerTreeDock->setWidget( mLayerTreeView );
addDockWidget( Qt::LeftDockWidgetArea, mLayerTreeDock );

mLayerTreeCanvasBridge = new QgsLayerTreeMapCanvasBridge( QgsProject::instance()->layerTreeRoot(), mMapCanvas );
mLayerTreeCanvasBridge->setParent(this);
mLayerTreeCanvasBridge = new QgsLayerTreeMapCanvasBridge( QgsProject::instance()->layerTreeRoot(), mMapCanvas, this );

mMapLayerOrder = new QgsCustomLayerOrderWidget(mLayerTreeCanvasBridge, this);
mMapLayerOrder->setObjectName("theMapLayerOrder");

QCheckBox *orderCb = new QCheckBox( tr( "Control rendering order" ) );
orderCb->setChecked( false );

mMapLayerOrder->setWhatsThis( tr( "Map layer list that displays all layers in drawing order." ) );
mLayerOrderDock = new QDockWidget( tr( "Layer order" ), this );
mLayerOrderDock->setObjectName( "LayerOrder" );
mLayerOrderDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );

QWidget* w = new QWidget( this );
QVBoxLayout* l = new QVBoxLayout;
l->setMargin( 0 );
l->addWidget( mMapLayerOrder );
l->addWidget( orderCb );
w->setLayout( l );
mLayerOrderDock->setWidget( w );
addDockWidget( Qt::LeftDockWidgetArea, mLayerOrderDock );
mLayerOrderDock->hide();
}


@@ -2262,51 +2275,6 @@ void QgisApp::layerTreeViewCurrentChanged(const QModelIndex& current, const QMod
}


void QgisApp::initLegend()
{
mMapLegend->setWhatsThis( tr( "Map legend that displays all the layers currently on the map canvas. Click on the check box to turn a layer on or off. Double click on a layer in the legend to customize its appearance and set other properties." ) );
mLegendDock = new QDockWidget( tr( "Layers" ), this );
mLegendDock->setObjectName( "Legend" );
mLegendDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );

QCheckBox *orderCb = new QCheckBox( tr( "Control rendering order" ) );
orderCb->setChecked( false );

connect( orderCb, SIGNAL( toggled( bool ) ), mMapLegend, SLOT( unsetUpdateDrawingOrder( bool ) ) );
connect( mMapLegend, SIGNAL( updateDrawingOrderUnchecked( bool ) ), orderCb, SLOT( setChecked( bool ) ) );

QWidget *w = new QWidget( this );
QLayout *l = new QVBoxLayout;
l->setMargin( 0 );
l->addWidget( mMapLegend );
w->setLayout( l );
mLegendDock->setWidget( w );
addDockWidget( Qt::LeftDockWidgetArea, mLegendDock );

// add to the Panel submenu
mPanelMenu->addAction( mLegendDock->toggleViewAction() );

mMapLayerOrder->setWhatsThis( tr( "Map layer list that displays all layers in drawing order." ) );
mLayerOrderDock = new QDockWidget( tr( "Layer order" ), this );
mLayerOrderDock->setObjectName( "LayerOrder" );
mLayerOrderDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );

w = new QWidget( this );
l = new QVBoxLayout;
l->setMargin( 0 );
l->addWidget( mMapLayerOrder );
l->addWidget( orderCb );
w->setLayout( l );
mLayerOrderDock->setWidget( w );
addDockWidget( Qt::LeftDockWidgetArea, mLayerOrderDock );
mLayerOrderDock->hide();

// add to the Panel submenu
mPanelMenu->addAction( mLayerOrderDock->toggleViewAction() );

return;
}

void QgisApp::createMapTips()
{
// Set up the timer for maptips. The timer is reset everytime the mouse is moved
@@ -9504,7 +9472,7 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml )
else
{
vlp = new QgsVectorLayerProperties( vlayer, this );
connect( vlp, SIGNAL( refreshLegend( QString, QgsLegendItem::Expansion ) ), mLayerTreeView, SLOT( refreshLayerSymbology( QString ) ) );
connect( vlp, SIGNAL( refreshLegend( QString ) ), mLayerTreeView, SLOT( refreshLayerSymbology( QString ) ) );
}

if ( vlp->exec() )
@@ -44,12 +44,11 @@ class QgsComposer;
class QgsComposerView;
class QgsComposerManager;
class QgsContrastEnhancement;
class QgsCustomLayerOrderWidget;
class QgsGeometry;
class QgsFeature;
class QgsLayerTreeMapCanvasBridge;
class QgsLayerTreeView;
class QgsLegend;
class QgsLayerOrder;
class QgsMapCanvas;
class QgsMapLayer;
class QgsMapTip;
@@ -1327,7 +1326,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void createStatusBar();
void setupConnections();
void initLayerTreeView();
void initLegend();
void createOverview();
void createCanvasTools();
void createMapTips();
@@ -1371,7 +1369,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

// docks ------------------------------------------
QDockWidget *mLayerTreeDock;
QDockWidget *mLegendDock;
QDockWidget *mLayerOrderDock;
QDockWidget *mOverviewDock;
QDockWidget *mpGpsDock;
@@ -1473,10 +1470,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsLayerTreeView* mLayerTreeView;
//! Helper class that connects layer tree with map canvas
QgsLayerTreeMapCanvasBridge* mLayerTreeCanvasBridge;
//! Table of contents (legend) for the map
QgsLegend *mMapLegend;
//! Table of contents (legend) to order layers of the map
QgsLayerOrder *mMapLayerOrder;
QgsCustomLayerOrderWidget* mMapLayerOrder;
//! Cursor for the overview map
QCursor *mOverviewMapCursor;
//! scale factor
@@ -35,7 +35,6 @@
#include "qgsmapcanvas.h"
#include "qgsproject.h"
#include "qgslayertreeview.h"
#include "qgslegend.h"
#include "qgsshortcutsmanager.h"
#include "qgsattributedialog.h"
#include "qgsfield.h"
@@ -21,7 +21,6 @@
#include "qgsapplication.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayerregistry.h"
#include "qgslegend.h"
#include "qgsvectorlayer.h"

#include "qgsmaptoolselectutils.h"
@@ -20,7 +20,6 @@

#include "qgsmaptoollabel.h"
#include "qgsrectangle.h"
#include "qgslegend.h"
#include "qgscoordinatetransform.h"

class QgsRubberBand;
@@ -22,7 +22,6 @@
#include "qgisapp.h"
#include "qgisappstylesheet.h"
#include "qgshighlight.h"
#include "qgslegend.h"
#include "qgsmapcanvas.h"
#include "qgsmaprenderer.h"
#include "qgsgenericprojectionselector.h"
@@ -33,7 +33,6 @@
#include "qgslabeldialog.h"
#include "qgslabelinggui.h"
#include "qgslabel.h"
#include "qgslegenditem.h"
#include "qgsgenericprojectionselector.h"
#include "qgslogger.h"
#include "qgsmaplayerregistry.h"
@@ -573,7 +572,7 @@ void QgsVectorLayerProperties::apply()
layer->setSimplifyMethod( simplifyMethod );

// update symbology
emit refreshLegend( layer->id(), QgsLegendItem::DontChange );
emit refreshLegend( layer->id() );

layer->triggerRepaint();
// notify the project we've made a change
@@ -27,7 +27,6 @@
#include "qgsdelattrdialog.h"
#include "qgsattributetypedialog.h"
#include "qgsfield.h"
#include "qgslegenditem.h"
#include "qgsmapcanvas.h"
#include "qgscontexthelp.h"
#include "qgsexpressionbuilderdialog.h"
@@ -123,7 +122,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private

/** emitted when changes to layer were saved to update legend */
void refreshLegend( QString layerID, bool expandItem );
void refreshLegend( QString layerID, QgsLegendItem::Expansion expandItem );
void refreshLegend( QString layerID );

void toggleEditing( QgsMapLayer * );

@@ -4,8 +4,9 @@

#include "qgsmapcanvas.h"

QgsLayerTreeMapCanvasBridge::QgsLayerTreeMapCanvasBridge(QgsLayerTreeGroup *root, QgsMapCanvas *canvas)
: mRoot(root)
QgsLayerTreeMapCanvasBridge::QgsLayerTreeMapCanvasBridge(QgsLayerTreeGroup *root, QgsMapCanvas *canvas, QObject* parent)
: QObject(parent)
, mRoot(root)
, mCanvas(canvas)
, mPendingCanvasUpdate(false)
, mHasCustomLayerOrder(false)
@@ -15,7 +15,7 @@ class GUI_EXPORT QgsLayerTreeMapCanvasBridge : public QObject
{
Q_OBJECT
public:
QgsLayerTreeMapCanvasBridge(QgsLayerTreeGroup* root, QgsMapCanvas* canvas);
QgsLayerTreeMapCanvasBridge(QgsLayerTreeGroup* root, QgsMapCanvas* canvas, QObject* parent = 0);

bool hasCustomLayerOrder() const { return mHasCustomLayerOrder; }
QStringList customLayerOrder() const { return mCustomLayerOrder; }
@@ -380,6 +380,8 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
// Add check if vector layer when disconnecting from selectionChanged slot
// Ticket #811 - racicot
QgsMapLayer *currentLayer = layer( i );
if ( !currentLayer )
continue;
disconnect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) );
QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer );
if ( isVectLyr )
@@ -53,8 +53,6 @@ class QGraphicsScene;

class QgsMapToPixel;
class QgsMapLayer;
class QgsLegend;
class QgsLegendView;
class QgsHighlight;
class QgsVectorLayer;

@@ -127,7 +127,7 @@ void QgsTileScaleWidget::showTileScale( QMainWindow *mainWindow )
QgsTileScaleWidget *tws = new QgsTileScaleWidget( canvas );
tws->setObjectName( "theTileScaleWidget" );

QObject *legend = mainWindow->findChild<QObject*>( "theMapLegend" );
QObject *legend = mainWindow->findChild<QObject*>( "theLayerTreeView" );
if ( legend )
{
connect( legend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),

0 comments on commit 55c4ae5

Please sign in to comment.