Skip to content

Commit b72e01f

Browse files
committedJan 14, 2019
Use QgsStyleModel in Style Manager dialog
Fixes MANY symbol filtering issues in the dialog, and brings many improvements (e.g. hidpi fixes, nicer tooltips, etc)
1 parent ef250c4 commit b72e01f

File tree

4 files changed

+432
-370
lines changed

4 files changed

+432
-370
lines changed
 

‎python/gui/auto_generated/symbology/qgsstylemanagerdialog.sip.in

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212

13+
1314
class QgsStyleManagerDialog : QDialog
1415
{
1516
%Docstring
@@ -75,7 +76,11 @@ Close the dialog
7576
Open the associated help
7677
%End
7778

78-
void itemChanged( QStandardItem *item );
79+
void itemChanged( QStandardItem *item ) /Deprecated/;
80+
%Docstring
81+
82+
.. deprecated:: in QGIS 3.6 - has no effect and will be removed in QGIS 4.0
83+
%End
7984

8085
void groupChanged( const QModelIndex & );
8186
void groupRenamed( QStandardItem * );
@@ -153,28 +158,36 @@ Remove all tags from selected symbols
153158

154159
protected:
155160

156-
void populateTypes();
161+
void populateTypes() /Deprecated/;
157162
%Docstring
158-
populate combo box with known style items (symbols, color ramps)
163+
Populate combo box with known style items (symbols, color ramps).
164+
165+
.. deprecated:: in QGIS 3.6 - has no effect and will be removed in QGIS 4.0
159166
%End
160167

161168
void populateGroups();
162169
%Docstring
163170
populate the groups
164171
%End
165-
void setSymbolsChecked( const QStringList & );
172+
173+
void setSymbolsChecked( const QStringList & ) /Deprecated/;
166174
%Docstring
167-
to set symbols checked when in editing mode
175+
176+
.. deprecated:: in QGIS 3.6 - has no effect and will be removed in QGIS 4.0
168177
%End
169178

170-
void populateSymbols( const QStringList &symbolNames, bool checkable = false );
179+
void populateSymbols( const QStringList &symbolNames, bool checkable = false ) /Deprecated/;
171180
%Docstring
172-
populate list view with symbols of the current type with the given names
181+
Populates the list view with symbols of the current type with the given names.
182+
183+
.. deprecated:: No longer required in QGIS 3.6, as the model is updated live. Has no effect and will be removed in QGIS 4.0
173184
%End
174185

175-
void populateColorRamps( const QStringList &colorRamps, bool checkable = false );
186+
void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) /Deprecated/;
176187
%Docstring
177-
populate list view with color ramps
188+
Populates the list view with color ramps of the current type with the given names.
189+
190+
.. deprecated:: No longer required in QGIS 3.6, as the model is updated live. Has no effect and will be removed in QGIS 4.0
178191
%End
179192

180193
int currentItemType();

‎src/gui/symbology/qgsstylemanagerdialog.cpp

Lines changed: 215 additions & 234 deletions
Large diffs are not rendered by default.

‎src/gui/symbology/qgsstylemanagerdialog.h

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,37 @@
2323

2424
#include "ui_qgsstylemanagerdialogbase.h"
2525
#include "qgshelp.h"
26+
#include "qgsstylemodel.h"
2627
#include "qgis_gui.h"
2728

2829
class QgsStyle;
2930

31+
#ifndef SIP_RUN
32+
///@cond PRIVATE
33+
class QgsCheckableStyleModel: public QgsStyleProxyModel
34+
{
35+
Q_OBJECT
36+
public:
37+
38+
explicit QgsCheckableStyleModel( QgsStyle *style, QObject *parent = nullptr );
39+
40+
void setCheckable( bool checkable );
41+
void setCheckTag( const QString &tag );
42+
43+
Qt::ItemFlags flags( const QModelIndex &index ) const override;
44+
QVariant data( const QModelIndex &index, int role ) const override;
45+
bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
46+
47+
private:
48+
49+
QgsStyle *mStyle = nullptr;
50+
bool mCheckable = false;
51+
QString mCheckTag;
52+
53+
};
54+
#endif
55+
///@endcond
56+
3057
/**
3158
* \ingroup gui
3259
* \class QgsStyleManagerDialog
@@ -83,7 +110,10 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
83110
//! Open the associated help
84111
void showHelp();
85112

86-
void itemChanged( QStandardItem *item );
113+
/**
114+
* \deprecated in QGIS 3.6 - has no effect and will be removed in QGIS 4.0
115+
*/
116+
Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
87117

