mirror of
https://github.com/fralx/LimeReport.git
synced 2025-01-11 17:18:10 +03:00
resourcePath property has been added to ImageItem
This commit is contained in:
parent
eac1a029d9
commit
229e8f529d
@ -56,7 +56,9 @@ BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *par
|
||||
|
||||
void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||
{
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty() && m_picture.isNull()){
|
||||
|
||||
if (m_picture.isNull()){
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty()){
|
||||
IDataSource* ds = dataManager->dataSource(m_datasource);
|
||||
if (ds) {
|
||||
QVariant data = ds->data(m_field);
|
||||
@ -67,6 +69,9 @@ void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass,
|
||||
m_picture.loadFromData(data.toByteArray());
|
||||
}
|
||||
}
|
||||
} else if (!m_resourcePath.isEmpty()){
|
||||
m_picture = QImage(m_resourcePath);
|
||||
}
|
||||
}
|
||||
if (m_autoSize){
|
||||
setWidth(m_picture.width());
|
||||
@ -80,6 +85,11 @@ bool ImageItem::isNeedUpdateSize(RenderPass) const
|
||||
return m_picture.isNull() || m_autoSize;
|
||||
}
|
||||
|
||||
QString ImageItem::resourcePath() const
|
||||
{
|
||||
return m_resourcePath;
|
||||
}
|
||||
|
||||
qreal ImageItem::minHeight() const{
|
||||
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 keepAspectRatio READ keepAspectRatio WRITE setKeepAspectRatio)
|
||||
Q_PROPERTY(bool center READ center WRITE setCenter)
|
||||
Q_PROPERTY(QString resourcePath READ resourcePath WRITE setResourcePath)
|
||||
public:
|
||||
ImageItem(QObject *owner, QGraphicsItem *parent);
|
||||
virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void setImage(QImage value);
|
||||
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;
|
||||
void setDatasource(const QString &datasource);
|
||||
QString field() const;
|
||||
@ -73,7 +75,7 @@ protected:
|
||||
bool drawDesignBorders() const {return m_picture.isNull();}
|
||||
private:
|
||||
QImage m_picture;
|
||||
QString m_content;
|
||||
QString m_resourcePath;
|
||||
QString m_datasource;
|
||||
QString m_field;
|
||||
bool m_autoSize;
|
||||
|
Loading…
Reference in New Issue
Block a user