11/* **************************************************************************
2- qgsscalevisibilitywidget .cpp
2+ qgsscalerangewidget .cpp
33 --------------------------------------
44 Date : 25.04.2014
55 Copyright : (C) 2014 Denis Rouzaud
1313* *
1414***************************************************************************/
1515
16- #include " qgsscalevisibilitywidget .h"
16+ #include " qgsscalerangewidget .h"
1717#include " qgsapplication.h"
1818#include " qgsproject.h"
1919
20- QgsScaleVisibilityWidget::QgsScaleVisibilityWidget ( QWidget *parent )
20+
21+ QgsScaleRangeWidget::QgsScaleRangeWidget ( QWidget *parent )
2122 : QWidget( parent )
2223 , mCanvas( 0 )
2324{
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 );
2530
31+ mMaximumScaleIconLabel = new QLabel (this );
2632 mMaximumScaleIconLabel ->setPixmap ( QgsApplication::getThemePixmap ( " /mActionZoomIn.svg" ) );
33+ mMinimumScaleIconLabel = new QLabel (this );
2734 mMinimumScaleIconLabel ->setPixmap ( QgsApplication::getThemePixmap ( " /mActionZoomOut.svg" ) );
2835
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 );
3145}
3246
33- QgsScaleVisibilityWidget ::~QgsScaleVisibilityWidget ()
47+ QgsScaleRangeWidget ::~QgsScaleRangeWidget ()
3448{
3549}
3650
37- void QgsScaleVisibilityWidget ::showEvent ( QShowEvent * )
51+ void QgsScaleRangeWidget ::showEvent ( QShowEvent * )
3852{
3953 bool projectScales = QgsProject::instance ()->readBoolEntry ( " Scales" , " /useProjectScales" );
4054 if ( projectScales )
@@ -45,47 +59,57 @@ void QgsScaleVisibilityWidget::showEvent( QShowEvent * )
4559 }
4660}
4761
48- void QgsScaleVisibilityWidget ::setMapCanvas ( QgsMapCanvas *mapCanvas )
62+ void QgsScaleRangeWidget ::setMapCanvas ( QgsMapCanvas *mapCanvas )
4963{
64+ if (mMinimumScaleSetCurrentPushButton )
65+ delete mMinimumScaleSetCurrentPushButton ;
66+ if (mMaximumScaleSetCurrentPushButton )
67+ delete mMaximumScaleSetCurrentPushButton ;
5068 if ( !mapCanvas )
5169 return ;
5270
5371 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 );
5680}
5781
58- void QgsScaleVisibilityWidget ::setMinimumScale ( double scale )
82+ void QgsScaleRangeWidget ::setMinimumScale ( double scale )
5983{
6084 mMinimumScaleComboBox ->setScale ( scale );
6185}
6286
63- double QgsScaleVisibilityWidget ::minimumScale ()
87+ double QgsScaleRangeWidget ::minimumScale ()
6488{
6589 return mMinimumScaleComboBox ->scale ();
6690}
6791
68- void QgsScaleVisibilityWidget ::setMaximumScale ( double scale )
92+ void QgsScaleRangeWidget ::setMaximumScale ( double scale )
6993{
7094 mMaximumScaleComboBox ->setScale ( scale );
7195}
7296
73- double QgsScaleVisibilityWidget ::maximumScale ()
97+ double QgsScaleRangeWidget ::maximumScale ()
7498{
7599 return mMaximumScaleComboBox ->scale ();
76100}
77101
78- void QgsScaleVisibilityWidget::on_mMinimumScaleSetCurrentPushButton_clicked ()
102+ void QgsScaleRangeWidget::setMinScaleFromCanvas ()
79103{
80104 mMinimumScaleComboBox ->setScale ( 1.0 / mCanvas ->mapSettings ().scale () );
81105}
82106
83- void QgsScaleVisibilityWidget::on_mMaximumScaleSetCurrentPushButton_clicked ()
107+ void QgsScaleRangeWidget::setMaxScaleFromCanvas ()
84108{
85109 mMaximumScaleComboBox ->setScale ( 1.0 / mCanvas ->mapSettings ().scale () );
86110}
87111
88- void QgsScaleVisibilityWidget ::setFromLayer ( QgsMapLayer *layer )
112+ void QgsScaleRangeWidget ::setFromLayer ( QgsMapLayer *layer )
89113{
90114 mMinimumScaleComboBox ->setScale ( 1.0 / layer->minimumScale () );
91115 mMaximumScaleComboBox ->setScale ( 1.0 / layer->maximumScale () );
0 commit comments