0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-27 01:48:09 +03:00
LimeReport/limereport/items/lrimageitem.h

89 lines
4.2 KiB
C
Raw Normal View History

2016-02-17 10:11:00 +03:00
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
****************************************************************************/
#ifndef LRIMAGEITEM_H
#define LRIMAGEITEM_H
#include "lritemdesignintf.h"
namespace LimeReport{
class ImageItem : public LimeReport::ItemDesignIntf
{
Q_OBJECT
Q_PROPERTY(QImage image READ image WRITE setImage)
Q_PROPERTY(int opacity READ opacity WRITE setOpacity)
Q_PROPERTY(QString datasource READ datasource WRITE setDatasource)
Q_PROPERTY(QString field READ field WRITE setField)
Q_PROPERTY(bool autoSize READ autoSize WRITE setAutoSize)
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)
2016-02-17 10:11:00 +03:00
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 setResourcePath(const QString &value){m_resourcePath=value;}
QString resourcePath() const;
2016-02-17 10:11:00 +03:00
QString datasource() const;
void setDatasource(const QString &datasource);
QString field() const;
void setField(const QString &field);
bool autoSize() const;
void setAutoSize(bool autoSize);
bool scale() const;
void setScale(bool scale);
bool keepAspectRatio() const;
void setKeepAspectRatio(bool keepAspectRatio);
bool center() const;
void setCenter(bool center);
qreal minHeight() const;
protected:
BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
2016-02-17 10:28:27 +03:00
void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
2016-02-17 10:11:00 +03:00
bool isNeedUpdateSize(RenderPass) const;
2016-02-17 10:19:50 +03:00
bool drawDesignBorders() const {return m_picture.isNull();}
2016-02-17 10:11:00 +03:00
private:
QImage m_picture;
QString m_resourcePath;
2016-02-17 10:11:00 +03:00
QString m_datasource;
QString m_field;
bool m_autoSize;
bool m_scale;
bool m_keepAspectRatio;
bool m_center;
};
}
#endif // LRIMAGEITEM_H