2121QgsScaleRangeWidget::QgsScaleRangeWidget ( QWidget *parent )
2222 : QWidget( parent )
2323 , mCanvas( 0 )
24- , mMaximumScaleSetCurrentPushButton( 0 )
25- , mMinimumScaleSetCurrentPushButton( 0 )
2624{
2725 mLayout = new QGridLayout ( this );
2826 mLayout ->setContentsMargins ( 0 , 0 , 0 , 0 );
@@ -43,19 +41,21 @@ QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent )
4341 mMaximumScaleIconLabel = new QLabel ( this );
4442 mMaximumScaleIconLabel ->setPixmap ( QgsApplication::getThemePixmap ( " /mActionZoomIn.svg" ) );
4543
46- mMinimumScaleComboBox = new QgsScaleComboBox ( this );
47- mMaximumScaleComboBox = new QgsScaleComboBox ( this );
44+ mMinimumScaleWidget = new QgsScaleWidget ( this );
45+ mMaximumScaleWidget = new QgsScaleWidget ( this );
46+ mMinimumScaleWidget ->setShowCurrentScaleButton ( true );
47+ mMaximumScaleWidget ->setShowCurrentScaleButton ( true );
4848 reloadProjectScales ();
4949 // add start, add comprehension of scales by settings fake ordered values
50- mMinimumScaleComboBox -> setCurrentIndex ( 2 );
51- mMaximumScaleComboBox -> setCurrentIndex ( mMinimumScaleComboBox -> currentIndex () + 2 );
50+ mMinimumScaleWidget -> setScale ( 1 / 100000 );
51+ mMaximumScaleWidget -> setScale ( 1 / 1000 );
5252
5353 mLayout ->addWidget ( minLbl, 0 , 0 , 2 , 1 );
5454 mLayout ->addWidget ( mMinimumScaleIconLabel , 0 , 1 );
55- mLayout ->addWidget ( mMinimumScaleComboBox , 0 , 2 );
55+ mLayout ->addWidget ( mMinimumScaleWidget , 0 , 2 );
5656 mLayout ->addWidget ( maxLbl, 0 , 3 , 2 , 1 );
5757 mLayout ->addWidget ( mMaximumScaleIconLabel , 0 , 4 );
58- mLayout ->addWidget ( mMaximumScaleComboBox , 0 , 5 );
58+ mLayout ->addWidget ( mMaximumScaleWidget , 0 , 5 );
5959
6060 mLayout ->setColumnStretch ( 0 , 0 );
6161 mLayout ->setColumnStretch ( 1 , 0 );
@@ -75,56 +75,35 @@ void QgsScaleRangeWidget::reloadProjectScales()
7575 if ( projectScales )
7676 {
7777 QStringList scalesList = QgsProject::instance ()->readListEntry ( " Scales" , " /ScalesList" );
78- mMinimumScaleComboBox ->updateScales ( scalesList );
79- mMaximumScaleComboBox ->updateScales ( scalesList );
78+ mMinimumScaleWidget ->updateScales ( scalesList );
79+ mMaximumScaleWidget ->updateScales ( scalesList );
8080 }
8181}
8282
8383void QgsScaleRangeWidget::setMapCanvas ( QgsMapCanvas *mapCanvas )
8484{
85- if ( mMinimumScaleSetCurrentPushButton )
86- {
87- delete mMinimumScaleSetCurrentPushButton ;
88- mMinimumScaleSetCurrentPushButton = 0 ;
89- }
90- if ( mMaximumScaleSetCurrentPushButton )
91- {
92- delete mMaximumScaleSetCurrentPushButton ;
93- mMaximumScaleSetCurrentPushButton = 0 ;
94- }
95-
96- if ( !mapCanvas )
97- return ;
98-
99- mCanvas = mapCanvas;
100-
101- mMinimumScaleSetCurrentPushButton = new QPushButton ( tr ( " current" ), this );
102- connect ( mMinimumScaleSetCurrentPushButton , SIGNAL ( clicked () ), this , SLOT ( setMinScaleFromCanvas () ) );
103- mMaximumScaleSetCurrentPushButton = new QPushButton ( tr ( " current" ), this );
104- connect ( mMaximumScaleSetCurrentPushButton , SIGNAL ( clicked () ), this , SLOT ( setMaxScaleFromCanvas () ) );
105-
106- mLayout ->addWidget ( mMinimumScaleSetCurrentPushButton , 1 , 2 );
107- mLayout ->addWidget ( mMaximumScaleSetCurrentPushButton , 1 , 5 );
85+ mMinimumScaleWidget ->setMapCanvas ( mapCanvas );
86+ mMaximumScaleWidget ->setMapCanvas ( mapCanvas );
10887}
10988
11089void QgsScaleRangeWidget::setMinimumScale ( double scale )
11190{
112- mMinimumScaleComboBox ->setScale ( scale );
91+ mMinimumScaleWidget ->setScale ( scale );
11392}
11493
11594double QgsScaleRangeWidget::minimumScale ()
11695{
117- return mMinimumScaleComboBox ->scale ();
96+ return mMinimumScaleWidget ->scale ();
11897}
11998
12099void QgsScaleRangeWidget::setMaximumScale ( double scale )
121100{
122- mMaximumScaleComboBox ->setScale ( scale );
101+ mMaximumScaleWidget ->setScale ( scale );
123102}
124103
125104double QgsScaleRangeWidget::maximumScale ()
126105{
127- return mMaximumScaleComboBox ->scale ();
106+ return mMaximumScaleWidget ->scale ();
128107}
129108
130109double QgsScaleRangeWidget::minimumScaleDenom ()
@@ -143,14 +122,3 @@ void QgsScaleRangeWidget::setScaleRange( double min, double max )
143122 setMinimumScale ( min );
144123}
145124
146- void QgsScaleRangeWidget::setMinScaleFromCanvas ()
147- {
148- mMinimumScaleComboBox ->setScale ( 1.0 / mCanvas ->mapSettings ().scale () );
149- }
150-
151- void QgsScaleRangeWidget::setMaxScaleFromCanvas ()
152- {
153- mMaximumScaleComboBox ->setScale ( 1.0 / mCanvas ->mapSettings ().scale () );
154- }
155-
156-
0 commit comments