QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 "qgshelp.h"
26 #include "qgsstylemodel.h"
27 #include "qgis_gui.h"
28 
29 class QgsStyle;
31 class QgsMessageBar;
32 
33 #ifndef SIP_RUN
34 class QgsCheckableStyleModel: public QgsStyleProxyModel
36 {
37  Q_OBJECT
38  public:
39 
40  explicit QgsCheckableStyleModel( QgsStyleModel *sourceModel, QObject *parent = nullptr, bool readOnly = false );
41  explicit QgsCheckableStyleModel( QgsStyle *style, QObject *parent = nullptr, bool readOnly = false );
42 
43  void setCheckable( bool checkable );
44  void setCheckTag( const QString &tag );
45 
46  Qt::ItemFlags flags( const QModelIndex &index ) const override;
47  QVariant data( const QModelIndex &index, int role ) const override;
48  bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
49 
50  private:
51 
52  QgsStyle *mStyle = nullptr;
53  bool mCheckable = false;
54  QString mCheckTag;
55  bool mReadOnly = false;
56 
57 };
58 #endif
59 
67 class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleManagerDialogBase
68 {
69  Q_OBJECT
70 
71  public:
72 
80  QgsStyleManagerDialog( QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
81  bool readOnly = false );
82 
83  // TODO QGIS 4.0 -- rename "RampType" to "rampType".
84 
90  static QString addColorRampStatic( QWidget *parent, QgsStyle *style,
91  const QString &RampType = QString() );
92 
98  void setFavoritesGroupVisible( bool show );
99 
105  void setSmartGroupsVisible( bool show );
106 
116  void setBaseStyleName( const QString &name );
117 
118  public slots:
119 
120  // TODO QGIS 4.0 -- most of this should be private
121 
126  void activate();
127 
132  void addItem();
133 
137  void editItem();
138 
142  void removeItem();
143 
150  void exportItemsSVG();
151 
158  void exportItemsPNG();
159 
166  void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
167 
173  void exportItems();
174 
180  void importItems();
181 
185  void populateList();
186 
190  void onFinished();
191 
193  void onClose();
194 
196  void showHelp();
197 
201  Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
202 
206  void groupChanged( const QModelIndex & );
207 
211  void groupRenamed( QStandardItem *item );
212 
216  int addTag();
217 
221  int addSmartgroup();
222 
226  void removeGroup();
227 
231  void tagSymbolsAction();
232 
236  void editSmartgroupAction();
237 
241  Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
242 
246  void filterSymbols( const QString &filter );
247 
249  void symbolSelected( const QModelIndex & );
250 
252  void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
253 
255  void grouptreeContextMenu( QPoint );
256 
258  void listitemsContextMenu( QPoint );
259 
260  protected slots:
261 
269  bool addColorRamp( const QString &type = QString() );
270 
272  void addFavoriteSelectedSymbols();
274  void removeFavoriteSelectedSymbols();
276  void tagSelectedSymbols( bool newTag = false );
278  void detagSelectedSymbols();
279 
280  protected:
281 
287  Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
288 
290  void populateGroups();
291 
295  Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
296 
302  Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
303 
309  Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
310 
311  int currentItemType();
312  QString currentItemName();
313 
315  bool addSymbol( int symbolType = -1 );
316 
317  bool editSymbol();
318  bool editColorRamp();
319 
323  Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
324 
328  Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
329 
331  void enableSymbolInputs( bool );
333  void enableGroupInputs( bool );
335  void enableItemsForGroupingMode( bool );
336 
338  void setBold( QStandardItem * );
339 
340  private slots:
341 
342  void tabItemType_currentChanged( int );
343 
344  void copyItemsToDefault();
345 
346  void copyItem();
347 
348  void pasteItem();
349 
350  private:
351  int selectedItemType();
352 
356  bool allTypesSelected() const;
357 
358  struct ItemDetails
359  {
360  QgsStyle::StyleEntity entityType;
361  QgsSymbol::SymbolType symbolType;
362  QString name;
363  };
364 
365  QList< ItemDetails > selectedItems();
366 
370  static int copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
371  QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
372  bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );
373 
374  QgsMessageBar *mMessageBar = nullptr;
375 
376  QgsStyle *mStyle = nullptr;
377 
378  QgsCheckableStyleModel *mModel = nullptr;
379 
380  QString mStyleFilename;
381 
382  bool mModified = false;
383 
385  bool mGroupingMode = false;
386 
388  QStringList mTagList;
389 
391  QMenu *mGroupMenu = nullptr;
392 
394  QMenu *mGroupListMenu = nullptr;
395 
397  QMenu *mGroupTreeContextMenu = nullptr;
398 
400  QMenu *mMenuBtnAddItemColorRamp = nullptr;
401 
403  QMenu *mMenuBtnAddItemAll = nullptr;
404 
406  QMenu *mMenuBtnAddItemLabelSettings = nullptr;
407 
409  QMenu *mMenuBtnAddItemLegendPatchShape = nullptr;
410 
412  QMenu *mMenuBtnAddItemSymbol3D = nullptr;
413 
414  QAction *mActionCopyToDefault = nullptr;
415 
416  QAction *mActionCopyItem = nullptr;
417  QAction *mActionPasteItem = nullptr;
418 
419  int mBlockGroupUpdates = 0;
420 
421  bool mReadOnly = false;
422  bool mFavoritesGroupVisible = true;
423  bool mSmartGroupVisible = true;
424  QString mBaseName;
425 
426  bool addTextFormat();
427  bool editTextFormat();
428 
429  bool addLabelSettings( QgsWkbTypes::GeometryType type );
430  bool editLabelSettings();
431 
432  bool addLegendPatchShape( QgsSymbol::SymbolType type );
433  bool editLegendPatchShape();
434 
435  bool addSymbol3D( const QString &type );
436  bool editSymbol3D();
437 
439 };
440 
441 #endif
QgsStyleModel
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
Definition: qgsstylemodel.h:108
QgsStyleManagerDialog
A dialog allowing users to customize and populate a QgsStyle.
Definition: qgsstylemanagerdialog.h:68
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsMessageBar
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
qgsstylemodel.h
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
QgsStyle
Definition: qgsstyle.h:160
QgsSymbol::SymbolType
SymbolType
Type of the symbol.
Definition: qgssymbol.h:86
QgsStyleProxyModel
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
Definition: qgsstylemodel.h:215
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgshelp.h
QgsStyleExportImportDialog
Definition: qgsstyleexportimportdialog.h:41
QgsTemporaryCursorOverride
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:222
QgsStyle::StyleEntity
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:179