Init commit

This commit is contained in:
Arin Alexander 2019-02-25 16:22:10 +03:00
parent 9bd392f4ac
commit 005e65f3e3
8 changed files with 93 additions and 22 deletions

View File

@ -52,8 +52,8 @@ namespace LimeReport {
namespace Const{ namespace Const{
int const RESIZE_HANDLE_SIZE = 10; int const RESIZE_HANDLE_SIZE = 5;
int const SELECTION_PEN_SIZE = 4; int const SELECTION_PEN_SIZE = 1;
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE; int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE; int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE;
double const RESIZE_ZONE_OPACITY = 0.5; double const RESIZE_ZONE_OPACITY = 0.5;

View File

@ -304,6 +304,12 @@ bool BandDesignIntf::isUnique() const
return true; return true;
} }
void BandDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode)
{
ItemsContainerDesignInft::setItemMode(mode);
updateBandMarkerGeometry();
}
QString BandDesignIntf::datasourceName(){ QString BandDesignIntf::datasourceName(){
return m_dataSourceName; return m_dataSourceName;
} }
@ -728,14 +734,19 @@ BandDesignIntf* BandDesignIntf::findParentBand()
return 0; return 0;
} }
void BandDesignIntf::geometryChangedEvent(QRectF, QRectF ) void BandDesignIntf::updateBandMarkerGeometry()
{ {
if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){ if (parentItem() && m_bandMarker){
QPointF sp = parentItem()->mapToScene(pos()); QPointF sp = parentItem()->mapToScene(pos());
if (m_bandMarker){
m_bandMarker->setPos((sp.x()-m_bandMarker->boundingRect().width()),sp.y()); m_bandMarker->setPos((sp.x()-m_bandMarker->boundingRect().width()),sp.y());
m_bandMarker->setHeight(rect().height()); m_bandMarker->setHeight(rect().height());
} }
}
void BandDesignIntf::geometryChangedEvent(QRectF, QRectF )
{
if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){
updateBandMarkerGeometry();
} }
foreach (BaseDesignIntf* item, childBaseItems()) { foreach (BaseDesignIntf* item, childBaseItems()) {
if (item->itemAlign()!=DesignedItemAlign){ if (item->itemAlign()!=DesignedItemAlign){

View File

@ -142,6 +142,7 @@ public:
virtual QString bandTitle() const; virtual QString bandTitle() const;
virtual QIcon bandIcon() const; virtual QIcon bandIcon() const;
virtual bool isUnique() const; virtual bool isUnique() const;
void setItemMode(BaseDesignIntf::ItemMode mode);
void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0); void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0);
void restoreItems(); void restoreItems();
void recalcItems(DataSourceManager* dataManager); void recalcItems(DataSourceManager* dataManager);
@ -250,6 +251,8 @@ public:
void setBackgroundOpacity(int value); void setBackgroundOpacity(int value);
int bootomSpace() const; int bootomSpace() const;
void setBootomSpace(int bootomSpace); void setBootomSpace(int bootomSpace);
void updateBandMarkerGeometry();
signals: signals:
void bandRendered(BandDesignIntf* band); void bandRendered(BandDesignIntf* band);
void preparedForRender(); void preparedForRender();

View File

@ -81,7 +81,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
m_patternName(""), m_patternName(""),
m_patternItem(0), m_patternItem(0),
m_fillInSecondPass(false), m_fillInSecondPass(false),
m_watermark(false) m_watermark(false),
m_hovered(false)
{ {
setGeometry(QRectF(0, 0, m_width, m_height)); setGeometry(QRectF(0, 0, m_width, m_height));
if (BaseDesignIntf *item = dynamic_cast<BaseDesignIntf *>(parent)) { if (BaseDesignIntf *item = dynamic_cast<BaseDesignIntf *>(parent)) {
@ -104,7 +105,7 @@ QRectF BaseDesignIntf::boundingRect() const
} }
BaseDesignIntf::~BaseDesignIntf(void) { BaseDesignIntf::~BaseDesignIntf(void) {
delete m_selectionMarker; //delete m_selectionMarker;
delete m_joinMarker; delete m_joinMarker;
} }
@ -394,6 +395,9 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
drawBorder(ppainter, rect()); drawBorder(ppainter, rect());
if (isSelected()) {drawSelection(ppainter, rect());} if (isSelected()) {drawSelection(ppainter, rect());}
drawResizeZone(ppainter); 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){ QColor calcColor(QColor color){
@ -480,6 +484,14 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
m_resizeDirectionFlags = 0; m_resizeDirectionFlags = 0;
scene()->update(sceneBoundingRect()); scene()->update(sceneBoundingRect());
m_resizeAreas.clear(); 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){ if (value && !m_selectionMarker){
m_selectionMarker = new SelectionMarker(this); m_selectionMarker = new SelectionMarker(this);
m_selectionMarker->setColor(selectionMarkerColor()); m_selectionMarker->setColor(selectionMarkerColor());
m_selectionMarker->setZValue(zValue()-1);
updateSelectionMarker(); updateSelectionMarker();
m_selectionMarker->setVisible(true); m_selectionMarker->setVisible(true);
} else { } 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->drawLine(rect.right(),rect.bottom()-m_resizeHandleSize,rect.right(),rect.bottom());
// painter->setOpacity(Consts::SELECTION_COLOR_OPACITY); // painter->setOpacity(Consts::SELECTION_COLOR_OPACITY);
// painter->fillRect(rect,selectionColor()); // 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(); painter->restore();
} }
@ -1298,13 +1333,13 @@ void BaseDesignIntf::setMarginSize(int value)
void BaseDesignIntf::updateSelectionMarker() void BaseDesignIntf::updateSelectionMarker()
{ {
if (m_selectionMarker && (itemMode() & DesignMode || itemMode() & EditMode)) { // if (m_selectionMarker && (itemMode() & DesignMode || itemMode() & EditMode)) {
if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker); // if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker);
if (parentItem()) { // if (parentItem()) {
m_selectionMarker->setRect(rect()); // m_selectionMarker->setRect(rect());
m_selectionMarker->setPos(0,0); // m_selectionMarker->setPos(0,0);
} // }
} // }
} }
void BaseDesignIntf::drawResizeZone(QPainter* /*painter*/) void BaseDesignIntf::drawResizeZone(QPainter* /*painter*/)
@ -1561,6 +1596,18 @@ void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
if(baseItem) baseItem->hoverMoveEvent(event); if(baseItem) baseItem->hoverMoveEvent(event);
} }
void SelectionMarker::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
if (baseItem) baseItem->hoverLeaveEvent(event);
}
void SelectionMarker::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
if (baseItem) baseItem->hoverEnterEvent(event);
}
void SelectionMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) void SelectionMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
parentItem()->setSelected(true); parentItem()->setSelected(true);
@ -1596,7 +1643,7 @@ QRectF Marker::boundingRect() const
void Marker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) void Marker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{ {
QPen pen; QPen pen;
const int markerSize = 5; const int markerSize = Const::RESIZE_HANDLE_SIZE;
pen.setColor(color()); pen.setColor(color());
pen.setWidth(2); pen.setWidth(2);
pen.setStyle(Qt::DotLine); pen.setStyle(Qt::DotLine);

View File

@ -70,6 +70,8 @@ public:
SelectionMarker(QGraphicsItem* parent=0); SelectionMarker(QGraphicsItem* parent=0);
protected: protected:
void hoverMoveEvent(QGraphicsSceneHoverEvent *event); void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
@ -204,7 +206,7 @@ public:
void setItemPos(const QPointF &newPos); void setItemPos(const QPointF &newPos);
void setItemPos(qreal x, qreal y); 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;} ItemMode itemMode() const {return m_itemMode;}
virtual void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags); virtual void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags);
@ -305,10 +307,11 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event); void mousePressEvent(QGraphicsSceneMouseEvent* event);
void hoverMoveEvent(QGraphicsSceneHoverEvent* event); void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
//void virtual hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
virtual void geometryChangedEvent(QRectF newRect, QRectF oldRect); virtual void geometryChangedEvent(QRectF newRect, QRectF oldRect);
@ -415,7 +418,7 @@ private:
BaseDesignIntf* m_patternItem; BaseDesignIntf* m_patternItem;
bool m_fillInSecondPass; bool m_fillInSecondPass;
bool m_watermark; bool m_watermark;
bool m_hovered;
signals: signals:
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
void posChanging(QObject* object, QPointF newPos, QPointF oldPos); void posChanging(QObject* object, QPointF newPos, QPointF oldPos);

