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;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>642</width>
<height>516</height>
<width>662</width>
<height>561</height>
</rect>
</property>
<property name="sizePolicy">
@ -19,29 +19,33 @@
<property name="windowTitle">
<string>Form1</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<property name="margin">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>-990</y>
<width>619</width>
<height>1440</height>
<y>0</y>
<width>644</width>
<height>365</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QGridLayout">
<item row="0" column="0">
<attribute name="label">
<string>Basic label options and placement</string>
</attribute>
<widget class="QGroupBox" name="groupBox_8">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>621</width>
<height>174</height>
</rect>
</property>
<property name="title">
<string>Basic label options</string>
</property>
@ -185,11 +189,15 @@
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>621</width>
<height>106</height>
</rect>
</property>
<property name="title">
<string>Placement</string>
</property>
@ -265,31 +273,21 @@
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Font size units</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="radioFontSizeUnitsPoints">
<property name="text">
<string>Points</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radioFontSizeUnitsMap">
<property name="text">
<string>Map units</string>
<widget class="QWidget" name="page_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>644</width>
<height>365</height>
</rect>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<attribute name="label">
<string>Scale dependent rendering, buffer labels, font size units and offset</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="chkUseScaleDependentRendering">
<property name="title">
<string>Use scale dependent rendering</string>
@ -350,7 +348,7 @@
</layout>
</widget>
</item>
<item row="10" column="0">
<item>
<widget class="QGroupBox" name="chkUseBuffer">
<property name="enabled">
<bool>true</bool>
@ -440,30 +438,62 @@
</layout>
</widget>
</item>
<item row="11" column="0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Font size units</string>
</property>
<layout class="QGridLayout" name="_2">
<item row="0" column="0">
<widget class="QRadioButton" name="radioFontSizeUnitsPoints">
<property name="text">
<string>Points</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioFontSizeUnitsMap">
<property name="text">
<string>Map units</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="buttonGroup10">
<property name="title">
<string>Offset units</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="textLabel1_2_2_2_3">
<widget class="QLabel" name="textLabel1_2_3_2">
<property name="text">
<string>X Offset (pts)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="textLabel1_2_3_2">
<widget class="QDoubleSpinBox" name="spinXOffset">
<property name="minimum">
<double>-99.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="radioOffsetUnitsPoints">
<property name="text">
<string>Y Offset (pts)</string>
<string>Points</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QDoubleSpinBox" name="spinXOffset">
<property name="minimum">
<double>-99.000000000000000</double>
<widget class="QLabel" name="textLabel1_2_2_2_3">
<property name="text">
<string>Y Offset (pts)</string>
</property>
</widget>
</item>
@ -474,14 +504,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radioOffsetUnitsPoints">
<property name="text">
<string>Points</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="2">
<widget class="QRadioButton" name="radioOffsetUnitsMap">
<property name="text">
<string>Map units</string>
@ -491,8 +514,31 @@
</layout>
</widget>
</item>
<item row="12" column="0">
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>644</width>
<height>365</height>
</rect>
</property>
<attribute name="label">
<string>Data defined settings (placement and properties)</string>
</attribute>
<widget class="QGroupBox" name="groupBox_5">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>621</width>
<height>84</height>
</rect>
</property>
<property name="title">
<string>Data defined placement</string>
</property>
@ -531,9 +577,15 @@
</item>
</layout>
</widget>
</item>
<item row="13" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>621</width>
<height>246</height>
</rect>
</property>
<property name="title">
<string>Data defined properties</string>
</property>
@ -614,7 +666,7 @@
<item row="3" column="1">
<widget class="QComboBox" name="cboUnderlineField"/>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QLabel" name="textLabel4_3_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -630,10 +682,10 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="cboFontSizeField"/>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QLabel" name="textLabel4_3_2_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -649,36 +701,10 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="7" column="1">
<widget class="QComboBox" name="cboFontSizeTypeField"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="textLabel4_3_2_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Transparency</string>
</property>
<property name="buddy">
<cstring>cboFontTransparencyField</cstring>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="cboFontTransparencyField">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="textLabel4_3_2_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -694,14 +720,43 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QComboBox" name="cboFontColorField"/>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="cboStrikeOutField"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Strikeout</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="14" column="0">
</widget>
<widget class="QWidget" name="page_4">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>644</width>
<height>365</height>
</rect>
</property>
<attribute name="label">
<string>Data defined settings: buffer and position</string>
</attribute>
<widget class="QGroupBox" name="groupBox_6">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>621</width>
<height>84</height>
</rect>
</property>
<property name="title">
<string>Data defined buffer</string>
</property>
@ -759,9 +814,15 @@
</item>
</layout>
</widget>
</item>
<item row="15" column="0">
<widget class="QGroupBox" name="groupBox_7">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>621</width>
<height>138</height>
</rect>
</property>
<property name="title">
<string>Data defined position</string>
</property>
@ -832,12 +893,10 @@
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<item>
<widget class="QGroupBox" name="groupBox5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -872,7 +931,6 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>scrollArea</tabstop>
<tabstop>cboLabelField</tabstop>
<tabstop>leDefaultLabel</tabstop>
<tabstop>btnDefaultFont</tabstop>
@ -889,21 +947,13 @@
<tabstop>radioBelowLeft</tabstop>
<tabstop>radioBelow</tabstop>
<tabstop>radioBelowRight</tabstop>
<tabstop>radioFontSizeUnitsPoints</tabstop>
<tabstop>radioFontSizeUnitsMap</tabstop>
<tabstop>chkUseScaleDependentRendering</tabstop>
<tabstop>spinMinimumScale</tabstop>
<tabstop>spinMaximumScale</tabstop>
<tabstop>chkUseBuffer</tabstop>
<tabstop>pbnDefaultBufferColor_2</tabstop>
<tabstop>spinBufferSize</tabstop>
<tabstop>radioBufferUnitsPoints</tabstop>
<tabstop>radioBufferUnitsMap</tabstop>
<tabstop>spinBufferTransparency</tabstop>
<tabstop>spinXOffset</tabstop>
<tabstop>spinYOffset</tabstop>
<tabstop>radioOffsetUnitsPoints</tabstop>
<tabstop>radioOffsetUnitsMap</tabstop>
<tabstop>cboAlignmentField</tabstop>
<tabstop>cboAngleField</tabstop>
<tabstop>cboFontField</tabstop>
@ -912,7 +962,7 @@
<tabstop>cboUnderlineField</tabstop>
<tabstop>cboFontSizeField</tabstop>
<tabstop>cboFontSizeTypeField</tabstop>
<tabstop>cboFontTransparencyField</tabstop>
<tabstop>cboStrikeOutField</tabstop>
<tabstop>cboFontColorField</tabstop>
<tabstop>cboBufferTransparencyField</tabstop>
<tabstop>cboBufferSizeField</tabstop>