1
1
/* **************************************************************************
2
- qgsscalevisibilitywidget .cpp
2
+ qgsscalerangewidget .cpp
3
3
--------------------------------------
4
4
Date : 25.04.2014
5
5
Copyright : (C) 2014 Denis Rouzaud
13
13
* *
14
14
***************************************************************************/
15
15
16
- #include " qgsscalevisibilitywidget .h"
16
+ #include " qgsscalerangewidget .h"
17
17
#include " qgsapplication.h"
18
18
#include " qgsproject.h"
19
19
20
- QgsScaleVisibilityWidget::QgsScaleVisibilityWidget ( QWidget *parent )
20
+
21
+ QgsScaleRangeWidget::QgsScaleRangeWidget ( QWidget *parent )
21
22
: QWidget( parent )
22
23
, mCanvas( 0 )
23
24
{
24
- setupUi ( this );
25
+ mLayout = new QGridLayout ( this );
26
+ mLayout ->setContentsMargins ( 0 , 0 , 0 , 0 );
27
+
28
+ QLabel* maxLbl = new QLabel ( tr (" Maximimum (inclusive)" ), this );
29
+ QLabel* minLbl = new QLabel ( tr (" Minimimum (exclusive)" ), this );
25
30
31
+ mMaximumScaleIconLabel = new QLabel (this );
26
32
mMaximumScaleIconLabel ->setPixmap ( QgsApplication::getThemePixmap ( " /mActionZoomIn.svg" ) );
33
+ mMinimumScaleIconLabel = new QLabel (this );
27
34
mMinimumScaleIconLabel ->setPixmap ( QgsApplication::getThemePixmap ( " /mActionZoomOut.svg" ) );
28
35
29
- mMinimumScaleSetCurrentPushButton ->hide ();
30
- mMaximumScaleSetCurrentPushButton ->hide ();
36
+ mMaximumScaleComboBox = new QgsScaleComboBox (this );
37
+ mMinimumScaleComboBox = new QgsScaleComboBox (this );
38
+
39
+ mLayout ->addWidget (maxLbl, 0 , 0 );
40
+ mLayout ->addWidget (mMaximumScaleIconLabel , 0 , 1 );
41
+ mLayout ->addWidget (mMaximumScaleComboBox , 0 , 2 );
42
+ mLayout ->addWidget (minLbl, 0 , 3 );
43
+ mLayout ->addWidget (mMinimumScaleIconLabel , 0 , 4 );
44
+ mLayout ->addWidget (mMinimumScaleComboBox , 0 , 5 );
31
45
}
32
46
33
- QgsScaleVisibilityWidget ::~QgsScaleVisibilityWidget ()
47
+ QgsScaleRangeWidget ::~QgsScaleRangeWidget ()
34
48
{
35
49
}
36
50
37
- void QgsScaleVisibilityWidget ::showEvent ( QShowEvent * )
51
+ void QgsScaleRangeWidget ::showEvent ( QShowEvent * )
38
52
{
39
53
bool projectScales = QgsProject::instance ()->readBoolEntry ( " Scales" , " /useProjectScales" );
40
54
if ( projectScales )
@@ -45,47 +59,57 @@ void QgsScaleVisibilityWidget::showEvent( QShowEvent * )
45
59
}
46
60
}
47
61
48
- void QgsScaleVisibilityWidget ::setMapCanvas ( QgsMapCanvas *mapCanvas )
62
+ void QgsScaleRangeWidget ::setMapCanvas ( QgsMapCanvas *mapCanvas )
49
63
{
64
+ if (mMinimumScaleSetCurrentPushButton )
65
+ delete mMinimumScaleSetCurrentPushButton ;
66
+ if (mMaximumScaleSetCurrentPushButton )
67
+ delete mMaximumScaleSetCurrentPushButton ;
50
68
if ( !mapCanvas )
51
69
return ;
52
70
53
71
mCanvas = mapCanvas;
54
- mMinimumScaleSetCurrentPushButton ->show ();
55
- mMaximumScaleSetCurrentPushButton ->show ();
72
+
73
+ mMaximumScaleSetCurrentPushButton = new QToolButton ();
74
+ connect ( mMaximumScaleSetCurrentPushButton , SIGNAL (clicked ()), this , SLOT (setMaxScaleFromCanvas ()));
75
+ mMinimumScaleSetCurrentPushButton = new QToolButton ();
76
+ connect ( mMinimumScaleSetCurrentPushButton , SIGNAL (clicked ()), this , SLOT (setMinScaleFromCanvas ()));
77
+
78
+ mLayout ->addWidget (mMaximumScaleSetCurrentPushButton , 1 ,2 );
79
+ mLayout ->addWidget (mMinimumScaleSetCurrentPushButton , 1 ,5 );
56
80
}
57
81
58
- void QgsScaleVisibilityWidget ::setMinimumScale ( double scale )
82
+ void QgsScaleRangeWidget ::setMinimumScale ( double scale )
59
83
{
60
84
mMinimumScaleComboBox ->setScale ( scale );
61
85
}
62
86
63
- double QgsScaleVisibilityWidget ::minimumScale ()
87
+ double QgsScaleRangeWidget ::minimumScale ()
64
88
{
65
89
return mMinimumScaleComboBox ->scale ();
66
90
}
67
91
68
- void QgsScaleVisibilityWidget ::setMaximumScale ( double scale )
92
+ void QgsScaleRangeWidget ::setMaximumScale ( double scale )
69
93
{
70
94
mMaximumScaleComboBox ->setScale ( scale );
71
95
}
72
96
73
- double QgsScaleVisibilityWidget ::maximumScale ()
97
+ double QgsScaleRangeWidget ::maximumScale ()
74
98
{
75
99
return mMaximumScaleComboBox ->scale ();
76
100
}
77
101
78
- void QgsScaleVisibilityWidget::on_mMinimumScaleSetCurrentPushButton_clicked ()
102
+ void QgsScaleRangeWidget::setMinScaleFromCanvas ()
79
103
{
80
104
mMinimumScaleComboBox ->setScale ( 1.0 / mCanvas ->mapSettings ().scale () );
81
105
}
82
106
83
- void QgsScaleVisibilityWidget::on_mMaximumScaleSetCurrentPushButton_clicked ()
107
+ void QgsScaleRangeWidget::setMaxScaleFromCanvas ()
84
108
{
85
109
mMaximumScaleComboBox ->setScale ( 1.0 / mCanvas ->mapSettings ().scale () );
86
110
}
87
111
88
- void QgsScaleVisibilityWidget ::setFromLayer ( QgsMapLayer *layer )
112
+ void QgsScaleRangeWidget ::setFromLayer ( QgsMapLayer *layer )
89
113
{
90
114
mMinimumScaleComboBox ->setScale ( 1.0 / layer->minimumScale () );
91
115
mMaximumScaleComboBox ->setScale ( 1.0 / layer->maximumScale () );
0 commit comments