QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 explicit QgsCheckableStyleModel( QgsStyleModel *sourceModel, QObject *parent = nullptr, bool readOnly = false );
43 explicit QgsCheckableStyleModel( QgsStyle *style, QObject *parent = nullptr, bool readOnly = false );
44
45 void setCheckable( bool checkable );
46 void setCheckTag( const QString &tag );
47
48 Qt::ItemFlags flags( const QModelIndex &index ) const override;
49 QVariant data( const QModelIndex &index, int role ) const override;
50 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
51
52 private:
53 QgsStyle *mStyle = nullptr;
54 bool mCheckable = false;
55 QString mCheckTag;
56 bool mReadOnly = false;
57};
58#endif
60
67class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleManagerDialogBase
68{
69 Q_OBJECT
70
71 public:
72#ifndef SIP_RUN
73
74 static inline QgsSettingsTreeNode *sTtreeStyleManager = QgsSettingsTree::sTreeApp->createChildNode( QStringLiteral( "style-manager" ) );
75
81#endif
82
90 QgsStyleManagerDialog( QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), bool readOnly = false );
91
99 QgsStyleManagerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
100
101 // TODO QGIS 4.0 -- rename "RampType" to "rampType".
102
108 static QString addColorRampStatic( QWidget *parent, QgsStyle *style, const QString &RampType = QString() );
109
115 void setFavoritesGroupVisible( bool show );
116
122 void setSmartGroupsVisible( bool show );
123
133 void setBaseStyleName( const QString &name );
134
135 public slots:
136
137 // TODO QGIS 4.0 -- most of this should be private
138
143 void activate();
144
149 void addItem();
150
154 void editItem();
155
159 void removeItem();
160
167 void exportItemsSVG();
168
175 void exportItemsPNG();
176
183 void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
184
190 void exportItems();
191
197 void importItems();
198
202 void populateList();
203
207 void onFinished();
208
210 void onClose();
211
213 void showHelp();
214
218 Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
219
223 void groupChanged( const QModelIndex & );
224
228 void groupRenamed( QStandardItem *item );
229
233 int addTag();
234
238 int addSmartgroup();
239
243 void removeGroup();
244
248 void tagSymbolsAction();
249
253 void editSmartgroupAction();
254
258 Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
259
263 void filterSymbols( const QString &filter );
264
266 void symbolSelected( const QModelIndex & );
267
269 void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
270
272 void grouptreeContextMenu( QPoint );
273
275 void listitemsContextMenu( QPoint );
276
277 protected slots:
278
286 bool addColorRamp( const QString &type = QString() );
287
289 void addFavoriteSelectedSymbols();
291 void removeFavoriteSelectedSymbols();
293 void tagSelectedSymbols( bool newTag = false );
295 void detagSelectedSymbols();
296
297 protected:
303 Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
304
306 void populateGroups();
307
311 Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
312
318 Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
319
325 Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
326
327 int currentItemType();
328 QString currentItemName();
329
331 bool addSymbol( int symbolType = -1 );
332
333 bool editSymbol();
334 bool editColorRamp();
335
339 Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
340
344 Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
345
347 void enableSymbolInputs( bool );
349 void enableGroupInputs( bool );
351 void enableItemsForGroupingMode( bool );
352
354 void setBold( QStandardItem * );
355
356 private slots:
357
358 void tabItemType_currentChanged( int );
359
360 void copyItemsToDefault();
361
362 void copyItem();
363
364 void pasteItem();
365
366 void setThumbnailSize( int );
367
368 void currentStyleAboutToBeDestroyed();
369
370 private:
371 void init();
372
373 void setCurrentStyle( QgsStyle *style );
374 int selectedItemType();
375
379 bool allTypesSelected() const;
380
381 bool isReadOnly() const;
382
383 struct ItemDetails
384 {
385 QgsStyle::StyleEntity entityType;
386 Qgis::SymbolType symbolType;
387 QString name;
388 };
389
390 enum GroupModelRoles
391 {
392 Name = Qt::UserRole + 1,
393 TagName
394 };
395
396 QList<ItemDetails> selectedItems();
397
401 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 );
402
403 QgsMessageBar *mMessageBar = nullptr;
404
405 QgsStyle *mStyle = nullptr;
406
407 QgsCheckableStyleModel *mModel = nullptr;
408
409 QgsProjectStyleDatabaseModel *mProjectStyleModel = nullptr;
410
411 QString mStyleFilename;
412
413 bool mModified = false;
414
416 bool mGroupingMode = false;
417
419 QStringList mTagList;
420
421 QMenu *mShareMenu = nullptr;
422
424 QMenu *mGroupMenu = nullptr;
425
427 QMenu *mGroupListMenu = nullptr;
428
430 QMenu *mGroupTreeContextMenu = nullptr;
431
433 QMenu *mMenuBtnAddItemColorRamp = nullptr;
434
436 QMenu *mMenuBtnAddItemAll = nullptr;
437
439 QMenu *mMenuBtnAddItemLabelSettings = nullptr;
440
442 QMenu *mMenuBtnAddItemLegendPatchShape = nullptr;
443
445 QMenu *mMenuBtnAddItemSymbol3D = nullptr;
446
447 QAction *mActionCopyToDefault = nullptr;
448
449 QAction *mActionCopyItem = nullptr;
450 QAction *mActionPasteItem = nullptr;
451 QAction *mExportAction = nullptr;
452 QAction *mImportAction = nullptr;
453
454 int mBlockGroupUpdates = 0;
455 int mBlockStyleDatabaseChanges = 0;
456
457 bool mReadOnly = false;
458 bool mFavoritesGroupVisible = true;
459 bool mSmartGroupVisible = true;
460 QString mBaseName;
461
462 static QString sPreviousTag;
463
464 bool addTextFormat();
465 bool editTextFormat();
466
467 bool addLabelSettings( Qgis::GeometryType type );
468 bool editLabelSettings();
469
470 bool addLegendPatchShape( Qgis::SymbolType type );
471 bool editLegendPatchShape();
472
473 bool addSymbol3D( const QString &type );
474 bool editSymbol3D();
475
476 void addStyleDatabase( bool createNew );
477
479};
480
481#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