21
21
QgsScaleRangeWidget::QgsScaleRangeWidget ( QWidget *parent )
22
22
: QWidget( parent )
23
23
, mCanvas( 0 )
24
- , mMaximumScaleSetCurrentPushButton( 0 )
25
- , mMinimumScaleSetCurrentPushButton( 0 )
26
24
{
27
25
mLayout = new QGridLayout ( this );
28
26
mLayout ->setContentsMargins ( 0 , 0 , 0 , 0 );
@@ -43,19 +41,21 @@ QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent )
43
41
mMaximumScaleIconLabel = new QLabel ( this );
44
42
mMaximumScaleIconLabel ->setPixmap ( QgsApplication::getThemePixmap ( " /mActionZoomIn.svg" ) );
45
43
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 );
48
48
reloadProjectScales ();
49
49
// 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 );
52
52
53
53
mLayout ->addWidget ( minLbl, 0 , 0 , 2 , 1 );
54
54
mLayout ->addWidget ( mMinimumScaleIconLabel , 0 , 1 );
55
- mLayout ->addWidget ( mMinimumScaleComboBox , 0 , 2 );
55
+ mLayout ->addWidget ( mMinimumScaleWidget , 0 , 2 );
56
56
mLayout ->addWidget ( maxLbl, 0 , 3 , 2 , 1 );
57
57
mLayout ->addWidget ( mMaximumScaleIconLabel , 0 , 4 );
58
- mLayout ->addWidget ( mMaximumScaleComboBox , 0 , 5 );
58
+ mLayout ->addWidget ( mMaximumScaleWidget , 0 , 5 );
59
59
60
60
mLayout ->setColumnStretch ( 0 , 0 );
61
61
mLayout ->setColumnStretch ( 1 , 0 );
@@ -75,56 +75,35 @@ void QgsScaleRangeWidget::reloadProjectScales()
75
75
if ( projectScales )
76
76
{
77
77
QStringList scalesList = QgsProject::instance ()->readListEntry ( " Scales" , " /ScalesList" );
78
- mMinimumScaleComboBox ->updateScales ( scalesList );
79
- mMaximumScaleComboBox ->updateScales ( scalesList );
78
+ mMinimumScaleWidget ->updateScales ( scalesList );
79
+ mMaximumScaleWidget ->updateScales ( scalesList );
80
80
}
81
81
}
82
82
83
83
void QgsScaleRangeWidget::setMapCanvas ( QgsMapCanvas *mapCanvas )
84
84
{
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 );
108
87
}
109
88
110
89
void QgsScaleRangeWidget::setMinimumScale ( double scale )
111
90
{
112
- mMinimumScaleComboBox ->setScale ( scale );
91
+ mMinimumScaleWidget ->setScale ( scale );
113
92
}
114
93
115
94
double QgsScaleRangeWidget::minimumScale ()
116
95
{
117
- return mMinimumScaleComboBox ->scale ();
96
+ return mMinimumScaleWidget ->scale ();
118
97
}
119
98
120
99
void QgsScaleRangeWidget::setMaximumScale ( double scale )
121
100
{
122
- mMaximumScaleComboBox ->setScale ( scale );
101
+ mMaximumScaleWidget ->setScale ( scale );
123
102
}
124
103
125
104
double QgsScaleRangeWidget::maximumScale ()
126
105
{
127
- return mMaximumScaleComboBox ->scale ();
106
+ return mMaximumScaleWidget ->scale ();
128
107
}
129
108
130
109
double QgsScaleRangeWidget::minimumScaleDenom ()
@@ -143,14 +122,3 @@ void QgsScaleRangeWidget::setScaleRange( double min, double max )
143
122
setMinimumScale ( min );
144
123
}
145
124
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