QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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( QgsStyle *style, QObject *parent = nullptr, bool readOnly = false );
41 
42  void setCheckable( bool checkable );
43  void setCheckTag( const QString &tag );
44 
45  Qt::ItemFlags flags( const QModelIndex &index ) const override;
46  QVariant data( const QModelIndex &index, int role ) const override;
47  bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
48 
49  private:
50 
51  QgsStyle *mStyle = nullptr;
52  bool mCheckable = false;
53  QString mCheckTag;
54  bool mReadOnly = false;
55 
56 };
57 #endif
58 
66 class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleManagerDialogBase
67 {
68  Q_OBJECT
69 
70  public:
71 
79  QgsStyleManagerDialog( QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
80  bool readOnly = false );
81 
85  static QString addColorRampStatic( QWidget *parent, QgsStyle *style,
86  QString RampType = QString() );
87 
93  void setFavoritesGroupVisible( bool show );
94 
100  void setSmartGroupsVisible( bool show );
101 
111  void setBaseStyleName( const QString &name );
112 
113  public slots:
114 
115  // TODO QGIS 4.0 -- most of this should be private
116 
121  void activate();
122 
127  void addItem();
128 
132  void editItem();
133 
137  void removeItem();
138 
145  void exportItemsSVG();
146 
153  void exportItemsPNG();
154 
161  void exportSelectedItemsImages( const QString &dir, const QString &format, QSize size );
162 
168  void exportItems();
169 
175  void importItems();
176 
180  void populateList();
181 
185  void onFinished();
186 
188  void onClose();
189 
191  void showHelp();
192 
196  Q_DECL_DEPRECATED void itemChanged( QStandardItem *item ) SIP_DEPRECATED;
197 
201  void groupChanged( const QModelIndex & );
202 
206  void groupRenamed( QStandardItem *item );
207 
211  int addTag();
212 
216  int addSmartgroup();
217 
221  void removeGroup();
222 
226  void tagSymbolsAction();
227 
231  void editSmartgroupAction();
232 
236  Q_DECL_DEPRECATED void regrouped( QStandardItem * ) SIP_DEPRECATED;
237 
241  void filterSymbols( const QString &filter );
242 
244  void symbolSelected( const QModelIndex & );
245 
247  void selectedSymbolsChanged( const QItemSelection &selected, const QItemSelection &deselected );
248 
250  void grouptreeContextMenu( QPoint );
251 
253  void listitemsContextMenu( QPoint );
254 
255  protected slots:
256  bool addColorRamp( QAction *action );
258  void addFavoriteSelectedSymbols();
260  void removeFavoriteSelectedSymbols();
262  void tagSelectedSymbols( bool newTag = false );
264  void detagSelectedSymbols();
265 
266  protected:
267 
273  Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED;
274 
276  void populateGroups();
277 
281  Q_DECL_DEPRECATED void setSymbolsChecked( const QStringList & ) SIP_DEPRECATED;
282 
288  Q_DECL_DEPRECATED void populateSymbols( const QStringList &symbolNames, bool checkable = false ) SIP_DEPRECATED;
289 
295  Q_DECL_DEPRECATED void populateColorRamps( const QStringList &colorRamps, bool checkable = false ) SIP_DEPRECATED;
296 
297  int currentItemType();
298  QString currentItemName();
299 
301  bool addSymbol( int symbolType = -1 );
303  bool addColorRamp();
304 
305  bool editSymbol();
306  bool editColorRamp();
307 
311  Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED;
312 
316  Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED;
317 
319  void enableSymbolInputs( bool );
321  void enableGroupInputs( bool );
323  void enableItemsForGroupingMode( bool );
324 
326  void setBold( QStandardItem * );
327 
328  private slots:
329 
330  void tabItemType_currentChanged( int );
331 
332  void copyItemsToDefault();
333 
334  private:
335  int selectedItemType();
336 
340  bool allTypesSelected() const;
341 
342  struct ItemDetails
343  {
344  QgsStyle::StyleEntity entityType;
345  QgsSymbol::SymbolType symbolType;
346  QString name;
347  };
348 
349  QList< ItemDetails > selectedItems();
350 
354  static int copyItems( const QList< ItemDetails > &items, QgsStyle *src, QgsStyle *dst,
355  QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
356  bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );
357 
358  QgsMessageBar *mMessageBar = nullptr;
359 
360  QgsStyle *mStyle = nullptr;
361 
362  QgsCheckableStyleModel *mModel = nullptr;
363 
364  QString mStyleFilename;
365 
366  bool mModified = false;
367 
369  bool mGroupingMode = false;
370 
372  QStringList mTagList;
373 
375  QMenu *mGroupMenu = nullptr;
376 
378  QMenu *mGroupListMenu = nullptr;
379 
381  QMenu *mGroupTreeContextMenu = nullptr;
382 
384  QMenu *mMenuBtnAddItemColorRamp = nullptr;
385 
387  QMenu *mMenuBtnAddItemAll = nullptr;
388 
389  QAction *mActionCopyToDefault = nullptr;
390 
391  int mBlockGroupUpdates = 0;
392 
393  bool mReadOnly = false;
394  bool mFavoritesGroupVisible = true;
395  bool mSmartGroupVisible = true;
396  QString mBaseName;
397 
399 };
400 
401 #endif
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:46
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: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 ...