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;
149class GUI_EXPORT QgsSvgSelectorLoader :
public QThread
159 QgsSvgSelectorLoader( QObject *parent =
nullptr );
161 ~QgsSvgSelectorLoader()
override;
180 void setPath(
const QString &path )
192 void foundSvgs( QStringList svgs );
197 bool mCanceled =
false;
198 QStringList mQueuedSvgs;
200 QElapsedTimer mTimer;
201 int mTimerThreshold = 0;
202 QSet< QString > mTraversedPaths;
204 void loadPath(
const QString &path );
205 void loadImages(
const QString &path );
214class GUI_EXPORT QgsSvgGroupLoader :
public QThread
224 QgsSvgGroupLoader( QObject *parent =
nullptr );
226 ~QgsSvgGroupLoader()
override;
244 void setParentPaths(
const QStringList &parentPaths )
246 mParentPaths = parentPaths;
256 void foundPath(
const QString &parentPath,
const QString &path );
260 QStringList mParentPaths;
261 bool mCanceled =
false;
262 QSet< QString > mTraversedPaths;
264 void loadGroup(
const QString &parentPath );
326 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
327 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
333 QPixmap createPreview(
const QString &entry )
const;
334 QgsSvgSelectorLoader *mSvgLoader =
nullptr;
344 void addSvgs(
const QStringList &svgs );
365 QgsSvgGroupLoader *mLoader =
nullptr;
366 QHash< QString, QStandardItem * > mPathItemHash;
370 void addPath(
const QString &parentPath,
const QString &path );
392 QString currentSvgPath()
const;
404 void setAllowParameters(
bool allow );
423 void setBrowserVisible(
bool visible );
439 void setSvgPath(
const QString &svgPath );
445 void setSvgParameters(
const QMap<QString, QgsProperty> ¶meters );
460 void populateIcons(
const QModelIndex &idx );
461 void svgSelectionChanged(
const QModelIndex &idx );
462 void updateCurrentSvgPath(
const QString &svgPath );
463 void svgSourceChanged(
const QString &text );
467 QString mCurrentSvgPath;
468 bool mAllowParameters =
false;
469 bool mBrowserVisible =
true;
470 QgsSvgParametersModel *mParametersModel =
nullptr;
486 Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags,
487 QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close | QDialogButtonBox::Ok,
488 Qt::Orientation orientation = Qt::Horizontal );
494 QVBoxLayout *mLayout =
nullptr;
495 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.