Skip to content

Commit abb2510

Browse files
committed
update the scale range widget with the new scale widget
1 parent 3310efb commit abb2510

File tree

2 files changed

+19
-59
lines changed

2 files changed

+19
-59
lines changed

src/gui/qgsscalerangewidget.cpp

+16-48
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
QgsScaleRangeWidget::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

8383
void 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

11089
void QgsScaleRangeWidget::setMinimumScale( double scale )
11190
{
112-
mMinimumScaleComboBox->setScale( scale );
91+
mMinimumScaleWidget->setScale( scale );
11392
}
11493

11594
double QgsScaleRangeWidget::minimumScale()
11695
{
117-
return mMinimumScaleComboBox->scale();
96+
return mMinimumScaleWidget->scale();
11897
}
11998

12099
void QgsScaleRangeWidget::setMaximumScale( double scale )
121100
{
122-
mMaximumScaleComboBox->setScale( scale );
101+
mMaximumScaleWidget->setScale( scale );
123102
}
124103

125104
double QgsScaleRangeWidget::maximumScale()
126105
{
127-
return mMaximumScaleComboBox->scale();
106+
return mMaximumScaleWidget->scale();
128107
}
129108

130109
double 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-

src/gui/qgsscalerangewidget.h

+3-11
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818

1919
#include <QGridLayout>
2020
#include <QLabel>
21-
#include <QPushButton>
22-
2321

2422
#include "qgscollapsiblegroupbox.h"
2523
#include "qgsmaplayer.h"
2624
#include "qgsmapcanvas.h"
27-
#include "qgsscalecombobox.h"
25+
#include "qgsscalewidget.h"
2826

2927

3028
class GUI_EXPORT QgsScaleRangeWidget : public QWidget
@@ -64,10 +62,6 @@ class GUI_EXPORT QgsScaleRangeWidget : public QWidget
6462

6563
void setScaleRange( double min, double max );
6664

67-
private slots:
68-
void setMaxScaleFromCanvas();
69-
void setMinScaleFromCanvas();
70-
7165
private:
7266
//! pointer to the map canvas used for current buttons.
7367
QgsMapCanvas* mCanvas;
@@ -76,10 +70,8 @@ class GUI_EXPORT QgsScaleRangeWidget : public QWidget
7670
QGridLayout* mLayout;
7771
QLabel* mMaximumScaleIconLabel;
7872
QLabel* mMinimumScaleIconLabel;
79-
QPushButton* mMaximumScaleSetCurrentPushButton;
80-
QPushButton* mMinimumScaleSetCurrentPushButton;
81-
QgsScaleComboBox* mMaximumScaleComboBox;
82-
QgsScaleComboBox* mMinimumScaleComboBox;
73+
QgsScaleWidget* mMaximumScaleWidget;
74+
QgsScaleWidget* mMinimumScaleWidget;
8375
};
8476

8577
#endif // QGSSCALERANGEWIDGET_H

0 commit comments

Comments
 (0)