|
23 | 23 | #include "qgsproject.h"
|
24 | 24 | #include "qgsvectorlayer.h"
|
25 | 25 |
|
26 |
| -const QgsPropertiesDefinition QgsComposerObject::PROPERTY_DEFINITIONS |
| 26 | +QgsPropertiesDefinition QgsComposerObject::PROPERTY_DEFINITIONS; |
| 27 | + |
| 28 | +void QgsComposerObject::initPropertyDefinitions() |
27 | 29 | {
|
28 |
| - { QgsComposerObject::TestProperty, QgsPropertyDefinition( "dataDefinedProperty" , QgsPropertyDefinition::DataTypeString, "invalid property", QString() ) }, |
29 |
| - { QgsComposerObject::PresetPaperSize, QgsPropertyDefinition( "dataDefinedPaperSize" , QgsPropertyDefinition::DataTypeString, QObject::tr( "Paper size" ), QObject::tr( "string " ) + QLatin1String( "[<b>A5</b>|<b>A4</b>|<b>A3</b>|<b>A2</b>|<b>A1</b>|<b>A0</b>" |
30 |
| - "<b>B5</b>|<b>B4</b>|<b>B3</b>|<b>B2</b>|<b>B1</b>|<b>B0</b>" |
31 |
| - "<b>Legal</b>|<b>Ansi A</b>|<b>Ansi B</b>|<b>Ansi C</b>|<b>Ansi D</b>|<b>Ansi E</b>" |
32 |
| - "<b>Arch A</b>|<b>Arch B</b>|<b>Arch C</b>|<b>Arch D</b>|<b>Arch E</b>|<b>Arch E1</b>]" |
33 |
| - ) ) }, |
34 |
| - { QgsComposerObject::PaperWidth, QgsPropertyDefinition( "dataDefinedPaperWidth", QObject::tr( "Page width" ), QgsPropertyDefinition::DoublePositive ) }, |
35 |
| - { QgsComposerObject::PaperHeight, QgsPropertyDefinition( "dataDefinedPaperHeight" , QObject::tr( "Page height" ), QgsPropertyDefinition::DoublePositive ) }, |
36 |
| - { QgsComposerObject::NumPages, QgsPropertyDefinition( "dataDefinedNumPages" , QObject::tr( "Number of pages" ), QgsPropertyDefinition::IntegerPositive ) }, |
37 |
| - { QgsComposerObject::PaperOrientation, QgsPropertyDefinition( "dataDefinedPaperOrientation", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), QObject::tr( "string " ) + QLatin1String( "[<b>portrait</b>|<b>landscape</b>]" ) ) }, |
38 |
| - { QgsComposerObject::PageNumber, QgsPropertyDefinition( "dataDefinedPageNumber" , QObject::tr( "Page number" ), QgsPropertyDefinition::IntegerPositive ) }, |
39 |
| - { QgsComposerObject::PositionX, QgsPropertyDefinition( "dataDefinedPositionX" , QObject::tr( "Position (X)" ), QgsPropertyDefinition::Double ) }, |
40 |
| - { QgsComposerObject::PositionY, QgsPropertyDefinition( "dataDefinedPositionY" , QObject::tr( "Position (Y)" ), QgsPropertyDefinition::Double ) }, |
41 |
| - { QgsComposerObject::ItemWidth, QgsPropertyDefinition( "dataDefinedWidth" , QObject::tr( "Width" ), QgsPropertyDefinition::DoublePositive ) }, |
42 |
| - { QgsComposerObject::ItemHeight, QgsPropertyDefinition( "dataDefinedHeight" , QObject::tr( "Height" ), QgsPropertyDefinition::DoublePositive ) }, |
43 |
| - { QgsComposerObject::ItemRotation, QgsPropertyDefinition( "dataDefinedRotation" , QObject::tr( "Rotation angle" ), QgsPropertyDefinition::Double ) }, |
44 |
| - { QgsComposerObject::Transparency, QgsPropertyDefinition( "dataDefinedTransparency" , QObject::tr( "Transparency" ), QgsPropertyDefinition::Transparency ) }, |
45 |
| - { QgsComposerObject::BlendMode, QgsPropertyDefinition( "dataDefinedBlendMode" , QObject::tr( "Blend mode" ), QgsPropertyDefinition::BlendMode ) }, |
46 |
| - { QgsComposerObject::ExcludeFromExports, QgsPropertyDefinition( "dataDefinedExcludeExports", QObject::tr( "Exclude item from exports" ), QgsPropertyDefinition::Boolean ) }, |
47 |
| - { QgsComposerObject::FrameColor, QgsPropertyDefinition( "dataDefinedFrameColor", QObject::tr( "Frame color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
48 |
| - { QgsComposerObject::BackgroundColor, QgsPropertyDefinition( "dataDefinedBackgroundColor", QObject::tr( "Background color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
49 |
| - { QgsComposerObject::MapRotation, QgsPropertyDefinition( "dataDefinedMapRotation" , QObject::tr( "Map rotation" ), QgsPropertyDefinition::Double ) }, |
50 |
| - { QgsComposerObject::MapScale, QgsPropertyDefinition( "dataDefinedMapScale" , QObject::tr( "Map scale" ), QgsPropertyDefinition::DoublePositive ) }, |
51 |
| - { QgsComposerObject::MapXMin, QgsPropertyDefinition( "dataDefinedMapXMin" , QObject::tr( "Extent minimum X" ), QgsPropertyDefinition::Double ) }, |
52 |
| - { QgsComposerObject::MapYMin, QgsPropertyDefinition( "dataDefinedMapYMin" , QObject::tr( "Extent minimum Y" ), QgsPropertyDefinition::Double ) }, |
53 |
| - { QgsComposerObject::MapXMax, QgsPropertyDefinition( "dataDefinedMapXMax" , QObject::tr( "Extent maximum X" ), QgsPropertyDefinition::Double ) }, |
54 |
| - { QgsComposerObject::MapYMax, QgsPropertyDefinition( "dataDefinedMapYMax" , QObject::tr( "Extent maximum Y" ), QgsPropertyDefinition::Double ) }, |
55 |
| - { QgsComposerObject::MapAtlasMargin, QgsPropertyDefinition( "dataDefinedMapAtlasMargin" , QObject::tr( "Atlas margin" ), QgsPropertyDefinition::DoublePositive ) }, |
56 |
| - { QgsComposerObject::MapLayers, QgsPropertyDefinition( "dataDefinedMapLayers", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), tr( "list of map layer names separated by | characters" ) ) }, |
57 |
| - { QgsComposerObject::MapStylePreset, QgsPropertyDefinition( "dataDefinedMapStylePreset", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), tr( "list of map layer names separated by | characters" ) ) }, |
58 |
| - { QgsComposerObject::PictureSource, QgsPropertyDefinition( "dataDefinedSource" , QObject::tr( "Picture source (URL)" ), QgsPropertyDefinition::String ) }, |
59 |
| - { QgsComposerObject::SourceUrl, QgsPropertyDefinition( "dataDefinedSourceUrl" , QObject::tr( "Source URL" ), QgsPropertyDefinition::String ) }, |
60 |
| - { QgsComposerObject::PictureSvgBackgroundColor, QgsPropertyDefinition( "dataDefinedSvgBackgroundColor" , QObject::tr( "SVG background color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
61 |
| - { QgsComposerObject::PictureSvgOutlineColor, QgsPropertyDefinition( "dataDefinedSvgOutlineColor" , QObject::tr( "SVG outline color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
62 |
| - { QgsComposerObject::PictureSvgOutlineWidth, QgsPropertyDefinition( "dataDefinedSvgOutlineWidth" , QObject::tr( "SVG outline width" ), QgsPropertyDefinition::DoublePositive ) }, |
63 |
| - { QgsComposerObject::LegendTitle, QgsPropertyDefinition( "dataDefinedLegendTitle" , QObject::tr( "Legend title" ), QgsPropertyDefinition::String ) }, |
64 |
| - { QgsComposerObject::LegendColumnCount, QgsPropertyDefinition( "dataDefinedLegendColumns" , QObject::tr( "Number of columns" ), QgsPropertyDefinition::IntegerPositiveGreaterZero ) }, |
65 |
| - { QgsComposerObject::ScalebarFillColor, QgsPropertyDefinition( "dataDefinedScalebarFill" , QObject::tr( "Fill color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
66 |
| - { QgsComposerObject::ScalebarFillColor2, QgsPropertyDefinition( "dataDefinedScalebarFill2" , QObject::tr( "Secondary fill color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
67 |
| - { QgsComposerObject::ScalebarLineColor, QgsPropertyDefinition( "dataDefinedScalebarLineColor" , QObject::tr( "Line color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
68 |
| - { QgsComposerObject::ScalebarLineWidth, QgsPropertyDefinition( "dataDefinedScalebarLineWidth" , QObject::tr( "Line width" ), QgsPropertyDefinition::DoublePositive ) }, |
69 |
| -}; |
| 30 | + if ( !PROPERTY_DEFINITIONS.isEmpty() ) |
| 31 | + return; |
70 | 32 |
|
| 33 | + PROPERTY_DEFINITIONS = QgsPropertiesDefinition |
| 34 | + { |
| 35 | + { QgsComposerObject::TestProperty, QgsPropertyDefinition( "dataDefinedProperty" , QgsPropertyDefinition::DataTypeString, "invalid property", QString() ) }, |
| 36 | + { QgsComposerObject::PresetPaperSize, QgsPropertyDefinition( "dataDefinedPaperSize" , QgsPropertyDefinition::DataTypeString, QObject::tr( "Paper size" ), QObject::tr( "string " ) + QLatin1String( "[<b>A5</b>|<b>A4</b>|<b>A3</b>|<b>A2</b>|<b>A1</b>|<b>A0</b>" |
| 37 | + "<b>B5</b>|<b>B4</b>|<b>B3</b>|<b>B2</b>|<b>B1</b>|<b>B0</b>" |
| 38 | + "<b>Legal</b>|<b>Ansi A</b>|<b>Ansi B</b>|<b>Ansi C</b>|<b>Ansi D</b>|<b>Ansi E</b>" |
| 39 | + "<b>Arch A</b>|<b>Arch B</b>|<b>Arch C</b>|<b>Arch D</b>|<b>Arch E</b>|<b>Arch E1</b>]" |
| 40 | + ) ) }, |
| 41 | + { QgsComposerObject::PaperWidth, QgsPropertyDefinition( "dataDefinedPaperWidth", QObject::tr( "Page width" ), QgsPropertyDefinition::DoublePositive ) }, |
| 42 | + { QgsComposerObject::PaperHeight, QgsPropertyDefinition( "dataDefinedPaperHeight" , QObject::tr( "Page height" ), QgsPropertyDefinition::DoublePositive ) }, |
| 43 | + { QgsComposerObject::NumPages, QgsPropertyDefinition( "dataDefinedNumPages" , QObject::tr( "Number of pages" ), QgsPropertyDefinition::IntegerPositive ) }, |
| 44 | + { QgsComposerObject::PaperOrientation, QgsPropertyDefinition( "dataDefinedPaperOrientation", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), QObject::tr( "string " ) + QLatin1String( "[<b>portrait</b>|<b>landscape</b>]" ) ) }, |
| 45 | + { QgsComposerObject::PageNumber, QgsPropertyDefinition( "dataDefinedPageNumber" , QObject::tr( "Page number" ), QgsPropertyDefinition::IntegerPositive ) }, |
| 46 | + { QgsComposerObject::PositionX, QgsPropertyDefinition( "dataDefinedPositionX" , QObject::tr( "Position (X)" ), QgsPropertyDefinition::Double ) }, |
| 47 | + { QgsComposerObject::PositionY, QgsPropertyDefinition( "dataDefinedPositionY" , QObject::tr( "Position (Y)" ), QgsPropertyDefinition::Double ) }, |
| 48 | + { QgsComposerObject::ItemWidth, QgsPropertyDefinition( "dataDefinedWidth" , QObject::tr( "Width" ), QgsPropertyDefinition::DoublePositive ) }, |
| 49 | + { QgsComposerObject::ItemHeight, QgsPropertyDefinition( "dataDefinedHeight" , QObject::tr( "Height" ), QgsPropertyDefinition::DoublePositive ) }, |
| 50 | + { QgsComposerObject::ItemRotation, QgsPropertyDefinition( "dataDefinedRotation" , QObject::tr( "Rotation angle" ), QgsPropertyDefinition::Double ) }, |
| 51 | + { QgsComposerObject::Transparency, QgsPropertyDefinition( "dataDefinedTransparency" , QObject::tr( "Transparency" ), QgsPropertyDefinition::Transparency ) }, |
| 52 | + { QgsComposerObject::BlendMode, QgsPropertyDefinition( "dataDefinedBlendMode" , QObject::tr( "Blend mode" ), QgsPropertyDefinition::BlendMode ) }, |
| 53 | + { QgsComposerObject::ExcludeFromExports, QgsPropertyDefinition( "dataDefinedExcludeExports", QObject::tr( "Exclude item from exports" ), QgsPropertyDefinition::Boolean ) }, |
| 54 | + { QgsComposerObject::FrameColor, QgsPropertyDefinition( "dataDefinedFrameColor", QObject::tr( "Frame color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
| 55 | + { QgsComposerObject::BackgroundColor, QgsPropertyDefinition( "dataDefinedBackgroundColor", QObject::tr( "Background color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
| 56 | + { QgsComposerObject::MapRotation, QgsPropertyDefinition( "dataDefinedMapRotation" , QObject::tr( "Map rotation" ), QgsPropertyDefinition::Double ) }, |
| 57 | + { QgsComposerObject::MapScale, QgsPropertyDefinition( "dataDefinedMapScale" , QObject::tr( "Map scale" ), QgsPropertyDefinition::DoublePositive ) }, |
| 58 | + { QgsComposerObject::MapXMin, QgsPropertyDefinition( "dataDefinedMapXMin" , QObject::tr( "Extent minimum X" ), QgsPropertyDefinition::Double ) }, |
| 59 | + { QgsComposerObject::MapYMin, QgsPropertyDefinition( "dataDefinedMapYMin" , QObject::tr( "Extent minimum Y" ), QgsPropertyDefinition::Double ) }, |
| 60 | + { QgsComposerObject::MapXMax, QgsPropertyDefinition( "dataDefinedMapXMax" , QObject::tr( "Extent maximum X" ), QgsPropertyDefinition::Double ) }, |
| 61 | + { QgsComposerObject::MapYMax, QgsPropertyDefinition( "dataDefinedMapYMax" , QObject::tr( "Extent maximum Y" ), QgsPropertyDefinition::Double ) }, |
| 62 | + { QgsComposerObject::MapAtlasMargin, QgsPropertyDefinition( "dataDefinedMapAtlasMargin" , QObject::tr( "Atlas margin" ), QgsPropertyDefinition::DoublePositive ) }, |
| 63 | + { QgsComposerObject::MapLayers, QgsPropertyDefinition( "dataDefinedMapLayers", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), tr( "list of map layer names separated by | characters" ) ) }, |
| 64 | + { QgsComposerObject::MapStylePreset, QgsPropertyDefinition( "dataDefinedMapStylePreset", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), tr( "list of map layer names separated by | characters" ) ) }, |
| 65 | + { QgsComposerObject::PictureSource, QgsPropertyDefinition( "dataDefinedSource" , QObject::tr( "Picture source (URL)" ), QgsPropertyDefinition::String ) }, |
| 66 | + { QgsComposerObject::SourceUrl, QgsPropertyDefinition( "dataDefinedSourceUrl" , QObject::tr( "Source URL" ), QgsPropertyDefinition::String ) }, |
| 67 | + { QgsComposerObject::PictureSvgBackgroundColor, QgsPropertyDefinition( "dataDefinedSvgBackgroundColor" , QObject::tr( "SVG background color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
| 68 | + { QgsComposerObject::PictureSvgOutlineColor, QgsPropertyDefinition( "dataDefinedSvgOutlineColor" , QObject::tr( "SVG outline color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
| 69 | + { QgsComposerObject::PictureSvgOutlineWidth, QgsPropertyDefinition( "dataDefinedSvgOutlineWidth" , QObject::tr( "SVG outline width" ), QgsPropertyDefinition::DoublePositive ) }, |
| 70 | + { QgsComposerObject::LegendTitle, QgsPropertyDefinition( "dataDefinedLegendTitle" , QObject::tr( "Legend title" ), QgsPropertyDefinition::String ) }, |
| 71 | + { QgsComposerObject::LegendColumnCount, QgsPropertyDefinition( "dataDefinedLegendColumns" , QObject::tr( "Number of columns" ), QgsPropertyDefinition::IntegerPositiveGreaterZero ) }, |
| 72 | + { QgsComposerObject::ScalebarFillColor, QgsPropertyDefinition( "dataDefinedScalebarFill" , QObject::tr( "Fill color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
| 73 | + { QgsComposerObject::ScalebarFillColor2, QgsPropertyDefinition( "dataDefinedScalebarFill2" , QObject::tr( "Secondary fill color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
| 74 | + { QgsComposerObject::ScalebarLineColor, QgsPropertyDefinition( "dataDefinedScalebarLineColor" , QObject::tr( "Line color" ), QgsPropertyDefinition::ColorWithAlpha ) }, |
| 75 | + { QgsComposerObject::ScalebarLineWidth, QgsPropertyDefinition( "dataDefinedScalebarLineWidth" , QObject::tr( "Line width" ), QgsPropertyDefinition::DoublePositive ) }, |
| 76 | + }; |
| 77 | +} |
71 | 78 |
|
72 | 79 | QgsComposerObject::QgsComposerObject( QgsComposition* composition )
|
73 | 80 | : QObject( nullptr )
|
74 | 81 | , mComposition( composition )
|
75 | 82 | {
|
| 83 | + initPropertyDefinitions(); |
76 | 84 |
|
77 | 85 | // data defined strings
|
78 | 86 |
|
|
0 commit comments