Skip to content

Commit 7003ed0

Browse files
author
jef
committedDec 28, 2009
apply #2199
git-svn-id: http://svn.osgeo.org/qgis/trunk@12642 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9b7a041 commit 7003ed0

File tree

8 files changed

+810
-673
lines changed

8 files changed

+810
-673
lines changed
 

‎python/core/qgslabel.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public:
3838
BorderColor,
3939
BorderStyle,
4040
MultilineEnabled,
41+
StrikeOut, // added in 1.5
4142
LabelFieldCount
4243
};
4344

‎python/core/qgslabelattributes.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public:
4747
bool underlineIsSet ( ) const;
4848
bool underline ( ) const;
4949

50+
/* strikeout added in 1.5 */
51+
void setStrikeOut( bool enable );
52+
bool strikeOutIsSet ( ) const;
53+
bool strikeOut ( ) const;
54+
5055
void setSize ( double size, int type );
5156
bool sizeIsSet ( ) const;
5257
int sizeType ( ) const;

‎src/app/qgslabeldialog.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ void QgsLabelDialog::init( )
8989
cboUnderlineField->addItems( myFieldStringList );
9090
cboUnderlineField->setCurrentIndex( itemNoForField( mLabel->labelField( QgsLabel::Underline ), myFieldStringList ) );
9191

92+
cboStrikeOutField->clear();
93+
cboStrikeOutField->addItems( myFieldStringList );
94+
cboStrikeOutField->setCurrentIndex( itemNoForField( mLabel->labelField( QgsLabel::StrikeOut ), myFieldStringList ) );
95+
9296
cboFontSizeField->clear();
9397
cboFontSizeField->addItems( myFieldStringList );
9498
cboFontSizeField->setCurrentIndex( itemNoForField( mLabel->labelField( QgsLabel::Size ), myFieldStringList ) );
@@ -196,6 +200,14 @@ void QgsLabelDialog::init( )
196200
{
197201
mFont.setUnderline( false );
198202
}
203+
if ( myLabelAttributes->strikeOutIsSet() )
204+
{
205+
mFont.setStrikeOut( myLabelAttributes->strikeOut() );
206+
}
207+
else
208+
{
209+
mFont.setStrikeOut( false );
210+
}
199211

200212
mFontColor = myLabelAttributes->color();
201213

@@ -270,8 +282,6 @@ void QgsLabelDialog::init( )
270282

271283
//NOTE: do we need this line too? TS
272284
spinBufferSize->setValue( myLabelAttributes->bufferSize() );
273-
//TODO - transparency attributes for buffers
274-
275285
}
276286

277287

@@ -364,6 +374,7 @@ void QgsLabelDialog::apply()
364374
myLabelAttributes->setBold( mFont.bold() );
365375
myLabelAttributes->setItalic( mFont.italic() );
366376
myLabelAttributes->setUnderline( mFont.underline() );
377+
myLabelAttributes->setStrikeOut( mFont.strikeOut() );
367378
myLabelAttributes->setColor( mFontColor );
368379
myTypeInt = 0;
369380
if ( radioOffsetUnitsPoints->isChecked() )
@@ -412,6 +423,7 @@ void QgsLabelDialog::apply()
412423
mLabel->setLabelField( QgsLabel::Bold, fieldIndexFromName( cboBoldField->currentText() ) );
413424
mLabel->setLabelField( QgsLabel::Italic, fieldIndexFromName( cboItalicField->currentText() ) );
414425
mLabel->setLabelField( QgsLabel::Underline, fieldIndexFromName( cboUnderlineField->currentText() ) );
426+
mLabel->setLabelField( QgsLabel::StrikeOut, fieldIndexFromName( cboStrikeOutField->currentText() ) );
415427
mLabel->setLabelField( QgsLabel::Size, fieldIndexFromName( cboFontSizeField->currentText() ) );
416428
mLabel->setLabelField( QgsLabel::SizeType, fieldIndexFromName( cboFontSizeTypeField->currentText() ) );
417429
mLabel->setLabelField( QgsLabel::Color, fieldIndexFromName( cboFontColorField->currentText() ) );

‎src/core/qgslabel.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ void QgsLabel::renderLabel( QgsRenderContext &renderContext,
207207
font.setUnderline(( bool ) value.toInt() );
208208
}
209209

