Skip to content
Permalink
Browse files
More integration of layer tree view in QGIS app
  • Loading branch information
wonder-sk committed May 21, 2014
1 parent 21b2a9a commit 72b3ef742e2514901d6dcae1815a09b3c5511edf
@@ -15,25 +15,27 @@
* *
***************************************************************************/
#include "qgsgpsinformationwidget.h"
#include "qgsnmeaconnection.h"
#include "qgsgpsconnectionregistry.h"
#include "qgsgpsdetector.h"

#include "info.h"

#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgscoordinatetransform.h"
#include "qgsfeatureaction.h"
#include "qgsgeometry.h"
#include "qgsgpsconnectionregistry.h"
#include "qgsgpsdetector.h"
#include "qgslayertreeview.h"
#include "qgslogger.h"
#include "qgsmaprenderer.h"
#include "qgsmaptooladdfeature.h"
#include "qgsnmeaconnection.h"
#include "qgspoint.h"
#include "qgsproject.h"
#include "qgsrubberband.h"
#include "qgsmaprenderer.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include "qgsproject.h"
#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgsfeatureaction.h"
#include "qgsgeometry.h"
#include "qgisapp.h"

//for avoid intersections static method
#include "qgsmaptooladdfeature.h"

// QWT Charting widget
#include <qwt_global.h>
@@ -66,8 +68,6 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
{
setupUi( this );

// to connect signals that layers have changed (which layer, edit state)
mpLegend = QgisApp::instance()->legend();
mpLastLayer = 0;

mLastGpsPosition = QgsPoint( 0.0, 0.0 );
@@ -232,7 +232,7 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
//SLM - added functionality
mLogFile = 0;

connect( mpLegend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
this, SLOT( updateCloseFeatureButton( QgsMapLayer* ) ) );

mStackedWidget->setCurrentIndex( 3 ); // force to Options
@@ -96,7 +96,6 @@ class QgsGPSInformationWidget: public QWidget, private Ui::QgsGPSInformationWidg
QList<QgsPoint> mCaptureList;
FixStatus mLastFixStatus;
QString mDateTimeFormat; // user specified format string in registry (no UI presented)
QgsLegend * mpLegend;
QgsVectorLayer * mpLastLayer;
QFile * mLogFile;
QTextStream mLogFileTextStream;
@@ -18,13 +18,13 @@
#include "nodetool/qgsselectedfeature.h"
#include "nodetool/qgsvertexentry.h"

#include "qgsproject.h"
#include "qgisapp.h"
#include "qgslayertreeview.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsproject.h"
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgslogger.h"
#include "qgisapp.h"
#include "qgslegend.h"

#include <QMouseEvent>
#include <QRubberBand>
@@ -370,7 +370,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
emit messageDiscarded();

mSelectedFeature = new QgsSelectedFeature( snapResults[0].snappedAtGeometry, vlayer, mCanvas );
connect( QgisApp::instance()->legend(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) );
connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) );
connect( mSelectedFeature, SIGNAL( destroyed() ), this, SLOT( selectedFeatureDestroyed() ) );
connect( vlayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
mIsPoint = vlayer->geometryType() == QGis::Point;
@@ -657,7 +657,7 @@ void QgsMapToolNodeTool::cleanTool( bool deleteSelectedFeature )
QgsVectorLayer *vlayer = mSelectedFeature->vlayer();
Q_ASSERT( vlayer );

disconnect( QgisApp::instance()->legend(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) );
disconnect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) );
disconnect( mSelectedFeature, SIGNAL( destroyed() ), this, SLOT( selectedFeatureDestroyed() ) );
disconnect( vlayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );

@@ -23,7 +23,7 @@
#include <qgsrubberband.h>
#include <qgisapp.h>
#include <qgsmaprenderer.h>
#include <qgslegend.h>
#include <qgslayertreeview.h>
#include <qgsproject.h>

QgsSelectedFeature::QgsSelectedFeature( QgsFeatureId featureId,
@@ -107,7 +107,7 @@ void QgsSelectedFeature::setSelectedFeature( QgsFeatureId featureId, QgsVectorLa
mGeometry = 0;

// signal changing of current layer
connect( QgisApp::instance()->legend(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) );
connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) );

// feature was deleted
connect( mVlayer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( featureDeleted( QgsFeatureId ) ) );
@@ -550,6 +550,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
//set the focus to the map canvas
mMapCanvas->setFocus();

mLayerTreeView = new QgsLayerTreeView( this );

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

@@ -2181,6 +2183,12 @@ QgsLegend *QgisApp::legend()
return mMapLegend;
}

QgsLayerTreeView* QgisApp::layerTreeView()
{
Q_ASSERT( mLayerTreeView );
return mLayerTreeView;
}

