void PropertyBrowser::applyImageLayerValue(PropertyId id, const QVariant &val) { ImageLayer *imageLayer = static_cast<ImageLayer*>(mObject); QUndoStack *undoStack = mMapDocument->undoStack(); switch (id) { case ImageSourceProperty: { const QString imageSource = val.toString(); const QColor &color = imageLayer->transparentColor(); undoStack->push(new ChangeImageLayerProperties(mMapDocument, imageLayer, color, imageSource)); break; } case ColorProperty: { QColor color = val.value<QColor>(); if (color == Qt::gray) color = QColor(); const QString &imageSource = imageLayer->imageSource(); undoStack->push(new ChangeImageLayerProperties(mMapDocument, imageLayer, color, imageSource)); break; } default: break; } }
QVariant MapToVariantConverter::toVariant(const ImageLayer &imageLayer) const { QVariantMap imageLayerVariant; imageLayerVariant[QLatin1String("type")] = QLatin1String("imagelayer"); addLayerAttributes(imageLayerVariant, imageLayer); const QString rel = toFileReference(imageLayer.imageSource(), mMapDir); imageLayerVariant[QLatin1String("image")] = rel; const QColor transColor = imageLayer.transparentColor(); if (transColor.isValid()) imageLayerVariant[QLatin1String("transparentcolor")] = transColor.name(); return imageLayerVariant; }