From 7da0cfd7e2768f3e4ed7d0e1c87abb9c65169383 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 21 Dec 2016 22:09:10 +0300 Subject: [PATCH] backgroundBrushStyle property has been added --- limereport/items/lrshapeitem.cpp | 2 +- limereport/items/lrtextitem.h | 1 + limereport/lrbanddesignintf.cpp | 36 ++++++++++++++------------ limereport/lrbanddesignintf.h | 3 ++- limereport/lrbasedesignintf.cpp | 44 +++++++++++++++++--------------- limereport/lrbasedesignintf.h | 43 +++++++++++++++++++++---------- 6 files changed, 77 insertions(+), 52 deletions(-) diff --git a/limereport/items/lrshapeitem.cpp b/limereport/items/lrshapeitem.cpp index f52b1c8..a1b37d9 100644 --- a/limereport/items/lrshapeitem.cpp +++ b/limereport/items/lrshapeitem.cpp @@ -85,7 +85,7 @@ void ShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, pen.setStyle(m_penStyle); painter->setPen(pen); QBrush brush(m_shapeBrushColor,m_shapeBrushType); - + brush.setTransform(painter->worldTransform().inverted()); painter->setBrush(brush); painter->setBackground(QBrush(Qt::NoBrush)); painter->setOpacity(qreal(m_opacity)/100); diff --git a/limereport/items/lrtextitem.h b/limereport/items/lrtextitem.h index adab6b3..535bcd4 100644 --- a/limereport/items/lrtextitem.h +++ b/limereport/items/lrtextitem.h @@ -68,6 +68,7 @@ class TextItem : public LimeReport::ContentItemDesignIntf, IPageInit { Q_PROPERTY(QString format READ format WRITE setFormat) Q_PROPERTY(ValueType valueType READ valueType WRITE setValueType) Q_PROPERTY(QString followTo READ followTo WRITE setFollowTo) + Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle) public: enum AutoWidth{NoneAutoWidth,MaxWordLength,MaxStringLength}; diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 2fe29b8..c6993ad 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -183,16 +183,20 @@ BandDesignIntf::~BandDesignIntf() 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(backgroundBrushStyle())); + brush.setTransform(painter->worldTransform().inverted()); + painter->fillRect(rect(), brush); } - if (itemMode()&DesignMode){ - ppainter->save(); + + if (itemMode() & DesignMode){ + painter->save(); QString bandText = 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); QVector bandNameRects; @@ -204,22 +208,22 @@ void BandDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o //if (isSelected()) ppainter->setPen(QColor(167,244,167)); // else ppainter->setPen(QColor(220,220,220)); - ppainter->setFont(font); + painter->setFont(font); for (int i=0;isetRenderHint(QPainter::Antialiasing); - ppainter->setBrush(bandColor()); - ppainter->setOpacity(Const::BAND_NAME_AREA_OPACITY); - ppainter->drawRoundedRect(labelRect,8,8); - ppainter->setOpacity(Const::BAND_NAME_TEXT_OPACITY); - ppainter->setPen(Qt::black); - ppainter->drawText(bandNameRects[i],Qt::AlignHCenter,bandText); + painter->setRenderHint(QPainter::Antialiasing); + painter->setBrush(bandColor()); + painter->setOpacity(Const::BAND_NAME_AREA_OPACITY); + painter->drawRoundedRect(labelRect,8,8); + painter->setOpacity(Const::BAND_NAME_TEXT_OPACITY); + painter->setPen(Qt::black); + 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 diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 1f21919..fea245a 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -92,6 +92,7 @@ class BandDesignIntf : public BaseDesignIntf Q_PROPERTY(bool keepBottomSpace READ keepBottomSpaceOption WRITE setKeepBottomSpaceOption ) Q_PROPERTY(QString parentBand READ parentBandName WRITE setParentBandName DESIGNABLE false ) 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_ENUMS(BandColumnsLayoutType) friend class BandMarker; @@ -121,7 +122,7 @@ public: BandDesignIntf(BandsType bandType, const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0); ~BandDesignIntf(); - void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual BandsType bandType() const; virtual QString bandTitle() const; virtual QIcon bandIcon() const; diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 7025a0f..77967f4 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -64,14 +64,13 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q m_BGMode(OpaqueMode), m_opacity(100), m_borderLinesFlags(0), - m_hintFrame(0), m_storageTypeName(storageTypeName), m_itemMode(DesignMode), m_objectState(ObjectCreated), m_selectionMarker(0), m_joinMarker(0), - m_backgroundBrush(Solid), - m_backgroundBrushcolor(Qt::white), + m_backgroundBrushStyle(SolidPattern), + m_backgroundColor(Qt::white), m_margin(4), m_itemAlign(DesignedItemAlign), m_changingItemAlign(false), @@ -122,21 +121,23 @@ QString BaseDesignIntf::parentReportItemName() const else return ""; } -void BaseDesignIntf::setBackgroundBrushMode(BaseDesignIntf::BrushMode value) +void BaseDesignIntf::setBackgroundBrushStyle(BrushStyle value) { - if ( value != m_backgroundBrush ){ - m_backgroundBrush=value; + if ( value != m_backgroundBrushStyle ){ + BrushStyle oldValue = m_backgroundBrushStyle; + m_backgroundBrushStyle=value; if (!isLoading()) update(); + notify("backgroundBrushStyle", static_cast(oldValue), static_cast(value)); } } void BaseDesignIntf::setBackgroundColor(QColor value) { - if (value != m_backgroundBrushcolor){ - QColor oldValue = m_backgroundBrushcolor; - m_backgroundBrushcolor=value; + if (value != m_backgroundColor){ + QColor oldValue = m_backgroundColor; + m_backgroundColor=value; 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(widget); setupPainter(ppainter); - drawBorder(ppainter, rect()); if (isSelected()) {drawSelection(ppainter, rect());} drawResizeZone(ppainter); @@ -512,24 +512,28 @@ QColor calcColor(QColor color){ return Qt::white; else 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(m_backgroundBrushStyle)); + brush.setTransform(painter->worldTransform().inverted()); + if (isSelected() && (opacity() == 100) && (m_BGMode!=TransparentMode)) { - ppainter->fillRect(rect(), QBrush(QColor(m_backgroundBrushcolor))); + painter->fillRect(rect(), brush); } else { if (m_BGMode == OpaqueMode) { - ppainter->setOpacity(qreal(m_opacity) / 100); - ppainter->fillRect(rect(), QBrush(m_backgroundBrushcolor)); + painter->setOpacity(qreal(m_opacity) / 100); + painter->fillRect(rect(), brush); } else if (itemMode() & DesignMode){ - ppainter->setOpacity(0.1); - ppainter->fillRect(rect(), QBrush(QPixmap(":/report/empty"))); + painter->setOpacity(0.1); + painter->fillRect(rect(), QBrush(QPixmap(":/report/images/empty"))); } } - ppainter->restore(); + painter->restore(); } void BaseDesignIntf::hoverMoveEvent(QGraphicsSceneHoverEvent *event) diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index d9bdf3f..d6b32f6 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -83,7 +83,7 @@ class BaseDesignIntf : Q_INTERFACES(QGraphicsItem) Q_ENUMS(BGMode) Q_ENUMS(Qt::BrushStyle) - Q_ENUMS(BrushMode) + Q_ENUMS(BrushStyle) Q_ENUMS(ItemAlign) Q_FLAGS(BorderLines) Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometryProperty NOTIFY geometryChanged) @@ -96,8 +96,23 @@ class BaseDesignIntf : Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) public: - enum BGMode { TransparentMode,OpaqueMode}; - enum BrushMode{Solid,None}; + enum BGMode { TransparentMode, OpaqueMode}; + + enum BrushStyle{ NoBrush, + SolidPattern, + Dense1Pattern, + Dense2Pattern, + Dense3Pattern, + Dense4Pattern, + Dense5Pattern, + Dense6Pattern, + Dense7Pattern, + HorPattern, + VerPattern, + CrossPattern, + BDiagPattern, + FDiagPattern }; + enum ResizeFlags { Fixed = 0, ResizeLeft = 1, ResizeRight = 2, @@ -124,13 +139,13 @@ public: BaseDesignIntf(const QString& storageTypeName, QObject* owner = 0, QGraphicsItem* parent = 0); virtual ~BaseDesignIntf(); - void setParentReportItem(const QString& value); + void setParentReportItem(const QString& value); QString parentReportItemName() const; - BrushMode backgroundBrushMode() const {return m_backgroundBrush;} - void setBackgroundBrushMode(BrushMode value); - QColor backgroundColor() const {return m_backgroundBrushcolor;} - void setBackgroundColor(QColor value); + BrushStyle backgroundBrushStyle() const {return m_backgroundBrushStyle;} + void setBackgroundBrushStyle(BrushStyle value); + QColor backgroundColor() const {return m_backgroundColor;} + void setBackgroundColor(QColor value); QPen pen() const; void setPen(QPen& pen); @@ -155,7 +170,7 @@ public: virtual QSizeF sizeMM() const; 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; void setFixedPos(bool fixedPos); @@ -329,13 +344,13 @@ private: void turnOnSelectionMarker(bool value); private: QPointF m_startPos; - //QPointF m_startScenePos; int m_resizeHandleSize; int m_selectionPenSize; int m_possibleResizeDirectionFlags; int m_possibleMoveDirectionFlags; int m_resizeDirectionFlags; - qreal m_width, m_height; + qreal m_width; + qreal m_height; QPen m_pen; QFont m_font; QColor m_fontColor; @@ -357,7 +372,6 @@ private: QRectF m_rightRect; QVector m_resizeAreas; - QFrame* m_hintFrame; QString m_storageTypeName; ItemMode m_itemMode; @@ -365,8 +379,9 @@ private: SelectionMarker* m_selectionMarker; Marker* m_joinMarker; - BrushMode m_backgroundBrush; - QColor m_backgroundBrushcolor; + BrushStyle m_backgroundBrushStyle; + QColor m_backgroundColor; + RenderPass m_currentPass; int m_margin; QString m_itemTypeName;