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 <QItemDelegate>
60class 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;
127class GUI_EXPORT QgsSvgParameterValueDelegate :
public QItemDelegate
132 QgsSvgParameterValueDelegate( QObject *parent =
nullptr )
133 : QItemDelegate( 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;
148class GUI_EXPORT QgsSvgSelectorLoader :
public QThread
157 QgsSvgSelectorLoader( QObject *parent =
nullptr );
159 ~QgsSvgSelectorLoader()
override;
178 void setPath(
const QString &path )
190 void foundSvgs( QStringList svgs );
194 bool mCanceled =
false;
195 QStringList mQueuedSvgs;
197 QElapsedTimer mTimer;
198 int mTimerThreshold = 0;
199 QSet<QString> mTraversedPaths;
201 void loadPath(
const QString &path );
202 void loadImages(
const QString &path );
210class GUI_EXPORT QgsSvgGroupLoader :
public QThread
219 QgsSvgGroupLoader( QObject *parent =
nullptr );
221 ~QgsSvgGroupLoader()
override;
239 void setParentPaths(
const QStringList &parentPaths )
241 mParentPaths = parentPaths;
251 void foundPath(
const QString &parentPath,
const QString &path );
254 QStringList mParentPaths;
255 bool mCanceled =
false;
256 QSet<QString> mTraversedPaths;
258 void loadGroup(
const QString &parentPath );
317 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
318 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
324 QPixmap createPreview(
const QString &entry )
const;
325 QgsSvgSelectorLoader *mSvgLoader =
nullptr;
335 void addSvgs(
const QStringList &svgs );
337 friend class TestQgsSvgSelectorWidget;
357 QgsSvgGroupLoader *mLoader =
nullptr;
358 QHash<QString, QStandardItem *> mPathItemHash;
362 void addPath(
const QString &parentPath,
const QString &path );
385 QString currentSvgPath()
const;
397 void setAllowParameters(
bool allow );
416 void setBrowserVisible(
bool visible );
432 void setSvgPath(
const QString &svgPath );
438 void setSvgParameters(
const QMap<QString, QgsProperty> ¶meters );
457 void populateIcons(
const QModelIndex &idx );
458 void svgSelectionChanged(
const QModelIndex &idx );
459 void updateCurrentSvgPath(
const QString &svgPath );
460 void svgSourceChanged(
const QString &text );
464 QString mCurrentSvgPath;
465 bool mAllowParameters =
false;
466 bool mBrowserVisible =
true;
467 QgsSvgParametersModel *mParametersModel =
nullptr;
481 QgsSvgSelectorDialog( QWidget *parent
SIP_TRANSFERTHIS =
nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close | QDialogButtonBox::Ok, Qt::Orientation orientation = Qt::Horizontal );
487 QVBoxLayout *mLayout =
nullptr;
488 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.