Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move Martins labeling-ng from plugin to core/app
git-svn-id: http://svn.osgeo.org/qgis/trunk@13607 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 31, 2010
1 parent d3bbe11 commit c0e7506
Show file tree
Hide file tree
Showing 21 changed files with 266 additions and 182 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -157,6 +157,7 @@
<file>themes/default/mActionInOverview.png</file>
<file>themes/default/mActionInvertSelection.png</file>
<file>themes/default/mActionLabel.png</file>
<file>themes/default/mActionLabeling.png</file>
<file>themes/default/mActionLowerItems.png</file>
<file>themes/default/mActionMapTips.png</file>
<file>themes/default/mActionMeasure.png</file>
Expand Down
File renamed without changes
5 changes: 5 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -27,6 +27,9 @@ SET(QGIS_APP_SRCS
qgshelpviewer.cpp
qgsidentifyresults.cpp
qgslabeldialog.cpp
qgslabelengineconfigdialog.cpp
qgslabelinggui.cpp
qgslabelpreview.cpp
qgsmaptooladdfeature.cpp
qgsmaptooladdvertex.cpp
qgsmaptooladdisland.cpp
Expand Down Expand Up @@ -140,6 +143,8 @@ SET (QGIS_APP_MOC_HDRS
qgsdelattrdialog.h
qgsfieldcalculator.h
qgsformannotationdialog.h
qgslabelinggui.h
qgslabelengineconfigdialog.h
qgsmaptoolmeasureangle.h
qgsnewvectorlayerdialog.h
qgsgraduatedsymboldialog.h
Expand Down
38 changes: 36 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -112,6 +112,7 @@
#include "qgsexception.h"
#include "qgsfeature.h"
#include "qgsformannotationitem.h"
#include "qgslabelinggui.h"
#include "qgsnewvectorlayerdialog.h"
#include "qgshelpviewer.h"
#include "qgsgenericprojectionselector.h"
Expand Down Expand Up @@ -525,6 +526,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mMapCanvas->freeze( false );
mMapCanvas->clearExtentHistory(); // reset zoomnext/zoomlast
mLastComposerId = 0;
mLBL = new QgsPalLabeling();;
} // QgisApp ctor


Expand Down Expand Up @@ -570,6 +572,8 @@ QgisApp::~QgisApp()
deletePrintComposers();
removeAnnotationItems();

delete mLBL;

// delete map layer registry and provider registry
QgsApplication::exitQgis();
}
Expand Down Expand Up @@ -959,6 +963,9 @@ void QgisApp::createActions()
mActionAnnotation->setCheckable( true );
connect( mActionAnnotation, SIGNAL( triggered() ), this, SLOT( modifyAnnotation() ) );

mActionLabeling = new QAction( getThemeIcon( "mActionLabeling.png" ), tr( "Labeling" ), this );
connect( mActionLabeling, SIGNAL( triggered() ), this, SLOT( labeling() ) );

// Layer Menu Items

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

mLayerMenu->addAction( mActionHideAllLayers );
mLayerMenu->addAction( mActionShowAllLayers );
mLayerMenu->addAction( mActionLabeling );

// Settings Menu

Expand Down Expand Up @@ -1653,6 +1661,7 @@ void QgisApp::createToolBars()
mAttributesToolBar->addAction( mActionMapTips );
mAttributesToolBar->addAction( mActionShowBookmarks );
mAttributesToolBar->addAction( mActionNewBookmark );
mAttributesToolBar->addAction( mActionLabeling );
// Annotation tools
QToolButton *annotationToolButton = new QToolButton();
annotationToolButton->setPopupMode( QToolButton::InstantPopup );
Expand Down Expand Up @@ -3017,9 +3026,9 @@ void QgisApp::newVectorLayer()
return;
}

fileName = openFileDialog->selectedFiles().first();
fileName = openFileDialog->selectedFiles().first();

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

