Skip to content

Commit b2a4c76

Browse files
committed
[FEATURE] Merge of legend refactoring work
This replaces the existing tree widget implementation with more modular approach. In summary: - tree hierarchy in CORE library: QgsLayerTreeNode, QgsLayerTreeLayer, QgsLayerTreeGroup - model/view based tree view: QgsLayerTreeModel, QgsLayerTreeView - tree synchronization with map layer registry: QgsLayerTreeRegistryBridge - controlling of map canvas: QgsLayerTreeCanvasBridge Conflicts: src/ui/qgisapp.ui
2 parents 7f218c7 + 0b072e6 commit b2a4c76

File tree

75 files changed

+5093
-6085
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5093
-6085
lines changed

python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ INCLUDE_DIRECTORIES(
8686
../src/gui/attributetable
8787
../src/gui/editorwidgets
8888
../src/gui/editorwidgets/core
89+
../src/gui/layertree
8990

9091
${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h
9192
)

python/gui/gui.sip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
%Include qgsrubberband.sip
7777
%Include qgsscalecombobox.sip
7878
%Include qgsscalerangewidget.sip
79+
%Include qgsscalevisibilitydialog.sip
7980
%Include qgssearchquerybuilder.sip
8081
%Include qgstextannotationitem.sip
8182
%Include qgsvertexmarker.sip
@@ -146,3 +147,5 @@
146147
%Include editorwidgets/core/qgseditorwidgetfactory.sip
147148
%Include editorwidgets/core/qgseditorwidgetregistry.sip
148149
%Include editorwidgets/core/qgseditorwidgetwrapper.sip
150+
151+
%Include layertree/qgslayertreeview.sip

python/gui/qgisinterface.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class QgisInterface : QObject
3232

3333
virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
3434

35+
virtual QgsLayerTreeView* layerTreeView() = 0;
36+
3537
public slots: // TODO: do these functions really need to be slots?
3638

3739
/* Exposed functions */
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class QgsScaleVisibilityDialog : QObject
2+
{
3+
%TypeHeaderCode
4+
#include <qgsscalevisibilitydialog.h>
5+
%End
6+
7+
public:
8+
explicit QgsScaleVisibilityDialog( QWidget *parent = 0, QString title = QString(), QgsMapCanvas* mapCanvas = 0 );
9+
10+
//! return if scale visibilty is enabled
11+
bool hasScaleVisibility();
12+
13+
//! return minimum scale (true scale, not scale denominator)
14+
double minimumScale();
15+
16+
//! return maximum scale (true scale, not scale denominator)
17+
double maximumScale();
18+
19+
20+
public slots:
21+
//! set if scale visibility is enabled
22+
void setScaleVisiblity( bool hasScaleVisibility );
23+
24+
//! set minimum scale (true scale, not scale denominator)
25+
void setMinimumScale( double minScale );
26+
27+
//! set maximum scale (true scale, not scale denominator)
28+
void setMaximumScale( double maxScale );
29+
30+
};

src/app/CMakeLists.txt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ SET(QGIS_APP_SRCS
33
qgisappinterface.cpp
44
qgisappstylesheet.cpp
55
qgsabout.cpp
6+
qgsapplayertreeviewmenuprovider.cpp
67
qgssponsors.cpp
78
qgsaddattrdialog.cpp
89
qgsaddtaborgroup.cpp
@@ -129,13 +130,7 @@ SET(QGIS_APP_SRCS
129130
composer/qgscompositionwidget.cpp
130131
composer/qgsatlascompositionwidget.cpp
131132

132-
legend/qgslegendgroup.cpp
133-
legend/qgslegend.cpp
134133
legend/qgsapplegendinterface.cpp
135-
legend/qgslegenditem.cpp
136-
legend/qgslegendlayer.cpp
137-
legend/qgslegendsymbologyitem.cpp
138-
legend/qgslayerorder.cpp
139134

140135
ogr/qgsogrhelperfunctions.cpp
141136
ogr/qgsopenvectorlayerdialog.cpp
@@ -272,10 +267,7 @@ SET (QGIS_APP_MOC_HDRS
272267
composer/qgscompositionwidget.h
273268
composer/qgsatlascompositionwidget.h
274269

275-
legend/qgslegend.h
276270
legend/qgsapplegendinterface.h
277-
legend/qgslegendlayer.h
278-
legend/qgslayerorder.h
279271

280272
ogr/qgsopenvectorlayerdialog.h
281273
ogr/qgsnewogrconnection.h
@@ -428,11 +420,22 @@ INCLUDE_DIRECTORIES(
428420
${QWT_INCLUDE_DIR}
429421
${QT_QTUITOOLS_INCLUDE_DIR}
430422
${QEXTSERIALPORT_INCLUDE_DIR}
431-
../analysis/raster ../analysis/openstreetmap
423+
../analysis/raster
424+
../analysis/openstreetmap
432425
../core
433426
../core/gps
434-
../core/composer ../core/dxf ../core/raster ../core/symbology-ng
435-
../gui ../gui/symbology-ng ../gui/attributetable ../gui/raster ../gui/editorwidgets ../gui/editorwidgets/core
427+
../core/composer
428+
../core/dxf
429+
../core/layertree
430+
../core/raster
431+
../core/symbology-ng
432+
../gui
433+
../gui/symbology-ng
434+
../gui/attributetable
435+
../gui/raster
436+
../gui/editorwidgets
437+
../gui/editorwidgets/core
438+
../gui/layertree
436439
../plugins
437440
../python
438441
gps

src/app/composer/qgscomposerlegendwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ void QgsComposerLegendWidget::updateLegend()
922922

923923

924924
//and also group info
925-
QgsAppLegendInterface legendIface( app->legend() );
925+
QgsAppLegendInterface legendIface( app->layerTreeView() );
926926
QList< GroupLayerInfo > groupInfo = legendIface.groupLayerRelationship();
927927
mLegend->model()->setLayerSetAndGroups( layerIdList, groupInfo );
928928
mLegend->endCommand();

src/app/gps/qgsgpsinformationwidget.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,27 @@
1515
* *
1616
***************************************************************************/
1717
#include "qgsgpsinformationwidget.h"
18-
#include "qgsnmeaconnection.h"
19-
#include "qgsgpsconnectionregistry.h"
20-
#include "qgsgpsdetector.h"
18+
2119
#include "info.h"
20+
21+
#include "qgisapp.h"
22+
#include "qgsapplication.h"
2223
#include "qgscoordinatetransform.h"
24+
#include "qgsfeatureaction.h"
25+
#include "qgsgeometry.h"
26+
#include "qgsgpsconnectionregistry.h"
27+
#include "qgsgpsdetector.h"
28+
#include "qgslayertreeview.h"
29+
#include "qgslogger.h"
30+
#include "qgsmaprenderer.h"
31+
#include "qgsmaptooladdfeature.h"
32+
#include "qgsnmeaconnection.h"
2333
#include "qgspoint.h"
34+
#include "qgsproject.h"
2435
#include "qgsrubberband.h"
25-
#include "qgsmaprenderer.h"
2636
#include "qgsvectordataprovider.h"
2737
#include "qgsvectorlayer.h"
28-
#include "qgsproject.h"
29-
#include "qgsapplication.h"
30-
#include "qgslogger.h"
31-
#include "qgsfeatureaction.h"
32-
#include "qgsgeometry.h"
33-
#include "qgisapp.h"
3438

35-
//for avoid intersections static method
36-
#include "qgsmaptooladdfeature.h"
3739

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

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

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

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

238238
mStackedWidget->setCurrentIndex( 3 ); // force to Options

src/app/gps/qgsgpsinformationwidget.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class QgsGPSConnection;
3131
class QgsGPSTrackerThread;
3232
struct QgsGPSInformation;
3333

34-
class QgsLegend;
3534
class QFile;
3635
class QColor;
3736

@@ -96,7 +95,6 @@ class QgsGPSInformationWidget: public QWidget, private Ui::QgsGPSInformationWidg
9695
QList<QgsPoint> mCaptureList;
9796
FixStatus mLastFixStatus;
9897
QString mDateTimeFormat; // user specified format string in registry (no UI presented)
99-
QgsLegend * mpLegend;
10098
QgsVectorLayer * mpLastLayer;
10199
QFile * mLogFile;
102100
QTextStream mLogFileTextStream;

0 commit comments

Comments
 (0)