QGIS API Documentation 4.3.0-Master (0cfde48c85b)
Loading...
Searching...
No Matches
qgsmaplayerstylemanagerwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaplayerstylemanagerwidget.h
3 ---------------------
4 begin : June 2016
5 copyright : (C) 2016 by Nathan Woodrow
6 email : woodrow dot nathan 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#ifndef QGSMAPLAYERSTYLEMANAGERWIDGET_H
16#define QGSMAPLAYERSTYLEMANAGERWIDGET_H
17
18#include "qgis_gui.h"
20
21#include <QAbstractListModel>
22#include <QListView>
23#include <QWidget>
24
25class QgsMapLayer;
26class QgsMapCanvas;
27
28class QStandardItem;
29
38class GUI_EXPORT QgsMapLayerStyleModel : public QAbstractListModel
39{
40 Q_OBJECT
41
42 public:
46 QgsMapLayerStyleModel( QgsMapLayerStyleManager *manager, QObject *parent SIP_TRANSFERTHIS = nullptr );
47
48 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
49 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
50 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
51 Qt::ItemFlags flags( const QModelIndex &index ) const override;
52
56 QModelIndex indexForName( const QString &name ) const;
57
58 private slots:
59
60 void styleAdded( const QString &name );
61 void styleRemoved( const QString &name );
62 void styleRenamed( const QString &oldname, const QString &newname );
63
64 private:
65 QPointer< QgsMapLayerStyleManager > mManager;
66 QStringList mStyleNames;
67};
68
74{
75 Q_OBJECT
76 public:
83 QgsMapLayerStyleManagerWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent = nullptr );
84
85 public slots:
86 void apply() override {}
87
88 private slots:
89 void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
90 void currentStyleChanged( const QString &name );
91 void addStyle();
92 void removeStyle();
93 void saveAsDefault();
94 void loadDefault();
95 void saveStyle();
96 void loadStyle();
97
98 private:
99 QgsMapLayerStyleModel *mModel = nullptr;
100 QListView *mStyleList = nullptr;
101};
102
103#endif // QGSMAPLAYERSTYLEMANAGERWIDGET_H
Map canvas is a class for displaying all GIS data types on a canvas.
QgsMapLayerConfigWidget(QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent=nullptr)
A panel widget that can be shown in the map style dock.
QgsMapLayerStyleManagerWidget(QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent=nullptr)
Style manager widget to manage the layers styles.
Management of styles for use with one map layer.
A model for display of styles from a QgsMapLayerStyleManager.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QModelIndex indexForName(const QString &name) const
Returns the model index corresponding to the specified style name.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
QgsMapLayerStyleModel(QgsMapLayerStyleManager *manager, QObject *parent=nullptr)
Constructor for QgsMapLayerStyleModel, showing styles from the specified manager.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Base class for all map layer types.
Definition qgsmaplayer.h:83
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52