-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsstylemanagerdialog.h
451 lines (349 loc) · 12.7 KB
/
qgsstylemanagerdialog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
/***************************************************************************
qgsstylemanagerdialog.h
---------------------
begin : November 2009
copyright : (C) 2009 by Martin Dobias
email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSSTYLEV2MANAGERDIALOG_H
#define QGSSTYLEV2MANAGERDIALOG_H
#include <QDialog>
#include <QStandardItem>
#include <QAction>
#include <QMenu>
#include "ui_qgsstylemanagerdialogbase.h"
#include "qgshelp.h"
#include "qgsstylemodel.h"
#include "qgis_gui.h"
class QgsStyle;
class QgsTemporaryCursorOverride;
class QgsMessageBar;
#ifndef SIP_RUN
///@cond PRIVATE
class QgsCheckableStyleModel: public QgsStyleProxyModel
{
Q_OBJECT
public:
explicit QgsCheckableStyleModel( QgsStyleModel *sourceModel, QObject *parent = nullptr, bool readOnly = false );
explicit QgsCheckableStyleModel( QgsStyle *style, QObject *parent = nullptr, bool readOnly = false );
void setCheckable( bool checkable );
void setCheckTag( const QString &tag );
Qt::ItemFlags flags( const QModelIndex &index ) const override;
QVariant data( const QModelIndex &index, int role ) const override;
bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
private:
QgsStyle *mStyle = nullptr;
bool mCheckable = false;
QString mCheckTag;
bool mReadOnly = false;
};
#endif
///@endcond
/**
* \ingroup gui
* \class QgsStyleManagerDialog
*
* \brief A dialog allowing users to customize and populate a QgsStyle.
*/
class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleManagerDialogBase
{
Q_OBJECT
public:
/**
* Constructor for QgsStyleManagerDialog, with the specified \a parent widget and window \a flags.
*
* The \a style argument specifies the linked QgsStyle database. Symbols and objects contained within
* this style will be shown in the dialog, and changes made within the dialog will be applied to \a style.
* The \a style object must last for the lifetime of the dialog.
*/
QgsStyleManagerDialog( QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
bool readOnly = false );
// TODO QGIS 4.0 -- rename "RampType" to "rampType".
/**
* Opens the add color ramp dialog, returning the new color ramp's name if the ramp has been added.
*
* The \a RampType argument should be set to a string representing a valid QgsColorRamp::type() value.
*/
static QString addColorRampStatic( QWidget *parent, QgsStyle *style,
const QString &RampType = QString() );
/**
* Sets whether the favorites group should be shown. The default is to show the group.
*
* \since QGIS 3.6
*/
void setFavoritesGroupVisible( bool show );
/**
* Sets whether smart groups should be shown. The default is to show the groups.
*
* \since QGIS 3.6
*/
void setSmartGroupsVisible( bool show );
/**
* Sets the base \a name for the style, which is used by the dialog to reflect the
* original style/XML file name.
*
* \a name should be stripped of any extensions and folder information, e.g. "transport_styles",
* not "d:/stuff/transport_styles.xml".
*
* \since QGIS 3.6
*/
void setBaseStyleName( const QString &name );
public slots:
// TODO QGIS 4.0 -- most of this should be private
/**
* Raises, unminimizes and activates this window
* \since QGIS 3.4
*/
void activate();
/**
* Triggers the dialog for adding a new item, based on the currently
* selected item type tab.
*/
void addItem();
/**
* Triggers the dialog for editing the current item.
*/
void editItem();
/**
* Removes the current selected item.
*/
void removeItem();
/**
* Triggers the dialog to export selected items as SVG files.
*
* \see exportItemsPNG()
* \see exportSelectedItemsImages()
*/
void exportItemsSVG();
/**
* Triggers the dialog to export selected items as PNG files.
*
* \see exportItemsSVG()
* \see exportSelectedItemsImages()
*/
void exportItemsPNG();
/**
* Triggers the dialog to export selected items as images of the specified \a format and \a size.
*
* \see exportItemsSVG()
* \see exportItemsPNG()
*/
void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
/**
* Triggers the dialog to export items.
*
* \see importItems()
*/
void exportItems();
/**
* Triggers the dialog to import items.
*
* \see exportItems()
*/
void importItems();
/**
* Refreshes the list of items.
*/
void populateList();
/**
* Called when the dialog is going to be closed.
*/
void onFinished();
//! Closes the dialog
void onClose();
//! Opens the associated help
void showHelp();
/**
* \deprecated since QGIS 3.6 - has no effect and will be removed in QGIS 4.0
*/
Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
/**
* Triggered when the current group (or tag) is changed.
*/
void groupChanged( const QModelIndex & );
/**
* Triggered when a group \a item is renamed.
*/
void groupRenamed( QStandardItem *item );
/**
* Triggers the dialog to add a new tag.
*/
int addTag();
/**
* Triggers the dialog to add a new smart group.
*/
int addSmartgroup();
/**
* Removes the selected tag or smartgroup.
*/
void removeGroup();
/**
* Toggles the interactive item tagging mode.
*/
void tagSymbolsAction();
/**
* Triggers the dialog for editing the selected smart group.
*/
void editSmartgroupAction();
/**
* \deprecated since QGIS 3.6 - has no effect and will be removed in QGIS 4.0
*/
Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
/**
* Sets the \a filter string to filter symbols by.
*/
void filterSymbols( const QString &filter );
//! Perform symbol specific tasks when selected
void symbolSelected( const QModelIndex & );
//! Perform tasks when the selected symbols change
void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
//! Context menu for the groupTree
void grouptreeContextMenu( QPoint );
//! Context menu for the listItems ( symbols list )
void listitemsContextMenu( QPoint );
protected slots:
/**
* Triggers adding a new color ramp.
*
* If \a type is set to a string representing a valid QgsColorRamp::type() value then a new ramp
* of that type will be created. If \a type is empty, then the user will be prompted to select
* the color ramp type.
*/
bool addColorRamp( const QString &type = QString() );
//! Add selected symbols to favorites
void addFavoriteSelectedSymbols();
//! Remove selected symbols from favorites
void removeFavoriteSelectedSymbols();
//! Tag selected symbols using menu item selection
void tagSelectedSymbols( bool newTag = false );
//! Remove all tags from selected symbols
void detagSelectedSymbols();
protected:
/**
* Populate combo box with known style items (symbols, color ramps).
*
* \deprecated since QGIS 3.6 - has no effect and will be removed in QGIS 4.0
*/
Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
//! populate the groups
void populateGroups();
/**
* \deprecated since QGIS 3.6 - has no effect and will be removed in QGIS 4.0
*/
Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
/**
* Populates the list view with symbols of the current type with the given names.
*
* \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
*/
Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
/**
* Populates the list view with color ramps of the current type with the given names.
*
* \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
*/
Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
int currentItemType();
QString currentItemName();
//! add a new symbol to style
bool addSymbol( int symbolType = -1 );
bool editSymbol();
bool editColorRamp();
/**
* \deprecated since QGIS 3.6 - has no effect and will be removed in QGIS 4.0
*/
Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
/**
* \deprecated since QGIS 3.6 - has no effect and will be removed in QGIS 4.0
*/
Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
//! Enables or disbables the symbol specific inputs
void enableSymbolInputs( bool );
//! Enables or disables the groupTree specific inputs
void enableGroupInputs( bool );
//! Enables or disables the groupTree items for grouping mode
void enableItemsForGroupingMode( bool );
//! sets the text of the item with bold font
void setBold( QStandardItem * );
private slots:
void tabItemType_currentChanged( int );
void copyItemsToDefault();
void copyItem();
void pasteItem();
void setThumbnailSize( int );
private:
int selectedItemType();
/**
* Returns TRUE if the "All" tab is selected.
*/
bool allTypesSelected() const;
struct ItemDetails
{
QgsStyle::StyleEntity entityType;
Qgis::SymbolType symbolType;
QString name;
};
enum GroupModelRoles
{
Name = Qt::UserRole + 1,
TagName
};
QList< ItemDetails > selectedItems();
/**
* Returns count of items copied, excluding skipped items.
*/
static int copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );
QgsMessageBar *mMessageBar = nullptr;
QgsStyle *mStyle = nullptr;
QgsCheckableStyleModel *mModel = nullptr;
QString mStyleFilename;
bool mModified = false;
//! Mode to display the symbol list
bool mGroupingMode = false;
//! space to store symbol tags
QStringList mTagList;
//! Context menu for the symbols/colorramps
QMenu *mGroupMenu = nullptr;
//! Sub-menu of \c mGroupMenu, dynamically filled to show one entry for every group
QMenu *mGroupListMenu = nullptr;
//! Context menu for the group tree
QMenu *mGroupTreeContextMenu = nullptr;
//! Menu for the "Add item" toolbutton when in colorramp mode
QMenu *mMenuBtnAddItemColorRamp = nullptr;
//! Menu for the "Add item" toolbutton when in all symbols mode
QMenu *mMenuBtnAddItemAll = nullptr;
//! Menu for the "Add item" toolbutton when in label settings mode
QMenu *mMenuBtnAddItemLabelSettings = nullptr;
//! Menu for the "Add item" toolbutton when in legend patch shape mode
QMenu *mMenuBtnAddItemLegendPatchShape = nullptr;
//! Menu for the "Add item" toolbutton when in 3d symbol mode
QMenu *mMenuBtnAddItemSymbol3D = nullptr;
QAction *mActionCopyToDefault = nullptr;
QAction *mActionCopyItem = nullptr;
QAction *mActionPasteItem = nullptr;
int mBlockGroupUpdates = 0;
bool mReadOnly = false;
bool mFavoritesGroupVisible = true;
bool mSmartGroupVisible = true;
QString mBaseName;
static QString sPreviousTag;
bool addTextFormat();
bool editTextFormat();
bool addLabelSettings( QgsWkbTypes::GeometryType type );
bool editLabelSettings();
bool addLegendPatchShape( Qgis::SymbolType type );
bool editLegendPatchShape();
bool addSymbol3D( const QString &type );
bool editSymbol3D();
friend class QgsStyleExportImportDialog;
};
#endif