QGIS API Documentation  2.99.0-Master (19b062c)
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 #include "qgis.h"
23 #include "qgis_gui.h"
24 
30 class GUI_EXPORT QgsScaleComboBox : public QComboBox
31 {
32  Q_OBJECT
33  Q_PROPERTY( double scale READ scale WRITE setScale NOTIFY scaleChanged )
34  Q_PROPERTY( double minScale READ minScale WRITE setMinScale )
35 
36  public:
37 
41  QgsScaleComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
42 
47  QString scaleString() const;
48 
53  bool setScaleString( const QString &string );
54 
60  double scale() const;
61 
68  double minScale() const { return mMinScale; }
69 
77  static QString toString( double scale );
78 
85  static double toDouble( const QString &string, bool *ok = nullptr );
86 
87  signals:
88 
93  void scaleChanged( double scale );
94 
95  public slots:
96 
101  void updateScales( const QStringList &scales = QStringList() );
102 
108  void setScale( double scale );
109 
116  void setMinScale( double scale );
117 
118  protected:
119  void showPopup() override;
120 
121  private slots:
122  void fixupScale();
123 
124  private:
125  double mScale = 1.0;
126  double mMinScale = 0.0;
127 };
128 
129 #endif // QGSSCALECOMBOBOX_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
A combobox which lets the user select map scale from predefined list and highlights nearest to curren...