0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-25 09:04:39 +03:00

Merge branch 'master' into develop

This commit is contained in:
Arin Alexander 2017-10-01 21:08:36 +03:00
commit e8e3562be6
2 changed files with 40 additions and 3 deletions

View File

@ -47,7 +47,7 @@ bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instanc
namespace LimeReport{ namespace LimeReport{
ImageItem::ImageItem(QObject* owner,QGraphicsItem* parent) ImageItem::ImageItem(QObject* owner,QGraphicsItem* parent)
:ItemDesignIntf(xmlTag,owner,parent),m_autoSize(false), m_scale(true), m_keepAspectRatio(true), m_center(true){} :ItemDesignIntf(xmlTag,owner,parent),m_autoSize(false), m_scale(true), m_keepAspectRatio(true), m_center(true), m_format(Binary){}
BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent) BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
{ {
@ -65,8 +65,21 @@ void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass,
if (data.isValid()){ if (data.isValid()){
if (data.type()==QVariant::Image){ if (data.type()==QVariant::Image){
m_picture = data.value<QImage>(); m_picture = data.value<QImage>();
} else } else {
switch (m_format) {
default:
case Binary:
m_picture.loadFromData(data.toByteArray()); m_picture.loadFromData(data.toByteArray());
break;
case Hex:
m_picture.loadFromData(QByteArray::fromHex(data.toByteArray()));
break;
case Base64:
m_picture.loadFromData(QByteArray::fromBase64(data.toByteArray()));
break;
}
}
} }
} }
} else if (!m_resourcePath.isEmpty()){ } else if (!m_resourcePath.isEmpty()){
@ -267,6 +280,19 @@ void ImageItem::setImage(QImage value)
} }
} }
ImageItem::Format ImageItem::format() const
{
return m_format;
}
void ImageItem::setFormat(Format format)
{
if (m_format!=format){
Format oldValue = m_format;
m_format=format;
update();
notify("format",oldValue,format);
}
}
} }

View File

@ -36,16 +36,24 @@ namespace LimeReport{
class ImageItem : public LimeReport::ItemDesignIntf class ImageItem : public LimeReport::ItemDesignIntf
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(Format)
Q_PROPERTY(QImage image READ image WRITE setImage) Q_PROPERTY(QImage image READ image WRITE setImage)
Q_PROPERTY(int opacity READ opacity WRITE setOpacity) Q_PROPERTY(int opacity READ opacity WRITE setOpacity)
Q_PROPERTY(QString datasource READ datasource WRITE setDatasource) Q_PROPERTY(QString datasource READ datasource WRITE setDatasource)
Q_PROPERTY(QString field READ field WRITE setField) Q_PROPERTY(QString field READ field WRITE setField)
Q_PROPERTY(Format format READ format WRITE setFormat)
Q_PROPERTY(bool autoSize READ autoSize WRITE setAutoSize) Q_PROPERTY(bool autoSize READ autoSize WRITE setAutoSize)
Q_PROPERTY(bool scale READ scale WRITE setScale) Q_PROPERTY(bool scale READ scale WRITE setScale)
Q_PROPERTY(bool keepAspectRatio READ keepAspectRatio WRITE setKeepAspectRatio) Q_PROPERTY(bool keepAspectRatio READ keepAspectRatio WRITE setKeepAspectRatio)
Q_PROPERTY(bool center READ center WRITE setCenter) Q_PROPERTY(bool center READ center WRITE setCenter)
Q_PROPERTY(QString resourcePath READ resourcePath WRITE setResourcePath) Q_PROPERTY(QString resourcePath READ resourcePath WRITE setResourcePath)
public: public:
enum Format {
Binary = 0,
Hex = 1,
Base64 = 2
};
ImageItem(QObject *owner, QGraphicsItem *parent); ImageItem(QObject *owner, QGraphicsItem *parent);
virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void setImage(QImage value); void setImage(QImage value);
@ -65,6 +73,8 @@ public:
void setKeepAspectRatio(bool keepAspectRatio); void setKeepAspectRatio(bool keepAspectRatio);
bool center() const; bool center() const;
void setCenter(bool center); void setCenter(bool center);
Format format() const;
void setFormat(Format format);
qreal minHeight() const; qreal minHeight() const;
@ -82,6 +92,7 @@ private:
bool m_scale; bool m_scale;
bool m_keepAspectRatio; bool m_keepAspectRatio;
bool m_center; bool m_center;
Format m_format;
}; };
} }