QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsscalecombobox.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsscalecombobox.h
3  ------------------------
4  begin : January 7, 2012
5  copyright : (C) 2012 by Alexander Bruy
6  email : alexander dot bruy at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSSCALECOMBOBOX_H
19 #define QGSSCALECOMBOBOX_H
20 
21 #include <QComboBox>
22 
27 class GUI_EXPORT QgsScaleComboBox : public QComboBox
28 {
29  Q_OBJECT
30  public:
31  QgsScaleComboBox( QWidget* parent = nullptr );
32  virtual ~QgsScaleComboBox();
33 
35  QString scaleString();
37  bool setScaleString( const QString& scaleTxt );
39  double scale() const;
41  void setScale( double scale );
43  double minScale() const { return mMinScale; }
44 
46  // Performs rounding, so an exact representation is not to
47  // be expected.
48  static QString toString( double scale );
50  static double toDouble( const QString& scaleString, bool *ok = nullptr );
51 
52  signals:
54  void scaleChanged( double scale );
55 
56  public slots:
57  void updateScales( const QStringList &scales = QStringList() );
58 
65  void setMinScale( double scale );
66 
67  protected:
68  void showPopup() override;
69 
70  private slots:
71  void fixupScale();
72 
73  private:
74  double mScale;
75  double mMinScale;
76 };
77 
78 #endif // QGSSCALECOMBOBOX_H
double minScale() const
Function to read the min scale.
virtual void showPopup()
A combobox which lets the user select map scale from predefined list and highlights nearest to curren...