QGIS API Documentation 3.39.0-Master (3783037d301)
Loading...
Searching...
No Matches
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
34class GUI_EXPORT QgsFieldConditionalFormatWidget : public QgsPanelWidget, private Ui::QgsFieldConditionalWidget
35{
36 Q_OBJECT
37 public:
38
42 explicit QgsFieldConditionalFormatWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
43
49 Q_DECL_DEPRECATED void viewRules() SIP_DEPRECATED;
50
54 void setLayer( QgsVectorLayer *layer );
55
56 // TODO QGIS 4.0 - make private
57
63 void editStyle( int index, const QgsConditionalStyle &style );
64
68 Q_DECL_DEPRECATED void loadStyle( const QgsConditionalStyle &style ) SIP_DEPRECATED;
69
75 Q_DECL_DEPRECATED void reset() SIP_DEPRECATED;
76
80 void setPresets( const QList<QgsConditionalStyle> &styles );
81
86 static QList<QgsConditionalStyle> defaultPresets();
87
88 signals:
89
97 void rulesUpdated( const QString &fieldName );
98
99 private:
100 QgsVectorLayer *mLayer = nullptr;
101 int mEditIndex = -1;
102 bool mEditing = false;
103 bool mPanelHandled = false;
104 QStandardItemModel *mModel = nullptr;
105
106 QList<QgsConditionalStyle> mPresets;
107
108 QList<QgsConditionalStyle> getStyles();
109
110 private slots:
111
112 void typeChanged();
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.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53