Skip to content

Commit

Permalink
apply #2199
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12642 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 28, 2009
1 parent 80c4825 commit d20f327
Show file tree
Hide file tree
Showing 8 changed files with 810 additions and 673 deletions.
1 change: 1 addition & 0 deletions python/core/qgslabel.sip
Expand Up @@ -38,6 +38,7 @@ public:
BorderColor,
BorderStyle,
MultilineEnabled,
StrikeOut, // added in 1.5
LabelFieldCount
};

Expand Down
5 changes: 5 additions & 0 deletions python/core/qgslabelattributes.sip
Expand Up @@ -47,6 +47,11 @@ public:
bool underlineIsSet ( ) const;
bool underline ( ) const;

/* strikeout added in 1.5 */
void setStrikeOut( bool enable );
bool strikeOutIsSet ( ) const;
bool strikeOut ( ) const;

void setSize ( double size, int type );
bool sizeIsSet ( ) const;
int sizeType ( ) const;
Expand Down
16 changes: 14 additions & 2 deletions src/app/qgslabeldialog.cpp
Expand Up @@ -89,6 +89,10 @@ void QgsLabelDialog::init( )
cboUnderlineField->addItems( myFieldStringList );
cboUnderlineField->setCurrentIndex( itemNoForField( mLabel->labelField( QgsLabel::Underline ), myFieldStringList ) );

cboStrikeOutField->clear();
cboStrikeOutField->addItems( myFieldStringList );
cboStrikeOutField->setCurrentIndex( itemNoForField( mLabel->labelField( QgsLabel::StrikeOut ), myFieldStringList ) );

cboFontSizeField->clear();
cboFontSizeField->addItems( myFieldStringList );
cboFontSizeField->setCurrentIndex( itemNoForField( mLabel->labelField( QgsLabel::Size ), myFieldStringList ) );
Expand Down Expand Up @@ -196,6 +200,14 @@ void QgsLabelDialog::init( )
{
mFont.setUnderline( false );
}
if ( myLabelAttributes->strikeOutIsSet() )
{
mFont.setStrikeOut( myLabelAttributes->strikeOut() );
}
else
{
mFont.setStrikeOut( false );
}

mFontColor = myLabelAttributes->color();

Expand Down Expand Up @@ -270,8 +282,6 @@ void QgsLabelDialog::init( )

//NOTE: do we need this line too? TS
spinBufferSize->setValue( myLabelAttributes->bufferSize() );
//TODO - transparency attributes for buffers

}


Expand Down Expand Up @@ -364,6 +374,7 @@ void QgsLabelDialog::apply()
myLabelAttributes->setBold( mFont.bold() );
myLabelAttributes->setItalic( mFont.italic() );
myLabelAttributes->setUnderline( mFont.underline() );
myLabelAttributes->setStrikeOut( mFont.strikeOut() );
myLabelAttributes->setColor( mFontColor );
myTypeInt = 0;
if ( radioOffsetUnitsPoints->isChecked() )
Expand Down Expand Up @@ -412,6 +423,7 @@ void QgsLabelDialog::apply()
mLabel->setLabelField( QgsLabel::Bold, fieldIndexFromName( cboBoldField->currentText() ) );
mLabel->setLabelField( QgsLabel::Italic, fieldIndexFromName( cboItalicField->currentText() ) );
mLabel->setLabelField( QgsLabel::Underline, fieldIndexFromName( cboUnderlineField->currentText() ) );
mLabel->setLabelField( QgsLabel::StrikeOut, fieldIndexFromName( cboStrikeOutField->currentText() ) );
mLabel->setLabelField( QgsLabel::Size, fieldIndexFromName( cboFontSizeField->currentText() ) );
mLabel->setLabelField( QgsLabel::SizeType, fieldIndexFromName( cboFontSizeTypeField->currentText() ) );
mLabel->setLabelField( QgsLabel::Color, fieldIndexFromName( cboFontColorField->currentText() ) );
Expand Down
45 changes: 45 additions & 0 deletions src/core/qgslabel.cpp
Expand Up @@ -207,6 +207,16 @@ void QgsLabel::renderLabel( QgsRenderContext &renderContext,
font.setUnderline(( bool ) value.toInt() );
}

