QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 <QStandardItemModel>
20 #include <QStandardItem>
21 
22 #include "ui_qgsfieldconditionalformatwidget.h"
23 #include "qgsconditionalstyle.h"
24 #include "qgis_gui.h"
25 
32 class GUI_EXPORT QgsFieldConditionalFormatWidget : public QWidget, private Ui::QgsFieldConditionalWidget
33 {
34  Q_OBJECT
35  public:
36 
40  explicit QgsFieldConditionalFormatWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
41 
45  void viewRules();
46 
51  void setLayer( QgsVectorLayer *layer );
52 
58  void editStyle( int index, const QgsConditionalStyle &style );
59 
63  void loadStyle( const QgsConditionalStyle &style );
64 
68  void reset();
69 
74  void setPresets( const QList<QgsConditionalStyle> &styles );
75 
81  QList<QgsConditionalStyle> defaultPresets() const;
82 
83  signals:
84 
89  void rulesUpdated( const QString &fieldName );
90 
91  public slots:
92 
93  private:
94  QgsVectorLayer *mLayer = nullptr;
95  int mEditIndex = 0;
96  bool mEditing = false;
97  QStandardItemModel *mModel = nullptr;
98  QStandardItemModel *mPresetsModel = nullptr;
99  QList<QgsConditionalStyle> mPresets;
100 
101  QList<QgsConditionalStyle> getStyles();
102 
103  void setFormattingFromStyle( const QgsConditionalStyle &style );
104 
105  private slots:
106  void setExpression();
107  void presetSet( int index );
108  bool isCustomSet();
109  void ruleClicked( const QModelIndex &index );
110  void reloadStyles();
111  void cancelRule();
112  void deleteRule();
113  void saveRule();
114  void addNewRule();
115  void fieldChanged( const QString &fieldName );
116 
117 };
118 
119 #endif // QGSFIELDCONDITIONALFORMATWIDGET_H
A widget for customizing conditional formatting options.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Conditional styling for a rule.
QDomDocument getStyles(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Returns an SLD file with the styles of the requested layers.
Represents a vector layer which manages a vector based data sets.