Skip to content

Commit c0e7506

Browse files
author
mhugent
committed
Move Martins labeling-ng from plugin to core/app
git-svn-id: http://svn.osgeo.org/qgis/trunk@13607 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent d3bbe11 commit c0e7506

21 files changed

+266
-182
lines changed

images/images.qrc

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<file>themes/default/mActionInOverview.png</file>
158158
<file>themes/default/mActionInvertSelection.png</file>
159159
<file>themes/default/mActionLabel.png</file>
160+
<file>themes/default/mActionLabeling.png</file>
160161
<file>themes/default/mActionLowerItems.png</file>
161162
<file>themes/default/mActionMapTips.png</file>
162163
<file>themes/default/mActionMeasure.png</file>
File renamed without changes.

src/app/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ SET(QGIS_APP_SRCS
2727
qgshelpviewer.cpp
2828
qgsidentifyresults.cpp
2929
qgslabeldialog.cpp
30+
qgslabelengineconfigdialog.cpp
31+
qgslabelinggui.cpp
32+
qgslabelpreview.cpp
3033
qgsmaptooladdfeature.cpp
3134
qgsmaptooladdvertex.cpp
3235
qgsmaptooladdisland.cpp
@@ -140,6 +143,8 @@ SET (QGIS_APP_MOC_HDRS
140143
qgsdelattrdialog.h
141144
qgsfieldcalculator.h
142145
qgsformannotationdialog.h
146+
qgslabelinggui.h
147+
qgslabelengineconfigdialog.h
143148
qgsmaptoolmeasureangle.h
144149
qgsnewvectorlayerdialog.h
145150
qgsgraduatedsymboldialog.h

src/app/qgisapp.cpp

+36-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
#include "qgsexception.h"
113113
#include "qgsfeature.h"
114114
#include "qgsformannotationitem.h"
115+
#include "qgslabelinggui.h"
115116
#include "qgsnewvectorlayerdialog.h"
116117
#include "qgshelpviewer.h"
117118
#include "qgsgenericprojectionselector.h"
@@ -525,6 +526,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
525526
mMapCanvas->freeze( false );
526527
mMapCanvas->clearExtentHistory(); // reset zoomnext/zoomlast
527528
mLastComposerId = 0;
529+
mLBL = new QgsPalLabeling();;
528530
} // QgisApp ctor
529531

530532

@@ -570,6 +572,8 @@ QgisApp::~QgisApp()
570572
deletePrintComposers();
571573
removeAnnotationItems();
572574

575+
delete mLBL;
576+
573577
// delete map layer registry and provider registry
574578
QgsApplication::exitQgis();
575579
}
@@ -959,6 +963,9 @@ void QgisApp::createActions()
959963
mActionAnnotation->setCheckable( true );
960964
connect( mActionAnnotation, SIGNAL( triggered() ), this, SLOT( modifyAnnotation() ) );
961965

966+
mActionLabeling = new QAction( getThemeIcon( "mActionLabeling.png" ), tr( "Labeling" ), this );
967+
connect( mActionLabeling, SIGNAL( triggered() ), this, SLOT( labeling() ) );
968+
962969
// Layer Menu Items
963970

964971
mActionNewVectorLayer = new QAction( getThemeIcon( "mActionNewVectorLayer.png" ), tr( "New Shapefile Layer..." ), this );
@@ -1483,6 +1490,7 @@ void QgisApp::createMenus()
14831490

14841491
mLayerMenu->addAction( mActionHideAllLayers );
14851492
mLayerMenu->addAction( mActionShowAllLayers );
1493+
mLayerMenu->addAction( mActionLabeling );
14861494

14871495
// Settings Menu
14881496

@@ -1653,6 +1661,7 @@ void QgisApp::createToolBars()
16531661
mAttributesToolBar->addAction( mActionMapTips );
16541662
mAttributesToolBar->addAction( mActionShowBookmarks );
16551663
mAttributesToolBar->addAction( mActionNewBookmark );
1664+
mAttributesToolBar->addAction( mActionLabeling );
16561665
// Annotation tools
16571666
QToolButton *annotationToolButton = new QToolButton();
16581667
annotationToolButton->setPopupMode( QToolButton::InstantPopup );
@@ -3017,9 +3026,9 @@ void QgisApp::newVectorLayer()
30173026
return;
30183027
}
30193028

3020-
fileName = openFileDialog->selectedFiles().first();
3029+
fileName = openFileDialog->selectedFiles().first();
30213030

3022-
if( fileformat == "ESRI Shapefile" && !fileName.endsWith( ".shp", Qt::CaseInsensitive ) )
3031+
if ( fileformat == "ESRI Shapefile" && !fileName.endsWith( ".shp", Qt::CaseInsensitive ) )
30233032
fileName += ".shp";
30243033

