QGIS API Documentation  3.0.2-Girona (307d082)
qgsfieldconditionalformatwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfieldconditionalformatwidget.h
3  ---------------------
4  begin : August 2015
5  copyright : (C) 2015 by Nathan Woodrow
6  email : woodrow dot nathan at gmail dot 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 #ifndef QGSFIELDCONDITIONALFORMATWIDGET_H
16 #define QGSFIELDCONDITIONALFORMATWIDGET_H
17 
18 #include <QWidget>
19 #include "qgis.h"
20 #include <QStandardItemModel>
21 #include <QStandardItem>
22 
23 #include "ui_qgsfieldconditionalformatwidget.h"
24 #include "qgsconditionalstyle.h"
25 #include "qgis_gui.h"
26 
33 class GUI_EXPORT QgsFieldConditionalFormatWidget : public QWidget, private Ui::QgsFieldConditionalWidget
34 {
35  Q_OBJECT
36  public:
37 
42  explicit QgsFieldConditionalFormatWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
43 
47  void viewRules();
48 
53  void setLayer( QgsVectorLayer *layer );
54 
60  void editStyle( int index, const QgsConditionalStyle &style );
61 
65  void loadStyle( const QgsConditionalStyle &style );
66 
70  void reset();
71 
76  void setPresets( const QList<QgsConditionalStyle> &styles );
77 
83  QList<QgsConditionalStyle> defaultPresets() const;
84 
85  signals:
86 
91  void rulesUpdated( const QString &fieldName );
92 
93  public slots:
94 
95  private:
96  QgsVectorLayer *mLayer = nullptr;
97  int mEditIndex = 0;
98  bool mEditing = false;
99  QStandardItemModel *mModel = nullptr;
100  QStandardItemModel *mPresetsModel = nullptr;
101  QList<QgsConditionalStyle> mPresets;
102 
103  QList<QgsConditionalStyle> getStyles();
104 
105  void setFormattingFromStyle( const QgsConditionalStyle &style );
106 
107  private slots:
108  void setExpression();
109  void presetSet( int index );
110  bool isCustomSet();
111  void ruleClicked( const QModelIndex &index );
112  void reloadStyles();
113  void cancelRule();
114  void deleteRule();
115  void saveRule();
116  void addNewRule();
117  void fieldChanged( const QString &fieldName );
118 
119 };
120 
121 #endif // QGSFIELDCONDITIONALFORMATWIDGET_H
A widget for customising conditional formatting options.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Conditional styling for a rule.
Represents a vector layer which manages a vector based data sets.