mirror of
https://github.com/fralx/LimeReport.git
synced 2025-01-25 23:51:03 +03:00
resourcePath property has been added to ImageItem
This commit is contained in:
parent
eac1a029d9
commit
229e8f529d
@ -56,16 +56,21 @@ BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *par
|
|||||||
|
|
||||||
void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||||
{
|
{
|
||||||
if (!m_datasource.isEmpty() && !m_field.isEmpty() && m_picture.isNull()){
|
|
||||||
IDataSource* ds = dataManager->dataSource(m_datasource);
|
if (m_picture.isNull()){
|
||||||
if (ds) {
|
if (!m_datasource.isEmpty() && !m_field.isEmpty()){
|
||||||
QVariant data = ds->data(m_field);
|
IDataSource* ds = dataManager->dataSource(m_datasource);
|
||||||
if (data.isValid()){
|
if (ds) {
|
||||||
if (data.type()==QVariant::Image){
|
QVariant data = ds->data(m_field);
|
||||||
m_picture = data.value<QImage>();
|
if (data.isValid()){
|
||||||
} else
|
if (data.type()==QVariant::Image){
|
||||||
m_picture.loadFromData(data.toByteArray());
|
m_picture = data.value<QImage>();
|
||||||
}
|
} else
|
||||||
|
m_picture.loadFromData(data.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (!m_resourcePath.isEmpty()){
|
||||||
|
m_picture = QImage(m_resourcePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_autoSize){
|
if (m_autoSize){
|
||||||
@ -80,6 +85,11 @@ bool ImageItem::isNeedUpdateSize(RenderPass) const
|
|||||||
return m_picture.isNull() || m_autoSize;
|
return m_picture.isNull() || m_autoSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ImageItem::resourcePath() const
|
||||||
|
{
|
||||||
|
return m_resourcePath;
|
||||||
|
}
|
||||||
|
|
||||||
qreal ImageItem::minHeight() const{
|
qreal ImageItem::minHeight() const{
|
||||||
if (!m_picture.isNull() && autoSize())
|
if (!m_picture.isNull() && autoSize())
|
||||||
{
|
{
|
||||||
|
@ -44,12 +44,14 @@ class ImageItem : public LimeReport::ItemDesignIntf
|
|||||||
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)
|
||||||
public:
|
public:
|
||||||
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);
|
||||||
QImage image(){return m_picture;}
|
QImage image(){return m_picture;}
|
||||||
void setContent(const QString &value){m_content=value;}
|
void setResourcePath(const QString &value){m_resourcePath=value;}
|
||||||
|
QString resourcePath() const;
|
||||||
QString datasource() const;
|
QString datasource() const;
|
||||||
void setDatasource(const QString &datasource);
|
void setDatasource(const QString &datasource);
|
||||||
QString field() const;
|
QString field() const;
|
||||||
@ -72,8 +74,8 @@ protected:
|
|||||||
bool isNeedUpdateSize(RenderPass) const;
|
bool isNeedUpdateSize(RenderPass) const;
|
||||||
bool drawDesignBorders() const {return m_picture.isNull();}
|
bool drawDesignBorders() const {return m_picture.isNull();}
|
||||||
private:
|
private:
|
||||||
QImage m_picture;
|
QImage m_picture;
|
||||||
QString m_content;
|
QString m_resourcePath;
|
||||||
QString m_datasource;
|
QString m_datasource;
|
||||||
QString m_field;
|
QString m_field;
|
||||||
bool m_autoSize;
|
bool m_autoSize;
|
||||||
|
Loading…
Reference in New Issue
Block a user