QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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#include "qgspanelwidget.h"
22#include "qgspanelwidgetstack.h"
23
24#include "ui_qgsfieldconditionalformatwidget.h"
25#include "ui_qgseditconditionalformatrulewidget.h"
26#include "qgsconditionalstyle.h"
27#include "qgis_gui.h"
28
35class GUI_EXPORT QgsFieldConditionalFormatWidget : public QgsPanelWidget, private Ui::QgsFieldConditionalWidget
36{
37 Q_OBJECT
38 public:
39
43 explicit QgsFieldConditionalFormatWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
44
50 Q_DECL_DEPRECATED void viewRules() SIP_DEPRECATED;
51
55 void setLayer( QgsVectorLayer *layer );
56
57 // TODO QGIS 4.0 - make private
58
64 void editStyle( int index, const QgsConditionalStyle &style );
65
69 Q_DECL_DEPRECATED void loadStyle( const QgsConditionalStyle &style ) SIP_DEPRECATED;
70
76 Q_DECL_DEPRECATED void reset() SIP_DEPRECATED;
77
81 void setPresets( const QList<QgsConditionalStyle> &styles );
82
87 static QList<QgsConditionalStyle> defaultPresets();
88
89 signals:
90
98 void rulesUpdated( const QString &fieldName );
99
100 private:
101 QgsVectorLayer *mLayer = nullptr;
102 int mEditIndex = -1;
103 bool mEditing = false;
104 bool mPanelHandled = false;
105 QStandardItemModel *mModel = nullptr;
106
107 QList<QgsConditionalStyle> mPresets;
108
109 QList<QgsConditionalStyle> getStyles();
110
111 private slots:
112
113 void ruleClicked( const QModelIndex &index );
114 void reloadStyles();
115 void addNewRule();
116 void fieldChanged( const QString &fieldName );
117 void deleteCurrentRule();
118
119};
120
127class GUI_EXPORT QgsEditConditionalFormatRuleWidget : public QgsPanelWidget, private Ui::QgsEditConditionalRuleWidget
128{
129 Q_OBJECT
130
131 public:
132
136 explicit QgsEditConditionalFormatRuleWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
137
141 void setLayer( QgsVectorLayer *layer );
142
146 void setPresets( const QList<QgsConditionalStyle> &styles );
147
153 void loadStyle( const QgsConditionalStyle &style );
154
160 QgsConditionalStyle currentStyle() const;
161
165 void setRule( const QString &rule );
166
167 signals:
168
172 void ruleSaved();
173
178
182 void canceled();
183
184 private:
185 QgsVectorLayer *mLayer = nullptr;
186 int mEditIndex = 0;
187 bool mEditing = false;
188 QStandardItemModel *mModel = nullptr;
189 QStandardItemModel *mPresetsModel = nullptr;
190 QList<QgsConditionalStyle> mPresets;
191
192 void setFormattingFromStyle( const QgsConditionalStyle &style );
193
194 private slots:
195 void setExpression();
196 void presetSet( int index );
197 bool isCustomSet();
198
199};
200
201#endif // QGSFIELDCONDITIONALFORMATWIDGET_H
Conditional styling for a rule.
A widget for customizing an individual conditional formatting rule.
void canceled()
Emitted when a user has opted to cancel the rule modification.
void ruleDeleted()
Emitted when a user has opted to deleted the current rule.
void ruleSaved()
Emitted when a user has opted to save the current rule.
A widget for customizing conditional formatting options.
void rulesUpdated(const QString &fieldName)
Emitted when the conditional styling rules are updated.
Base class for any widget that can be shown as a inline panel.
Represents a vector layer which manages a vector based data sets.
QDomDocument getStyles(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request)
Returns an SLD file with the styles of the requested layers.
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53