Skip to content

Commit fa57840

Browse files
committed
Add GUI elements to change composer map grid annotation format
1 parent 5821e2b commit fa57840

File tree

4 files changed

+68
-30
lines changed

4 files changed

+68
-30
lines changed

src/app/composer/qgscomposermapwidget.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QWidg
5151
mGridTypeComboBox->insertItem( 0, tr( "Solid" ) );
5252
mGridTypeComboBox->insertItem( 1, tr( "Cross" ) );
5353

54+
mAnnotationFormatComboBox->insertItem( 0, tr( "Decimal" ) );
55+
mAnnotationFormatComboBox->insertItem( 1, tr( "DegreeMinute" ) );
56+
mAnnotationFormatComboBox->insertItem( 2, tr( "DegreeMinuteSecond" ) );
57+
5458
insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
5559
insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
5660
insertAnnotationPositionEntries( mAnnotationPositionTopComboBox );
@@ -372,6 +376,10 @@ void QgsComposerMapWidget::updateGuiElements()
372376
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "No frame" ) ) );
373377
}
374378

379+
//grid annotation format
380+
QgsComposerMap::GridAnnotationFormat gf = mComposerMap->gridAnnotationFormat();
381+
mAnnotationFormatComboBox->setCurrentIndex(( int )gf );
382+
375383
//grid annotation position
376384
initAnnotationPositionBox( mAnnotationPositionLeftComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Left ) );
377385
initAnnotationPositionBox( mAnnotationPositionRightComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Right ) );
@@ -457,6 +465,7 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
457465
mLineColorButton->blockSignals( b );
458466
mDrawAnnotationCheckBox->blockSignals( b );
459467
mAnnotationFontButton->blockSignals( b );
468+
mAnnotationFormatComboBox->blockSignals( b );
460469
mAnnotationPositionLeftComboBox->blockSignals( b );
461470
mAnnotationPositionRightComboBox->blockSignals( b );
462471
mAnnotationPositionTopComboBox->blockSignals( b );
@@ -767,6 +776,20 @@ void QgsComposerMapWidget::on_mDistanceToMapFrameSpinBox_valueChanged( double d
767776
mComposerMap->endCommand();
768777
}
769778

