QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsmultiedittoolbutton.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmultiedittoolbutton.h
3  ------------------------
4  Date : March 2016
5  Copyright : (C) 2016 Nyall Dawson
6  Email : nyall dot dawson at gmail.com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSMULTIEDITTOOLBUTTON_H
17 #define QGSMULTIEDITTOOLBUTTON_H
18 
19 #include "qgsfields.h"
20 #include "qgis_sip.h"
21 #include <QToolButton>
22 #include "qgis_gui.h"
23 
32 class GUI_EXPORT QgsMultiEditToolButton : public QToolButton
33 {
34  Q_OBJECT
35 
36  public:
37 
39  enum State
40  {
44  };
45 
50  explicit QgsMultiEditToolButton( QWidget *parent SIP_TRANSFERTHIS = nullptr );
51 
55  State state() const { return mState; }
56 
62  void setField( const QgsField &field ) { mField = field; }
63 
64  public slots:
65 
72  void setIsMixed( bool mixed ) { mIsMixedValues = mixed; updateState(); }
73 
80  void setIsChanged( bool changed ) { mIsChanged = changed; updateState(); }
81 
88  void resetChanges() { mIsChanged = false; updateState(); }
89 
94  void changesCommitted() { mIsMixedValues = false; mIsChanged = false; updateState(); }
95 
96  signals:
97 
99  void setFieldValueTriggered();
100 
102  void resetFieldValueTriggered();
103 
104  private slots:
105 
106  void aboutToShowMenu();
107  void setFieldTriggered();
108  void resetFieldTriggered();
109 
110  private:
111 
112  bool mIsMixedValues = false;
113  bool mIsChanged = false;
114  State mState = Default;
115  QgsField mField;
116 
117  QMenu *mMenu = nullptr;
118 
119  void updateState();
120 
121 };
122 
123 #endif // QGSMULTIEDITTOOLBUTTON_H
qgsfields.h
QgsMultiEditToolButton::state
State state() const
Returns the current displayed state of the button.
Definition: qgsmultiedittoolbutton.h:55
QgsMultiEditToolButton::setIsChanged
void setIsChanged(bool changed)
Sets whether the associated field has changed.
Definition: qgsmultiedittoolbutton.h:80
QgsMultiEditToolButton::resetChanges
void resetChanges()
Resets the changed state for the field.
Definition: qgsmultiedittoolbutton.h:88
QgsMultiEditToolButton::setField
void setField(const QgsField &field)
Sets the field associated with this button.
Definition: qgsmultiedittoolbutton.h:62
QgsMultiEditToolButton::MixedValues
@ MixedValues
Mixed state, some features have different values for the widget.
Definition: qgsmultiedittoolbutton.h:42
QgsMultiEditToolButton::Default
@ Default
Default state, all features have same value for widget.
Definition: qgsmultiedittoolbutton.h:41
QgsMultiEditToolButton::setIsMixed
void setIsMixed(bool mixed)
Sets whether the associated field contains mixed values.
Definition: qgsmultiedittoolbutton.h:72
qgis_sip.h
QgsMultiEditToolButton
Definition: qgsmultiedittoolbutton.h:32
QgsMultiEditToolButton::changesCommitted
void changesCommitted()
Called when field values have been changed and field now contains all the same values.
Definition: qgsmultiedittoolbutton.h:94
QgsMultiEditToolButton::Changed
@ Changed
Value for widget has changed but changes have not yet been committed.
Definition: qgsmultiedittoolbutton.h:43
QgsMultiEditToolButton::State
State
Button states.
Definition: qgsmultiedittoolbutton.h:39
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsField
Definition: qgsfield.h:49