Skip to content
Permalink
Browse files

[FEATURE] add new labeling to vector layer properties

- add 'deprecated' label to old labeling in vector layer properties
  • Loading branch information
jef-n committed Aug 7, 2012
1 parent 511e89c commit a033d474fd52a0e22713b30c6372dd10f66647d1
@@ -1884,6 +1884,12 @@ QgsMapCanvas *QgisApp::mapCanvas()
return mMapCanvas;
}

QgsPalLabeling *QgisApp::palLabeling()
{
Q_ASSERT( mLBL );
return mLBL;
}

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." ) );
@@ -3842,14 +3848,36 @@ void QgisApp::labeling()
QMessageBox::warning( this, tr( "Labeling" ), tr( "Please select a vector layer first." ) );
return;
}

QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( layer );

QgsLabelingGui labelGui( mLBL, vlayer, mMapCanvas, this );
QDialog *dlg = new QDialog( this );
dlg->setWindowTitle( tr( "Layer labeling settings" ) );
QgsLabelingGui *labelingGui = new QgsLabelingGui( mLBL, vlayer, mMapCanvas, dlg );

QVBoxLayout *layout = new QVBoxLayout( dlg );
layout->addWidget( labelingGui );

QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply, Qt::Horizontal, dlg );
layout->addWidget( buttonBox );

dlg->setLayout( layout );

if ( labelGui.exec() )
QSettings settings;
dlg->restoreGeometry( settings.value( "/Windows/Labeling/geometry" ).toByteArray() );

connect( buttonBox->button( QDialogButtonBox::Ok ), SIGNAL( clicked() ), dlg, SLOT( accept() ) );
connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL( clicked() ), dlg, SLOT( reject() ) );
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), labelingGui, SLOT( apply() ) );

if ( dlg->exec() )
{
labelingGui->apply();

settings.setValue( "/Windows/Labeling/geometry", dlg->saveGeometry() );

// alter labeling - save the changes
labelGui.layerSettings().writeToLayer( vlayer );
labelingGui->layerSettings().writeToLayer( vlayer );

// trigger refresh
if ( mMapCanvas )
@@ -3858,6 +3886,8 @@ void QgisApp::labeling()
}
}

delete dlg;

activateDeactivateLayerRelatedActions( layer );
}

@@ -161,8 +161,12 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void openFile( const QString & fileName );
//!Overloaded version of the private function with same name that takes the imagename as a parameter
void saveMapAsImage( QString, QPixmap * );

/** Get the mapcanvas object from the app */
QgsMapCanvas *mapCanvas();

/** Get the mapcanvas object from the app */
QgsMapCanvas * mapCanvas();
QgsPalLabeling *palLabeling();

//! Set theme (icons)
void setTheme( QString themeName = "default" );
@@ -22,10 +22,10 @@
#include <qgsvectordataprovider.h>
#include <qgsmaplayerregistry.h>

#include "qgspallabeling.h"
#include "qgslabelengineconfigdialog.h"
#include "qgsexpressionbuilderdialog.h"
#include "qgsexpression.h"
#include "qgsmapcanvas.h"

#include <QColorDialog>
#include <QFontDialog>
@@ -34,16 +34,14 @@
#include <QMessageBox>
#include <QSettings>


QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QWidget* parent )
: QDialog( parent ), mLBL( lbl ), mLayer( layer ), mMapCanvas( mapCanvas )
: QWidget( parent ), mLBL( lbl ), mLayer( layer ), mMapCanvas( mapCanvas )
{
if ( !layer ) return;

setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/Labeling/geometry" ).toByteArray() );

connect( btnTextColor, SIGNAL( clicked() ), this, SLOT( changeTextColor() ) );
connect( btnChangeFont, SIGNAL( clicked() ), this, SLOT( changeTextFont() ) );
connect( chkBuffer, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ) );
@@ -206,13 +204,10 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
{
connect( placementRadios[i], SIGNAL( toggled( bool ) ), this, SLOT( updateOptions() ) );
}
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
}

QgsLabelingGui::~QgsLabelingGui()
{
QSettings settings;
settings.setValue( "/Windows/Labeling/geometry", saveGeometry() );
}

void QgsLabelingGui::apply()
@@ -26,12 +26,12 @@ class QgsMapCanvas;

#include "qgspallabeling.h"

class QgsLabelingGui : public QDialog, private Ui::QgsLabelingGuiBase
class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
{
Q_OBJECT

public:
QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QWidget* parent );
QgsLabelingGui( QgsPalLabeling *lbl, QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QWidget* parent );
~QgsLabelingGui();

