QGIS API Documentation  3.23.0-Master (dd0cd13a00)
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
35 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
60 
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  void setThumbnailSize( int );
351 
352  private:
353  int selectedItemType();
354 
358  bool allTypesSelected() const;
359 
360  struct ItemDetails
361  {
362  QgsStyle::StyleEntity entityType;
363  Qgis::SymbolType symbolType;
364  QString name;
365  };
366 
367  enum GroupModelRoles
368  {
369  Name = Qt::UserRole + 1,
370  TagName
371  };
372 
373  QList< ItemDetails > selectedItems();
374 
378  static int copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
379  QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
380  bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );
381 
382  QgsMessageBar *mMessageBar = nullptr;
383 
384  QgsStyle *mStyle = nullptr;
385 
386  QgsCheckableStyleModel *mModel = nullptr;
387 
388  QString mStyleFilename;
389 
390  bool mModified = false;
391 
393  bool mGroupingMode = false;
394 
396  QStringList mTagList;
397 
399  QMenu *mGroupMenu = nullptr;
400 
402  QMenu *mGroupListMenu = nullptr;
403 
405  QMenu *mGroupTreeContextMenu = nullptr;
406 
408  QMenu *mMenuBtnAddItemColorRamp = nullptr;
409 
411  QMenu *mMenuBtnAddItemAll = nullptr;
412 
414  QMenu *mMenuBtnAddItemLabelSettings = nullptr;
415 
417  QMenu *mMenuBtnAddItemLegendPatchShape = nullptr;
418 
420  QMenu *mMenuBtnAddItemSymbol3D = nullptr;
421 
422  QAction *mActionCopyToDefault = nullptr;
423 
424  QAction *mActionCopyItem = nullptr;
425  QAction *mActionPasteItem = nullptr;
426 
427  int mBlockGroupUpdates = 0;
428 
429  bool mReadOnly = false;
430  bool mFavoritesGroupVisible = true;
431  bool mSmartGroupVisible = true;
432  QString mBaseName;
433 
434  static QString sPreviousTag;
435 
436  bool addTextFormat();
437  bool editTextFormat();
438 
439  bool addLabelSettings( QgsWkbTypes::GeometryType type );
440  bool editLabelSettings();
441 
442  bool addLegendPatchShape( Qgis::SymbolType type );
443  bool editLegendPatchShape();
444 
445  bool addSymbol3D( const QString &type );
446  bool editSymbol3D();
447 
449 };
450 
451 #endif
SymbolType
Symbol types.
Definition: qgis.h:183
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
A dialog allowing users to customize and populate a QgsStyle.
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:179
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:221
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
@ TagName
Tag name.
Definition: qgsstyle.h:100