27 #include <QStandardItemModel>
28 #include <QStandardItem>
30 #include <QToolButton>
59 if ( role == Qt::DisplayRole || role == Qt::EditRole )
63 if ( role == Qt::CheckStateRole )
72 if ( role == Qt::CheckStateRole )
95 , mPreviewPicture( 0 )
114 mEffectsList->setModel(
mModel );
131 mEffectsList->setCurrentIndex( newIndex );
159 int count = stack->
count();
160 for (
int i = count - 1; i >= 0; i-- )
177 QModelIndex currentIdx = mEffectsList->currentIndex();
185 int currentRow = item ? item->
row() : 0;
187 mUpButton->setEnabled( currentRow > 0 );
188 mDownButton->setEnabled( currentRow < rowCount - 1 );
189 mRemoveButton->setEnabled( rowCount > 1 );
195 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
196 previewImage.
fill( Qt::transparent );
197 painter.
begin( &previewImage );
204 previewPicPainter.
begin( &previewPic );
205 previewPicPainter.
setPen( Qt::red );
208 previewPicPainter.
end();
249 int index = stackedWidget->addWidget( widget );
250 stackedWidget->setCurrentIndex( index );
276 int row = item->
row();
279 int layerIdx = root->
rowCount() - row - 1;
284 int newSelection = qMin( row, root->
rowCount() - 1 );
286 mEffectsList->setCurrentIndex( newIdx );
310 int row = item->
row();
314 int layerIdx = root->
rowCount() - row - 1;
323 mEffectsList->setCurrentIndex( newIdx );
335 int effectIdx = root->
rowCount() - item->
row() - 1;
350 , mPropertiesWidget( 0 )
378 , mEnabledCheckBox( 0 )
380 , mPreviewPicture( 0 )
387 mEnabledCheckBox =
new QCheckBox(
this );
388 mEnabledCheckBox->
setText(
tr(
"Draw effects" ) );
399 connect( mButton, SIGNAL( clicked() ),
this, SLOT( showDialog() ) );
400 connect( mEnabledCheckBox, SIGNAL( toggled(
bool ) ),
this, SLOT( enableToggled(
bool ) ) );
407 delete mPreviewPicture;
437 delete mPreviewPicture;
438 mPreviewPicture =
new QPicture( picture );
441 void QgsEffectStackCompactWidget::showDialog()
448 if ( mPreviewPicture )
450 dialog.setPreviewPicture( *mPreviewPicture );
452 if ( dialog.exec() == QDialog::Accepted )
461 void QgsEffectStackCompactWidget::enableToggled(
bool checked )
void setContentsMargins(int left, int top, int right, int bottom)
void setEnabled(const bool enabled)
Sets whether the effect is enabled.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
void setRenderHint(RenderHint hint, bool on)
QStandardItem * invisibleRootItem() const
QList< QStandardItem * > takeRow(int row)
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
A dialog for modifying the properties of a QgsEffectStack, including adding and reordering effects wi...
bool enabled() const
Returns whether the effect is enabled.
Base class for visual effects which can be applied to QPicture drawings.
EffectItem(QgsPaintEffect *effect, QgsEffectStackPropertiesWidget *propertiesWidget)
A generic dialog with layout and button box.
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
QgsEffectStackPropertiesDialog(QgsEffectStack *stack, QWidget *parent=0, const Qt::WindowFlags &f=0)
QgsEffectStackPropertiesDialog constructor.
QgsEffectStackPropertiesWidget * mWidget
QString tr(const char *sourceText, const char *disambiguation, int n)
int type() const override
virtual void setData(const QVariant &value, int role)
static QgsRenderContext createRenderContext(QPainter *p)
Creates a render context for a pixel based device.
int count() const
Returns count of effects contained by the stack.
void setPreviewPicture(const QPicture &picture)
Sets the picture to use for effect previews for the dialog.
QModelIndex indexFromItem(const QStandardItem *item) const
void fill(uint pixelValue)
static QgsPaintEffectRegistry * instance()
virtual QString type() const =0
Returns the effect type.
void setPen(const QColor &color)
void drawEllipse(const QRectF &rectangle)
void appendRow(const QList< QStandardItem * > &items)
void insertRows(int row, const QList< QStandardItem * > &items)
void setBrush(const QBrush &brush)
virtual QgsPaintEffect * clone() const override
Duplicates an effect by creating a deep copy of the effect.
A paint effect which consists of a stack of other chained paint effects.
bool changeEffect(const int index, QgsPaintEffect *effect)
Replaces the effect at a specified position within the stack.
bool insertEffect(const int index, QgsPaintEffect *effect)
Inserts an effect at a specified index within the stack.
~QgsEffectStackPropertiesDialog()
QgsPaintEffectAbstractMetadata * effectMetadata(const QString &name) const
Returns the metadata for a specific effect.
QStandardItem * child(int row, int column) const
QgsEffectStack * stack()
Returns effect stack attached to the dialog.
QgsPaintEffect * effect()
Contains information about the context of a rendering operation.
const QAbstractItemModel * model() const
QStandardItem * itemFromIndex(const QModelIndex &index) const
QVBoxLayout * layout()
Returns the central layout. Widgets added to it must have this dialog as parent.
void translate(const QPointF &offset)
QModelIndex index() const
void setText(const QString &text)
QgsEffectStackPropertiesWidget * mPropertiesWidget
QVariant data(int role) const override
void setEffect(QgsPaintEffect *effect)
void setData(const QVariant &value, int role) override
virtual void render(QPicture &picture, QgsRenderContext &context)
Renders a picture using the effect.
A paint effect which draws the source picture with minor or no alterations.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool begin(QPaintDevice *device)
QgsPaintEffect * effect(int index) const
Returns a pointer to the effect at a specified index within the stack.
void setCheckable(bool checkable)
virtual QVariant data(int role) const
void insertRow(int row, const QList< QStandardItem * > &items)
void setEditable(bool editable)
void setSpacing(int spacing)
QgsPaintEffect * takeEffect(const int index)
Removes an effect from the stack and returns a pointer to it.