enc = openFileDialog->encoding();
Expand Down Expand Up @@ -3738,6 +3747,31 @@ void QgisApp::modifyAnnotation()
mMapCanvas->setMapTool( mMapTools.mAnnotation );
}

void QgisApp::labeling()
{
QgsMapLayer* layer = activeLayer();
if ( layer == NULL || layer->type() != QgsMapLayer::VectorLayer )
{
QMessageBox::warning( this, "Labeling", "Please select a vector layer first." );
return;
}
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( layer );

QgsLabelingGui labelGui( mLBL, vlayer, this );

if ( labelGui.exec() )
{
// alter labeling - save the changes
labelGui.layerSettings().writeToLayer( vlayer );

// trigger refresh
if ( mMapCanvas )
{
mMapCanvas->refresh();
}
}
}

void QgisApp::attributeTable()
{
if ( mMapCanvas && mMapCanvas->isDrawing() )
Expand Down
8 changes: 8 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -52,6 +52,7 @@ class QgsMapCanvas;
class QgsMapLayer;
class QgsMapTip;
class QgsMapTool;
class QgsPalLabeling;
class QgsPoint;
class QgsProviderRegistry;
class QgsPythonUtils;
Expand Down Expand Up @@ -650,6 +651,9 @@ class QgisApp : public QMainWindow
void addTextAnnotation();
void modifyAnnotation();

//! shows label settings dialog (for labeling-ng)
void labeling();

//! show the attribute table for the currently selected layer
void attributeTable();

Expand Down Expand Up @@ -876,6 +880,7 @@ class QgisApp : public QMainWindow
QAction *mActionTextAnnotation;
QAction *mActionFormAnnotation;
QAction *mActionAnnotation;
QAction *mActionLabeling;

QAction *mActionNewVectorLayer;
QAction *mActionNewSpatialiteLayer;
Expand Down Expand Up @@ -1116,6 +1121,9 @@ class QgisApp : public QMainWindow
//! Persistent GPS toolbox
QgsGPSInformationWidget * mpGpsWidget;
#endif

QgsPalLabeling* mLBL;

//! project changed
void projectChanged( const QDomDocument & );
};
Expand Down
@@ -1,8 +1,8 @@
#include "engineconfigdialog.h"
#include "qgslabelengineconfigdialog.h"

#include "pallabeling.h"
#include "qgspallabeling.h"

EngineConfigDialog::EngineConfigDialog( PalLabeling* lbl, QWidget* parent )
QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QgsPalLabeling* lbl, QWidget* parent )
: QDialog( parent ), mLBL( lbl )
{
setupUi( this );
Expand All @@ -25,10 +25,10 @@ EngineConfigDialog::EngineConfigDialog( PalLabeling* lbl, QWidget* parent )
}


void EngineConfigDialog::onOK()
void QgsLabelEngineConfigDialog::onOK()
{
// save
mLBL->setSearchMethod(( PalLabeling::Search ) cboSearchMethod->currentIndex() );
mLBL->setSearchMethod(( QgsPalLabeling::Search ) cboSearchMethod->currentIndex() );

mLBL->setNumCandidatePositions( spinCandPoint->value(),
spinCandLine->value(),
Expand Down
23 changes: 23 additions & 0 deletions src/app/qgslabelengineconfigdialog.h
@@ -0,0 +1,23 @@
#ifndef QGSLABELENGINECONFIGDIALOG_H
#define QGSLABELENGINECONFIGDIALOG_H

#include <QDialog>

#include "ui_qgsengineconfigdialog.h"

class QgsPalLabeling;

class QgsLabelEngineConfigDialog : public QDialog, private Ui::QgsEngineConfigDialog
{
Q_OBJECT
public:
QgsLabelEngineConfigDialog( QgsPalLabeling* lbl, QWidget* parent = NULL );

public slots:
void onOK();

protected:
QgsPalLabeling* mLBL;
};

#endif // QGSLABELENGINECONFIGDIALOG_H

0 comments on commit c0e7506

Please sign in to comment.