QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 "qgsfield.h"
20 #include <QToolButton>
21 
29 class GUI_EXPORT QgsMultiEditToolButton : public QToolButton
30 {
31  Q_OBJECT
32 
33  public:
34 
36  enum State
37  {
41  };
42 
46  explicit QgsMultiEditToolButton( QWidget *parent = nullptr );
47 
50  State state() const { return mState; }
51 
56  void setField( const QgsField& field ) { mField = field; }
57 
58  public slots:
59 
66  void setIsMixed( bool mixed ) { mIsMixedValues = mixed; updateState(); }
67 
74  void setIsChanged( bool changed ) { mIsChanged = changed; updateState(); }
75 
81  void resetChanges() { mIsChanged = false; updateState(); }
82 
86  void changesCommitted() { mIsMixedValues = false; mIsChanged = false; updateState(); }
87 
88  signals:
89 
91  void setFieldValueTriggered();
92 
94  void resetFieldValueTriggered();
95 
96  private slots:
97 
98  void aboutToShowMenu();
99  void setFieldTriggered();
100  void resetFieldTriggered();
101 
102  private:
103 
104  bool mIsMixedValues;
105  bool mIsChanged;
106  State mState;
107  QgsField mField;
108 
109  QMenu* mMenu;
110 
111  void updateState();
112 
113 };
114 
115 #endif // QGSMULTIEDITTOOLBUTTON_H
void resetChanges()
Resets the changed state for the field.
A tool button widget which is displayed next to editor widgets in attribute forms, and allows for controlling how the widget behaves and interacts with the form while in multi edit mode.
void changesCommitted()
Called when field values have been changed and field now contains all the same values.
State state() const
Returns the current displayed state of the button.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:44
void setIsChanged(bool changed)
Sets whether the associated field has changed.
void setField(const QgsField &field)
Sets the field associated with this button.
void setIsMixed(bool mixed)
Sets whether the associated field contains mixed values.