QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsfieldconditionalformatwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfieldconditionalformatwidget.h
3  -------------------
4  begin :
5  copyright :
6  email :
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 QGSFIELDCONDITIONALFORMATWIDGET_H
19 #define QGSFIELDCONDITIONALFORMATWIDGET_H
20 
21 #include <QWidget>
22 #include <QStandardItemModel>
23 #include <QStandardItem>
24 
25 #include "ui_qgsfieldconditionalformatwidget.h"
26 #include "qgsfieldcombobox.h"
27 #include "qgsconditionalstyle.h"
28 
34 class GUI_EXPORT QgsFieldConditionalFormatWidget : public QWidget, private Ui::QgsFieldConditionalWidget
35 {
36  Q_OBJECT
37  public:
38 
42  explicit QgsFieldConditionalFormatWidget( QWidget *parent = nullptr );
43 
45 
48  void viewRules();
49 
53  void setLayer( QgsVectorLayer* theLayer );
54 
59  void editStyle( int index, const QgsConditionalStyle& style );
60 
64  void loadStyle( const QgsConditionalStyle& style );
65 
68  void reset();
69 
74  void setPresets( const QList<QgsConditionalStyle>& styles );
75 
81  QList<QgsConditionalStyle> defaultPresets() const;
82 
83  signals:
84 
88  void rulesUpdated( const QString& fieldName );
89 
90  public slots:
91 
92  private:
93  QgsVectorLayer* mLayer;
94  int mEditIndex;
95  bool mEditing;
96  QStandardItemModel* mModel;
97  QStandardItemModel* mPresetsModel;
98  QgsSymbolV2* mSymbol;
100 
101  QList<QgsConditionalStyle> getStyles();
102 
103  void setFormattingFromStyle( const QgsConditionalStyle& style );
104 
105  private slots:
106  void setExpression();
107  void updateIcon();
108  void presetSet( int index );
109  bool isCustomSet();
110  void ruleClicked( const QModelIndex& index );
111  void reloadStyles();
112  void cancelRule();
113  void deleteRule();
114  void saveRule();
115  void addNewRule();
116  void fieldChanged( const QString& fieldName );
117 
118 };
119 
120 #endif // QGSFIELDCONDITIONALFORMATWIDGET_H
A widget for customising conditional formatting options.
static unsigned index
Conditional styling for a rule.
Represents a vector layer which manages a vector based data sets.