QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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:
304 Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
305
307 void populateGroups();
308
312 Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
313
319 Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
320
326 Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
327
328 int currentItemType();
329 QString currentItemName();
330
332 bool addSymbol( int symbolType = -1 );
333
334 bool editSymbol();
335 bool editColorRamp();
336
340 Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
341
345 Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
346
348 void enableSymbolInputs( bool );
350 void enableGroupInputs( bool );
352 void enableItemsForGroupingMode( bool );
353
355 void setBold( QStandardItem * );
356
357 private slots:
358
359 void tabItemType_currentChanged( int );
360
361 void copyItemsToDefault();
362
363 void copyItem();
364
365 void pasteItem();
366
367 void setThumbnailSize( int );
368
369 void currentStyleAboutToBeDestroyed();
370
371 private:
372 void init();
373
374 void setCurrentStyle( QgsStyle *style );
375 int selectedItemType();
376
380 bool allTypesSelected() const;
381
382 bool isReadOnly() const;
383
384 struct ItemDetails
385 {
386 QgsStyle::StyleEntity entityType;
388 QString name;
389 };
390
391 enum GroupModelRoles
392 {
393 Name = Qt::UserRole + 1,
394 TagName
395 };
396
397 QList<ItemDetails> selectedItems();
398
402 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 );
403
404 QgsMessageBar *mMessageBar = nullptr;
405
406 QgsStyle *mStyle = nullptr;
407
408 QgsCheckableStyleModel *mModel = nullptr;
409
410 QgsProjectStyleDatabaseModel *mProjectStyleModel = nullptr;
411
412 QString mStyleFilename;
413
414 bool mModified = false;
415
417 bool mGroupingMode = false;
418
420 QStringList mTagList;
421
422 QMenu *mShareMenu = nullptr;
423
425 QMenu *mGroupMenu = nullptr;
426
428 QMenu *mGroupListMenu = nullptr;
429
431 QMenu *mGroupTreeContextMenu = nullptr;
432
434 QMenu *mMenuBtnAddItemColorRamp = nullptr;
435
437 QMenu *mMenuBtnAddItemAll = nullptr;
438
440 QMenu *mMenuBtnAddItemLabelSettings = nullptr;
441
443 QMenu *mMenuBtnAddItemLegendPatchShape = nullptr;
444
446 QMenu *mMenuBtnAddItemSymbol3D = nullptr;
447
448 QAction *mActionCopyToDefault = nullptr;
449
450 QAction *mActionCopyItem = nullptr;
451 QAction *mActionPasteItem = nullptr;
452 QAction *mExportAction = nullptr;
453 QAction *mImportAction = nullptr;
454
455 int mBlockGroupUpdates = 0;
456 int mBlockStyleDatabaseChanges = 0;
457
458 bool mReadOnly = false;
459 bool mFavoritesGroupVisible = true;
460 bool mSmartGroupVisible = true;
461 QString mBaseName;
462
463 static QString sPreviousTag;
464
465 bool addTextFormat();
466 bool editTextFormat();
467
468 bool addLabelSettings( Qgis::GeometryType type );
469 bool editLabelSettings();
470
471 bool addLegendPatchShape( Qgis::SymbolType type );
472 bool editLegendPatchShape();
473
474 bool addSymbol3D( const QString &type );
475 bool editSymbol3D();
476
477 void addStyleDatabase( bool createNew );
478
480};
481
482#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