QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsstylemanagerdialog.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsstylemanagerdialog.h
3 ---------------------
4 begin : November 2009
5 copyright : (C) 2009 by Martin Dobias
6 email : wonder dot sk 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
16#ifndef QGSSTYLEV2MANAGERDIALOG_H
17#define QGSSTYLEV2MANAGERDIALOG_H
18
19#include <QDialog>
20#include <QStandardItem>
21#include <QAction>
22#include <QMenu>
23
24#include "ui_qgsstylemanagerdialogbase.h"
25#include "qgshelp.h"
26#include "qgsstylemodel.h"
27#include "qgis_gui.h"
28#include "qgis_sip.h"
30
31class QgsStyle;
33class QgsMessageBar;
35
36#ifndef SIP_RUN
38class QgsCheckableStyleModel: public QgsStyleProxyModel
39{
40 Q_OBJECT
41 public:
42
43 explicit QgsCheckableStyleModel( QgsStyleModel *sourceModel, QObject *parent = nullptr, bool readOnly = false );
44 explicit QgsCheckableStyleModel( QgsStyle *style, QObject *parent = nullptr, bool readOnly = false );
45
46 void setCheckable( bool checkable );
47 void setCheckTag( const QString &tag );
48
49 Qt::ItemFlags flags( const QModelIndex &index ) const override;
50 QVariant data( const QModelIndex &index, int role ) const override;
51 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
52
53 private:
54
55 QgsStyle *mStyle = nullptr;
56 bool mCheckable = false;
57 QString mCheckTag;
58 bool mReadOnly = false;
59
60};
61#endif
63
70class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleManagerDialogBase
71{
72 Q_OBJECT
73
74 public:
75#ifndef SIP_RUN
76
81 static const inline QgsSettingsEntryString settingLastStyleDatabaseFolder = QgsSettingsEntryString( QStringLiteral( "last-style-database-folder" ), QgsSettings::Prefix::STYLE_MANAGER, QString(), QStringLiteral( "Last used folder for style databases" ) );
82#endif
83
91 QgsStyleManagerDialog( QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
92 bool readOnly = false );
93
101 QgsStyleManagerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
102
103 // TODO QGIS 4.0 -- rename "RampType" to "rampType".
104
110 static QString addColorRampStatic( QWidget *parent, QgsStyle *style,
111 const QString &RampType = QString() );
112
118 void setFavoritesGroupVisible( bool show );
119
125 void setSmartGroupsVisible( bool show );
126
136 void setBaseStyleName( const QString &name );
137
138 public slots:
139
140 // TODO QGIS 4.0 -- most of this should be private
141
146 void activate();
147
152 void addItem();
153
157 void editItem();
158
162 void removeItem();
163
170 void exportItemsSVG();
171
178 void exportItemsPNG();
179
186 void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
187
193 void exportItems();
194
200 void importItems();
201
205 void populateList();
206
210 void onFinished();
211
213 void onClose();
214
216 void showHelp();
217
221 Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
222
226 void groupChanged( const QModelIndex & );
227
231 void groupRenamed( QStandardItem *item );
232
236 int addTag();
237
241 int addSmartgroup();
242
246 void removeGroup();
247
251 void tagSymbolsAction();
252
256 void editSmartgroupAction();
257
261 Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
262
266 void filterSymbols( const QString &filter );
267
269 void symbolSelected( const QModelIndex & );
270
272 void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
273
275 void grouptreeContextMenu( QPoint );
276
278 void listitemsContextMenu( QPoint );
279
280 protected slots:
281
289 bool addColorRamp( const QString &type = QString() );
290
292 void addFavoriteSelectedSymbols();
294 void removeFavoriteSelectedSymbols();
296 void tagSelectedSymbols( bool newTag = false );
298 void detagSelectedSymbols();
299
300 protected:
301
307 Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
308
310 void populateGroups();
311
315 Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
316
322 Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
323
329 Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
330
331 int currentItemType();
332 QString currentItemName();
333
335 bool addSymbol( int symbolType = -1 );
336
337 bool editSymbol();
338 bool editColorRamp();
339
343 Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
344
348 Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
349
351 void enableSymbolInputs( bool );
353 void enableGroupInputs( bool );
355 void enableItemsForGroupingMode( bool );
356
358 void setBold( QStandardItem * );
359
360 private slots:
361
362 void tabItemType_currentChanged( int );
363
364 void copyItemsToDefault();
365
366 void copyItem();
367
368 void pasteItem();
369
370 void setThumbnailSize( int );
371
372 void currentStyleAboutToBeDestroyed();
373
374 private:
375
376 void init();
377
378 void setCurrentStyle( QgsStyle *style );
379 int selectedItemType();
380
384 bool allTypesSelected() const;
385
386 bool isReadOnly() const;
387
388 struct ItemDetails
389 {
390 QgsStyle::StyleEntity entityType;
391 Qgis::SymbolType symbolType;
392 QString name;
393 };
394
395 enum GroupModelRoles
396 {
397 Name = Qt::UserRole + 1,
398 TagName
399 };
400
401 QList< ItemDetails > selectedItems();
402
406 static int copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
407 QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
408 bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );
409
410 QgsMessageBar *mMessageBar = nullptr;
411
412 QgsStyle *mStyle = nullptr;
413
414 QgsCheckableStyleModel *mModel = nullptr;
415
416 QgsProjectStyleDatabaseModel *mProjectStyleModel = nullptr;
417
418 QString mStyleFilename;
419
420 bool mModified = false;
421
423 bool mGroupingMode = false;
424
426 QStringList mTagList;
427
428 QMenu *mShareMenu = nullptr;
429
431 QMenu *mGroupMenu = nullptr;
432
434 QMenu *mGroupListMenu = nullptr;
435
437 QMenu *mGroupTreeContextMenu = nullptr;
438
440 QMenu *mMenuBtnAddItemColorRamp = nullptr;
441
443 QMenu *mMenuBtnAddItemAll = nullptr;
444
446 QMenu *mMenuBtnAddItemLabelSettings = nullptr;
447
449 QMenu *mMenuBtnAddItemLegendPatchShape = nullptr;
450
452 QMenu *mMenuBtnAddItemSymbol3D = nullptr;
453
454 QAction *mActionCopyToDefault = nullptr;
455
456 QAction *mActionCopyItem = nullptr;
457 QAction *mActionPasteItem = nullptr;
458 QAction *mExportAction = nullptr;
459 QAction *mImportAction = nullptr;
460
461 int mBlockGroupUpdates = 0;
462 int mBlockStyleDatabaseChanges = 0;
463
464 bool mReadOnly = false;
465 bool mFavoritesGroupVisible = true;
466 bool mSmartGroupVisible = true;
467 QString mBaseName;
468
469 static QString sPreviousTag;
470
471 bool addTextFormat();
472 bool editTextFormat();
473
474 bool addLabelSettings( QgsWkbTypes::GeometryType type );
475 bool editLabelSettings();
476
477 bool addLegendPatchShape( Qgis::SymbolType type );
478 bool editLegendPatchShape();
479
480 bool addSymbol3D( const QString &type );
481 bool editSymbol3D();
482
483 void addStyleDatabase( bool createNew );
484
486};
487
488#endif
SymbolType
Symbol types.
Definition: qgis.h:206
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
List model representing the style databases associated with a QgsProject.
A string settings entry.
static const char * STYLE_MANAGER
Definition: qgssettings.h:108
A dialog allowing users to customize and populate a QgsStyle.
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:179
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:221
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
@ TagName
Tag name.
Definition: qgsstyle.h:100