From fed80a8be168a8fe85b04d346dd57b4c744a2a12 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Thu, 21 Feb 2019 19:21:09 +0300 Subject: [PATCH 01/10] Preview printer initialization changed --- limereport/lrpreviewreportwidget.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/limereport/lrpreviewreportwidget.cpp b/limereport/lrpreviewreportwidget.cpp index 7b3290d..3f2a984 100644 --- a/limereport/lrpreviewreportwidget.cpp +++ b/limereport/lrpreviewreportwidget.cpp @@ -208,29 +208,29 @@ void PreviewReportWidget::printPages(QPrinter* printer) void PreviewReportWidget::print() { - if (m_defaultPrinter){ - printPages(m_defaultPrinter); - } else { + QPrinterInfo pi; + QPrinter lp(QPrinter::HighResolution); - QPrinterInfo pi; - QPrinter printer(QPrinter::HighResolution); - - if (!pi.defaultPrinter().isNull()) + if (!pi.defaultPrinter().isNull()){ #ifdef HAVE_QT4 - printer.setPrinterName(pi.defaultPrinter().printerName()); + lp.setPrinterName(pi.defaultPrinter().printerName()); #endif #ifdef HAVE_QT5 #if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) - printer.setPrinterName(pi.defaultPrinterName()); + lp.setPrinterName(pi.defaultPrinterName()); #else - printer.setPrinterName(pi.defaultPrinter().printerName()); + lp.setPrinterName(pi.defaultPrinter().printerName()); #endif #endif - QPrintDialog dialog(&printer,QApplication::activeWindow()); - if (dialog.exec()==QDialog::Accepted){ - printPages(&printer); - } } + + QPrinter* printer = m_defaultPrinter ? m_defaultPrinter : &lp; + + QPrintDialog dialog(printer,QApplication::activeWindow()); + if (dialog.exec()==QDialog::Accepted){ + printPages(printer); + } + } void PreviewReportWidget::printToPDF() From 9bd392f4aca430133d7608ba7b05d0e2137fc9a5 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 22 Feb 2019 20:30:09 +0300 Subject: [PATCH 02/10] Lost headers moving has been fixed --- limereport/lrreportrender.cpp | 26 +++++++++++++++++++++++--- limereport/lrreportrender.h | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 08333c9..81523df 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -148,7 +148,8 @@ void ReportRender::renameChildItems(BaseDesignIntf *item){ ReportRender::ReportRender(QObject *parent) :QObject(parent), m_renderPageItem(0), m_pageCount(0), - m_lastRenderedHeader(0), m_lastDataBand(0), m_lastRenderedFooter(0), m_currentColumn(0), m_newPageStarted(false) + m_lastRenderedHeader(0), m_lastDataBand(0), m_lastRenderedFooter(0), + m_currentColumn(0), m_newPageStarted(false), m_lostHeadersMoved(false) { initColumns(); } @@ -490,7 +491,11 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign bandClone->columnsFillDirection()==BandDesignIntf::VerticalUniform)) { startNewColumn(); - if (patternBand->bandHeader() && patternBand->bandHeader()->columnsCount()>1){ + if (patternBand->bandHeader() && + patternBand->bandHeader()->columnsCount()>1 && + !m_lostHeadersMoved && + patternBand->bandNestingLevel() == 0 + ){ renderBand(patternBand->bandHeader(), 0, mode); } } else { @@ -1164,7 +1169,15 @@ BandDesignIntf *ReportRender::saveUppperPartReturnBottom(BandDesignIntf *band, i if (band->columnsCount()>1 && (band->columnsFillDirection()==BandDesignIntf::Vertical || band->columnsFillDirection()==BandDesignIntf::VerticalUniform)){ - startNewColumn(); + startNewColumn(); + if (patternBand->bandHeader() && + patternBand->bandHeader()->columnsCount()>1 && + !m_lostHeadersMoved && + patternBand->bandNestingLevel() == 0 + ){ + renderBand(patternBand->bandHeader(), 0, StartNewPageAsNeeded); + } + } else { savePage(); startNewPage(); @@ -1332,12 +1345,16 @@ void ReportRender::checkLostHeadersOnPrevPage() } if (lostHeaders.size() > 0){ + m_lostHeadersMoved = true; qSort(lostHeaders.begin(), lostHeaders.end(), bandLessThen); foreach(BandDesignIntf* header, lostHeaders){ registerBand(header); } + } else { + m_lostHeadersMoved = false; } + } void ReportRender::checkLostHeadersInPrevColumn() @@ -1365,10 +1382,13 @@ void ReportRender::checkLostHeadersInPrevColumn() } if (lostHeaders.size() > 0){ + m_lostHeadersMoved = true; qSort(lostHeaders.begin(), lostHeaders.end(), bandLessThen); foreach(BandDesignIntf* header, lostHeaders){ registerBand(header); } + } else { + m_lostHeadersMoved = false; } } diff --git a/limereport/lrreportrender.h b/limereport/lrreportrender.h index 541f325..d31efce 100644 --- a/limereport/lrreportrender.h +++ b/limereport/lrreportrender.h @@ -215,6 +215,7 @@ private: QVector m_columnedBandItems; unsigned long long m_currentNameIndex; bool m_newPageStarted; + bool m_lostHeadersMoved; }; } // namespace LimeReport From 005e65f3e344be33cbe67c271603fd35db78f36f Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Mon, 25 Feb 2019 16:22:10 +0300 Subject: [PATCH 03/10] Init commit --- include/lrglobal.h | 4 +- limereport/lrbanddesignintf.cpp | 21 ++++++--- limereport/lrbanddesignintf.h | 3 ++ limereport/lrbasedesignintf.cpp | 67 ++++++++++++++++++++++++----- limereport/lrbasedesignintf.h | 9 ++-- limereport/lrglobal.h | 4 +- limereport/lrpageitemdesignintf.cpp | 6 +++ limereport/lrpageitemdesignintf.h | 1 + 8 files changed, 93 insertions(+), 22 deletions(-) diff --git a/include/lrglobal.h b/include/lrglobal.h index ba5a363..76af327 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -52,8 +52,8 @@ namespace LimeReport { namespace Const{ - int const RESIZE_HANDLE_SIZE = 10; - int const SELECTION_PEN_SIZE = 4; + int const RESIZE_HANDLE_SIZE = 5; + int const SELECTION_PEN_SIZE = 1; int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE; int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE; double const RESIZE_ZONE_OPACITY = 0.5; diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index c77f86c..94dc795 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -304,6 +304,12 @@ bool BandDesignIntf::isUnique() const return true; } +void BandDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode) +{ + ItemsContainerDesignInft::setItemMode(mode); + updateBandMarkerGeometry(); +} + QString BandDesignIntf::datasourceName(){ return m_dataSourceName; } @@ -728,14 +734,19 @@ BandDesignIntf* BandDesignIntf::findParentBand() return 0; } +void BandDesignIntf::updateBandMarkerGeometry() +{ + if (parentItem() && m_bandMarker){ + QPointF sp = parentItem()->mapToScene(pos()); + m_bandMarker->setPos((sp.x()-m_bandMarker->boundingRect().width()),sp.y()); + m_bandMarker->setHeight(rect().height()); + } +} + void BandDesignIntf::geometryChangedEvent(QRectF, QRectF ) { if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){ - QPointF sp = parentItem()->mapToScene(pos()); - if (m_bandMarker){ - m_bandMarker->setPos((sp.x()-m_bandMarker->boundingRect().width()),sp.y()); - m_bandMarker->setHeight(rect().height()); - } + updateBandMarkerGeometry(); } foreach (BaseDesignIntf* item, childBaseItems()) { if (item->itemAlign()!=DesignedItemAlign){ diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 16009a5..193cf9c 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -142,6 +142,7 @@ public: virtual QString bandTitle() const; virtual QIcon bandIcon() const; virtual bool isUnique() const; + void setItemMode(BaseDesignIntf::ItemMode mode); void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0); void restoreItems(); void recalcItems(DataSourceManager* dataManager); @@ -250,6 +251,8 @@ public: void setBackgroundOpacity(int value); int bootomSpace() const; void setBootomSpace(int bootomSpace); + void updateBandMarkerGeometry(); + signals: void bandRendered(BandDesignIntf* band); void preparedForRender(); diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 0cb6c09..5c00bd6 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -81,7 +81,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q m_patternName(""), m_patternItem(0), m_fillInSecondPass(false), - m_watermark(false) + m_watermark(false), + m_hovered(false) { setGeometry(QRectF(0, 0, m_width, m_height)); if (BaseDesignIntf *item = dynamic_cast(parent)) { @@ -104,7 +105,7 @@ QRectF BaseDesignIntf::boundingRect() const } BaseDesignIntf::~BaseDesignIntf(void) { - delete m_selectionMarker; + //delete m_selectionMarker; delete m_joinMarker; } @@ -394,6 +395,9 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o drawBorder(ppainter, rect()); if (isSelected()) {drawSelection(ppainter, rect());} drawResizeZone(ppainter); +// if (m_hovered) ppainter->drawImage( +// QRectF(QPointF(rect().topRight().x()-24, rect().bottomLeft().y()-24), +// QSizeF(24, 24)),QImage(":/items/images/settings.png")); } QColor calcColor(QColor color){ @@ -480,6 +484,14 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *) m_resizeDirectionFlags = 0; scene()->update(sceneBoundingRect()); m_resizeAreas.clear(); + m_hovered = false; + update(); +} + +void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + m_hovered = true; + update(); } @@ -710,6 +722,7 @@ void BaseDesignIntf::turnOnSelectionMarker(bool value) if (value && !m_selectionMarker){ m_selectionMarker = new SelectionMarker(this); m_selectionMarker->setColor(selectionMarkerColor()); + m_selectionMarker->setZValue(zValue()-1); updateSelectionMarker(); m_selectionMarker->setVisible(true); } else { @@ -1119,6 +1132,28 @@ void BaseDesignIntf::drawSelection(QPainter *painter, QRectF /*rect*/) const // painter->drawLine(rect.right(),rect.bottom()-m_resizeHandleSize,rect.right(),rect.bottom()); // painter->setOpacity(Consts::SELECTION_COLOR_OPACITY); // painter->fillRect(rect,selectionColor()); + + QPen pen(Qt::red,m_selectionPenSize); + painter->setPen(pen); + painter->setBrush(QBrush(Qt::red)); + const int markerSize = Const::RESIZE_HANDLE_SIZE; + painter->drawRect(QRectF(-markerSize,-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().right()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().right()-markerSize,rect().top()-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().left()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().left()-markerSize, + rect().bottom()-rect().height()/2-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().right()-markerSize, + rect().bottom()-rect().height()/2-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize, + rect().top()-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize, + rect().bottom()-markerSize,markerSize*2,markerSize*2)); + + pen.setStyle(Qt::DotLine); + painter->setPen(pen); + painter->setBrush(QBrush(Qt::transparent)); + painter->drawRect(rect()); painter->restore(); } @@ -1298,13 +1333,13 @@ void BaseDesignIntf::setMarginSize(int value) void BaseDesignIntf::updateSelectionMarker() { - if (m_selectionMarker && (itemMode() & DesignMode || itemMode() & EditMode)) { - if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker); - if (parentItem()) { - m_selectionMarker->setRect(rect()); - m_selectionMarker->setPos(0,0); - } - } +// if (m_selectionMarker && (itemMode() & DesignMode || itemMode() & EditMode)) { +// if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker); +// if (parentItem()) { +// m_selectionMarker->setRect(rect()); +// m_selectionMarker->setPos(0,0); +// } +// } } void BaseDesignIntf::drawResizeZone(QPainter* /*painter*/) @@ -1561,6 +1596,18 @@ void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event) if(baseItem) baseItem->hoverMoveEvent(event); } +void SelectionMarker::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + BaseDesignIntf* baseItem = dynamic_cast(parentItem()); + if (baseItem) baseItem->hoverLeaveEvent(event); +} + +void SelectionMarker::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + BaseDesignIntf* baseItem = dynamic_cast(parentItem()); + if (baseItem) baseItem->hoverEnterEvent(event); +} + void SelectionMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) { parentItem()->setSelected(true); @@ -1596,7 +1643,7 @@ QRectF Marker::boundingRect() const void Marker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { QPen pen; - const int markerSize = 5; + const int markerSize = Const::RESIZE_HANDLE_SIZE; pen.setColor(color()); pen.setWidth(2); pen.setStyle(Qt::DotLine); diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 9bfb288..9b7d599 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -70,6 +70,8 @@ public: SelectionMarker(QGraphicsItem* parent=0); protected: void hoverMoveEvent(QGraphicsSceneHoverEvent *event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); + void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); @@ -204,7 +206,7 @@ public: void setItemPos(const QPointF &newPos); void setItemPos(qreal x, qreal y); - void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode); + virtual void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode); ItemMode itemMode() const {return m_itemMode;} virtual void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags); @@ -305,10 +307,11 @@ protected: void mousePressEvent(QGraphicsSceneMouseEvent* event); void hoverMoveEvent(QGraphicsSceneHoverEvent* event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - //void virtual hoverEnterEvent(QGraphicsSceneHoverEvent *event); + void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); + void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); virtual void geometryChangedEvent(QRectF newRect, QRectF oldRect); @@ -415,7 +418,7 @@ private: BaseDesignIntf* m_patternItem; bool m_fillInSecondPass; bool m_watermark; - + bool m_hovered; signals: void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void posChanging(QObject* object, QPointF newPos, QPointF oldPos); diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index ba5a363..76af327 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -52,8 +52,8 @@ namespace LimeReport { namespace Const{ - int const RESIZE_HANDLE_SIZE = 10; - int const SELECTION_PEN_SIZE = 4; + int const RESIZE_HANDLE_SIZE = 5; + int const SELECTION_PEN_SIZE = 1; int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE; int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE; double const RESIZE_ZONE_OPACITY = 0.5; diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 0f8d98a..c3ad3cb 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -164,6 +164,12 @@ QRectF PageItemDesignIntf::boundingRect() const } } +void PageItemDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode) +{ + ItemsContainerDesignInft::setItemMode(mode); + relocateBands(); +} + void PageItemDesignIntf::clear() { foreach(QGraphicsItem* item, childItems()){ diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 39c0fe3..09fa2d6 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -90,6 +90,7 @@ public: virtual QColor pageBorderColor() const; virtual QColor gridColor() const; virtual QRectF boundingRect() const; + void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode); void clear(); const BandsList& childBands() const {return m_bands;} BandDesignIntf * bandByType(BandDesignIntf::BandsType bandType) const; From f85b56480855ee902c18d46a4ca13bff27d3e485 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 26 Feb 2019 20:29:13 +0300 Subject: [PATCH 04/10] Selection border painting has been fixed --- limereport/lrbasedesignintf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 5c00bd6..fdd0bf4 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -52,7 +52,7 @@ namespace LimeReport BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, QGraphicsItem *parent) : QObject(owner), QGraphicsItem(parent), - m_resizeHandleSize(Const::RESIZE_HANDLE_SIZE), + m_resizeHandleSize(Const::RESIZE_HANDLE_SIZE*2), m_selectionPenSize(Const::SELECTION_PEN_SIZE), m_possibleResizeDirectionFlags(ResizeTop | ResizeBottom | ResizeLeft | ResizeRight), m_possibleMoveDirectionFlags(All), @@ -1136,6 +1136,7 @@ void BaseDesignIntf::drawSelection(QPainter *painter, QRectF /*rect*/) const QPen pen(Qt::red,m_selectionPenSize); painter->setPen(pen); painter->setBrush(QBrush(Qt::red)); + painter->setOpacity(1); const int markerSize = Const::RESIZE_HANDLE_SIZE; painter->drawRect(QRectF(-markerSize,-markerSize,markerSize*2,markerSize*2)); painter->drawRect(QRectF(rect().right()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2)); From 6ce77268fdd3c15e04e57e28392e72330cfea614 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 27 Feb 2019 00:50:59 +0300 Subject: [PATCH 05/10] Join & selection marker has been removed --- limereport/lrbasedesignintf.cpp | 176 ++++------------------------ limereport/lrbasedesignintf.h | 38 +----- limereport/lrpagedesignintf.cpp | 92 ++++++++++++--- limereport/lrpagedesignintf.h | 5 +- limereport/lrpageitemdesignintf.cpp | 2 +- 5 files changed, 102 insertions(+), 211 deletions(-) diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index fdd0bf4..55aed88 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -69,8 +69,6 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q m_storageTypeName(storageTypeName), m_itemMode(DesignMode), m_objectState(ObjectCreated), - m_selectionMarker(0), - m_joinMarker(0), m_backgroundBrushStyle(SolidPattern), m_backgroundColor(Qt::white), m_margin(4), @@ -82,7 +80,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q m_patternItem(0), m_fillInSecondPass(false), m_watermark(false), - m_hovered(false) + m_hovered(false), + m_joinMarkerOn(false) { setGeometry(QRectF(0, 0, m_width, m_height)); if (BaseDesignIntf *item = dynamic_cast(parent)) { @@ -106,7 +105,7 @@ QRectF BaseDesignIntf::boundingRect() const BaseDesignIntf::~BaseDesignIntf(void) { //delete m_selectionMarker; - delete m_joinMarker; + //delete m_joinMarker; } void BaseDesignIntf::setParentReportItem(const QString &value) @@ -391,10 +390,13 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o { Q_UNUSED(option); Q_UNUSED(widget); + ppainter->save(); setupPainter(ppainter); drawBorder(ppainter, rect()); - if (isSelected()) {drawSelection(ppainter, rect());} + if (m_joinMarkerOn) { drawMarker(ppainter, Const::JOIN_COLOR);} + if (isSelected() && !m_joinMarkerOn) {drawMarker(ppainter, Const::SELECTION_COLOR);} drawResizeZone(ppainter); + ppainter->restore(); // if (m_hovered) ppainter->drawImage( // QRectF(QPointF(rect().topRight().x()-24, rect().bottomLeft().y()-24), // QSizeF(24, 24)),QImage(":/items/images/settings.png")); @@ -573,6 +575,7 @@ void BaseDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event) moveSelectedItems(tmpPos - pos()); if (page()->selectedItems().count()==1 && (page()->magneticMovement())) page()->itemMoved(this); + } } } @@ -673,15 +676,17 @@ QPointF BaseDesignIntf::modifyPosForAlignedItem(const QPointF& pos){ void BaseDesignIntf::turnOnJoinMarker(bool value) { - if (value){ - m_joinMarker = new Marker(this); - m_joinMarker->setColor(Const::JOIN_COLOR); - m_joinMarker->setRect(rect()); - m_joinMarker->setVisible(true); - } else { - delete m_joinMarker; - m_joinMarker = 0; - } + m_joinMarkerOn = value; + update(); +// if (value){ +// m_joinMarker = new Marker(this); +// m_joinMarker->setColor(Const::JOIN_COLOR); +// m_joinMarker->setRect(rect()); +// m_joinMarker->setVisible(true); +// } else { +// delete m_joinMarker; +// m_joinMarker = 0; +// } } void BaseDesignIntf::updateItemAlign(){ @@ -717,20 +722,6 @@ void BaseDesignIntf::updatePossibleDirectionFlags(){ } } -void BaseDesignIntf::turnOnSelectionMarker(bool value) -{ - if (value && !m_selectionMarker){ - m_selectionMarker = new SelectionMarker(this); - m_selectionMarker->setColor(selectionMarkerColor()); - m_selectionMarker->setZValue(zValue()-1); - updateSelectionMarker(); - m_selectionMarker->setVisible(true); - } else { - delete m_selectionMarker; - m_selectionMarker = 0; - } -} - bool BaseDesignIntf::fillInSecondPass() const { return m_fillInSecondPass; @@ -988,7 +979,6 @@ void BaseDesignIntf::setGeometry(QRectF rect) m_leftRect = QRectF(0-resizeHandleSize(), 0-resizeHandleSize(), resizeHandleSize()*2, height()+resizeHandleSize()*2); m_rightRect = QRectF(width() - resizeHandleSize(), 0-resizeHandleSize(), resizeHandleSize()*2, height()+resizeHandleSize()*2); m_boundingRect = QRectF(); - updateSelectionMarker(); if (!isLoading()){ geometryChangedEvent(geometry(), m_oldGeometry); emit geometryChanged(this, geometry(), m_oldGeometry); @@ -1074,11 +1064,9 @@ void BaseDesignIntf::initMode(ItemMode mode) QVariant BaseDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == QGraphicsItem::ItemPositionHasChanged) { - updateSelectionMarker(); } if (change == QGraphicsItem::ItemSelectedChange) { - turnOnSelectionMarker(value.toBool()); emit itemSelectedHasBeenChanged(this, value.toBool()); } if (change == QGraphicsItem::ItemParentHasChanged) { @@ -1118,24 +1106,13 @@ QPainterPath BaseDesignIntf::shape() const return path; } -void BaseDesignIntf::drawSelection(QPainter *painter, QRectF /*rect*/) const +void BaseDesignIntf::drawMarker(QPainter *painter, QColor color) const { painter->save(); - // painter->setPen(QPen(Qt::red,m_selectionPenSize)); - // painter->drawLine(QPointF(m_resizeHandleSize,0),QPointF(0,0)); - // painter->drawLine(QPointF(0,m_resizeHandleSize),QPointF(0,0)); - // painter->drawLine(rect.right()-m_resizeHandleSize,0,rect.right(),0); - // painter->drawLine(rect.right(),m_resizeHandleSize,rect.right(),0); - // painter->drawLine(0,rect.bottom(),0,rect.bottom()-10); - // painter->drawLine(0,rect.bottom(),m_resizeHandleSize,rect.bottom()); - // painter->drawLine(rect.right()-m_resizeHandleSize,rect.bottom(),rect.right(),rect.bottom()); - // painter->drawLine(rect.right(),rect.bottom()-m_resizeHandleSize,rect.right(),rect.bottom()); - // painter->setOpacity(Consts::SELECTION_COLOR_OPACITY); - // painter->fillRect(rect,selectionColor()); - QPen pen(Qt::red,m_selectionPenSize); + QPen pen(color, m_selectionPenSize); painter->setPen(pen); - painter->setBrush(QBrush(Qt::red)); + painter->setBrush(QBrush(color)); painter->setOpacity(1); const int markerSize = Const::RESIZE_HANDLE_SIZE; painter->drawRect(QRectF(-markerSize,-markerSize,markerSize*2,markerSize*2)); @@ -1202,7 +1179,6 @@ void BaseDesignIntf::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) QRectF newGeometry = geometry(); if (newGeometry != m_oldGeometry) { geometryChangedEvent(newGeometry, m_oldGeometry); - updateSelectionMarker(); emit(posChanged(this, newGeometry.topLeft(), m_oldGeometry.topLeft())); } QGraphicsItem::mouseReleaseEvent(event); @@ -1332,17 +1308,6 @@ void BaseDesignIntf::setMarginSize(int value) } } -void BaseDesignIntf::updateSelectionMarker() -{ -// if (m_selectionMarker && (itemMode() & DesignMode || itemMode() & EditMode)) { -// if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker); -// if (parentItem()) { -// m_selectionMarker->setRect(rect()); -// m_selectionMarker->setPos(0,0); -// } -// } -} - void BaseDesignIntf::drawResizeZone(QPainter* /*painter*/) { @@ -1585,103 +1550,6 @@ void BaseDesignIntf::notify(const QVector& propertyNames) emit propertyesChanged(propertyNames); } -SelectionMarker::SelectionMarker(QGraphicsItem *parent)//, QGraphicsScene *scene) - : Marker(parent) -{ - setAcceptHoverEvents(true); -} - -void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - BaseDesignIntf* baseItem = dynamic_cast(parentItem()); - if(baseItem) baseItem->hoverMoveEvent(event); -} - -void SelectionMarker::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - BaseDesignIntf* baseItem = dynamic_cast(parentItem()); - if (baseItem) baseItem->hoverLeaveEvent(event); -} - -void SelectionMarker::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - BaseDesignIntf* baseItem = dynamic_cast(parentItem()); - if (baseItem) baseItem->hoverEnterEvent(event); -} - -void SelectionMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - parentItem()->setSelected(true); - BaseDesignIntf* baseItem = dynamic_cast(parentItem()); - if(baseItem) baseItem->mousePressEvent(event); - QGraphicsItem::mousePressEvent(event); -} - -void SelectionMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - BaseDesignIntf* baseItem = dynamic_cast(parentItem()); - if(baseItem) baseItem->mouseReleaseEvent(event); -} - -void SelectionMarker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -{ - BaseDesignIntf* baseItem = dynamic_cast(parentItem()); - if(baseItem) baseItem->mouseDoubleClickEvent(event); - QGraphicsItem::mouseDoubleClickEvent(event); -} - -void SelectionMarker::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - BaseDesignIntf* baseItem = dynamic_cast(parentItem()); - if(baseItem) baseItem->mouseMoveEvent(event); -} - -QRectF Marker::boundingRect() const -{ - return m_rect.adjusted(-15,-15,15,15); -} - -void Marker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - QPen pen; - const int markerSize = Const::RESIZE_HANDLE_SIZE; - pen.setColor(color()); - pen.setWidth(2); - pen.setStyle(Qt::DotLine); - painter->setPen(pen); - painter->setOpacity(Const::SELECTION_COLOR_OPACITY); - painter->drawRect(rect()); - painter->setBrush(color()); - painter->setPen(Qt::transparent); - painter->setOpacity(1); - painter->drawRect(QRectF(-markerSize,-markerSize,markerSize*2,markerSize*2)); - painter->drawRect(QRectF(rect().right()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2)); - painter->drawRect(QRectF(rect().right()-markerSize,rect().top()-markerSize,markerSize*2,markerSize*2)); - painter->drawRect(QRectF(rect().left()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2)); - painter->drawRect(QRectF(rect().left()-markerSize, - rect().bottom()-rect().height()/2-markerSize,markerSize*2,markerSize*2)); - painter->drawRect(QRectF(rect().right()-markerSize, - rect().bottom()-rect().height()/2-markerSize,markerSize*2,markerSize*2)); - painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize, - rect().top()-markerSize,markerSize*2,markerSize*2)); - painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize, - rect().bottom()-markerSize,markerSize*2,markerSize*2)); -} - -QRectF Marker::rect() const -{ - return m_rect; -} - -QColor Marker::color() const -{ - return m_color; -} - -BaseDesignIntf *Marker::object() const -{ - return m_object; -} QMap BaseDesignIntf::getStringForTranslation(){ return QMap(); diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 9b7d599..becf95a 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -47,37 +47,6 @@ enum ItemModes{ DesignMode=1, PreviewMode=2, PrintMode=4, EditMode=8, LayoutEdit class ReportEnginePrivate; class PageDesignIntf; -class BaseDesignIntf; - -class Marker : public QGraphicsItem{ -public: - Marker(QGraphicsItem* parent=0):QGraphicsItem(parent),m_object(NULL){} - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *); - void setRect(QRectF rect){prepareGeometryChange();m_rect=rect;} - void setColor(QColor color){m_color=color;} - QRectF rect() const; - QColor color() const; - BaseDesignIntf *object() const; -private: - QRectF m_rect; - QColor m_color; - BaseDesignIntf* m_object; -}; - -class SelectionMarker : public Marker{ -public: - SelectionMarker(QGraphicsItem* parent=0); -protected: - void hoverMoveEvent(QGraphicsSceneHoverEvent *event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); -}; - class DataSourceManager; class ReportRender; @@ -334,7 +303,7 @@ protected: void drawDesignModeBorder(QPainter* painter, QRectF rect) const; void drawRenderModeBorder(QPainter *painter, QRectF rect) const; void drawResizeZone(QPainter*); - void drawSelection(QPainter* painter, QRectF) const; + void drawMarker(QPainter* painter, QColor color) const; void drawPinArea(QPainter* painter) const; void initResizeZones(); @@ -361,12 +330,10 @@ protected: qreal calcAbsolutePosX(qreal currentOffset, BaseDesignIntf* item); private: - void updateSelectionMarker(); int resizeDirectionFlags(QPointF position); void moveSelectedItems(QPointF delta); Qt::CursorShape getPossibleCursor(int cursorFlags); void updatePossibleDirectionFlags(); - void turnOnSelectionMarker(bool value); private: QPointF m_startPos; int m_resizeHandleSize; @@ -401,8 +368,6 @@ private: ItemMode m_itemMode; ObjectState m_objectState; - SelectionMarker* m_selectionMarker; - Marker* m_joinMarker; BrushStyle m_backgroundBrushStyle; QColor m_backgroundColor; @@ -419,6 +384,7 @@ private: bool m_fillInSecondPass; bool m_watermark; bool m_hovered; + bool m_joinMarkerOn; signals: void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void posChanging(QObject* object, QPointF newPos, QPointF oldPos); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 1bb5558..b8a164c 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -339,6 +339,15 @@ void PageDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event) qreal posY = div(pageItem()->mapFromScene(event->scenePos()).y(), verticalGridStep()).quot * verticalGridStep(); qreal posX = div(pageItem()->mapFromScene(event->scenePos()).x(), verticalGridStep()).quot * horizontalGridStep(); m_itemInsertRect->setPos(posX,posY); + if (magneticMovement()){ + rectMoved( + QRectF(m_itemInsertRect->pos().x(), + m_itemInsertRect->pos().y(), + m_itemInsertRect->boundingRect().width(), + m_itemInsertRect->boundingRect().height() + ) + ); + } } else { if (m_insertMode) m_itemInsertRect->setVisible(false); } @@ -1102,9 +1111,53 @@ void PageDesignIntf::endUpdate() emit pageUpdateFinished(this); } + +void PageDesignIntf::activateItemToJoin(QRectF itemRect, QList& items){ + QRectF r1(itemRect.x(), itemRect.y()-50, itemRect.width(), itemRect.height()+100); + QRectF r2(itemRect.x()-50, itemRect.y(), itemRect.width()+100, itemRect.height()); + qreal maxSquare = 0; + + if (m_joinItem) { + m_joinItem->turnOnJoinMarker(false); + m_joinItem = 0; + } + + foreach(ItemProjections p, items){ + qreal tmpSquare = qMax(p.square(r1)/itemRect.width(),p.square(r2)/itemRect.height()); + if (tmpSquare>maxSquare) { + maxSquare = tmpSquare; + m_joinItem = p.item(); + if (p.square(r1)/itemRect.width() > p.square(r2) / itemRect.height()) + m_joinType = Width; + else + m_joinType = Height; + } + } + + if (m_joinItem) m_joinItem->turnOnJoinMarker(true); +} + +void PageDesignIntf::rectMoved(QRectF itemRect, BaseDesignIntf* container){ + if (!container){ + container = bandAt(QPointF(itemRect.topLeft())); + if (!container) container = this->pageItem(); + } + + if (container){ + m_projections.clear(); + foreach(BaseDesignIntf* bi, container->childBaseItems()){ + m_projections.append(ItemProjections(bi)); + } + } + + activateItemToJoin(itemRect, m_projections); + +} + void PageDesignIntf::itemMoved(BaseDesignIntf *item) { if (m_movedItem!=item){ + m_movedItem = item; BaseDesignIntf* curItem = dynamic_cast(item->parentItem()); ; while (curItem){ m_movedItemContainer = dynamic_cast(curItem); @@ -1122,28 +1175,29 @@ void PageDesignIntf::itemMoved(BaseDesignIntf *item) } } - QRectF r1(item->pos().x(),item->pos().y()-50,item->width(),item->height()+100); - QRectF r2(item->pos().x()-50,item->pos().y(),item->width()+100,item->height()); - qreal maxSquare = 0; + activateItemToJoin(item->geometry(), m_projections); +// QRectF r1(item->pos().x(),item->pos().y()-50,item->width(),item->height()+100); +// QRectF r2(item->pos().x()-50,item->pos().y(),item->width()+100,item->height()); +// qreal maxSquare = 0; - if (m_joinItem) { - m_joinItem->turnOnJoinMarker(false); - m_joinItem = 0; - } +// if (m_joinItem) { +// m_joinItem->turnOnJoinMarker(false); +// m_joinItem = 0; +// } - foreach(ItemProjections p, m_projections){ - qreal tmpSquare = qMax(p.square(r1)/item->width(),p.square(r2)/item->height()); - if (tmpSquare>maxSquare) { - maxSquare = tmpSquare; - m_joinItem = p.item(); - if (p.square(r1)/item->width()>p.square(r2)/item->height()) - m_joinType = Width; - else - m_joinType = Height; - } - } +// foreach(ItemProjections p, m_projections){ +// qreal tmpSquare = qMax(p.square(r1)/item->width(),p.square(r2)/item->height()); +// if (tmpSquare>maxSquare) { +// maxSquare = tmpSquare; +// m_joinItem = p.item(); +// if (p.square(r1)/item->width()>p.square(r2)/item->height()) +// m_joinType = Width; +// else +// m_joinType = Height; +// } +// } - if (m_joinItem) m_joinItem->turnOnJoinMarker(true); +// if (m_joinItem) m_joinItem->turnOnJoinMarker(true); } diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h index 901ddbc..49f8031 100644 --- a/limereport/lrpagedesignintf.h +++ b/limereport/lrpagedesignintf.h @@ -166,6 +166,7 @@ namespace LimeReport { bool isUpdating(){return m_updating;} void endUpdate(); + void rectMoved(QRectF itemRect, BaseDesignIntf* container = 0); void itemMoved(BaseDesignIntf* item); bool magneticMovement() const; void setMagneticMovement(bool magneticMovement); @@ -175,6 +176,7 @@ namespace LimeReport { void setPropertyToSelectedItems(const char *name, const QVariant &value); + protected: virtual void keyPressEvent(QKeyEvent *event); @@ -272,7 +274,7 @@ namespace LimeReport { const QVariant& oldPropertyValue, const QVariant& newPropertyValue); void changeSelectedGroupProperty(const QString& name,const QVariant& value); - + void activateItemToJoin(QRectF itemRect, QList& items); private: enum JoinType{Width, Height}; LimeReport::PageItemDesignIntf::Ptr m_pageItem; @@ -312,6 +314,7 @@ namespace LimeReport { JoinType m_joinType; bool m_magneticMovement; ReportSettings* m_reportSettings; + }; class AbstractPageCommand : public CommandIf{ diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index c3ad3cb..d0f949e 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -479,7 +479,7 @@ void PageItemDesignIntf::relocateBands() { if (isLoading()) return; - int bandSpace = (itemMode() & DesignMode)?4:0; + int bandSpace = (itemMode() & DesignMode)?0:0; QVector posByColumn; From 1c2aed14f49835f2cf07d6c305943e19fb33bf7c Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 27 Feb 2019 22:34:34 +0300 Subject: [PATCH 06/10] TableBuilder has been fixed --- limereport/lrscriptenginemanager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 2689501..f6197e9 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -1881,6 +1881,7 @@ QObject* TableBuilder::addRow() checkBaseLayout(); if (m_baseLayout && m_patternLayout){ HorizontalLayout* newRow = new HorizontalLayout(m_baseLayout, m_baseLayout); + newRow->setLayoutSpacing(m_horizontalLayout->layoutSpacing()); for(int i = 0; i < m_horizontalLayout->childrenCount(); ++i){ BaseDesignIntf* item = dynamic_cast(m_patternLayout->at(i)); BaseDesignIntf* cloneItem = item->cloneItem(item->itemMode(), newRow, newRow); From 8c278f847302ae9d9e965b9a4ac0b327c302affc Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Thu, 28 Feb 2019 12:28:38 +0300 Subject: [PATCH 07/10] common.pri has been changed --- common.pri | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common.pri b/common.pri index dca1d40..ddf7199 100644 --- a/common.pri +++ b/common.pri @@ -132,7 +132,7 @@ TRANSLATIONS_PATH = $$PWD/translations greaterThan(QT_MAJOR_VERSION, 4) { DEFINES *= HAVE_QT5 - QT *= printsupport widgets qml + QT *= printsupport widgets contains(QT,uitools){ message(uitools) DEFINES *= HAVE_UI_LOADER @@ -140,6 +140,7 @@ greaterThan(QT_MAJOR_VERSION, 4) { contains(CONFIG, qjsengine){ message(qjsengine) DEFINES *= USE_QJSENGINE + QT *= qml } } From 1bb6fc8f5a8bab925b398392071b7b1aef0e7077 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 1 Mar 2019 02:47:19 +0300 Subject: [PATCH 08/10] Band marker has been refactored Selection & join markers have been returned back --- limereport/lrbanddesignintf.cpp | 37 ++++++++- limereport/lrbanddesignintf.h | 6 +- limereport/lrbasedesignintf.cpp | 129 ++++++++++++++++++++++++++++---- limereport/lrbasedesignintf.h | 35 ++++++++- 4 files changed, 188 insertions(+), 19 deletions(-) diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 94dc795..f4a0038 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -39,7 +39,9 @@ namespace LimeReport { BandMarker::BandMarker(BandDesignIntf *band, QGraphicsItem* parent) :QGraphicsItem(parent),m_rect(0,0,30,30),m_band(band) -{} +{ + setAcceptHoverEvents(true); +} QRectF BandMarker::boundingRect() const { @@ -52,6 +54,13 @@ void BandMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem* /**opt painter->setOpacity(Const::BAND_MARKER_OPACITY); painter->fillRect(boundingRect(),m_color); painter->setOpacity(1); + painter->setPen(QPen(QBrush(Qt::white),2)); + painter->fillRect(QRectF( + boundingRect().bottomLeft().x(), + boundingRect().bottomLeft().y()-4, + boundingRect().width(),4), Qt::white + ); + painter->setRenderHint(QPainter::Antialiasing); qreal size = (boundingRect().width()setBrush(LimeReport::Const::SELECTION_COLOR); painter->drawEllipse(r.adjusted(7,7,-7,-7)); } + painter->restore(); } @@ -104,6 +114,31 @@ void BandMarker::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) m_band->contextMenuEvent(event); } +void BandMarker::hoverMoveEvent(QGraphicsSceneHoverEvent* event) +{ + if (QRectF(0, height()-10, width(), 10).contains(event->pos())){ + setCursor(Qt::SizeVerCursor); + } else { + unsetCursor(); + } +} + +void BandMarker::mouseMoveEvent(QGraphicsSceneMouseEvent* event) +{ + qreal delta = event->pos().y() - event->lastPos().y(); + if (hasCursor()){ + m_band->setHeight(m_band->height() + delta); + } else { + if (!m_band->isFixedPos()) + m_band->setItemPos(QPointF(m_band->pos().x(),m_band->pos().y()+delta)); + } +} + +void BandMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) +{ + m_band->posChanged(m_band, m_band->pos(), m_band->pos()); +} + BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, QObject* owner, QGraphicsItem *parent) : ItemsContainerDesignInft(xmlTypeName, owner,parent), m_bandType(bandType), diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 193cf9c..33bca63 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -62,8 +62,12 @@ public: qreal width(){return m_rect.width();} qreal height(){return m_rect.height();} protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mousePressEvent(QGraphicsSceneMouseEvent *event); void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); + + void hoverMoveEvent(QGraphicsSceneHoverEvent* event); + void mouseMoveEvent(QGraphicsSceneMouseEvent* event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); private: QRectF m_rect; QColor m_color; diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 55aed88..efebfd8 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -81,7 +81,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q m_fillInSecondPass(false), m_watermark(false), m_hovered(false), - m_joinMarkerOn(false) + m_joinMarkerOn(false), + m_selectionMarker(0) { setGeometry(QRectF(0, 0, m_width, m_height)); if (BaseDesignIntf *item = dynamic_cast(parent)) { @@ -104,8 +105,7 @@ QRectF BaseDesignIntf::boundingRect() const } BaseDesignIntf::~BaseDesignIntf(void) { - //delete m_selectionMarker; - //delete m_joinMarker; + } void BaseDesignIntf::setParentReportItem(const QString &value) @@ -393,8 +393,8 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o ppainter->save(); setupPainter(ppainter); drawBorder(ppainter, rect()); - if (m_joinMarkerOn) { drawMarker(ppainter, Const::JOIN_COLOR);} - if (isSelected() && !m_joinMarkerOn) {drawMarker(ppainter, Const::SELECTION_COLOR);} +// if (m_joinMarkerOn) { drawMarker(ppainter, Const::JOIN_COLOR);} +// if (isSelected() && !m_joinMarkerOn) {drawMarker(ppainter, Const::SELECTION_COLOR);} drawResizeZone(ppainter); ppainter->restore(); // if (m_hovered) ppainter->drawImage( @@ -677,16 +677,15 @@ QPointF BaseDesignIntf::modifyPosForAlignedItem(const QPointF& pos){ void BaseDesignIntf::turnOnJoinMarker(bool value) { m_joinMarkerOn = value; - update(); -// if (value){ -// m_joinMarker = new Marker(this); -// m_joinMarker->setColor(Const::JOIN_COLOR); -// m_joinMarker->setRect(rect()); -// m_joinMarker->setVisible(true); -// } else { -// delete m_joinMarker; -// m_joinMarker = 0; -// } + if (value){ + m_joinMarker = new Marker(this, this); + m_joinMarker->setColor(Const::JOIN_COLOR); + m_joinMarker->setRect(rect()); + m_joinMarker->setVisible(true); + } else { + delete m_joinMarker; + m_joinMarker = 0; + } } void BaseDesignIntf::updateItemAlign(){ @@ -750,6 +749,31 @@ void BaseDesignIntf::setWatermark(bool watermark) } } +void BaseDesignIntf::updateSelectionMarker() +{ + if (m_selectionMarker && (itemMode() & DesignMode || itemMode() & EditMode)) { + if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker); + if (parentItem()) { + m_selectionMarker->setRect(rect()); + m_selectionMarker->setPos(0,0); + } + } +} + +void BaseDesignIntf::turnOnSelectionMarker(bool value) +{ + if (value && !m_selectionMarker){ + m_selectionMarker = new SelectionMarker(this, this); + m_selectionMarker->setColor(selectionMarkerColor()); + updateSelectionMarker(); + m_selectionMarker->setVisible(true); + m_selectionMarker->setZValue(10000); + } else { + delete m_selectionMarker; + m_selectionMarker = 0; + } +} + QString BaseDesignIntf::patternName() const { return (m_patternName.isEmpty()) ? objectName() : m_patternName; @@ -979,6 +1003,7 @@ void BaseDesignIntf::setGeometry(QRectF rect) m_leftRect = QRectF(0-resizeHandleSize(), 0-resizeHandleSize(), resizeHandleSize()*2, height()+resizeHandleSize()*2); m_rightRect = QRectF(width() - resizeHandleSize(), 0-resizeHandleSize(), resizeHandleSize()*2, height()+resizeHandleSize()*2); m_boundingRect = QRectF(); + updateSelectionMarker(); if (!isLoading()){ geometryChangedEvent(geometry(), m_oldGeometry); emit geometryChanged(this, geometry(), m_oldGeometry); @@ -1064,9 +1089,11 @@ void BaseDesignIntf::initMode(ItemMode mode) QVariant BaseDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == QGraphicsItem::ItemPositionHasChanged) { + updateSelectionMarker(); } if (change == QGraphicsItem::ItemSelectedChange) { + turnOnSelectionMarker(value.toBool()); emit itemSelectedHasBeenChanged(this, value.toBool()); } if (change == QGraphicsItem::ItemParentHasChanged) { @@ -1179,7 +1206,7 @@ void BaseDesignIntf::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) QRectF newGeometry = geometry(); if (newGeometry != m_oldGeometry) { geometryChangedEvent(newGeometry, m_oldGeometry); - emit(posChanged(this, newGeometry.topLeft(), m_oldGeometry.topLeft())); + emit posChanged(this, newGeometry.topLeft(), m_oldGeometry.topLeft()); } QGraphicsItem::mouseReleaseEvent(event); } @@ -1569,4 +1596,74 @@ void BookmarkContainerDesignIntf::copyBookmarks(BookmarkContainerDesignIntf* sou } } +QRectF Marker::boundingRect() const +{ + return m_rect.adjusted(-15,-15,15,15); +} + +void Marker::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) +{ + QPen pen; + const int markerSize = 5; + pen.setColor(color()); + pen.setWidth(2); + pen.setStyle(Qt::DotLine); + painter->setPen(pen); + painter->setOpacity(Const::SELECTION_COLOR_OPACITY); + painter->drawRect(rect()); + painter->setBrush(color()); + painter->setPen(Qt::transparent); + painter->setOpacity(1); + painter->drawRect(QRectF(-markerSize,-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().right()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().right()-markerSize,rect().top()-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().left()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().left()-markerSize, + rect().bottom()-rect().height()/2-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().right()-markerSize, + rect().bottom()-rect().height()/2-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize, + rect().top()-markerSize,markerSize*2,markerSize*2)); + painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize, + rect().bottom()-markerSize,markerSize*2,markerSize*2)); +} + +SelectionMarker::SelectionMarker(QGraphicsItem* parent, BaseDesignIntf* owner) + : Marker(parent, owner) +{ + setAcceptHoverEvents(true); +} + +void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +{ + if (owner()) owner()->hoverMoveEvent(event); + QGraphicsItem::hoverMoveEvent(event); +} + +void SelectionMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if (owner()){ + owner()->setSelected(true); + owner()->mousePressEvent(event); + } + QGraphicsItem::mousePressEvent(event); +} + +void SelectionMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (owner()) owner()->mouseReleaseEvent(event); +} + +void SelectionMarker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) +{ + if (owner()) owner()->mouseDoubleClickEvent(event); + QGraphicsItem::mouseDoubleClickEvent(event); +} + +void SelectionMarker::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + qDebug() << "mouse move"; + if (owner()) owner()->mouseMoveEvent(event); +} + } //namespace LimeReport diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index becf95a..b3f5b35 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -47,6 +47,35 @@ enum ItemModes{ DesignMode=1, PreviewMode=2, PrintMode=4, EditMode=8, LayoutEdit class ReportEnginePrivate; class PageDesignIntf; +class BaseDesignIntf; + +class Marker : public QGraphicsItem{ +public: + Marker(QGraphicsItem* parent = 0, BaseDesignIntf* owner = 0): QGraphicsItem(parent), m_owner(owner){} + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *); + void setRect(QRectF rect){prepareGeometryChange();m_rect=rect;} + void setColor(QColor color){m_color=color;} + QRectF rect() const {return m_rect;} + QColor color() const {return m_color;} + BaseDesignIntf* owner() const {return m_owner;} +private: + QRectF m_rect; + QColor m_color; + BaseDesignIntf* m_owner; +}; + +class SelectionMarker : public Marker{ +public: + SelectionMarker(QGraphicsItem* parent=0, BaseDesignIntf* owner = 0); +protected: + void hoverMoveEvent(QGraphicsSceneHoverEvent *event); + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); + void mouseMoveEvent(QGraphicsSceneMouseEvent *event); +}; + class DataSourceManager; class ReportRender; @@ -151,6 +180,7 @@ public: virtual QPainterPath shape() const; void setFixedPos(bool fixedPos); + bool isFixedPos(){return m_fixedPos;} int resizeHandleSize() const; void setMMFactor(qreal mmFactor); @@ -252,7 +282,8 @@ public: void setFillInSecondPass(bool fillInSecondPass); bool isWatermark() const; virtual void setWatermark(bool watermark); - + void updateSelectionMarker(); + void turnOnSelectionMarker(bool value); Q_INVOKABLE QString setItemWidth(qreal width); Q_INVOKABLE QString setItemHeight(qreal height); Q_INVOKABLE qreal getItemWidth(); @@ -385,6 +416,8 @@ private: bool m_watermark; bool m_hovered; bool m_joinMarkerOn; + SelectionMarker* m_selectionMarker; + Marker* m_joinMarker; signals: void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void posChanging(QObject* object, QPointF newPos, QPointF oldPos); From ed28faf784d6732043a3f8f8ba2c233fce967341 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 1 Mar 2019 17:32:48 +0300 Subject: [PATCH 09/10] Default band's background filling mode changed to transparent --- limereport/lrbanddesignintf.cpp | 6 ++++-- limereport/lrbasedesignintf.cpp | 15 +++++++++++++-- limereport/lrbasedesignintf.h | 4 ++++ limereport/lrpagedesignintf.cpp | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index f4a0038..9e3323a 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -54,11 +54,11 @@ void BandMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem* /**opt painter->setOpacity(Const::BAND_MARKER_OPACITY); painter->fillRect(boundingRect(),m_color); painter->setOpacity(1); - painter->setPen(QPen(QBrush(Qt::white),2)); + painter->setPen(QPen(QBrush(Qt::lightGray),2)); painter->fillRect(QRectF( boundingRect().bottomLeft().x(), boundingRect().bottomLeft().y()-4, - boundingRect().width(),4), Qt::white + boundingRect().width(),4), Qt::lightGray ); painter->setRenderHint(QPainter::Antialiasing); @@ -175,6 +175,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q if (parentItem) setWidth(parentItem->width()); } + setBackgroundMode(BGMode::TransparentMode); + setFillTransparentInDesignMode(false); setHeight(100); setFixedPos(true); setFlag(QGraphicsItem::ItemClipsChildrenToShape); diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index efebfd8..5426419 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -82,7 +82,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q m_watermark(false), m_hovered(false), m_joinMarkerOn(false), - m_selectionMarker(0) + m_selectionMarker(0), + m_fillTransparentInDesignMode(true) { setGeometry(QRectF(0, 0, m_width, m_height)); if (BaseDesignIntf *item = dynamic_cast(parent)) { @@ -430,7 +431,7 @@ void BaseDesignIntf::prepareRect(QPainter *painter, const QStyleOptionGraphicsIt qreal o = (itemMode() & DesignMode) ? 0.5 : qreal(m_opacity) / 100; painter->setOpacity(o); painter->fillRect(r, brush); - } else if (itemMode() & DesignMode){ + } else if ((itemMode() & DesignMode) && fillTransparentInDesignMode()){ painter->setOpacity(0.1); painter->fillRect(r, QBrush(QPixmap(":/report/images/empty"))); } @@ -721,6 +722,16 @@ void BaseDesignIntf::updatePossibleDirectionFlags(){ } } +bool BaseDesignIntf::fillTransparentInDesignMode() const +{ + return m_fillTransparentInDesignMode; +} + +void BaseDesignIntf::setFillTransparentInDesignMode(bool fillTransparentInDesignMode) +{ + m_fillTransparentInDesignMode = fillTransparentInDesignMode; +} + bool BaseDesignIntf::fillInSecondPass() const { return m_fillInSecondPass; diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index b3f5b35..6209b97 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -295,6 +295,9 @@ public: Q_INVOKABLE QString setItemPosX(qreal xValue); Q_INVOKABLE QString setItemPosY(qreal yValue); + bool fillTransparentInDesignMode() const; + void setFillTransparentInDesignMode(bool fillTransparentInDesignMode); + protected: //ICollectionContainer @@ -418,6 +421,7 @@ private: bool m_joinMarkerOn; SelectionMarker* m_selectionMarker; Marker* m_joinMarker; + bool m_fillTransparentInDesignMode; signals: void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void posChanging(QObject* object, QPointF newPos, QPointF oldPos); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index b8a164c..0e039d8 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -2481,7 +2481,7 @@ CommandIf::Ptr BandMoveFromToCommand::create(PageDesignIntf* page, int from, int bool BandMoveFromToCommand::doIt() { - if (page() && from != to) { + if (page() && page()->pageItem() && from != to) { page()->pageItem()->moveBandFromTo(from, to); return true; } From 76d542ce761b9693ffab4fd4e49dccf5b9392e0e Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 1 Mar 2019 17:44:49 +0300 Subject: [PATCH 10/10] Selection marker has been fixed --- limereport/lrbasedesignintf.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 5426419..e70199b 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -778,7 +778,6 @@ void BaseDesignIntf::turnOnSelectionMarker(bool value) m_selectionMarker->setColor(selectionMarkerColor()); updateSelectionMarker(); m_selectionMarker->setVisible(true); - m_selectionMarker->setZValue(10000); } else { delete m_selectionMarker; m_selectionMarker = 0;