mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 04:33:03 +03:00
backgroundBrushStyle property has been added
This commit is contained in:
parent
f72f1a743e
commit
7da0cfd7e2
@ -85,7 +85,7 @@ void ShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
pen.setStyle(m_penStyle);
|
pen.setStyle(m_penStyle);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
QBrush brush(m_shapeBrushColor,m_shapeBrushType);
|
QBrush brush(m_shapeBrushColor,m_shapeBrushType);
|
||||||
|
brush.setTransform(painter->worldTransform().inverted());
|
||||||
painter->setBrush(brush);
|
painter->setBrush(brush);
|
||||||
painter->setBackground(QBrush(Qt::NoBrush));
|
painter->setBackground(QBrush(Qt::NoBrush));
|
||||||
painter->setOpacity(qreal(m_opacity)/100);
|
painter->setOpacity(qreal(m_opacity)/100);
|
||||||
|
@ -68,6 +68,7 @@ class TextItem : public LimeReport::ContentItemDesignIntf, IPageInit {
|
|||||||
Q_PROPERTY(QString format READ format WRITE setFormat)
|
Q_PROPERTY(QString format READ format WRITE setFormat)
|
||||||
Q_PROPERTY(ValueType valueType READ valueType WRITE setValueType)
|
Q_PROPERTY(ValueType valueType READ valueType WRITE setValueType)
|
||||||
Q_PROPERTY(QString followTo READ followTo WRITE setFollowTo)
|
Q_PROPERTY(QString followTo READ followTo WRITE setFollowTo)
|
||||||
|
Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle)
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum AutoWidth{NoneAutoWidth,MaxWordLength,MaxStringLength};
|
enum AutoWidth{NoneAutoWidth,MaxWordLength,MaxStringLength};
|
||||||
|
@ -183,16 +183,20 @@ BandDesignIntf::~BandDesignIntf()
|
|||||||
delete m_bandNameLabel;
|
delete m_bandNameLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BandDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
if (backgroundColor()!=Qt::white) {
|
|
||||||
ppainter->fillRect(rect(),backgroundColor());
|
if ( !(backgroundColor() == Qt::white && backgroundBrushStyle() == SolidPattern) ) {
|
||||||
|
QBrush brush(backgroundColor(), static_cast<Qt::BrushStyle>(backgroundBrushStyle()));
|
||||||
|
brush.setTransform(painter->worldTransform().inverted());
|
||||||
|
painter->fillRect(rect(), brush);
|
||||||
}
|
}
|
||||||
if (itemMode()&DesignMode){
|
|
||||||
ppainter->save();
|
if (itemMode() & DesignMode){
|
||||||
|
painter->save();
|
||||||
QString bandText = objectName();
|
QString bandText = objectName();
|
||||||
if (parentBand()) bandText+=QLatin1String(" connected to ")+parentBand()->objectName();
|
if (parentBand()) bandText+=QLatin1String(" connected to ")+parentBand()->objectName();
|
||||||
QFont font("Arial",7*Const::fontFACTOR,-1,true);
|
QFont font("Arial", 7 * Const::fontFACTOR, -1, true);
|
||||||
QFontMetrics fontMetrics(font);
|
QFontMetrics fontMetrics(font);
|
||||||
|
|
||||||
QVector<QRectF> bandNameRects;
|
QVector<QRectF> bandNameRects;
|
||||||
@ -204,22 +208,22 @@ void BandDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
|
|||||||
//if (isSelected()) ppainter->setPen(QColor(167,244,167));
|
//if (isSelected()) ppainter->setPen(QColor(167,244,167));
|
||||||
// else ppainter->setPen(QColor(220,220,220));
|
// else ppainter->setPen(QColor(220,220,220));
|
||||||
|
|
||||||
ppainter->setFont(font);
|
painter->setFont(font);
|
||||||
for (int i=0;i<bandNameRects.count();i++){
|
for (int i=0;i<bandNameRects.count();i++){
|
||||||
QRectF labelRect = bandNameRects[i].adjusted(-2,-2,2,2);
|
QRectF labelRect = bandNameRects[i].adjusted(-2,-2,2,2);
|
||||||
if ((labelRect.height())<height() && (childBaseItems().isEmpty()) && !isSelected()){
|
if ((labelRect.height())<height() && (childBaseItems().isEmpty()) && !isSelected()){
|
||||||
ppainter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
ppainter->setBrush(bandColor());
|
painter->setBrush(bandColor());
|
||||||
ppainter->setOpacity(Const::BAND_NAME_AREA_OPACITY);
|
painter->setOpacity(Const::BAND_NAME_AREA_OPACITY);
|
||||||
ppainter->drawRoundedRect(labelRect,8,8);
|
painter->drawRoundedRect(labelRect,8,8);
|
||||||
ppainter->setOpacity(Const::BAND_NAME_TEXT_OPACITY);
|
painter->setOpacity(Const::BAND_NAME_TEXT_OPACITY);
|
||||||
ppainter->setPen(Qt::black);
|
painter->setPen(Qt::black);
|
||||||
ppainter->drawText(bandNameRects[i],Qt::AlignHCenter,bandText);
|
painter->drawText(bandNameRects[i],Qt::AlignHCenter,bandText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ppainter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
BaseDesignIntf::paint(ppainter,option,widget);
|
BaseDesignIntf::paint(painter,option,widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
BandDesignIntf::BandsType BandDesignIntf::bandType() const
|
BandDesignIntf::BandsType BandDesignIntf::bandType() const
|
||||||
|
@ -92,6 +92,7 @@ class BandDesignIntf : public BaseDesignIntf
|
|||||||
Q_PROPERTY(bool keepBottomSpace READ keepBottomSpaceOption WRITE setKeepBottomSpaceOption )
|
Q_PROPERTY(bool keepBottomSpace READ keepBottomSpaceOption WRITE setKeepBottomSpaceOption )
|
||||||
Q_PROPERTY(QString parentBand READ parentBandName WRITE setParentBandName DESIGNABLE false )
|
Q_PROPERTY(QString parentBand READ parentBandName WRITE setParentBandName DESIGNABLE false )
|
||||||
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
|
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
|
||||||
|
Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle)
|
||||||
Q_PROPERTY(bool printIfEmpty READ printIfEmpty WRITE setPrintIfEmpty)
|
Q_PROPERTY(bool printIfEmpty READ printIfEmpty WRITE setPrintIfEmpty)
|
||||||
Q_ENUMS(BandColumnsLayoutType)
|
Q_ENUMS(BandColumnsLayoutType)
|
||||||
friend class BandMarker;
|
friend class BandMarker;
|
||||||
@ -121,7 +122,7 @@ public:
|
|||||||
BandDesignIntf(BandsType bandType, const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0);
|
BandDesignIntf(BandsType bandType, const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0);
|
||||||
~BandDesignIntf();
|
~BandDesignIntf();
|
||||||
|
|
||||||
void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
virtual BandsType bandType() const;
|
virtual BandsType bandType() const;
|
||||||
virtual QString bandTitle() const;
|
virtual QString bandTitle() const;
|
||||||
virtual QIcon bandIcon() const;
|
virtual QIcon bandIcon() const;
|
||||||
|
@ -64,14 +64,13 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
|
|||||||
m_BGMode(OpaqueMode),
|
m_BGMode(OpaqueMode),
|
||||||
m_opacity(100),
|
m_opacity(100),
|
||||||
m_borderLinesFlags(0),
|
m_borderLinesFlags(0),
|
||||||
m_hintFrame(0),
|
|
||||||
m_storageTypeName(storageTypeName),
|
m_storageTypeName(storageTypeName),
|
||||||
m_itemMode(DesignMode),
|
m_itemMode(DesignMode),
|
||||||
m_objectState(ObjectCreated),
|
m_objectState(ObjectCreated),
|
||||||
m_selectionMarker(0),
|
m_selectionMarker(0),
|
||||||
m_joinMarker(0),
|
m_joinMarker(0),
|
||||||
m_backgroundBrush(Solid),
|
m_backgroundBrushStyle(SolidPattern),
|
||||||
m_backgroundBrushcolor(Qt::white),
|
m_backgroundColor(Qt::white),
|
||||||
m_margin(4),
|
m_margin(4),
|
||||||
m_itemAlign(DesignedItemAlign),
|
m_itemAlign(DesignedItemAlign),
|
||||||
m_changingItemAlign(false),
|
m_changingItemAlign(false),
|
||||||
@ -122,21 +121,23 @@ QString BaseDesignIntf::parentReportItemName() const
|
|||||||
else return "";
|
else return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseDesignIntf::setBackgroundBrushMode(BaseDesignIntf::BrushMode value)
|
void BaseDesignIntf::setBackgroundBrushStyle(BrushStyle value)
|
||||||
{
|
{
|
||||||
if ( value != m_backgroundBrush ){
|
if ( value != m_backgroundBrushStyle ){
|
||||||
m_backgroundBrush=value;
|
BrushStyle oldValue = m_backgroundBrushStyle;
|
||||||
|
m_backgroundBrushStyle=value;
|
||||||
if (!isLoading()) update();
|
if (!isLoading()) update();
|
||||||
|
notify("backgroundBrushStyle", static_cast<int>(oldValue), static_cast<int>(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseDesignIntf::setBackgroundColor(QColor value)
|
void BaseDesignIntf::setBackgroundColor(QColor value)
|
||||||
{
|
{
|
||||||
if (value != m_backgroundBrushcolor){
|
if (value != m_backgroundColor){
|
||||||
QColor oldValue = m_backgroundBrushcolor;
|
QColor oldValue = m_backgroundColor;
|
||||||
m_backgroundBrushcolor=value;
|
m_backgroundColor=value;
|
||||||
if (!isLoading()) update();
|
if (!isLoading()) update();
|
||||||
notify("backgroundColor",oldValue,m_backgroundBrushcolor);
|
notify("backgroundColor", oldValue, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,7 +497,6 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
|
|||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
setupPainter(ppainter);
|
setupPainter(ppainter);
|
||||||
|
|
||||||
drawBorder(ppainter, rect());
|
drawBorder(ppainter, rect());
|
||||||
if (isSelected()) {drawSelection(ppainter, rect());}
|
if (isSelected()) {drawSelection(ppainter, rect());}
|
||||||
drawResizeZone(ppainter);
|
drawResizeZone(ppainter);
|
||||||
@ -512,24 +512,28 @@ QColor calcColor(QColor color){
|
|||||||
return Qt::white;
|
return Qt::white;
|
||||||
else
|
else
|
||||||
return Qt::black;
|
return Qt::black;
|
||||||
};
|
}
|
||||||
|
|
||||||
void BaseDesignIntf::prepareRect(QPainter *ppainter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
void BaseDesignIntf::prepareRect(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||||
{
|
{
|
||||||
ppainter->save();
|
painter->save();
|
||||||
|
|
||||||
|
QBrush brush(m_backgroundColor,static_cast<Qt::BrushStyle>(m_backgroundBrushStyle));
|
||||||
|
brush.setTransform(painter->worldTransform().inverted());
|
||||||
|
|
||||||
if (isSelected() && (opacity() == 100) && (m_BGMode!=TransparentMode)) {
|
if (isSelected() && (opacity() == 100) && (m_BGMode!=TransparentMode)) {
|
||||||
ppainter->fillRect(rect(), QBrush(QColor(m_backgroundBrushcolor)));
|
painter->fillRect(rect(), brush);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (m_BGMode == OpaqueMode) {
|
if (m_BGMode == OpaqueMode) {
|
||||||
ppainter->setOpacity(qreal(m_opacity) / 100);
|
painter->setOpacity(qreal(m_opacity) / 100);
|
||||||
ppainter->fillRect(rect(), QBrush(m_backgroundBrushcolor));
|
painter->fillRect(rect(), brush);
|
||||||
} else if (itemMode() & DesignMode){
|
} else if (itemMode() & DesignMode){
|
||||||
ppainter->setOpacity(0.1);
|
painter->setOpacity(0.1);
|
||||||
ppainter->fillRect(rect(), QBrush(QPixmap(":/report/empty")));
|
painter->fillRect(rect(), QBrush(QPixmap(":/report/images/empty")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ppainter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseDesignIntf::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void BaseDesignIntf::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
@ -83,7 +83,7 @@ class BaseDesignIntf :
|
|||||||
Q_INTERFACES(QGraphicsItem)
|
Q_INTERFACES(QGraphicsItem)
|
||||||
Q_ENUMS(BGMode)
|
Q_ENUMS(BGMode)
|
||||||
Q_ENUMS(Qt::BrushStyle)
|
Q_ENUMS(Qt::BrushStyle)
|
||||||
Q_ENUMS(BrushMode)
|
Q_ENUMS(BrushStyle)
|
||||||
Q_ENUMS(ItemAlign)
|
Q_ENUMS(ItemAlign)
|
||||||
Q_FLAGS(BorderLines)
|
Q_FLAGS(BorderLines)
|
||||||
Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometryProperty NOTIFY geometryChanged)
|
Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometryProperty NOTIFY geometryChanged)
|
||||||
@ -96,8 +96,23 @@ class BaseDesignIntf :
|
|||||||
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
|
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum BGMode { TransparentMode,OpaqueMode};
|
enum BGMode { TransparentMode, OpaqueMode};
|
||||||
enum BrushMode{Solid,None};
|
|
||||||
|
enum BrushStyle{ NoBrush,
|
||||||
|
SolidPattern,
|
||||||
|
Dense1Pattern,
|
||||||
|
Dense2Pattern,
|
||||||
|
Dense3Pattern,
|
||||||
|
Dense4Pattern,
|
||||||
|
Dense5Pattern,
|
||||||
|
Dense6Pattern,
|
||||||
|
Dense7Pattern,
|
||||||
|
HorPattern,
|
||||||
|
VerPattern,
|
||||||
|
CrossPattern,
|
||||||
|
BDiagPattern,
|
||||||
|
FDiagPattern };
|
||||||
|
|
||||||
enum ResizeFlags { Fixed = 0,
|
enum ResizeFlags { Fixed = 0,
|
||||||
ResizeLeft = 1,
|
ResizeLeft = 1,
|
||||||
ResizeRight = 2,
|
ResizeRight = 2,
|
||||||
@ -124,13 +139,13 @@ public:
|
|||||||
BaseDesignIntf(const QString& storageTypeName, QObject* owner = 0, QGraphicsItem* parent = 0);
|
BaseDesignIntf(const QString& storageTypeName, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||||
virtual ~BaseDesignIntf();
|
virtual ~BaseDesignIntf();
|
||||||
|
|
||||||
void setParentReportItem(const QString& value);
|
void setParentReportItem(const QString& value);
|
||||||
QString parentReportItemName() const;
|
QString parentReportItemName() const;
|
||||||
|
|
||||||
BrushMode backgroundBrushMode() const {return m_backgroundBrush;}
|
BrushStyle backgroundBrushStyle() const {return m_backgroundBrushStyle;}
|
||||||
void setBackgroundBrushMode(BrushMode value);
|
void setBackgroundBrushStyle(BrushStyle value);
|
||||||
QColor backgroundColor() const {return m_backgroundBrushcolor;}
|
QColor backgroundColor() const {return m_backgroundColor;}
|
||||||
void setBackgroundColor(QColor value);
|
void setBackgroundColor(QColor value);
|
||||||
|
|
||||||
QPen pen() const;
|
QPen pen() const;
|
||||||
void setPen(QPen& pen);
|
void setPen(QPen& pen);
|
||||||
@ -155,7 +170,7 @@ public:
|
|||||||
virtual QSizeF sizeMM() const;
|
virtual QSizeF sizeMM() const;
|
||||||
|
|
||||||
void paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
void paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||||
void prepareRect(QPainter* ppainter, const QStyleOptionGraphicsItem*, QWidget*);
|
void prepareRect(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
virtual QPainterPath shape() const;
|
virtual QPainterPath shape() const;
|
||||||
|
|
||||||
void setFixedPos(bool fixedPos);
|
void setFixedPos(bool fixedPos);
|
||||||
@ -329,13 +344,13 @@ private:
|
|||||||
void turnOnSelectionMarker(bool value);
|
void turnOnSelectionMarker(bool value);
|
||||||
private:
|
private:
|
||||||
QPointF m_startPos;
|
QPointF m_startPos;
|
||||||
//QPointF m_startScenePos;
|
|
||||||
int m_resizeHandleSize;
|
int m_resizeHandleSize;
|
||||||
int m_selectionPenSize;
|
int m_selectionPenSize;
|
||||||
int m_possibleResizeDirectionFlags;
|
int m_possibleResizeDirectionFlags;
|
||||||
int m_possibleMoveDirectionFlags;
|
int m_possibleMoveDirectionFlags;
|
||||||
int m_resizeDirectionFlags;
|
int m_resizeDirectionFlags;
|
||||||
qreal m_width, m_height;
|
qreal m_width;
|
||||||
|
qreal m_height;
|
||||||
QPen m_pen;
|
QPen m_pen;
|
||||||
QFont m_font;
|
QFont m_font;
|
||||||
QColor m_fontColor;
|
QColor m_fontColor;
|
||||||
@ -357,7 +372,6 @@ private:
|
|||||||
QRectF m_rightRect;
|
QRectF m_rightRect;
|
||||||
|
|
||||||
QVector<QRectF*> m_resizeAreas;
|
QVector<QRectF*> m_resizeAreas;
|
||||||
QFrame* m_hintFrame;
|
|
||||||
QString m_storageTypeName;
|
QString m_storageTypeName;
|
||||||
ItemMode m_itemMode;
|
ItemMode m_itemMode;
|
||||||
|
|
||||||
@ -365,8 +379,9 @@ private:
|
|||||||
SelectionMarker* m_selectionMarker;
|
SelectionMarker* m_selectionMarker;
|
||||||
Marker* m_joinMarker;
|
Marker* m_joinMarker;
|
||||||
|
|
||||||
BrushMode m_backgroundBrush;
|
BrushStyle m_backgroundBrushStyle;
|
||||||
QColor m_backgroundBrushcolor;
|
QColor m_backgroundColor;
|
||||||
|
|
||||||
RenderPass m_currentPass;
|
RenderPass m_currentPass;
|
||||||
int m_margin;
|
int m_margin;
|
||||||
QString m_itemTypeName;
|
QString m_itemTypeName;
|
||||||
|
Loading…
Reference in New Issue
Block a user