0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-26 09:28:11 +03:00
LimeReport/limereport/items/lrimageitem.h
2016-03-21 02:12:30 +01:00

87 lines
4.1 KiB
C++

/***************************************************************************
* 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)
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;}
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);
void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
bool isNeedUpdateSize(RenderPass) const;
bool drawDesignBorders() const {return m_picture.isNull();}
private:
QImage m_picture;
QString m_content;
QString m_datasource;
QString m_field;
bool m_autoSize;
bool m_scale;
bool m_keepAspectRatio;
bool m_center;
};
}
#endif // LRIMAGEITEM_H