QGIS API Documentation 3.99.0-Master (26c88405ac0)
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
31class QgsStyle;
33class QgsMessageBar;
36
37#ifndef SIP_RUN
39class QgsCheckableStyleModel : public QgsStyleProxyModel
40{
41 Q_OBJECT
42 public:
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 QgsStyle *mStyle = nullptr;
55 bool mCheckable = false;
56 QString mCheckTag;
57 bool mReadOnly = false;
58};
59#endif
61
68class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleManagerDialogBase
69{
70 Q_OBJECT
71
72 public:
73#ifndef SIP_RUN
74
75 static inline QgsSettingsTreeNode *sTtreeStyleManager = QgsSettingsTree::sTreeApp->createChildNode( QStringLiteral( "style-manager" ) );
76
82#endif
83
91 QgsStyleManagerDialog( QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), bool readOnly = false );
92
100 QgsStyleManagerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
101
102 // TODO QGIS 4.0 -- rename "RampType" to "rampType".
103
109 static QString addColorRampStatic( QWidget *parent, QgsStyle *style, const QString &RampType = QString() );
110
116 void setFavoritesGroupVisible( bool show );
117
123 void setSmartGroupsVisible( bool show );
124
134 void setBaseStyleName( const QString &name );
135
136 public slots:
137
138 // TODO QGIS 4.0 -- most of this should be private
139
144 void activate();
145
150 void addItem();
151
155 void editItem();
156
160 void removeItem();
161
168 void exportItemsSVG();
169
176 void exportItemsPNG();
177
184 void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
185
191 void exportItems();
192
198 void importItems();
199
203 void populateList();
204
208 void onFinished();
209
211 void onClose();
212
214 void showHelp();
215
219 Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
220
224 void groupChanged( const QModelIndex & );
225
229 void groupRenamed( QStandardItem *item );
230
234 int addTag();
235
239 int addSmartgroup();
240
244 void removeGroup();
245
249 void tagSymbolsAction();
250
255
259 Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
260
264 void filterSymbols( const QString &filter );
265
267 void symbolSelected( const QModelIndex & );
268
270 void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
271
273 void grouptreeContextMenu( QPoint );
274
276 void listitemsContextMenu( QPoint );
277
278 protected slots:
279
287 bool addColorRamp( const QString &type = QString() );
288
294 void tagSelectedSymbols( bool newTag = false );
297
298 protected:
299
305 Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
306
308 void populateGroups();
309
313 Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
314
320 Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
321
327 Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
328
329 int currentItemType();
330 QString currentItemName();
331
333 bool addSymbol( int symbolType = -1 );
334
335 bool editSymbol();
336 bool editColorRamp();
337
341 Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
342
346 Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
347
349 void enableSymbolInputs( bool );
351 void enableGroupInputs( bool );
353 void enableItemsForGroupingMode( bool );
354
356 void setBold( QStandardItem * );
357
358 private slots:
359
360 void tabItemType_currentChanged( int );
361
362 void copyItemsToDefault();
363
364 void copyItem();
365
366 void pasteItem();
367
368 void setThumbnailSize( int );
369
370 void currentStyleAboutToBeDestroyed();
371
372 private:
373 void init();
374
375 void setCurrentStyle( QgsStyle *style );
376 int selectedItemType();
377
381 bool allTypesSelected() const;
382
383 bool isReadOnly() const;
384
385 struct ItemDetails
386 {
387 QgsStyle::StyleEntity entityType;
389 QString name;
390 };
391
392 enum GroupModelRoles
393 {
394 Name = Qt::UserRole + 1,
395 TagName
396 };
397
398 QList<ItemDetails> selectedItems();
399
403 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 );
404
405 QgsMessageBar *mMessageBar = nullptr;
406
407 QgsStyle *mStyle = nullptr;
408
409 QgsCheckableStyleModel *mModel = nullptr;
410
411 QgsProjectStyleDatabaseModel *mProjectStyleModel = nullptr;
412
413 QString mStyleFilename;
414
415 bool mModified = false;
416
418 bool mGroupingMode = false;
419
421 QStringList mTagList;
422
423 QMenu *mShareMenu = nullptr;
424
426 QMenu *mGroupMenu = nullptr;
427
429 QMenu *mGroupListMenu = nullptr;
430
432 QMenu *mGroupTreeContextMenu = nullptr;
433
435 QMenu *mMenuBtnAddItemColorRamp = nullptr;
436
438 QMenu *mMenuBtnAddItemAll = nullptr;
439
441 QMenu *mMenuBtnAddItemLabelSettings = nullptr;
442
444 QMenu *mMenuBtnAddItemLegendPatchShape = nullptr;
445
447 QMenu *mMenuBtnAddItemSymbol3D = nullptr;
448
449 QAction *mActionCopyToDefault = nullptr;
450
451 QAction *mActionCopyItem = nullptr;
452 QAction *mActionPasteItem = nullptr;
453 QAction *mExportAction = nullptr;
454 QAction *mImportAction = nullptr;
455
456 int mBlockGroupUpdates = 0;
457 int mBlockStyleDatabaseChanges = 0;
458
459 bool mReadOnly = false;
460 bool mFavoritesGroupVisible = true;
461 bool mSmartGroupVisible = true;
462 QString mBaseName;
463
464 static QString sPreviousTag;
465
466 bool addTextFormat();
467 bool editTextFormat();
468
469 bool addLabelSettings( Qgis::GeometryType type );
470 bool editLabelSettings();
471
472 bool addLegendPatchShape( Qgis::SymbolType type );
473 bool editLegendPatchShape();
474
475 bool addSymbol3D( const QString &type );
476 bool editSymbol3D();
477
478 void addStyleDatabase( bool createNew );
479
481};
482
483#endif
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:358
SymbolType
Symbol types.
Definition qgis.h:610
@ Hybrid
Hybrid symbol.
Definition qgis.h:614
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:88
StyleEntity
Enum for Entities involved in a style.
Definition qgsstyle.h:204
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