git-svn-id: http://svn.osgeo.org/qgis/trunk@12642 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
jef 2009-12-28 21:37:07 +00:00
parent 9b7a041be7
commit 7003ed00c4
8 changed files with 810 additions and 673 deletions

View File

@ -38,6 +38,7 @@ public:
BorderColor,
BorderStyle,
MultilineEnabled,
StrikeOut, // added in 1.5
LabelFieldCount
};

View File

@ -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;

View File

@ -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 ) );
@ -196,6 +200,14 @@ void QgsLabelDialog::init( )
{
mFont.setUnderline( false );
}
if ( myLabelAttributes->strikeOutIsSet() )
{
mFont.setStrikeOut( myLabelAttributes->strikeOut() );
}
else
{
mFont.setStrikeOut( false );
}
mFontColor = myLabelAttributes->color();
@ -270,8 +282,6 @@ void QgsLabelDialog::init( )
//NOTE: do we need this line too? TS
spinBufferSize->setValue( myLabelAttributes->bufferSize() );
//TODO - transparency attributes for buffers
}
@ -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() )
@ -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() ) );

View File

@ -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;
@ -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" );
@ -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() )

View File

@ -81,6 +81,7 @@ class CORE_EXPORT QgsLabel
BorderColor,
BorderStyle,
MultilineEnabled,
StrikeOut, // added in 1.5
LabelFieldCount
};

View File

@ -31,6 +31,7 @@ QgsLabelAttributes::QgsLabelAttributes( bool def )
mBoldIsSet( false ),
mItalicIsSet( false ),
mUnderlineIsSet( false ),
mStrikeOutIsSet( false ),
mSizeType( 0 ),
mSize( 0.0 ),
mSizeIsSet( false ),
@ -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 )
{

View File

@ -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;
@ -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;

File diff suppressed because it is too large Load Diff