QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 
86  static QString addColorRampStatic( QWidget *parent, QgsStyle *style,
87  QString RampType = QString() );
88 
94  void setFavoritesGroupVisible( bool show );
95 
101  void setSmartGroupsVisible( bool show );
102 
112  void setBaseStyleName( const QString &name );
113 
114  public slots:
115 
116  // TODO QGIS 4.0 -- most of this should be private
117 
122  void activate();
123 
128  void addItem();
129 
133  void editItem();
134 
138  void removeItem();
139 
146  void exportItemsSVG();
147 
154  void exportItemsPNG();
155 
162  void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
163 
169  void exportItems();
170 
176  void importItems();
177 
181  void populateList();
182 
186  void onFinished();
187 
189  void onClose();
190 
192  void showHelp();
193 
197  Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
198 
202  void groupChanged( const QModelIndex & );
203 
207  void groupRenamed( QStandardItem *item );
208 
212  int addTag();
213 
217  int addSmartgroup();
218 
222  void removeGroup();
223 
227  void tagSymbolsAction();
228 
232  void editSmartgroupAction();
233 
237  Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
238 
242  void filterSymbols( const QString &filter );
243 
245  void symbolSelected( const QModelIndex & );
246 
248  void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
249 
251  void grouptreeContextMenu( QPoint );
252 
254  void listitemsContextMenu( QPoint );
255 
256  protected slots:
257  bool addColorRamp( QAction *action );
259  void addFavoriteSelectedSymbols();
261  void removeFavoriteSelectedSymbols();
263  void tagSelectedSymbols( bool newTag = false );
265  void detagSelectedSymbols();
266 
267  protected:
268 
274  Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
275 
277  void populateGroups();
278 
282  Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
283 
289  Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
290 
296  Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
297 
298  int currentItemType();
299  QString currentItemName();
300 
302  bool addSymbol( int symbolType = -1 );
304  bool addColorRamp();
305 
306  bool editSymbol();
307  bool editColorRamp();
308 
312  Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
313 
317  Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
318 
320  void enableSymbolInputs( bool );
322  void enableGroupInputs( bool );
324  void enableItemsForGroupingMode( bool );
325 
327  void setBold( QStandardItem * );
328 
329  private slots:
330 
331  void tabItemType_currentChanged( int );
332 
333  void copyItemsToDefault();
334 
335  void copyItem();
336 
337  void pasteItem();
338 
339  private:
340  int selectedItemType();
341 
345  bool allTypesSelected() const;
346 
347  struct ItemDetails
348  {
349  QgsStyle::StyleEntity entityType;
350  QgsSymbol::SymbolType symbolType;
351  QString name;
352  };
353 
354  QList< ItemDetails > selectedItems();
355 
359  static int copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
360  QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
361  bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );
362 
363  QgsMessageBar *mMessageBar = nullptr;
364 
365  QgsStyle *mStyle = nullptr;
366 
367  QgsCheckableStyleModel *mModel = nullptr;
368 
369  QString mStyleFilename;
370 
371  bool mModified = false;
372 
374  bool mGroupingMode = false;
375 
377  QStringList mTagList;
378 
380  QMenu *mGroupMenu = nullptr;
381 
383  QMenu *mGroupListMenu = nullptr;
384 
386  QMenu *mGroupTreeContextMenu = nullptr;
387 
389  QMenu *mMenuBtnAddItemColorRamp = nullptr;
390 
392  QMenu *mMenuBtnAddItemAll = nullptr;
393 
395  QMenu *mMenuBtnAddItemLabelSettings = nullptr;
396 
397  QAction *mActionCopyToDefault = nullptr;
398 
399  QAction *mActionCopyItem = nullptr;
400  QAction *mActionPasteItem = nullptr;
401 
402  int mBlockGroupUpdates = 0;
403 
404  bool mReadOnly = false;
405  bool mFavoritesGroupVisible = true;
406  bool mSmartGroupVisible = true;
407  QString mBaseName;
408 
409  bool addTextFormat();
410  bool editTextFormat();
411 
412  bool addLabelSettings( QgsWkbTypes::GeometryType type );
413  bool editLabelSettings();
414 
416 };
417 
418 #endif
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
Definition: qgsstylemodel.h:45
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:203
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
A dialog allowing users to customize and populate a QgsStyle.
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:45
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:177
SymbolType
Type of the symbol.
Definition: qgssymbol.h:83
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139