QgsPluginManager *QgisApp::pluginManager()
{
Q_ASSERT( mPluginManager );
@@ -2380,7 +2388,6 @@ void QgisApp::initLayerTreeView()
QgsLayerTreeModel* model = new QgsLayerTreeModel( QgsProject::instance()->layerTreeRoot(), this );
model->setFlag(QgsLayerTreeModel::AllowVisibilityManagement);

mLayerTreeView = new QgsLayerTreeView( this );
mLayerTreeView->setModel( model );
mLayerTreeView->setMenuProvider( new QgsAppLayerTreeViewMenuProvider(mLayerTreeView, mMapCanvas) );

@@ -4340,7 +4347,8 @@ void QgisApp::hideAllLayers()
{
QgsDebugMsg( "hiding all layers!" );

legend()->setLayersVisible( false );
foreach ( QgsLayerTreeLayer* nodeLayer, mLayerTreeView->layerTreeModel()->rootGroup()->findLayers() )
nodeLayer->setVisible( false );
}


@@ -4349,7 +4357,8 @@ void QgisApp::showAllLayers()
{
QgsDebugMsg( "Showing all layers!" );

legend()->setLayersVisible( true );
foreach ( QgsLayerTreeLayer* nodeLayer, mLayerTreeView->layerTreeModel()->rootGroup()->findLayers() )
nodeLayer->setVisible( true );
}


@@ -433,6 +433,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! returns pointer to map legend
QgsLegend *legend();

QgsLayerTreeView* layerTreeView();

//! returns pointer to plugin manager
QgsPluginManager *pluginManager();

@@ -34,6 +34,7 @@
#include "qgsmaplayerregistry.h"
#include "qgsmapcanvas.h"
#include "qgsproject.h"
#include "qgslayertreeview.h"
#include "qgslegend.h"
#include "qgsshortcutsmanager.h"
#include "qgsattributedialog.h"
@@ -50,7 +51,7 @@ QgisAppInterface::QgisAppInterface( QgisApp * _qgis )
pluginManagerIface( _qgis->pluginManager() )
{
// connect signals
connect( qgis->legend(), SIGNAL( currentLayerChanged( QgsMapLayer * ) ),
connect( qgis->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer * ) ),
this, SIGNAL( currentLayerChanged( QgsMapLayer * ) ) );
connect( qgis, SIGNAL( currentThemeChanged( QString ) ),
this, SIGNAL( currentThemeChanged( QString ) ) );
@@ -16,14 +16,15 @@
#include "qgsmaptoolcapture.h"

#include "qgisapp.h"
#include "qgsvertexmarker.h"
#include "qgscursors.h"
#include "qgsrubberband.h"
#include "qgsgeometryvalidator.h"
#include "qgslayertreeview.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsmaprenderer.h"
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgslogger.h"
#include "qgsgeometryvalidator.h"
#include "qgsvertexmarker.h"

#include <QCursor>
#include <QPixmap>
@@ -46,7 +47,7 @@ QgsMapToolCapture::QgsMapToolCapture( QgsMapCanvas* canvas, enum CaptureMode too
QPixmap mySelectQPixmap = QPixmap(( const char ** ) capture_point_cursor );
mCursor = QCursor( mySelectQPixmap, 8, 8 );

connect( QgisApp::instance()->legend(), SIGNAL( currentLayerChanged( QgsMapLayer * ) ),
connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer * ) ),
this, SLOT( currentLayerChanged( QgsMapLayer * ) ) );
}

@@ -20,7 +20,6 @@
#include "qgsmaptooledit.h"
#include "qgspoint.h"
#include "qgsgeometry.h"
#include "qgslegend.h"

#include <QPoint>
#include <QList>
@@ -14,12 +14,12 @@
***************************************************************************/
#include "qgsundowidget.h"

#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgslayertreeview.h"
#include "qgsmaplayer.h"
#include "qgsmapcanvas.h"
#include "qgslegend.h"

#include "qgisapp.h"
#include "qgsapplication.h"

QgsUndoWidget::QgsUndoWidget( QWidget * parent, QgsMapCanvas * mapCanvas )
: QDockWidget( parent )
@@ -29,7 +29,7 @@ QgsUndoWidget::QgsUndoWidget( QWidget * parent, QgsMapCanvas * mapCanvas )

connect( undoButton, SIGNAL( clicked() ), this, SLOT( undo( ) ) );
connect( redoButton, SIGNAL( clicked() ), this, SLOT( redo( ) ) );
connect( QgisApp::instance()->legend(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
this, SLOT( layerChanged( QgsMapLayer* ) ) );

undoButton->setDisabled( true );

0 comments on commit 72b3ef7

Please sign in to comment.