View File

@ -52,8 +52,8 @@ namespace LimeReport {
namespace Const{ namespace Const{
int const RESIZE_HANDLE_SIZE = 10; int const RESIZE_HANDLE_SIZE = 5;
int const SELECTION_PEN_SIZE = 4; int const SELECTION_PEN_SIZE = 1;
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE; int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE; int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE;
double const RESIZE_ZONE_OPACITY = 0.5; double const RESIZE_ZONE_OPACITY = 0.5;

View File

@ -164,6 +164,12 @@ QRectF PageItemDesignIntf::boundingRect() const
} }
} }
void PageItemDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode)
{
ItemsContainerDesignInft::setItemMode(mode);
relocateBands();
}
void PageItemDesignIntf::clear() void PageItemDesignIntf::clear()
{ {
foreach(QGraphicsItem* item, childItems()){ foreach(QGraphicsItem* item, childItems()){

View File

@ -90,6 +90,7 @@ public:
virtual QColor pageBorderColor() const; virtual QColor pageBorderColor() const;
virtual QColor gridColor() const; virtual QColor gridColor() const;
virtual QRectF boundingRect() const; virtual QRectF boundingRect() const;
void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode);
void clear(); void clear();
const BandsList& childBands() const {return m_bands;} const BandsList& childBands() const {return m_bands;}
BandDesignIntf * bandByType(BandDesignIntf::BandsType bandType) const; BandDesignIntf * bandByType(BandDesignIntf::BandsType bandType) const;