value = fieldValue( StrikeOut, feature );
if ( value.isEmpty() )
{
font.setStrikeOut( mLabelAttributes->strikeOut() );
}
else
{
font.setStrikeOut(( bool ) value.toInt() );
}

//
QgsPoint overridePoint;
bool useOverridePoint = false;
Expand Down Expand Up @@ -832,6 +842,20 @@ void QgsLabel::readXML( const QDomNode& node )
readLabelField( el, Underline );
}

/* Strikeout */
scratchNode = node.namedItem( "strikeout" );

if ( scratchNode.isNull() )
{
QgsDebugMsg( "couldn't find QgsLabel ``strikeout'' attribute" );
}
else
{
el = scratchNode.toElement();
mLabelAttributes->setStrikeOut(( bool )el.attribute( "on", "0" ).toInt() );
readLabelField( el, StrikeOut );
}

/* Color */
scratchNode = node.namedItem( "color" );

Expand Down Expand Up @@ -1130,6 +1154,27 @@ void QgsLabel::writeXML( QDomNode & layer_node, QDomDocument & document ) const
}
labelattributes.appendChild( underline );

// strikeout
QDomElement strikeOut = document.createElement( "strikeout" );
if ( mLabelAttributes->strikeOutIsSet() )
{
strikeOut.setAttribute( "on", mLabelAttributes->strikeOut() );
if ( mLabelFieldIdx[StrikeOut] != -1 )
{
strikeOut.setAttribute( "fieldname", labelField( StrikeOut ) );
}
else
{
strikeOut.setAttribute( "fieldname", "" );
}
}
else
{
strikeOut.setAttribute( "on", 0 );
strikeOut.setAttribute( "fieldname", "" );
}
labelattributes.appendChild( strikeOut );

// color
QDomElement color = document.createElement( "color" );
if ( mLabelAttributes->colorIsSet() )
Expand Down
1 change: 1 addition & 0 deletions src/core/qgslabel.h
Expand Up @@ -81,6 +81,7 @@ class CORE_EXPORT QgsLabel
BorderColor,
BorderStyle,
MultilineEnabled,
StrikeOut, // added in 1.5
LabelFieldCount
};

Expand Down
17 changes: 17 additions & 0 deletions src/core/qgslabelattributes.cpp
Expand Up @@ -31,6 +31,7 @@ QgsLabelAttributes::QgsLabelAttributes( bool def )
mBoldIsSet( false ),
mItalicIsSet( false ),
mUnderlineIsSet( false ),
mStrikeOutIsSet( false ),
mSizeType( 0 ),
mSize( 0.0 ),
mSizeIsSet( false ),
Expand Down Expand Up @@ -247,6 +248,22 @@ bool QgsLabelAttributes::underline( void ) const
return mFont.underline();
}

void QgsLabelAttributes::setStrikeOut( bool enable )
{
mFont.setStrikeOut( enable );
mStrikeOutIsSet = true;
}

bool QgsLabelAttributes::strikeOutIsSet( void ) const
{
return mStrikeOutIsSet;
}

bool QgsLabelAttributes::strikeOut( void ) const
{
return mFont.strikeOut();
}


void QgsLabelAttributes::setSize( double size, int type )
{
Expand Down
8 changes: 7 additions & 1 deletion src/core/qgslabelattributes.h
Expand Up @@ -119,6 +119,11 @@ class CORE_EXPORT QgsLabelAttributes
bool underlineIsSet( void ) const;
bool underline( void ) const;

/* strikeout added in 1.5 */
void setStrikeOut( bool enable );
bool strikeOutIsSet( void ) const;
bool strikeOut( void ) const;

void setSize( double size, int type );
bool sizeIsSet( void ) const;
int sizeType( void ) const;
Expand Down Expand Up @@ -185,12 +190,13 @@ class CORE_EXPORT QgsLabelAttributes
QString mText;
bool mTextIsSet;

/** Font (family, weight, italic, underline) */
/** Font (family, weight, italic, underline, strikeout) */
QFont mFont;
bool mFamilyIsSet;
bool mBoldIsSet;
bool mItalicIsSet;
bool mUnderlineIsSet;
bool mStrikeOutIsSet;

/** Font size, size type */
int mSizeType;
Expand Down

0 comments on commit d20f327

Please sign in to comment.