17 #ifndef QGSSVGSELECTORWIDGET_H
18 #define QGSSVGSELECTORWIDGET_H
20 #include "ui_widget_svgselector.h"
26 #include <QAbstractListModel>
28 #include <QDialogButtonBox>
30 #include <QStandardItemModel>
33 #include <QElapsedTimer>
34 #include <QStyledItemDelegate>
57 class GUI_EXPORT QgsSvgParametersModel :
public QAbstractTableModel
62 enum class Column : int
68 QgsSvgParametersModel( QObject *parent =
nullptr );
71 void setParameters(
const QMap<QString, QgsProperty> ¶meters );
73 QMap<QString, QgsProperty> parameters()
const;
76 void removeParameters(
const QModelIndexList &indexList );
88 int rowCount(
const QModelIndex &parent )
const override;
89 int columnCount(
const QModelIndex &parent )
const override;
90 QVariant data(
const QModelIndex &index,
int role )
const override;
91 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
92 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
93 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
101 void parametersChanged(
const QMap<QString, QgsProperty> ¶meters );
106 Parameter(
const QString &name,
const QgsProperty &property )
107 : name( name ), property( property ) {}
113 QList<Parameter> mParameters;
124 class GUI_EXPORT QgsSvgParameterValueDelegate :
public QStyledItemDelegate
129 QgsSvgParameterValueDelegate( QObject *parent =
nullptr )
130 : QStyledItemDelegate( parent )
133 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
134 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
135 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
136 void updateEditorGeometry( QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
147 class GUI_EXPORT QgsSvgSelectorLoader :
public QThread
157 QgsSvgSelectorLoader( QObject *parent =
nullptr );
159 ~QgsSvgSelectorLoader()
override;
178 void setPath(
const QString &path )
190 void foundSvgs( QStringList svgs );
195 bool mCanceled =
false;
196 QStringList mQueuedSvgs;
198 QElapsedTimer mTimer;
199 int mTimerThreshold = 0;
200 QSet< QString > mTraversedPaths;
202 void loadPath(
const QString &path );
203 void loadImages(
const QString &path );
213 class GUI_EXPORT QgsSvgGroupLoader :
public QThread
223 QgsSvgGroupLoader( QObject *parent =
nullptr );
225 ~QgsSvgGroupLoader()
override;
243 void setParentPaths(
const QStringList &parentPaths )
245 mParentPaths = parentPaths;
255 void foundPath(
const QString &parentPath,
const QString &path );
259 QStringList mParentPaths;
260 bool mCanceled =
false;
261 QSet< QString > mTraversedPaths;
263 void loadGroup(
const QString &parentPath );
299 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
300 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
306 QPixmap createPreview(
const QString &entry )
const;
307 QgsSvgSelectorLoader *mSvgLoader =
nullptr;
317 void addSvgs(
const QStringList &svgs );
338 QgsSvgGroupLoader *mLoader =
nullptr;
339 QHash< QString, QStandardItem * > mPathItemHash;
343 void addPath(
const QString &parentPath,
const QString &path );
365 QString currentSvgPath()
const;
377 void setAllowParameters(
bool allow );
387 void setSvgPath(
const QString &svgPath );
393 void setSvgParameters(
const QMap<QString, QgsProperty> ¶meters );
408 void populateIcons(
const QModelIndex &idx );
409 void svgSelectionChanged(
const QModelIndex &idx );
410 void updateCurrentSvgPath(
const QString &svgPath );
411 void svgSourceChanged(
const QString &text );
415 QString mCurrentSvgPath;
416 bool mAllowParameters =
false;
417 QgsSvgParametersModel *mParametersModel =
nullptr;
433 Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags,
434 QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close | QDialogButtonBox::Ok,
435 Qt::Orientation orientation = Qt::Horizontal );
441 QVBoxLayout *mLayout =
nullptr;
442 QDialogButtonBox *mButtonBox =
nullptr;
Abstract interface for generating an expression context.
A store for object properties.
QgsSvgSelectorWidget * svgSelector()
Returns pointer to the embedded SVG selector widget.
A model for displaying SVG search paths.
A model for displaying SVG files with a preview icon.
A line edit widget with toolbutton for setting an SVG image path.
Represents a vector layer which manages a vector based data sets.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.