17 #ifndef QGSSVGSELECTORWIDGET_H
18 #define QGSSVGSELECTORWIDGET_H
20 #include "ui_widget_svgselector.h"
26 #include <QSortFilterProxyModel>
27 #include <QAbstractListModel>
29 #include <QDialogButtonBox>
31 #include <QStandardItemModel>
34 #include <QElapsedTimer>
35 #include <QStyledItemDelegate>
60 class GUI_EXPORT QgsSvgParametersModel :
public QAbstractTableModel
65 enum class Column : int
71 QgsSvgParametersModel( QObject *parent =
nullptr );
74 void setParameters(
const QMap<QString, QgsProperty> ¶meters );
76 QMap<QString, QgsProperty> parameters()
const;
79 void removeParameters(
const QModelIndexList &indexList );
91 int rowCount(
const QModelIndex &parent )
const override;
92 int columnCount(
const QModelIndex &parent )
const override;
93 QVariant data(
const QModelIndex &index,
int role )
const override;
94 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
95 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
96 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
104 void parametersChanged(
const QMap<QString, QgsProperty> ¶meters );
109 Parameter(
const QString &name,
const QgsProperty &property )
110 : name( name ), property( property ) {}
116 QList<Parameter> mParameters;
127 class GUI_EXPORT QgsSvgParameterValueDelegate :
public QStyledItemDelegate
132 QgsSvgParameterValueDelegate( QObject *parent =
nullptr )
133 : QStyledItemDelegate( parent )
136 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
137 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
138 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
139 void updateEditorGeometry( QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
150 class GUI_EXPORT QgsSvgSelectorLoader :
public QThread
160 QgsSvgSelectorLoader( QObject *parent =
nullptr );
162 ~QgsSvgSelectorLoader()
override;
181 void setPath(
const QString &path )
193 void foundSvgs( QStringList svgs );
198 bool mCanceled =
false;
199 QStringList mQueuedSvgs;
201 QElapsedTimer mTimer;
202 int mTimerThreshold = 0;
203 QSet< QString > mTraversedPaths;
205 void loadPath(
const QString &path );
206 void loadImages(
const QString &path );
216 class GUI_EXPORT QgsSvgGroupLoader :
public QThread
226 QgsSvgGroupLoader( QObject *parent =
nullptr );
228 ~QgsSvgGroupLoader()
override;
246 void setParentPaths(
const QStringList &parentPaths )
248 mParentPaths = parentPaths;
258 void foundPath(
const QString &parentPath,
const QString &path );
262 QStringList mParentPaths;
263 bool mCanceled =
false;
264 QSet< QString > mTraversedPaths;
266 void loadGroup(
const QString &parentPath );
328 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
329 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
335 QPixmap createPreview(
const QString &entry )
const;
336 QgsSvgSelectorLoader *mSvgLoader =
nullptr;
346 void addSvgs(
const QStringList &svgs );
367 QgsSvgGroupLoader *mLoader =
nullptr;
368 QHash< QString, QStandardItem * > mPathItemHash;
372 void addPath(
const QString &parentPath,
const QString &path );
394 QString currentSvgPath()
const;
406 void setAllowParameters(
bool allow );
418 void setBrowserVisible(
bool visible );
434 void setSvgPath(
const QString &svgPath );
440 void setSvgParameters(
const QMap<QString, QgsProperty> ¶meters );
455 void populateIcons(
const QModelIndex &idx );
456 void svgSelectionChanged(
const QModelIndex &idx );
457 void updateCurrentSvgPath(
const QString &svgPath );
458 void svgSourceChanged(
const QString &text );
462 QString mCurrentSvgPath;
463 bool mAllowParameters =
false;
464 bool mBrowserVisible =
true;
465 QgsSvgParametersModel *mParametersModel =
nullptr;
481 Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags,
482 QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close | QDialogButtonBox::Ok,
483 Qt::Orientation orientation = Qt::Horizontal );
489 QVBoxLayout *mLayout =
nullptr;
490 QDialogButtonBox *mButtonBox =
nullptr;
Abstract interface for generating an expression context.
A line edit widget with toolbutton for setting a raster image path.
A store for object properties.
QgsSvgSelectorWidget * svgSelector()
Returns pointer to the embedded SVG selector widget.
A model for displaying SVG files with a preview icon which can be filtered by file name.
A model for displaying SVG search paths.
A model for displaying SVG files with a preview icon.
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.