Skip to content
Permalink
Browse files

[gui] Remove deprecated labeling properties tab for new projects or o…

…lder ones that don't use them

- Deprecated tab remains active for older projects, if any layer uses them
- Deprecated tab an be disabled/enabled via console commands for project entry, e.g.:
  QgsProject.instance().writeEntry('DeprecatedLabels', '/Enabled', bool) or
  QgsProject.instance().removeEntry('DeprecatedLabels', '/')
  • Loading branch information
dakcarto committed Aug 31, 2013
1 parent 63fa7e2 commit cae08e4215183f6920493f8394b1405120f16096
Showing with 65 additions and 5 deletions.
  1. +39 −0 src/app/qgisapp.cpp
  2. +4 −0 src/app/qgisapp.h
  3. +22 −5 src/app/qgsvectorlayerproperties.cpp
@@ -1899,6 +1899,12 @@ void QgisApp::setupConnections()
connect( this, SIGNAL( projectRead() ),
this, SLOT( fileOpenedOKAfterLaunch() ) );

// handle deprecated labels in project for QGIS 2.0
connect( this, SIGNAL( newProject() ),
this, SLOT( checkForDeprecatedLabelsInProject() ) );
connect( this, SIGNAL( projectRead() ),
this, SLOT( checkForDeprecatedLabelsInProject() ) );

//
// Do we really need this ??? - its already connected to the esc key...TS
//
@@ -4602,6 +4608,39 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection )
delete dialog;
}

void QgisApp::checkForDeprecatedLabelsInProject()
{
bool ok;
QgsProject::instance()->readBoolEntry( "DeprecatedLabels", "/Enabled", false, &ok );
if ( ok ) // project already flagged (regardless of project property value)
{
return;
}

if ( QgsMapLayerRegistry::instance()->count() > 0 )
{
bool depLabelsUsed = false;
QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
for ( QMap<QString, QgsMapLayer*>::iterator it = layers.begin(); it != layers.end(); it++ )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( it.value() );
if ( !vl )
{
continue;
}

depLabelsUsed = vl->hasLabelsEnabled();
if ( depLabelsUsed )
{
break;
}
}
if ( depLabelsUsed )
{
QgsProject::instance()->writeEntry( "DeprecatedLabels", "/Enabled", true );
}
}
}

void QgisApp::layerProperties()
{
@@ -1038,6 +1038,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//! shows label settings dialog (for labeling-ng)
void labeling();

/** Check if deprecated labels are used in project, and flag projects that use them (QGIS 2.0)
*/
void checkForDeprecatedLabelsInProject();

//! save current vector layer
void saveAsFile();
void saveSelectionAsVectorFile();
@@ -267,7 +267,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(

QgsVectorLayerProperties::~QgsVectorLayerProperties()
{
if ( layer->hasGeometryType() )
if ( mOptsPage_LabelsOld && layer->hasGeometryType() )
{
disconnect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
}
@@ -412,6 +412,20 @@ void QgsVectorLayerProperties::syncToLayer( void )
mFieldsPropertiesDialog->init();

QObject::connect( labelCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( enableLabelOptions( bool ) ) );

// delete deprecated labels tab if not already used by project
// NOTE: this is not ideal, but a quick fix for QGIS 2.0 release
bool ok;
bool dl = QgsProject::instance()->readBoolEntry( "DeprecatedLabels", "/Enabled", false, &ok );
if ( !ok || ( ok && !dl ) ) // project not flagged or set to use deprecated labels
{
if ( mOptsPage_LabelsOld )
{
disconnect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
delete mOptsPage_LabelsOld;
mOptsPage_LabelsOld = 0;
}
}
} // reset()


@@ -462,10 +476,13 @@ void QgsVectorLayerProperties::apply()

actionDialog->apply();

if ( labelDialog )
labelDialog->apply();
layer->enableLabels( labelCheckBox->isChecked() );
layer->setLayerName( mLayerOrigNameLineEdit->text() );
if ( mOptsPage_LabelsOld )
{
if ( labelDialog )
labelDialog->apply();
layer->enableLabels( labelCheckBox->isChecked() );
layer->setLayerName( mLayerOrigNameLineEdit->text() );
}

// Apply fields settings
mFieldsPropertiesDialog->apply();

0 comments on commit cae08e4

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