779+
void QgsComposerMapWidget::on_mAnnotationFormatComboBox_currentIndexChanged( int index )
780+
{
781+
if ( !mComposerMap )
782+
{
783+
return;
784+
}
785+
786+
mComposerMap->beginCommand( tr( "Annotation format changed" ) );
787+
mComposerMap->setGridAnnotationFormat(( QgsComposerMap::GridAnnotationFormat )index );
788+
mComposerMap->updateBoundingRect();
789+
mComposerMap->update();
790+
mComposerMap->endCommand();
791+
}
792+
770793
void QgsComposerMapWidget::on_mAnnotationPositionLeftComboBox_currentIndexChanged( const QString& text )
771794
{
772795
handleChangedAnnotationPosition( QgsComposerMap::Left, text );

src/app/composer/qgscomposermapwidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
6363
void on_mAnnotationFontButton_clicked();
6464
void on_mDistanceToMapFrameSpinBox_valueChanged( double d );
6565

66+
void on_mAnnotationFormatComboBox_currentIndexChanged( int index );
67+
6668
//annotation position
6769
void on_mAnnotationPositionLeftComboBox_currentIndexChanged( const QString& text );
6870
void on_mAnnotationPositionRightComboBox_currentIndexChanged( const QString& text );

src/core/composer/qgscomposermap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
262262
void setGridAnnotationDirection( GridAnnotationDirection d, QgsComposerMap::Border border );
263263
GridAnnotationDirection gridAnnotationDirection( QgsComposerMap::Border border ) const;
264264

265+
void setGridAnnotationFormat( GridAnnotationFormat f ) { mGridAnnotationFormat = f; }
266+
GridAnnotationFormat gridAnnotationFormat() const { return mGridAnnotationFormat; }
267+
265268
/**Set grid frame style (NoGridFrame or Zebra)
266269
@note: this function was added in version 1.9*/
267270
void setGridFrameStyle( GridFrameStyle style ) { mGridFrameStyle = style; }

src/ui/qgscomposermapwidgetbase.ui

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>240</width>
9+
<width>265</width>
1010
<height>483</height>
1111
</rect>
1212
</property>
@@ -33,8 +33,8 @@
3333
<rect>
3434
<x>0</x>
3535
<y>0</y>
36-
<width>230</width>
37-
<height>395</height>
36+
<width>255</width>
37+
<height>392</height>
3838
</rect>
3939
</property>
4040
<attribute name="label">
@@ -251,8 +251,8 @@
251251
<rect>
252252
<x>0</x>
253253
<y>0</y>
254-
<width>230</width>
255-
<height>395</height>
254+
<width>255</width>
255+
<height>392</height>
256256
</rect>
257257
</property>
258258
<attribute name="label">
@@ -359,8 +359,8 @@
359359
<rect>
360360
<x>0</x>
361361
<y>0</y>
362-
<width>218</width>
363-
<height>716</height>
362+
<width>238</width>
363+
<height>770</height>
364364
</rect>
365365
</property>
366366
<attribute name="label">
@@ -591,9 +591,9 @@
591591
</property>
592592
</widget>
593593
</item>
594-
<item row="4" column="0" colspan="4">
594+
<item row="5" column="0" colspan="4">
595595
<layout class="QGridLayout" name="gridLayout_2">
596-
<item row="0" column="0">
596+
<item row="1" column="0">
597597
<widget class="QLabel" name="mAnnotationPositionLabelLeft">
598598
<property name="text">
599599
<string>Annotation position left side</string>
@@ -606,10 +606,10 @@
606606
</property>
607607
</widget>
608608
</item>
609-
<item row="0" column="1">
609+
<item row="1" column="1">
610610
<widget class="QComboBox" name="mAnnotationPositionLeftComboBox"/>
611611
</item>
612-
<item row="1" column="0">
612+
<item row="2" column="0">
613613
<widget class="QLabel" name="mAnnotationPositionLabelRight">
614614
<property name="text">
615615
<string>Annotation position right side</string>
@@ -622,10 +622,10 @@
622622
</property>
623623
</widget>
624624
</item>
625-
<item row="1" column="1">
625+
<item row="2" column="1">
626626
<widget class="QComboBox" name="mAnnotationPositionRightComboBox"/>
627627
</item>
628-
<item row="2" column="0">
628+
<item row="3" column="0">
629629
<widget class="QLabel" name="mAnnotationPositionLabelTop">
630630
<property name="text">
631631
<string>Annotation position top side</string>
@@ -638,10 +638,10 @@
638638
</property>
639639
</widget>
640640
</item>
641-
<item row="2" column="1">
641+
<item row="3" column="1">
642642
<widget class="QComboBox" name="mAnnotationPositionTopComboBox"/>
643643
</item>
644-
<item row="3" column="0">
644+
<item row="4" column="0">
645645
<widget class="QLabel" name="mAnnotationPositionLabelBottom">
646646
<property name="text">
647647
<string>Annotation position bottom side</string>
@@ -654,10 +654,10 @@
654654
</property>
655655
</widget>
656656
</item>
657-
<item row="3" column="1">
657+
<item row="4" column="1">
658658
<widget class="QComboBox" name="mAnnotationPositionBottomComboBox"/>
659659
</item>
660-
<item row="4" column="0">
660+
<item row="5" column="0">
661661
<widget class="QLabel" name="mAnnotationDirectionLabelLeft">
662662
<property name="frameShape">
663663
<enum>QFrame::NoFrame</enum>
@@ -673,10 +673,10 @@
673673
</property>
674674
</widget>
675675
</item>
676-
<item row="4" column="1">
676+
<item row="5" column="1">
677677
<widget class="QComboBox" name="mAnnotationDirectionComboBoxLeft"/>
678678
</item>
679-
<item row="5" column="0">
679+
<item row="6" column="0">
680680
<widget class="QLabel" name="mAnnotationDirectionLabelRight">
681681
<property name="text">
682682
<string>Annotation direction right side</string>
@@ -689,10 +689,10 @@
689689
</property>
690690
</widget>
691691
</item>
692-
<item row="5" column="1">
692+
<item row="6" column="1">
693693
<widget class="QComboBox" name="mAnnotationDirectionComboBoxRight"/>
694694
</item>
695-
<item row="6" column="0">
695+
<item row="7" column="0">
696696
<widget class="QLabel" name="mAnnotationDirectionLabelTop">
697697
<property name="text">
698698
<string>Annotation direction top side</string>
@@ -702,10 +702,10 @@
702702
</property>
703703
</widget>
704704
</item>
705-
<item row="6" column="1">
705+
<item row="7" column="1">
706706
<widget class="QComboBox" name="mAnnotationDirectionComboBoxTop"/>
707707
</item>
708-
<item row="7" column="0">
708+
<item row="8" column="0">
709709
<widget class="QLabel" name="mAnnotationDirectionLabeBottom">
710710
<property name="text">
711711
<string>Annotation direction bottom side</string>
@@ -715,19 +715,29 @@
715715
</property>
716716
</widget>
717717
</item>
718-
<item row="7" column="1">
718+
<item row="8" column="1">
719719
<widget class="QComboBox" name="mAnnotationDirectionComboBoxBottom"/>
720720
</item>
721+
<item row="0" column="0">
722+
<widget class="QLabel" name="mAnnotationFormatLabel">
723+
<property name="text">
724+
<string>Annotation format</string>
725+
</property>
726+
</widget>
727+
</item>
728+
<item row="0" column="1">
729+
<widget class="QComboBox" name="mAnnotationFormatComboBox"/>
730+
</item>
721731
</layout>
722732
</item>
723-
<item row="5" column="0">
733+
<item row="6" column="0">
724734
<widget class="QPushButton" name="mAnnotationFontButton">
725735
<property name="text">
726736
<string>Font...</string>
727737
</property>
728738
</widget>
729739
</item>
730-
<item row="6" column="0" colspan="2">
740+
<item row="7" column="0" colspan="2">
731741
<widget class="QLabel" name="mDistanceToFrameLabel">
732742
<property name="text">
733743
<string>Distance to map frame</string>
@@ -740,10 +750,10 @@
740750
</property>
741751
</widget>
742752
</item>
743-
<item row="6" column="2" colspan="2">
753+
<item row="7" column="2" colspan="2">
744754
<widget class="QDoubleSpinBox" name="mDistanceToMapFrameSpinBox"/>
745755
</item>
746-
<item row="7" column="0" colspan="2">
756+
<item row="8" column="0" colspan="2">
747757
<widget class="QLabel" name="mCoordinatePrecisionLabel">
748758
<property name="text">
749759
<string>Coordinate precision</string>
@@ -756,10 +766,10 @@
756766
</property>
757767
</widget>
758768
</item>
759-
<item row="7" column="2" colspan="2">
769+
<item row="8" column="2" colspan="2">
760770
<widget class="QSpinBox" name="mCoordinatePrecisionSpinBox"/>
761771
</item>
762-
<item row="8" column="0">
772+
<item row="9" column="0">
763773
<spacer name="verticalSpacer_2">
764774
<property name="orientation">
765775
<enum>Qt::Vertical</enum>

0 commit comments

Comments
 (0)