88118
void groupChanged( const QModelIndex & );
89119
void groupRenamed( QStandardItem * );
@@ -131,19 +161,34 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
131161

132162
protected:
133163

134-
//! populate combo box with known style items (symbols, color ramps)
135-
void populateTypes();
164+
/**
165+
* Populate combo box with known style items (symbols, color ramps).
166+
*
167+
* \deprecated in QGIS 3.6 - has no effect and will be removed in QGIS 4.0
168+
*/
169+
Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
136170

137171
//! populate the groups
138172
void populateGroups();
139-
//! to set symbols checked when in editing mode
140-
void setSymbolsChecked( const QStringList & );
141173

142-
//! populate list view with symbols of the current type with the given names
143-
void populateSymbols( const QStringList &symbolNames, bool checkable = false );
174+
/**
175+
* \deprecated in QGIS 3.6 - has no effect and will be removed in QGIS 4.0
176+
*/
177+
Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
178+
179+
/**
180+
* Populates the list view with symbols of the current type with the given names.
181+
*
182+
* \deprecated No longer required in QGIS 3.6, as the model is updated live. Has no effect and will be removed in QGIS 4.0
183+
*/
184+
Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
144185

145-
//! populate list view with color ramps
146-
void populateColorRamps( const QStringList &colorRamps, bool checkable = false );
186+
/**
187+
* Populates the list view with color ramps of the current type with the given names.
188+
*
189+
* \deprecated No longer required in QGIS 3.6, as the model is updated live. Has no effect and will be removed in QGIS 4.0
190+
*/
191+
Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
147192

148193
int currentItemType();
149194
QString currentItemName();
@@ -177,12 +222,14 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
177222

178223
QgsStyle *mStyle = nullptr;
179224

225+
QgsCheckableStyleModel *mModel = nullptr;
226+
180227
QString mStyleFilename;
181228

182229
bool mModified = false;
183230

184231
//! Mode to display the symbol list
185-
bool mGrouppingMode = false;
232+
bool mGroupingMode = false;
186233

187234
//! space to store symbol tags
188235
QStringList mTagList;

‎src/ui/qgsstylemanagerdialogbase.ui

