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