210+
value = fieldValue( StrikeOut, feature );
211+
if ( value.isEmpty() )
212+
{
213+
font.setStrikeOut( mLabelAttributes->strikeOut() );
214+
}
215+
else
216+
{
217+
font.setStrikeOut(( bool ) value.toInt() );
218+
}
219+
210220
//
211221
QgsPoint overridePoint;
212222
bool useOverridePoint = false;
@@ -832,6 +842,20 @@ void QgsLabel::readXML( const QDomNode& node )
832842
readLabelField( el, Underline );
833843
}
834844

845+
/* Strikeout */
846+
scratchNode = node.namedItem( "strikeout" );
847+
848+
if ( scratchNode.isNull() )
849+
{
850+
QgsDebugMsg( "couldn't find QgsLabel ``strikeout'' attribute" );
851+
}
852+
else
853+
{
854+
el = scratchNode.toElement();
855+
mLabelAttributes->setStrikeOut(( bool )el.attribute( "on", "0" ).toInt() );
856+
readLabelField( el, StrikeOut );
857+
}
858+
835859
/* Color */
836860
scratchNode = node.namedItem( "color" );
837861

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

1157+
// strikeout
1158+
QDomElement strikeOut = document.createElement( "strikeout" );
1159+
if ( mLabelAttributes->strikeOutIsSet() )
1160+
{
1161+
strikeOut.setAttribute( "on", mLabelAttributes->strikeOut() );
1162+
if ( mLabelFieldIdx[StrikeOut] != -1 )
1163+
{
1164+
strikeOut.setAttribute( "fieldname", labelField( StrikeOut ) );
1165+
}
1166+
else
1167+
{
1168+
strikeOut.setAttribute( "fieldname", "" );
1169+
}
1170+
}
1171+
else
1172+
{
1173+
strikeOut.setAttribute( "on", 0 );
1174+
strikeOut.setAttribute( "fieldname", "" );
1175+
}
1176+
labelattributes.appendChild( strikeOut );
1177+
11331178
// color
11341179
QDomElement color = document.createElement( "color" );
11351180
if ( mLabelAttributes->colorIsSet() )

‎src/core/qgslabel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class CORE_EXPORT QgsLabel
8181
BorderColor,
8282
BorderStyle,
8383
MultilineEnabled,
84+
StrikeOut, // added in 1.5
8485
LabelFieldCount
8586
};
8687

‎src/core/qgslabelattributes.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ QgsLabelAttributes::QgsLabelAttributes( bool def )
3131
mBoldIsSet( false ),
3232
mItalicIsSet( false ),
3333
mUnderlineIsSet( false ),
34+
mStrikeOutIsSet( false ),
3435
mSizeType( 0 ),
3536
mSize( 0.0 ),
3637
mSizeIsSet( false ),
@@ -247,6 +248,22 @@ bool QgsLabelAttributes::underline( void ) const
247248
return mFont.underline();
248249
}
249250

251+
void QgsLabelAttributes::setStrikeOut( bool enable )
252+
{
253+
mFont.setStrikeOut( enable );
254+
mStrikeOutIsSet = true;
255+
}
256+
257+
bool QgsLabelAttributes::strikeOutIsSet( void ) const
258+
{
259+
return mStrikeOutIsSet;
260+
}
261+
262+
bool QgsLabelAttributes::strikeOut( void ) const
263+
{
264+
return mFont.strikeOut();
265+
}
266+
250267

251268
void QgsLabelAttributes::setSize( double size, int type )
252269
{

‎src/core/qgslabelattributes.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ class CORE_EXPORT QgsLabelAttributes
119119
bool underlineIsSet( void ) const;
120120
bool underline( void ) const;
121121

122+
/* strikeout added in 1.5 */
123+
void setStrikeOut( bool enable );
124+
bool strikeOutIsSet( void ) const;
125+
bool strikeOut( void ) const;
126+
122127
void setSize( double size, int type );
123128
bool sizeIsSet( void ) const;
124129
int sizeType( void ) const;
@@ -185,12 +190,13 @@ class CORE_EXPORT QgsLabelAttributes
185190
QString mText;
186191
bool mTextIsSet;
187192

188-
/** Font (family, weight, italic, underline) */
193+
/** Font (family, weight, italic, underline, strikeout) */
189194
QFont mFont;
190195
bool mFamilyIsSet;
191196
bool mBoldIsSet;
192197
bool mItalicIsSet;
193198
bool mUnderlineIsSet;
199+
bool mStrikeOutIsSet;
194200

195201
/** Font size, size type */
196202
int mSizeType;

‎src/ui/qgslabeldialogbase.ui

Lines changed: 720 additions & 670 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.