30253034
enc = openFileDialog->encoding();
@@ -3738,6 +3747,31 @@ void QgisApp::modifyAnnotation()
37383747
mMapCanvas->setMapTool( mMapTools.mAnnotation );
37393748
}
37403749

3750+
void QgisApp::labeling()
3751+
{
3752+
QgsMapLayer* layer = activeLayer();
3753+
if ( layer == NULL || layer->type() != QgsMapLayer::VectorLayer )
3754+
{
3755+
QMessageBox::warning( this, "Labeling", "Please select a vector layer first." );
3756+
return;
3757+
}
3758+
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( layer );
3759+
3760+
QgsLabelingGui labelGui( mLBL, vlayer, this );
3761+
3762+
if ( labelGui.exec() )
3763+
{
3764+
// alter labeling - save the changes
3765+
labelGui.layerSettings().writeToLayer( vlayer );
3766+
3767+
// trigger refresh
3768+
if ( mMapCanvas )
3769+
{
3770+
mMapCanvas->refresh();
3771+
}
3772+
}
3773+
}
3774+
37413775
void QgisApp::attributeTable()
37423776
{
37433777
if ( mMapCanvas && mMapCanvas->isDrawing() )

src/app/qgisapp.h

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class QgsMapCanvas;
5252
class QgsMapLayer;
5353
class QgsMapTip;
5454
class QgsMapTool;
55+
class QgsPalLabeling;
5556
class QgsPoint;
5657
class QgsProviderRegistry;
5758
class QgsPythonUtils;
@@ -650,6 +651,9 @@ class QgisApp : public QMainWindow
650651
void addTextAnnotation();
651652
void modifyAnnotation();
652653

654+
//! shows label settings dialog (for labeling-ng)
655+
void labeling();
656+
653657
//! show the attribute table for the currently selected layer
654658
void attributeTable();
655659

@@ -876,6 +880,7 @@ class QgisApp : public QMainWindow
876880
QAction *mActionTextAnnotation;
877881
QAction *mActionFormAnnotation;
878882
QAction *mActionAnnotation;
883+
QAction *mActionLabeling;
879884

880885
QAction *mActionNewVectorLayer;
881886
QAction *mActionNewSpatialiteLayer;
@@ -1116,6 +1121,9 @@ class QgisApp : public QMainWindow
11161121
//! Persistent GPS toolbox
11171122
QgsGPSInformationWidget * mpGpsWidget;
11181123
#endif
1124+
1125+
QgsPalLabeling* mLBL;
1126+
11191127
//! project changed
11201128
void projectChanged( const QDomDocument & );
11211129
};

src/plugins/labeling/engineconfigdialog.cpp src/app/qgslabelengineconfigdialog.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#include "engineconfigdialog.h"
1+
#include "qgslabelengineconfigdialog.h"
22

3-
#include "pallabeling.h"
3+
#include "qgspallabeling.h"
44

5-
EngineConfigDialog::EngineConfigDialog( PalLabeling* lbl, QWidget* parent )
5+
QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QgsPalLabeling* lbl, QWidget* parent )
66
: QDialog( parent ), mLBL( lbl )
77
{
88
setupUi( this );
@@ -25,10 +25,10 @@ EngineConfigDialog::EngineConfigDialog( PalLabeling* lbl, QWidget* parent )
2525
}
2626

2727

28-
void EngineConfigDialog::onOK()
28+
void QgsLabelEngineConfigDialog::onOK()
2929
{
3030
// save
31-
mLBL->setSearchMethod(( PalLabeling::Search ) cboSearchMethod->currentIndex() );
31+
mLBL->setSearchMethod(( QgsPalLabeling::Search ) cboSearchMethod->currentIndex() );
3232

3333
mLBL->setNumCandidatePositions( spinCandPoint->value(),
3434
spinCandLine->value(),

src/app/qgslabelengineconfigdialog.h

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef QGSLABELENGINECONFIGDIALOG_H
2+
#define QGSLABELENGINECONFIGDIALOG_H
3+
4+
#include <QDialog>
5+
6+
#include "ui_qgsengineconfigdialog.h"
7+
8+
class QgsPalLabeling;
9+
10+
class QgsLabelEngineConfigDialog : public QDialog, private Ui::QgsEngineConfigDialog
11+
{
12+
Q_OBJECT
13+
public:
14+
QgsLabelEngineConfigDialog( QgsPalLabeling* lbl, QWidget* parent = NULL );
15+
16+
public slots:
17+
void onOK();
18+
19+
protected:
20+
QgsPalLabeling* mLBL;
21+
};
22+
23+
#endif // QGSLABELENGINECONFIGDIALOG_H

0 commit comments

Comments
 (0)