Lines changed: 138 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -145,123 +145,7 @@
145145
<property name="bottomMargin">
146146
<number>0</number>
147147
</property>
148-
<item row="1" column="0">
149-
<widget class="QTabWidget" name="tabItemType">
150-
<property name="sizePolicy">
151-
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
152-
<horstretch>0</horstretch>
153-
<verstretch>0</verstretch>
154-
</sizepolicy>
155-
</property>
156-
<property name="currentIndex">
157-
<number>0</number>
158-
</property>
159-
<property name="iconSize">
160-
<size>
161-
<width>20</width>
162-
<height>20</height>
163-
</size>
164-
</property>
165-
<widget class="QWidget" name="tabMarker">
166-
<property name="sizePolicy">
167-
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
168-
<horstretch>0</horstretch>
169-
<verstretch>0</verstretch>
170-
</sizepolicy>
171-
</property>
172-
<attribute name="icon">
173-
<iconset resource="../../images/images.qrc">
174-
<normaloff>:/images/themes/default/mIconPointLayer.svg</normaloff>:/images/themes/default/mIconPointLayer.svg</iconset>
175-
</attribute>
176-
<attribute name="title">
177-
<string>Marker</string>
178-
</attribute>
179-
</widget>
180-
<widget class="QWidget" name="tabLine">
181-
<property name="sizePolicy">
182-
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
183-
<horstretch>0</horstretch>
184-
<verstretch>0</verstretch>
185-
</sizepolicy>
186-
</property>
187-
<attribute name="icon">
188-
<iconset resource="../../images/images.qrc">
189-
<normaloff>:/images/themes/default/mIconLineLayer.svg</normaloff>:/images/themes/default/mIconLineLayer.svg</iconset>
190-
</attribute>
191-
<attribute name="title">
192-
<string>Line</string>
193-
</attribute>
194-
</widget>
195-
<widget class="QWidget" name="tabFill">
196-
<property name="sizePolicy">
197-
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
198-
<horstretch>0</horstretch>
199-
<verstretch>0</verstretch>
200-
</sizepolicy>
201-
</property>
202-
<attribute name="icon">
203-
<iconset resource="../../images/images.qrc">
204-
<normaloff>:/images/themes/default/mIconPolygonLayer.svg</normaloff>:/images/themes/default/mIconPolygonLayer.svg</iconset>
205-
</attribute>
206-
<attribute name="title">
207-
<string>Fill</string>
208-
</attribute>
209-
</widget>
210-
<widget class="QWidget" name="tabColorRamp">
211-
<property name="sizePolicy">
212-
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
213-
<horstretch>0</horstretch>
214-
<verstretch>0</verstretch>
215-
</sizepolicy>
216-
</property>
217-
<attribute name="icon">
218-
<iconset resource="../../images/images.qrc">
219-
<normaloff>:/images/themes/default/styleicons/color.svg</normaloff>:/images/themes/default/styleicons/color.svg</iconset>
220-
</attribute>
221-
<attribute name="title">
222-
<string>Color ramp</string>
223-
</attribute>
224-
</widget>
225-
</widget>
226-
</item>
227-
<item row="2" column="0">
228-
<widget class="QListView" name="listItems">
229-
<property name="sizePolicy">
230-
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
231-
<horstretch>0</horstretch>
232-
<verstretch>3</verstretch>
233-
</sizepolicy>
234-
</property>
235-
<property name="editTriggers">
236-
<set>QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
237-
</property>
238-
<property name="iconSize">
239-
<size>
240-
<width>77</width>
241-
<height>70</height>
242-
</size>
243-
</property>
244-
<property name="textElideMode">
245-
<enum>Qt::ElideNone</enum>
246-
</property>
247-
<property name="movement">
248-
<enum>QListView::Static</enum>
249-
</property>
250-
<property name="resizeMode">
251-
<enum>QListView::Adjust</enum>
252-
</property>
253-
<property name="spacing">
254-
<number>5</number>
255-
</property>
256-
<property name="viewMode">
257-
<enum>QListView::IconMode</enum>
258-
</property>
259-
<property name="wordWrap">
260-
<bool>true</bool>
261-
</property>
262-
</widget>
263-
</item>
264-
<item row="3" column="0">
148+
<item row="4" column="0">
265149
<layout class="QHBoxLayout" name="symbolBtnsLayout">
266150
<item>
267151
<widget class="QPushButton" name="btnAddItem">
@@ -327,6 +211,111 @@
327211
</item>
328212
</layout>
329213
</item>
214+
<item row="3" column="0">
215+
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
216+
<property name="spacing">
217+
<number>0</number>
218+
</property>
219+
<item>
220+
<widget class="QTabWidget" name="tabItemType">
221+
<property name="documentMode">
222+
<bool>true</bool>
223+
</property>
224+
<widget class="QWidget" name="tabMarker">
225+
<property name="sizePolicy">
226+
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
227+
<horstretch>0</horstretch>
228+
<verstretch>0</verstretch>
229+
</sizepolicy>
230+
</property>
231+
<attribute name="icon">
232+
<iconset resource="../../images/images.qrc">
233+
<normaloff>:/images/themes/default/mIconPointLayer.svg</normaloff>:/images/themes/default/mIconPointLayer.svg</iconset>
234+
</attribute>
235+
<attribute name="title">
236+
<string>Marker</string>
237+
</attribute>
238+
</widget>
239+
<widget class="QWidget" name="tabLine">
240+
<property name="sizePolicy">
241+
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
242+
<horstretch>0</horstretch>
243+
<verstretch>0</verstretch>
244+
</sizepolicy>
245+
</property>
246+
<attribute name="icon">
247+
<iconset resource="../../images/images.qrc">
248+
<normaloff>:/images/themes/default/mIconLineLayer.svg</normaloff>:/images/themes/default/mIconLineLayer.svg</iconset>
249+
</attribute>
250+
<attribute name="title">
251+
<string>Line</string>
252+
</attribute>
253+
</widget>
254+
<widget class="QWidget" name="tabFill">
255+
<property name="sizePolicy">
256+
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
257+
<horstretch>0</horstretch>
258+
<verstretch>0</verstretch>
259+
</sizepolicy>
260+
</property>
261+
<attribute name="icon">
262+
<iconset resource="../../images/images.qrc">
263+
<normaloff>:/images/themes/default/mIconPolygonLayer.svg</normaloff>:/images/themes/default/mIconPolygonLayer.svg</iconset>
264+
</attribute>
265+
<attribute name="title">
266+
<string>Fill</string>
267+
</attribute>
268+
</widget>
269+
<widget class="QWidget" name="tabColorRamp">
270+
<property name="sizePolicy">
271+
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
272+
<horstretch>0</horstretch>
273+
<verstretch>0</verstretch>
274+
</sizepolicy>
275+
</property>
276+
<attribute name="icon">
277+
<iconset resource="../../images/images.qrc">
278+
<normaloff>:/images/themes/default/styleicons/color.svg</normaloff>:/images/themes/default/styleicons/color.svg</iconset>
279+
</attribute>
280+
<attribute name="title">
281+
<string>Color ramp</string>
282+
</attribute>
283+
</widget>
284+
</widget>
285+
</item>
286+
<item>
287+
<widget class="QListView" name="listItems">
288+
<property name="editTriggers">
289+
<set>QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
290+
</property>
291+
<property name="iconSize">
292+
<size>
293+
<width>77</width>
294+
<height>70</height>
295+
</size>
296+
</property>
297+
<property name="textElideMode">
298+
<enum>Qt::ElideNone</enum>
299+
</property>
300+
<property name="movement">
301+
<enum>QListView::Static</enum>
302+
</property>
303+
<property name="resizeMode">
304+
<enum>QListView::Adjust</enum>
305+
</property>
306+
<property name="spacing">
307+
<number>5</number>
308+
</property>
309+
<property name="viewMode">
310+
<enum>QListView::IconMode</enum>
311+
</property>
312+
<property name="wordWrap">
313+
<bool>true</bool>
314+
</property>
315+
</widget>
316+
</item>
317+
</layout>
318+
</item>
330319
</layout>
331320
</widget>
332321
</widget>
@@ -524,6 +513,38 @@
524513
</tabstops>
525514
<resources>
526515
<include location="../../images/images.qrc"/>
516+
<include location="../../images/images.qrc"/>
517+
<include location="../../images/images.qrc"/>
518+
<include location="../../images/images.qrc"/>
519+
<include location="../../images/images.qrc"/>
520+
<include location="../../images/images.qrc"/>
521+
<include location="../../images/images.qrc"/>
522+
<include location="../../images/images.qrc"/>
523+
<include location="../../images/images.qrc"/>
524+
<include location="../../images/images.qrc"/>
525+
<include location="../../images/images.qrc"/>
526+
<include location="../../images/images.qrc"/>
527+
<include location="../../images/images.qrc"/>
528+
<include location="../../images/images.qrc"/>
529+
<include location="../../images/images.qrc"/>
530+
<include location="../../images/images.qrc"/>
531+
<include location="../../images/images.qrc"/>
532+
<include location="../../images/images.qrc"/>
533+
<include location="../../images/images.qrc"/>
534+
<include location="../../images/images.qrc"/>
535+
<include location="../../images/images.qrc"/>
536+
<include location="../../images/images.qrc"/>
537+
<include location="../../images/images.qrc"/>
538+
<include location="../../images/images.qrc"/>
539+
<include location="../../images/images.qrc"/>
540+
<include location="../../images/images.qrc"/>
541+
<include location="../../images/images.qrc"/>
542+
<include location="../../images/images.qrc"/>
543+
<include location="../../images/images.qrc"/>
544+
<include location="../../images/images.qrc"/>
545+
<include location="../../images/images.qrc"/>
546+
<include location="../../images/images.qrc"/>
547+
<include location="../../images/images.qrc"/>
527548
</resources>
528549
<connections>
529550
<connection>

0 commit comments

Comments
 (0)
Please sign in to comment.