Skip to content
Permalink
Browse files
unified signatures and removed unused function
  • Loading branch information
domi4484 committed Jan 10, 2022
1 parent 5e8a531 commit 4f3e705623d6780d68a20ee601bd2e73c57b1c93
Showing with 13 additions and 77 deletions.
  1. +4 −40 src/app/labeling/qgsmaptoollabel.cpp
  2. +0 −29 src/app/labeling/qgsmaptoollabel.h
  3. +3 −2 src/app/labeling/qgsmaptoolmovelabel.cpp
  4. +6 −6 src/app/labeling/qgsmaptoolpinlabels.cpp
@@ -631,12 +631,6 @@ QVariant QgsMapToolLabel::evaluateDataDefinedProperty( QgsPalLayerSettings::Prop
return labelSettings.dataDefinedProperties().value( property, context, defaultValue );
}

bool QgsMapToolLabel::currentLabelDataDefinedPosition( double &x, bool &xSuccess, double &y, bool &ySuccess, int &xCol, int &yCol ) const
{
int pointCol = -1;
return currentLabelDataDefinedPosition( x, xSuccess, y, ySuccess, xCol, yCol, pointCol );
}

bool QgsMapToolLabel::currentLabelDataDefinedPosition( double &x, bool &xSuccess, double &y, bool &ySuccess, int &xCol, int &yCol, int &pointCol ) const
{
QgsVectorLayer *vlayer = mCurrentLabel.layer;
@@ -736,10 +730,10 @@ bool QgsMapToolLabel::currentLabelDataDefinedRotation( double &rotation, bool &r
//test, if data defined x- and y- values are not null. Otherwise, the position is determined by PAL and the rotation cannot be fixed
if ( !ignoreXY )
{
int xCol, yCol;
int xCol, yCol, pointCol;
double x, y;
bool xSuccess, ySuccess;
if ( !currentLabelDataDefinedPosition( x, xSuccess, y, ySuccess, xCol, yCol ) || !xSuccess || !ySuccess )
if ( !currentLabelDataDefinedPosition( x, xSuccess, y, ySuccess, xCol, yCol, pointCol ) || !xSuccess || !ySuccess )
{
return false;
}
@@ -833,36 +827,6 @@ bool QgsMapToolLabel::diagramMoveable( QgsVectorLayer *vlayer, int &xCol, int &y
return false;
}

bool QgsMapToolLabel::labelMoveable( QgsVectorLayer *vlayer, int &xCol, int &yCol ) const
{
if ( !vlayer || !vlayer->isEditable() || !vlayer->labelsEnabled() )
{
return false;
}

const auto constSubProviders = vlayer->labeling()->subProviders();
for ( const QString &providerId : constSubProviders )
{
if ( labelMoveable( vlayer, vlayer->labeling()->settings( providerId ), xCol, yCol ) )
return true;
}

return false;
}

bool QgsMapToolLabel::labelMoveable( QgsVectorLayer *vlayer, const QgsPalLayerSettings &settings, int &xCol, int &yCol ) const
{
int pointCol = -1;
return labelMoveable( vlayer, settings, xCol, yCol, pointCol );
}

bool QgsMapToolLabel::layerCanPin( QgsVectorLayer *vlayer, int &xCol, int &yCol ) const
{
// currently same as QgsMapToolLabel::labelMoveable, but may change
bool canPin = labelMoveable( vlayer, xCol, yCol );
return canPin;
}

bool QgsMapToolLabel::labelCanShowHide( QgsVectorLayer *vlayer, int &showCol ) const
{
if ( !vlayer || !vlayer->isEditable() || !vlayer->labelsEnabled() )
@@ -895,11 +859,11 @@ bool QgsMapToolLabel::isPinned()
{
// for diagrams, the isPinned attribute is not set. So we check directly if
// there's data defined.
int xCol, yCol;
int xCol, yCol, pointCol;
double x, y;
bool xSuccess, ySuccess;

if ( currentLabelDataDefinedPosition( x, xSuccess, y, ySuccess, xCol, yCol ) && xSuccess && ySuccess )
if ( currentLabelDataDefinedPosition( x, xSuccess, y, ySuccess, xCol, yCol, pointCol ) && xSuccess && ySuccess )
rc = true;
}

@@ -45,15 +45,6 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapToolAdvancedDigitizing

void deactivate() override;

/**
* Returns TRUE if label move can be applied to a layer
* \param xCol out: index of the attribute for data defined x coordinate
* \param yCol out: index of the attribute for data defined y coordinate
* \returns TRUE if labels of layer can be moved
*/
bool labelMoveable( QgsVectorLayer *vlayer, int &xCol, int &yCol ) const;
bool labelMoveable( QgsVectorLayer *vlayer, const QgsPalLayerSettings &settings, int &xCol, int &yCol ) const;

/**
* Returns true if diagram move can be applied to a layer
* \param xCol out: index of the attribute for data defined x coordinate
@@ -62,14 +53,6 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapToolAdvancedDigitizing
*/
bool diagramMoveable( QgsVectorLayer *vlayer, int &xCol, int &yCol ) const;

/**
* Returns TRUE if layer has attribute fields set up
* \param xCol out: index of the attribute for data defined x coordinate
* \param yCol out: index of the attribute for data defined y coordinate
* \returns TRUE if layer fields set up and exist
*/
bool layerCanPin( QgsVectorLayer *vlayer, int &xCol, int &yCol ) const;

/**
* Returns TRUE if layer has attribute field set up for diagrams
* \param showCol out: attribute column for data defined diagram showing
@@ -179,18 +162,6 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapToolAdvancedDigitizing
//! Returns whether to preserve predefined rotation data during label pin/unpin operations
bool currentLabelPreserveRotation();

/**
* Gets data defined position of current label
* \param x out: data defined x-coordinate
* \param xSuccess out: FALSE if attribute value is NULL
* \param y out: data defined y-coordinate
* \param ySuccess out: FALSE if attribute value is NULL
* \param xCol out: index of the x position column
* \param yCol out: index of the y position column
* \returns FALSE if layer does not have data defined label position enabled
*/
bool currentLabelDataDefinedPosition( double &x, bool &xSuccess, double &y, bool &ySuccess, int &xCol, int &yCol ) const;

/**
* Gets data defined position of current label
* \param x out: data defined x-coordinate
@@ -193,7 +193,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )
if ( createAuxiliaryFields( indexes ) )
return;

if ( !labelMoveable( vlayer, mCurrentLabel.settings, xCol, yCol ) )
if ( !labelMoveable( vlayer, mCurrentLabel.settings, xCol, yCol, pointCol ) )
{
QString xColName = dataDefinedColumnName( QgsPalLayerSettings::PositionX, mCurrentLabel.settings, vlayer );
QString yColName = dataDefinedColumnName( QgsPalLayerSettings::PositionY, mCurrentLabel.settings, vlayer );
@@ -465,12 +465,13 @@ void QgsMapToolMoveLabel::keyReleaseEvent( QKeyEvent *e )
{
int xCol = -1;
int yCol = -1;
int pointCol = -1;
double xPosOrig = 0;
double yPosOrig = 0;
bool xSuccess = false;
bool ySuccess = false;

if ( !isCalloutMove && !currentLabelDataDefinedPosition( xPosOrig, xSuccess, yPosOrig, ySuccess, xCol, yCol ) )
if ( !isCalloutMove && !currentLabelDataDefinedPosition( xPosOrig, xSuccess, yPosOrig, ySuccess, xCol, yCol, pointCol ) )
{
break;
}
@@ -347,14 +347,14 @@ bool QgsMapToolPinLabels::pinUnpinCurrentLabel( bool pin )
return false;
}

// verify attribute table has x, y fields mapped
int xCol, yCol;
// verify attribute table has x, y or point fields mapped
int xCol, yCol, pointCol;
double xPosOrig, yPosOrig;
bool xSuccess, ySuccess;

if ( !currentLabelDataDefinedPosition( xPosOrig, xSuccess, yPosOrig, ySuccess, xCol, yCol ) )
if ( !currentLabelDataDefinedPosition( xPosOrig, xSuccess, yPosOrig, ySuccess, xCol, yCol, pointCol ) )
{
QgsDebugMsgLevel( QStringLiteral( "Label X or Y column not mapped, skipping" ), 2 );
QgsDebugMsgLevel( QStringLiteral( "Label X, Y or Point column not mapped, skipping" ), 2 );
return false;
}

@@ -461,11 +461,11 @@ bool QgsMapToolPinLabels::pinUnpinCurrentDiagram( bool pin )
return false;

// verify attribute table has x, y fields mapped
int xCol, yCol;
int xCol, yCol, pointCol;
double xPosOrig, yPosOrig;
bool xSuccess, ySuccess;

if ( !currentLabelDataDefinedPosition( xPosOrig, xSuccess, yPosOrig, ySuccess, xCol, yCol ) )
if ( !currentLabelDataDefinedPosition( xPosOrig, xSuccess, yPosOrig, ySuccess, xCol, yCol, pointCol ) )
return false;

// edit attribute table

0 comments on commit 4f3e705

Please sign in to comment.