QGIS API Documentation 3.99.0-Master (d270888f95f)
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 "ui_qgsstylemanagerdialogbase.h"
20
21#include "qgis_gui.h"
22#include "qgis_sip.h"
23#include "qgssettingstree.h"
24#include "qgsstylemodel.h"
25
26#include <QAction>
27#include <QDialog>
28#include <QMenu>
29#include <QStandardItem>
30#include <QString>
31
32using namespace Qt::StringLiterals;
33
34class QgsStyle;
36class QgsMessageBar;
39
40#ifndef SIP_RUN
42class QgsCheckableStyleModel : public QgsStyleProxyModel
43{
44 Q_OBJECT
45 public:
46 explicit QgsCheckableStyleModel( QgsStyleModel *sourceModel, QObject *parent = nullptr, bool readOnly = false );
47 explicit QgsCheckableStyleModel( QgsStyle *style, QObject *parent = nullptr, bool readOnly = false );
48
49 void setCheckable( bool checkable );
50 void setCheckTag( const QString &tag );
51
52 Qt::ItemFlags flags( const QModelIndex &index ) const override;
53 QVariant data( const QModelIndex &index, int role ) const override;
54 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
55
56 private:
57 QgsStyle *mStyle = nullptr;
58 bool mCheckable = false;
59 QString mCheckTag;
60 bool mReadOnly = false;
61};
62#endif
64
71class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleManagerDialogBase
72{
73 Q_OBJECT
74
75 public:
76#ifndef SIP_RUN
77
78 static inline QgsSettingsTreeNode *sTtreeStyleManager = QgsSettingsTree::sTreeApp->createChildNode( u"style-manager"_s );
79
85#endif
86
94 QgsStyleManagerDialog( QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), bool readOnly = false );
95
103 QgsStyleManagerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
104
105 // TODO QGIS 5.0 -- rename "RampType" to "rampType".
106
112 static QString addColorRampStatic( QWidget *parent, QgsStyle *style, const QString &RampType = QString() );
113
119 void setFavoritesGroupVisible( bool show );
120
126 void setSmartGroupsVisible( bool show );
127
137 void setBaseStyleName( const QString &name );
138
139 public slots:
140
141 // TODO QGIS 5.0 -- most of this should be private
142
147 void activate();
148
153 void addItem();
154
158 void editItem();
159
163 void removeItem();
164
171 void exportItemsSVG();
172
179 void exportItemsPNG();
180
187 void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
188
194 void exportItems();
195
201 void importItems();
202
206 void populateList();
207
211 void onFinished();
212
214 void onClose();
215
217 void showHelp();
218
222 Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
223
227 void groupChanged( const QModelIndex & );
228
232 void groupRenamed( QStandardItem *item );
233
237 int addTag();
238
242 int addSmartgroup();
243
247 void removeGroup();
248
252 void tagSymbolsAction();
253
258
262 Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
263
267 void filterSymbols( const QString &filter );
268
270 void symbolSelected( const QModelIndex & );
271
273 void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
274
276 void grouptreeContextMenu( QPoint );
277
279 void listitemsContextMenu( QPoint );
280
281 protected slots:
282
290 bool addColorRamp( const QString &type = QString() );
291
297 void tagSelectedSymbols( bool newTag = false );
300
301 protected:
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 void init();
376
377 void setCurrentStyle( QgsStyle *style );
378 int selectedItemType();
379
383 bool allTypesSelected() const;
384
385 bool isReadOnly() const;
386
387 struct ItemDetails
388 {
389 QgsStyle::StyleEntity entityType;
391 QString name;
392 };
393
394 enum GroupModelRoles
395 {
396 Name = Qt::UserRole + 1,
397 TagName
398 };
399
400 QList<ItemDetails> selectedItems();
401
405 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 );
406
407 QgsMessageBar *mMessageBar = nullptr;
408
409 QgsStyle *mStyle = nullptr;
410
411 QgsCheckableStyleModel *mModel = nullptr;
412
413 QgsProjectStyleDatabaseModel *mProjectStyleModel = nullptr;
414
415 QString mStyleFilename;
416
417 bool mModified = false;
418
420 bool mGroupingMode = false;
421
423 QStringList mTagList;
424
425 QMenu *mShareMenu = nullptr;
426
428 QMenu *mGroupMenu = nullptr;
429
431 QMenu *mGroupListMenu = nullptr;
432
434 QMenu *mGroupTreeContextMenu = nullptr;
435
437 QMenu *mMenuBtnAddItemColorRamp = nullptr;
438
440 QMenu *mMenuBtnAddItemAll = nullptr;
441
443 QMenu *mMenuBtnAddItemLabelSettings = nullptr;
444
446 QMenu *mMenuBtnAddItemLegendPatchShape = nullptr;
447
449 QMenu *mMenuBtnAddItemSymbol3D = nullptr;
450
451 QAction *mActionCopyToDefault = nullptr;
452
453 QAction *mActionCopyItem = nullptr;
454 QAction *mActionPasteItem = nullptr;
455 QAction *mExportAction = nullptr;
456 QAction *mImportAction = nullptr;
457
458 int mBlockGroupUpdates = 0;
459 int mBlockStyleDatabaseChanges = 0;
460
461 bool mReadOnly = false;
462 bool mFavoritesGroupVisible = true;
463 bool mSmartGroupVisible = true;
464 QString mBaseName;
465
466 static QString sPreviousTag;
467
468 bool addTextFormat();
469 bool editTextFormat();
470
471 bool addLabelSettings( Qgis::GeometryType type );
472 bool editLabelSettings();
473
474 bool addLegendPatchShape( Qgis::SymbolType type );
475 bool editLegendPatchShape();
476
477 bool addSymbol3D( const QString &type );
478 bool editSymbol3D();
479
480 void addStyleDatabase( bool createNew );
481
483};
484
485#endif
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:365
SymbolType
Symbol types.
Definition qgis.h:629
@ Hybrid
Hybrid symbol.
Definition qgis.h:633
A bar for displaying non-blocking messages to the user.
List model representing the style databases associated with a QgsProject.
A string settings entry.
A tree node for the settings tree to help organizing and introspecting the tree.
static QgsSettingsTreeNode * sTreeApp
Q_DECL_DEPRECATED bool removeSymbol()
void onClose()
Closes the dialog.
void groupRenamed(QStandardItem *item)
Triggered when a group item is renamed.
static const QgsSettingsEntryString * settingLastStyleDatabaseFolder
Last used folder for generic style database actions.
void addFavoriteSelectedSymbols()
Add selected symbols to favorites.
void selectedSymbolsChanged(const QItemSelection &selected, const QItemSelection &deselected)
Perform tasks when the selected symbols change.
void removeGroup()
Removes the selected tag or smartgroup.
void exportItems()
Triggers the dialog to export items.
static QgsSettingsTreeNode * sTtreeStyleManager
void setFavoritesGroupVisible(bool show)
Sets whether the favorites group should be shown.
void grouptreeContextMenu(QPoint)
Context menu for the groupTree.
void setBold(QStandardItem *)
sets the text of the item with bold font
void filterSymbols(const QString &filter)
Sets the filter string to filter symbols by.
void addItem()
Triggers the dialog for adding a new item, based on the currently selected item type tab.
void tagSymbolsAction()
Toggles the interactive item tagging mode.
void editSmartgroupAction()
Triggers the dialog for editing the selected smart group.
void showHelp()
Opens the associated help.
void detagSelectedSymbols()
Remove all tags from selected symbols.
void enableSymbolInputs(bool)
Enables or disbables the symbol specific inputs.
bool addSymbol(int symbolType=-1)
add a new symbol to style
Q_DECL_DEPRECATED void populateTypes()
Populate combo box with known style items (symbols, color ramps).
void populateList()
Refreshes the list of items.
void removeItem()
Removes the current selected item.
void groupChanged(const QModelIndex &)
Triggered when the current group (or tag) is changed.
QgsStyleManagerDialog(QgsStyle *style, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), bool readOnly=false)
Constructor for QgsStyleManagerDialog, with the specified parent widget and window flags.
void enableGroupInputs(bool)
Enables or disables the groupTree specific inputs.
int addTag()
Triggers the dialog to add a new tag.
void exportItemsSVG()
Triggers the dialog to export selected items as SVG files.
Q_DECL_DEPRECATED void populateSymbols(const QStringList &symbolNames, bool checkable=false)
Populates the list view with symbols of the current type with the given names.
void populateGroups()
populate the groups
Q_DECL_DEPRECATED bool removeColorRamp()
void importItems()
Triggers the dialog to import items.
void setBaseStyleName(const QString &name)
Sets the base name for the style, which is used by the dialog to reflect the original style/XML file ...
Q_DECL_DEPRECATED void regrouped(QStandardItem *)
Q_DECL_DEPRECATED void itemChanged(QStandardItem *item)
void exportItemsPNG()
Triggers the dialog to export selected items as PNG files.
void activate()
Raises, unminimizes and activates this window.
bool addColorRamp(const QString &type=QString())
Triggers adding a new color ramp.
void exportSelectedItemsImages(const QString &dir, const QString &format, QSize size)
Triggers the dialog to export selected items as images of the specified format and size.
void enableItemsForGroupingMode(bool)
Enables or disables the groupTree items for grouping mode.
Q_DECL_DEPRECATED void setSymbolsChecked(const QStringList &)
void onFinished()
Called when the dialog is going to be closed.
void listitemsContextMenu(QPoint)
Context menu for the listItems ( symbols list ).
void setSmartGroupsVisible(bool show)
Sets whether smart groups should be shown.
static QString addColorRampStatic(QWidget *parent, QgsStyle *style, const QString &RampType=QString())
Opens the add color ramp dialog, returning the new color ramp's name if the ramp has been added.
void symbolSelected(const QModelIndex &)
Perform symbol specific tasks when selected.
void editItem()
Triggers the dialog for editing the current item.
void removeFavoriteSelectedSymbols()
Remove selected symbols from favorites.
int addSmartgroup()
Triggers the dialog to add a new smart group.
void tagSelectedSymbols(bool newTag=false)
Tag selected symbols using menu item selection.
Q_DECL_DEPRECATED void populateColorRamps(const QStringList &colorRamps, bool checkable=false)
Populates the list view with color ramps of the current type with the given names.
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
A database of saved style entities, including symbols, color ramps, text formats and others.
Definition qgsstyle.h:89
StyleEntity
Enum for Entities involved in a style.
Definition qgsstyle.h:205
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53