QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "ui_qgseditconditionalformatrulewidget.h"
19#include "ui_qgsfieldconditionalformatwidget.h"
20
21#include "qgis_gui.h"
22#include "qgsconditionalstyle.h"
23#include "qgspanelwidget.h"
24#include "qgspanelwidgetstack.h"
25
26#include <QStandardItem>
27#include <QStandardItemModel>
28#include <QWidget>
29
35class GUI_EXPORT QgsFieldConditionalFormatWidget : public QgsPanelWidget, private Ui::QgsFieldConditionalWidget
36{
37 Q_OBJECT
38 public:
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
126class GUI_EXPORT QgsEditConditionalFormatRuleWidget : public QgsPanelWidget, private Ui::QgsEditConditionalRuleWidget
127{
128 Q_OBJECT
129
130 public:
134 explicit QgsEditConditionalFormatRuleWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
135
139 void setLayer( QgsVectorLayer *layer );
140
144 void setPresets( const QList<QgsConditionalStyle> &styles );
145
151 void loadStyle( const QgsConditionalStyle &style );
152
159
163 void setRule( const QString &rule );
164
165 signals:
166
170 void ruleSaved();
171
176
180 void canceled();
181
182 private:
183 QgsVectorLayer *mLayer = nullptr;
184 QStandardItemModel *mPresetsModel = nullptr;
185 QList<QgsConditionalStyle> mPresets;
186
187 void setFormattingFromStyle( const QgsConditionalStyle &style );
188
189 private slots:
190 void setExpression();
191 void presetSet( int index );
192 bool isCustomSet();
193};
194
195#endif // QGSFIELDCONDITIONALFORMATWIDGET_H
Conditional styling for a rule.
QgsEditConditionalFormatRuleWidget(QWidget *parent=nullptr)
Constructor for QgsFieldConditionalFormatWidget, with the specified parent widget.
void setPresets(const QList< QgsConditionalStyle > &styles)
Sets the preset styles that can be used for quick pick.
void loadStyle(const QgsConditionalStyle &style)
Sets the widget to match the settings from the specified style.
void setLayer(QgsVectorLayer *layer)
Sets the vector layer associated with the widget.
void setRule(const QString &rule)
Sets the current expression rule to show in the widget.
QgsConditionalStyle currentStyle() const
Returns the current style defined by the widget.
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.
QgsFieldConditionalFormatWidget(QWidget *parent=nullptr)
Constructor for QgsFieldConditionalFormatWidget.
void rulesUpdated(const QString &fieldName)
Emitted when the conditional styling rules are updated.
static QList< QgsConditionalStyle > defaultPresets()
Returns a list of the default presets.
Q_DECL_DEPRECATED void viewRules()
Switches the widget to the rules page.
Q_DECL_DEPRECATED void loadStyle(const QgsConditionalStyle &style)
Q_DECL_DEPRECATED void reset()
Resets the formatting options to their default state.
void editStyle(int index, const QgsConditionalStyle &style)
Switches the widget to the edit style mode for the specified style, where index is the index of the c...
void setPresets(const QList< QgsConditionalStyle > &styles)
Sets the preset styles that can be used for quick pick.
void setLayer(QgsVectorLayer *layer)
Sets the vector layer associated with the widget.
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.
Represents a vector layer which manages a vector based dataset.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53