QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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 "qgsstylemodel.h"
26#include "qgis_gui.h"
27#include "qgis_sip.h"
28#include "qgssettingstree.h"
29
30class QgsStyle;
32class 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
77 static inline QgsSettingsTreeNode *sTtreeStyleManager = QgsSettingsTree::sTreeApp->createChildNode( QStringLiteral( "style-manager" ) );
78
84#endif
85
93 QgsStyleManagerDialog( QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
94 bool readOnly = false );
95
103 QgsStyleManagerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
104
105 // TODO QGIS 4.0 -- rename "RampType" to "rampType".
106
112 static QString addColorRampStatic( QWidget *parent, QgsStyle *style,
113 const QString &RampType = QString() );
114
120 void setFavoritesGroupVisible( bool show );
121
127 void setSmartGroupsVisible( bool show );
128
138 void setBaseStyleName( const QString &name );
139
140 public slots:
141
142 // TODO QGIS 4.0 -- most of this should be private
143
148 void activate();
149
154 void addItem();
155
159 void editItem();
160
164 void removeItem();
165
172 void exportItemsSVG();
173
180 void exportItemsPNG();
181
188 void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
189
195 void exportItems();
196
202 void importItems();
203
207 void populateList();
208
212 void onFinished();
213
215 void onClose();
216
218 void showHelp();
219
223 Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
224
228 void groupChanged( const QModelIndex & );
229
233 void groupRenamed( QStandardItem *item );
234
238 int addTag();
239
243 int addSmartgroup();
244
248 void removeGroup();
249
253 void tagSymbolsAction();
254
258 void editSmartgroupAction();
259
263 Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
264
268 void filterSymbols( const QString &filter );
269
271 void symbolSelected( const QModelIndex & );
272
274 void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
275
277 void grouptreeContextMenu( QPoint );
278
280 void listitemsContextMenu( QPoint );
281
282 protected slots:
283
291 bool addColorRamp( const QString &type = QString() );
292
294 void addFavoriteSelectedSymbols();
296 void removeFavoriteSelectedSymbols();
298 void tagSelectedSymbols( bool newTag = false );
300 void detagSelectedSymbols();
301
302 protected:
303
309 Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
310
312 void populateGroups();
313
317 Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
318
324 Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
325
331 Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
332
333 int currentItemType();
334 QString currentItemName();
335
337 bool addSymbol( int symbolType = -1 );
338
339 bool editSymbol();
340 bool editColorRamp();
341
345 Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
346
350 Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
351
353 void enableSymbolInputs( bool );
355 void enableGroupInputs( bool );
357 void enableItemsForGroupingMode( bool );
358
360 void setBold( QStandardItem * );
361
362 private slots:
363
364 void tabItemType_currentChanged( int );
365
366 void copyItemsToDefault();
367
368 void copyItem();
369
370 void pasteItem();
371
372 void setThumbnailSize( int );
373
374 void currentStyleAboutToBeDestroyed();
375
376 private:
377
378 void init();
379
380 void setCurrentStyle( QgsStyle *style );
381 int selectedItemType();
382
386 bool allTypesSelected() const;
387
388 bool isReadOnly() const;
389
390 struct ItemDetails
391 {
392 QgsStyle::StyleEntity entityType;
393 Qgis::SymbolType symbolType;
394 QString name;
395 };
396
397 enum GroupModelRoles
398 {
399 Name = Qt::UserRole + 1,
400 TagName
401 };
402
403 QList< ItemDetails > selectedItems();
404
408 static int copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
409 QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
410 bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );
411
412 QgsMessageBar *mMessageBar = nullptr;
413
414 QgsStyle *mStyle = nullptr;
415
416 QgsCheckableStyleModel *mModel = nullptr;
417
418 QgsProjectStyleDatabaseModel *mProjectStyleModel = nullptr;
419
420 QString mStyleFilename;
421
422 bool mModified = false;
423
425 bool mGroupingMode = false;
426
428 QStringList mTagList;
429
430 QMenu *mShareMenu = nullptr;
431
433 QMenu *mGroupMenu = nullptr;
434
436 QMenu *mGroupListMenu = nullptr;
437
439 QMenu *mGroupTreeContextMenu = nullptr;
440
442 QMenu *mMenuBtnAddItemColorRamp = nullptr;
443
445 QMenu *mMenuBtnAddItemAll = nullptr;
446
448 QMenu *mMenuBtnAddItemLabelSettings = nullptr;
449
451 QMenu *mMenuBtnAddItemLegendPatchShape = nullptr;
452
454 QMenu *mMenuBtnAddItemSymbol3D = nullptr;
455
456 QAction *mActionCopyToDefault = nullptr;
457
458 QAction *mActionCopyItem = nullptr;
459 QAction *mActionPasteItem = nullptr;
460 QAction *mExportAction = nullptr;
461 QAction *mImportAction = nullptr;
462
463 int mBlockGroupUpdates = 0;
464 int mBlockStyleDatabaseChanges = 0;
465
466 bool mReadOnly = false;
467 bool mFavoritesGroupVisible = true;
468 bool mSmartGroupVisible = true;
469 QString mBaseName;
470
471 static QString sPreviousTag;
472
473 bool addTextFormat();
474 bool editTextFormat();
475
476 bool addLabelSettings( Qgis::GeometryType type );
477 bool editLabelSettings();
478
479 bool addLegendPatchShape( Qgis::SymbolType type );
480 bool editLegendPatchShape();
481
482 bool addSymbol3D( const QString &type );
483 bool editSymbol3D();
484
485 void addStyleDatabase( bool createNew );
486
488};
489
490#endif
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
SymbolType
Symbol types.
Definition qgis.h:574
A bar for displaying non-blocking messages to the user.
List model representing the style databases associated with a QgsProject.
A string settings entry.
QgsSettingsTreeNode is a tree node for the settings tree to help organizing and introspecting the tre...
QgsSettingsTreeNode * createChildNode(const QString &key)
Creates a normal tree node It will return the existing child node if it exists at the given key.
static QgsSettingsTreeNode * sTreeApp
A dialog allowing users to customize and populate a QgsStyle.
static const QgsSettingsEntryString * settingLastStyleDatabaseFolder
Last used folder for generic style database actions.
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:203
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53