QGIS API Documentation  3.6.0-Noosa (5873452)
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 
32 #ifndef SIP_RUN
33 class QgsCheckableStyleModel: public QgsStyleProxyModel
35 {
36  Q_OBJECT
37  public:
38 
39  explicit QgsCheckableStyleModel( QgsStyle *style, QObject *parent = nullptr, bool readOnly = false );
40 
41  void setCheckable( bool checkable );
42  void setCheckTag( const QString &tag );
43 
44  Qt::ItemFlags flags( const QModelIndex &index ) const override;
45  QVariant data( const QModelIndex &index, int role ) const override;
46  bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
47 
48  private:
49 
50  QgsStyle *mStyle = nullptr;
51  bool mCheckable = false;
52  QString mCheckTag;
53  bool mReadOnly = false;
54 
55 };
56 #endif
57 
65 class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleManagerDialogBase
66 {
67  Q_OBJECT
68 
69  public:
70 
78  QgsStyleManagerDialog( QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
79  bool readOnly = false );
80 
84  static QString addColorRampStatic( QWidget *parent, QgsStyle *style,
85  QString RampType = QString() );
86 
92  void setFavoritesGroupVisible( bool show );
93 
99  void setSmartGroupsVisible( bool show );
100 
110  void setBaseStyleName( const QString &name );
111 
112  public slots:
113 
114  // TODO QGIS 4.0 -- most of this should be private
115 
120  void activate();
121 
126  void addItem();
127 
131  void editItem();
132 
136  void removeItem();
137 
144  void exportItemsSVG();
145 
152  void exportItemsPNG();
153 
160  void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
161 
167  void exportItems();
168 
174  void importItems();
175 
179  void populateList();
180 
184  void onFinished();
185 
187  void onClose();
188 
190  void showHelp();
191 
195  Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
196 
200  void groupChanged( const QModelIndex & );
201 
205  void groupRenamed( QStandardItem *item );
206 
210  int addTag();
211 
215  int addSmartgroup();
216 
220  void removeGroup();
221 
225  void tagSymbolsAction();
226 
230  void editSmartgroupAction();
231 
235  Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
236 
240  void filterSymbols( const QString &filter );
241 
243  void symbolSelected( const QModelIndex & );
244 
246  void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
247 
249  void grouptreeContextMenu( QPoint );
250 
252  void listitemsContextMenu( QPoint );
253 
254  protected slots:
255  bool addColorRamp( QAction *action );
257  void addFavoriteSelectedSymbols();
259  void removeFavoriteSelectedSymbols();
261  void tagSelectedSymbols( bool newTag = false );
263  void detagSelectedSymbols();
264 
265  protected:
266 
272  Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
273 
275  void populateGroups();
276 
280  Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
281 
287  Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
288 
294  Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
295 
296  int currentItemType();
297  QString currentItemName();
298 
300  bool addSymbol( int symbolType = -1 );
302  bool addColorRamp();
303 
304  bool editSymbol();
305  bool editColorRamp();
306 
310  Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
311 
315  Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
316 
318  void enableSymbolInputs( bool );
320  void enableGroupInputs( bool );
322  void enableItemsForGroupingMode( bool );
323 
325  void setBold( QStandardItem * );
326 
327  private slots:
328 
329  void tabItemType_currentChanged( int );
330 
331  void copyItemsToDefault();
332 
333  private:
334  int selectedItemType();
335 
339  bool allTypesSelected() const;
340 
341  struct ItemDetails
342  {
343  QgsStyle::StyleEntity entityType;
344  QgsSymbol::SymbolType symbolType;
345  QString name;
346  };
347 
348  QList< ItemDetails > selectedItems();
349 
353  static int copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
354  QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
355  bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );
356 
357 
358  QgsStyle *mStyle = nullptr;
359 
360  QgsCheckableStyleModel *mModel = nullptr;
361 
362  QString mStyleFilename;
363 
364  bool mModified = false;
365 
367  bool mGroupingMode = false;
368 
370  QStringList mTagList;
371 
373  QMenu *mGroupMenu = nullptr;
374 
376  QMenu *mGroupListMenu = nullptr;
377 
379  QMenu *mGroupTreeContextMenu = nullptr;
380 
382  QMenu *mMenuBtnAddItemColorRamp = nullptr;
383 
385  QMenu *mMenuBtnAddItemAll = nullptr;
386 
387  QAction *mActionCopyToDefault = nullptr;
388 
389  int mBlockGroupUpdates = 0;
390 
391  bool mReadOnly = false;
392  bool mFavoritesGroupVisible = true;
393  bool mSmartGroupVisible = true;
394  QString mBaseName;
395 
397 };
398 
399 #endif
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:186
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
A dialog allowing users to customize and populate a QgsStyle.
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:95
SymbolType
Type of the symbol.
Definition: qgssymbol.h:83
#define SIP_DEPRECATED
Definition: qgis_sip.h:99
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...