QgsPalLayerSettings layerSettings();
@@ -32,6 +32,7 @@
#include "qgsfieldcalculator.h"
#include "qgsgraduatedsymboldialog.h"
#include "qgslabeldialog.h"
#include "qgslabelinggui.h"
#include "qgslabel.h"
#include "qgsgenericprojectionselector.h"
#include "qgslogger.h"
@@ -98,16 +99,21 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
connect( insertFieldButton, SIGNAL( clicked() ), this, SLOT( insertField() ) );
connect( insertExpressionButton, SIGNAL( clicked() ), this, SLOT( insertExpression() ) );


mAddAttributeButton->setIcon( QgsApplication::getThemeIcon( "/mActionNewAttribute.png" ) );
mDeleteAttributeButton->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteAttribute.png" ) );
mToggleEditingButton->setIcon( QgsApplication::getThemeIcon( "/mActionToggleEditing.png" ) );
mCalculateFieldButton->setIcon( QgsApplication::getThemeIcon( "/mActionCalculateField.png" ) );

connect( btnUseNewSymbology, SIGNAL( clicked() ), this, SLOT( useNewSymbology() ) );

QVBoxLayout *layout = new QVBoxLayout( labelingFrame );
layout->setMargin( 0 );
labelingDialog = new QgsLabelingGui( QgisApp::instance()->palLabeling(), layer, QgisApp::instance()->mapCanvas(), labelingFrame );
layout->addWidget( labelingDialog );
labelingFrame->setLayout( layout );

// Create the Label dialog tab
QVBoxLayout *layout = new QVBoxLayout( labelOptionsFrame );
layout = new QVBoxLayout( labelOptionsFrame );
layout->setMargin( 0 );
labelDialog = new QgsLabelDialog( layer->label(), labelOptionsFrame );
layout->addWidget( labelDialog );
@@ -657,6 +663,8 @@ QgsVectorLayer::EditType QgsVectorLayerProperties::editTypeFromButtonText( QStri

void QgsVectorLayerProperties::apply()
{
labelingDialog->apply();

//
// Set up sql subset query if applicable
//
@@ -37,6 +37,7 @@ class QgsApplyDialog;
class QgsLabelDialog;
class QgsVectorLayer;
class QgsVectorOverlayPlugin;
class QgsLabelingGui;

class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPropertiesBase
{
@@ -185,6 +186,8 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
QDialog* mRendererDialog;
/**Buffer renderer, which is assigned to the vector layer when apply is pressed*/
//QgsRenderer* bufferRenderer;
/**Labeling dialog. If apply is pressed, options are applied to vector's QgsLabel */
QgsLabelingGui *labelingDialog;
/**Label dialog. If apply is pressed, options are applied to vector's QgsLabel */
QgsLabelDialog* labelDialog;
/**Actions dialog. If apply is pressed, the actions are stored for later use */
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsLabelingGuiBase</class>
<widget class="QDialog" name="QgsLabelingGuiBase">
<widget class="QWidget" name="QgsLabelingGuiBase">
<property name="geometry">
<rect>
<x>0</x>
@@ -63,16 +63,6 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
@@ -473,8 +463,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>658</width>
<height>451</height>
<width>647</width>
<height>435</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_13">
@@ -935,8 +925,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>658</width>
<height>567</height>
<width>647</width>
<height>507</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_11">
@@ -1146,45 +1136,10 @@
<header>qgslabelpreview.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QgsLabelingGuiBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>353</x>
<y>459</y>
</hint>
<hint type="destinationlabel">
<x>309</x>
<y>430</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsLabelingGuiBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>353</x>
<y>459</y>
</hint>
<hint type="destinationlabel">
<x>353</x>
<y>430</y>
</hint>
</hints>
</connection>
<connection>
<sender>chkEnableLabeling</sender>
<signal>clicked(bool)</signal>
@@ -66,7 +66,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>2</number>
</property>
<property name="iconSize">
<size>
@@ -184,14 +184,35 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabWidgetPage2">
<widget class="QWidget" name="labelingTab">
<attribute name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/propertyicons/labels.png</normaloff>:/images/themes/default/propertyicons/labels.png</iconset>
</attribute>
<attribute name="title">
<string>Labels</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_47">
<item row="0" column="0">
<widget class="QFrame" name="labelingFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabWidgetPage2">
<attribute name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/propertyicons/labels.png</normaloff>:/images/themes/default/propertyicons/labels.png</iconset>
</attribute>
<attribute name="title">
<string>Labels (deprecated)</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QCheckBox" name="labelCheckBox">
@@ -371,7 +392,7 @@
<x>0</x>
<y>0</y>
<width>740</width>
<height>548</height>
<height>558</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
@@ -739,8 +760,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>231</height>
<width>722</width>
<height>540</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -851,8 +872,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>106</width>
<height>129</height>
<width>722</width>
<height>540</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_17">
@@ -944,8 +965,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>590</width>
<height>626</height>
<width>706</width>
<height>574</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_16">

0 comments on commit a033d47

Please sign in to comment.
You can’t perform that action at this time.