QGIS API Documentation  2.15.0-Master (5f66276)
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() );
59  void setMinScale( double scale );
60 
61  protected:
62  void showPopup() override;
63 
64  private slots:
65  void fixupScale();
66 
67  private:
68  double mScale;
69  double mMinScale;
70 };
71 
72 #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...