31
31
#include < QSettings>
32
32
33
33
QgsDecorationGridDialog::QgsDecorationGridDialog ( QgsDecorationGrid& deco, QWidget* parent )
34
- : QDialog( parent ), mDeco( deco ), mLineSymbol( 0 ), mMarkerSymbol( 0 )
34
+ : QDialog( parent ), mDeco( deco ), mLineSymbol( 0 ), mMarkerSymbol( 0 )
35
35
{
36
36
setupUi ( this );
37
37
38
38
QSettings settings;
39
- restoreGeometry ( settings.value ( " /Windows/DecorationGrid/geometry" ).toByteArray () );
39
+ // restoreGeometry( settings.value( "/Windows/DecorationGrid/geometry" ).toByteArray() );
40
40
41
41
chkEnable->setChecked ( mDeco .enabled () );
42
42
43
43
// mXMinLineEdit->setValidator( new QDoubleValidator( mXMinLineEdit ) );
44
44
45
- mGridTypeComboBox ->insertItem ( 0 , tr ( " Solid " ) );
46
- mGridTypeComboBox ->insertItem ( 1 , tr ( " Cross" ) );
47
- mGridTypeComboBox ->insertItem ( 2 , tr ( " Marker" ) );
45
+ mGridTypeComboBox ->insertItem ( QgsDecorationGrid::Solid , tr ( " Lines " ) );
46
+ mGridTypeComboBox ->insertItem ( QgsDecorationGrid::Cross , tr ( " Cross" ) );
47
+ mGridTypeComboBox ->insertItem ( QgsDecorationGrid::Marker , tr ( " Marker" ) );
48
48
49
- mAnnotationPositionComboBox ->insertItem ( 0 , tr ( " Inside frame" ) );
50
- // mAnnotationPositionComboBox->insertItem( 1 , tr( "Outside frame" ) );
49
+ mAnnotationPositionComboBox ->insertItem ( QgsDecorationGrid::InsideMapFrame , tr ( " Inside frame" ) );
50
+ // mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::OutsideMapFrame , tr( "Outside frame" ) );
51
51
52
- mAnnotationDirectionComboBox ->insertItem ( 0 , tr ( " Horizontal" ) );
53
- mAnnotationDirectionComboBox ->insertItem ( 1 , tr ( " Vertical" ) );
54
- mAnnotationDirectionComboBox ->insertItem ( 2 , tr ( " Horizontal and Vertical" ) );
55
- mAnnotationDirectionComboBox ->insertItem ( 2 , tr ( " Boundary direction" ) );
52
+ mAnnotationDirectionComboBox ->insertItem ( QgsDecorationGrid::Horizontal,
53
+ tr ( " Horizontal" ) );
54
+ mAnnotationDirectionComboBox ->insertItem ( QgsDecorationGrid::Vertical,
55
+ tr ( " Vertical" ) );
56
+ mAnnotationDirectionComboBox ->insertItem ( QgsDecorationGrid::HorizontalAndVertical,
57
+ tr ( " Horizontal and Vertical" ) );
58
+ mAnnotationDirectionComboBox ->insertItem ( QgsDecorationGrid::BoundaryDirection,
59
+ tr ( " Boundary direction" ) );
56
60
57
61
updateGuiElements ();
58
62
@@ -71,52 +75,16 @@ void QgsDecorationGridDialog::updateGuiElements()
71
75
mOffsetXSpinBox ->setValue ( mDeco .gridOffsetX () );
72
76
mOffsetYSpinBox ->setValue ( mDeco .gridOffsetY () );
73
77
74
- QgsDecorationGrid::GridStyle gridStyle = mDeco .gridStyle ();
75
- if ( gridStyle == QgsDecorationGrid::Cross )
76
- {
77
- mGridTypeComboBox ->setCurrentIndex ( mGridTypeComboBox ->findText ( tr ( " Cross" ) ) );
78
- }
79
- else if ( gridStyle == QgsDecorationGrid::Marker )
80
- {
81
- mGridTypeComboBox ->setCurrentIndex ( mGridTypeComboBox ->findText ( tr ( " Marker" ) ) );
82
- }
83
- else
84
- {
85
- mGridTypeComboBox ->setCurrentIndex ( mGridTypeComboBox ->findText ( tr ( " Solid" ) ) );
86
- }
87
-
78
+ mGridTypeComboBox ->setCurrentIndex (( int ) mDeco .gridStyle () );
79
+
88
80
mCrossWidthSpinBox ->setValue ( mDeco .crossLength () );
89
81
90
- QgsDecorationGrid::GridAnnotationPosition annotationPos = mDeco .gridAnnotationPosition ();
91
- if ( annotationPos == QgsDecorationGrid::InsideMapFrame )
92
- {
93
- mAnnotationPositionComboBox ->setCurrentIndex ( mAnnotationPositionComboBox ->findText ( tr ( " Inside frame" ) ) );
94
- }
95
- else
96
- {
97
- mAnnotationPositionComboBox ->setCurrentIndex ( mAnnotationPositionComboBox ->findText ( tr ( " Outside frame" ) ) );
98
- }
99
-
82
+ mAnnotationPositionComboBox ->setCurrentIndex (( int ) mDeco .gridAnnotationPosition () );
83
+
100
84
mDrawAnnotationCheckBox ->setChecked ( mDeco .showGridAnnotation () );
101
-
102
- QgsDecorationGrid::GridAnnotationDirection dir = mDeco .gridAnnotationDirection ();
103
- if ( dir == QgsDecorationGrid::Horizontal )
104
- {
105
- mAnnotationDirectionComboBox ->setCurrentIndex ( mAnnotationDirectionComboBox ->findText ( tr ( " Horizontal" ) ) );
106
- }
107
- else if ( dir == QgsDecorationGrid::Vertical )
108
- {
109
- mAnnotationDirectionComboBox ->setCurrentIndex ( mAnnotationDirectionComboBox ->findText ( tr ( " Vertical" ) ) );
110
- }
111
- else if ( dir == QgsDecorationGrid::HorizontalAndVertical )
112
- {
113
- mAnnotationDirectionComboBox ->setCurrentIndex ( mAnnotationDirectionComboBox ->findText ( tr ( " Horizontal and Vertical" ) ) );
114
- }
115
- else // BoundaryDirection
116
- {
117
- mAnnotationDirectionComboBox ->setCurrentIndex ( mAnnotationDirectionComboBox ->findText ( tr ( " Boundary direction" ) ) );
118
- }
119
-
85
+
86
+ mAnnotationDirectionComboBox ->setCurrentIndex (( int ) mDeco .gridAnnotationDirection () );
87
+
120
88
mCoordinatePrecisionSpinBox ->setValue ( mDeco .gridAnnotationPrecision () );
121
89
122
90
// QPen gridPen = mDeco.gridPen();
@@ -140,7 +108,7 @@ void QgsDecorationGridDialog::updateGuiElements()
140
108
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon ( mMarkerSymbol , mMarkerSymbolButton ->iconSize () );
141
109
mMarkerSymbolButton ->setIcon ( icon );
142
110
}
143
-
111
+
144
112
// blockAllSignals( false );
145
113
}
146
114
@@ -196,12 +164,12 @@ void QgsDecorationGridDialog::updateDecoFromGui()
196
164
mDeco .setGridAnnotationPrecision ( mCoordinatePrecisionSpinBox ->value () );
197
165
if ( mLineSymbol )
198
166
{
199
- mDeco .setLineSymbol ( mLineSymbol );
167
+ mDeco .setLineSymbol ( mLineSymbol );
200
168
mLineSymbol = dynamic_cast <QgsLineSymbolV2*>( mDeco .lineSymbol ()->clone () );
201
169
}
202
170
if ( mMarkerSymbol )
203
171
{
204
- mDeco .setMarkerSymbol ( mMarkerSymbol );
172
+ mDeco .setMarkerSymbol ( mMarkerSymbol );
205
173
mMarkerSymbol = dynamic_cast <QgsMarkerSymbolV2*>( mDeco .markerSymbol ()->clone () );
206
174
}
207
175
}
@@ -232,7 +200,7 @@ void QgsDecorationGridDialog::apply()
232
200
{
233
201
updateDecoFromGui ();
234
202
mDeco .update ();
235
- // accept();
203
+ // accept();
236
204
}
237
205
238
206
void QgsDecorationGridDialog::on_buttonBox_rejected ()
@@ -243,14 +211,22 @@ void QgsDecorationGridDialog::on_buttonBox_rejected()
243
211
244
212
// void QgsDecorationGridDialog::on_mLineColorButton_clicked()
245
213
// {
246
- // QColor newColor = QColorDialog::getColor( mLineColorButton->color() );
247
- // if ( newColor.isValid() )
248
- // {
249
- // mLineColorButton->setColor( newColor );
250
- // mDeco.setGridPenColor( newColor );
251
- // }
214
+ // QColor newColor = QColorDialog::getColor( mLineColorButton->color() );
215
+ // if ( newColor.isValid() )
216
+ // {
217
+ // mLineColorButton->setColor( newColor );
218
+ // mDeco.setGridPenColor( newColor );
219
+ // }
252
220
// }
253
221
222
+ void QgsDecorationGridDialog::on_mGridTypeComboBox_currentIndexChanged ( int index )
223
+ {
224
+ mLineSymbolButton ->setEnabled ( index == QgsDecorationGrid::Solid );
225
+ mCrossWidthSpinBox ->setEnabled ( index == QgsDecorationGrid::Cross );
226
+ mMarkerSymbolButton ->setEnabled ( index == QgsDecorationGrid::Marker );
227
+ }
228
+
229
+
254
230
void QgsDecorationGridDialog::on_mLineSymbolButton_clicked ()
255
231
{
256
232
if ( ! mLineSymbol )
0 commit comments