From 48cdd749eb6d200390e73e0f7c0d187586b19790 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Thu, 25 Sep 2014 15:08:51 +0200 Subject: [PATCH] add Qgs(Double)SpinBox to SIP --- python/gui/editorwidgets/qgsdoublespinbox.sip | 21 +++++++++++++++++++ python/gui/editorwidgets/qgsspinbox.sip | 21 +++++++++++++++++++ python/gui/gui.sip | 2 ++ src/gui/editorwidgets/qgsdoublespinbox.cpp | 2 +- src/gui/editorwidgets/qgsdoublespinbox.h | 3 +-- src/gui/editorwidgets/qgsspinbox.cpp | 2 +- src/gui/editorwidgets/qgsspinbox.h | 3 +-- 7 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 python/gui/editorwidgets/qgsdoublespinbox.sip create mode 100644 python/gui/editorwidgets/qgsspinbox.sip diff --git a/python/gui/editorwidgets/qgsdoublespinbox.sip b/python/gui/editorwidgets/qgsdoublespinbox.sip new file mode 100644 index 00000000000..cfa5676600c --- /dev/null +++ b/python/gui/editorwidgets/qgsdoublespinbox.sip @@ -0,0 +1,21 @@ +class QgsDoubleSpinBox : QDoubleSpinBox +{ +%TypeHeaderCode +#include +%End + + public: + explicit QgsDoubleSpinBox( QWidget *parent /TransferThis/ = 0 ); + + //! determines if the widget will show a clear button + //! @note the clear button will set the widget to its minimum value + void setShowClearButton( const bool showClearButton ); + bool showClearButton() const; + + //! Set the current value to the minimum + virtual void clear(); + + protected: + virtual void resizeEvent( QResizeEvent* event ); + virtual void changeEvent( QEvent* event ); +}; diff --git a/python/gui/editorwidgets/qgsspinbox.sip b/python/gui/editorwidgets/qgsspinbox.sip new file mode 100644 index 00000000000..a1e3d78c9bf --- /dev/null +++ b/python/gui/editorwidgets/qgsspinbox.sip @@ -0,0 +1,21 @@ +class QgsSpinBox : QSpinBox +{ +%TypeHeaderCode +#include +%End + + public: + explicit QgsSpinBox( QWidget *parent /TransferThis/ = 0 ); + + //! determines if the widget will show a clear button + //! @note the clear button will set the widget to its minimum value + void setShowClearButton( const bool showClearButton ); + bool showClearButton() const; + + //! Set the current value to the minimum + virtual void clear(); + + protected: + virtual void resizeEvent( QResizeEvent* event ); + virtual void changeEvent( QEvent* event ); +}; diff --git a/python/gui/gui.sip b/python/gui/gui.sip index 9254070ff65..86452329817 100644 --- a/python/gui/gui.sip +++ b/python/gui/gui.sip @@ -175,7 +175,9 @@ %Include editorwidgets/core/qgseditorwidgetfactory.sip %Include editorwidgets/core/qgseditorwidgetregistry.sip %Include editorwidgets/core/qgseditorwidgetwrapper.sip +%Include editorwidgets/qgsdoublespinbox.sip %Include editorwidgets/qgsrelationreferencewidget.sip %Include editorwidgets/qgsrelationreferencewidgetwrapper.sip +%Include editorwidgets/qgsspinbox.sip %Include layertree/qgslayertreeview.sip diff --git a/src/gui/editorwidgets/qgsdoublespinbox.cpp b/src/gui/editorwidgets/qgsdoublespinbox.cpp index 8cda614611e..9490b7261df 100644 --- a/src/gui/editorwidgets/qgsdoublespinbox.cpp +++ b/src/gui/editorwidgets/qgsdoublespinbox.cpp @@ -43,7 +43,7 @@ QgsDoubleSpinBox::QgsDoubleSpinBox( QWidget *parent ) connect( this, SIGNAL( valueChanged( double ) ), this, SLOT( changed( double ) ) ); } -void QgsDoubleSpinBox::setShowClearButton( bool showClearButton ) +void QgsDoubleSpinBox::setShowClearButton( const bool showClearButton ) { mShowClearButton = showClearButton; mClearButton->setVisible( mShowClearButton && isEnabled() && value() != minimum() ); diff --git a/src/gui/editorwidgets/qgsdoublespinbox.h b/src/gui/editorwidgets/qgsdoublespinbox.h index 0409ba8a224..ce4957687ee 100644 --- a/src/gui/editorwidgets/qgsdoublespinbox.h +++ b/src/gui/editorwidgets/qgsdoublespinbox.h @@ -32,7 +32,7 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox //! determines if the widget will show a clear button //! @note the clear button will set the widget to its minimum value - void setShowClearButton( bool showClearButton ); + void setShowClearButton( const bool showClearButton ); bool showClearButton() const {return mShowClearButton;} //! Set the current value to the minimum @@ -46,7 +46,6 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox void changed( const double &value ); private: - int spinButtonWidth() const; int frameWidth() const; bool mShowClearButton; diff --git a/src/gui/editorwidgets/qgsspinbox.cpp b/src/gui/editorwidgets/qgsspinbox.cpp index 53d1fe0caf3..4dd86abace5 100644 --- a/src/gui/editorwidgets/qgsspinbox.cpp +++ b/src/gui/editorwidgets/qgsspinbox.cpp @@ -43,7 +43,7 @@ QgsSpinBox::QgsSpinBox( QWidget *parent ) connect( this, SIGNAL( valueChanged( int ) ), this, SLOT( changed( int ) ) ); } -void QgsSpinBox::setShowClearButton( bool showClearButton ) +void QgsSpinBox::setShowClearButton( const bool showClearButton ) { mShowClearButton = showClearButton; mClearButton->setVisible( mShowClearButton && isEnabled() && value() != minimum() ); diff --git a/src/gui/editorwidgets/qgsspinbox.h b/src/gui/editorwidgets/qgsspinbox.h index de67f9fa61e..9d75cb4325c 100644 --- a/src/gui/editorwidgets/qgsspinbox.h +++ b/src/gui/editorwidgets/qgsspinbox.h @@ -32,7 +32,7 @@ class GUI_EXPORT QgsSpinBox : public QSpinBox //! determines if the widget will show a clear button //! @note the clear button will set the widget to its minimum value - void setShowClearButton( bool showClearButton ); + void setShowClearButton( const bool showClearButton ); bool showClearButton() const {return mShowClearButton;} //! Set the current value to the minimum @@ -46,7 +46,6 @@ class GUI_EXPORT QgsSpinBox : public QSpinBox void changed( const int& value ); private: - int spinButtonWidth() const; int frameWidth() const; bool mShowClearButton;