Commit 379467a3 authored by Boudewijn Rempt's avatar Boudewijn Rempt

we can dynamic_cast directly, no need for static_cast

parent 668902e5
......@@ -63,9 +63,7 @@ void KisBrushDelegate::paint(QPainter * painter, const QStyleOptionViewItem & op
if (! index.isValid())
return;
KisBrush * brush = static_cast<KisBrush*>(index.internalPointer());
if (!brush)
return;
KisBrush *brush = static_cast<KisBrush*>(index.internalPointer());
QRect itemRect = option.rect;
QImage thumbnail = brush->image();
......@@ -166,17 +164,14 @@ KisBrushChooser::~KisBrushChooser()
void KisBrushChooser::setBrush(KisBrushSP _brush)
{
KoResource *resource = static_cast<KoResource*>(_brush.data());
m_itemChooser->setCurrentResource( resource );
update( resource );
m_itemChooser->setCurrentResource(_brush.data());
update(_brush.data());
}
void KisBrushChooser::slotSetItemScale(qreal scaleValue)
{
KoResource * resource = static_cast<KoResource *>(m_itemChooser->currentResource());
if (resource) {
KisBrush *brush = static_cast<KisBrush *>(resource);
KisBrush *brush = dynamic_cast<KisBrush *>(m_itemChooser->currentResource());
if (brush) {
brush->setScale(scaleValue);
slotActivatedBrush(brush);
......@@ -185,10 +180,8 @@ void KisBrushChooser::slotSetItemScale(qreal scaleValue)
}
void KisBrushChooser::slotSetItemRotation(qreal rotationValue)
{
KoResource * resource = static_cast<KoResource *>(m_itemChooser->currentResource());
if (resource) {
KisBrush *brush = static_cast<KisBrush *>(resource);
KisBrush *brush = dynamic_cast<KisBrush *>(m_itemChooser->currentResource());
if (brush) {
brush->setAngle(rotationValue / 180.0 * M_PI);
slotActivatedBrush(brush);
......@@ -198,10 +191,8 @@ void KisBrushChooser::slotSetItemRotation(qreal rotationValue)
void KisBrushChooser::slotSetItemSpacing(qreal spacingValue)
{
KoResource * resource = static_cast<KoResource *>(m_itemChooser->currentResource());
if (resource) {
KisBrush *brush = static_cast<KisBrush *>(resource);
KisBrush *brush = dynamic_cast<KisBrush *>(m_itemChooser->currentResource());
if (brush) {
brush->setSpacing(spacingValue);
slotActivatedBrush(brush);
......@@ -211,42 +202,40 @@ void KisBrushChooser::slotSetItemSpacing(qreal spacingValue)
void KisBrushChooser::slotSetItemUseColorAsMask(bool useColorAsMask)
{
KoResource * resource = static_cast<KoResource *>(m_itemChooser->currentResource());
if (resource) {
KisGbrBrush* brush = dynamic_cast<KisGbrBrush*>(resource);
if (brush) {
brush->setUseColorAsMask(useColorAsMask);
slotActivatedBrush(brush);
KisGbrBrush *brush = dynamic_cast<KisGbrBrush *>(m_itemChooser->currentResource());
if (brush) {
brush->setUseColorAsMask(useColorAsMask);
slotActivatedBrush(brush);
emit sigBrushChanged();
}
emit sigBrushChanged();
}
}
void KisBrushChooser::update(KoResource * resource)
{
KisBrush* brush = static_cast<KisBrush*>(resource);
KisBrush* brush = dynamic_cast<KisBrush*>(resource);
QString text = QString("%1 (%2 x %3)")
.arg(i18n(brush->name().toUtf8().data()))
.arg(brush->width())
.arg(brush->height());
if (brush) {
QString text = QString("%1 (%2 x %3)")
.arg(i18n(brush->name().toUtf8().data()))
.arg(brush->width())
.arg(brush->height());
m_lbName->setText(text);
m_slSpacing->setValue(brush->spacing());
m_slRotation->setValue(brush->angle() * 180 / M_PI);
m_slScale->setValue(brush->scale());
m_lbName->setText(text);
m_slSpacing->setValue(brush->spacing());
m_slRotation->setValue(brush->angle() * 180 / M_PI);
m_slScale->setValue(brush->scale());
// useColorAsMask support is only in gimp brush so far
KisGbrBrush *gimpBrush = dynamic_cast<KisGbrBrush*>(resource);
if (gimpBrush) {
m_chkColorMask->setChecked(gimpBrush->useColorAsMask());
}
m_chkColorMask->setEnabled(brush->hasColor() && gimpBrush);
// useColorAsMask support is only in gimp brush so far
KisGbrBrush *gimpBrush = dynamic_cast<KisGbrBrush*>(resource);
if (gimpBrush) {
m_chkColorMask->setChecked(gimpBrush->useColorAsMask());
}
m_chkColorMask->setEnabled(brush->hasColor() && gimpBrush);
emit sigBrushChanged();
emit sigBrushChanged();
}
}
void KisBrushChooser::slotActivatedBrush(KoResource * resource)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment