mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 12:34:39 +03:00
Finish selection_and_preview_refactoring
This commit is contained in:
commit
8854f59916
@ -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;
|
||||||
|
@ -39,7 +39,9 @@ namespace LimeReport {
|
|||||||
|
|
||||||
BandMarker::BandMarker(BandDesignIntf *band, QGraphicsItem* parent)
|
BandMarker::BandMarker(BandDesignIntf *band, QGraphicsItem* parent)
|
||||||
:QGraphicsItem(parent),m_rect(0,0,30,30),m_band(band)
|
:QGraphicsItem(parent),m_rect(0,0,30,30),m_band(band)
|
||||||
{}
|
{
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
QRectF BandMarker::boundingRect() const
|
QRectF BandMarker::boundingRect() const
|
||||||
{
|
{
|
||||||
@ -52,6 +54,13 @@ void BandMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem* /**opt
|
|||||||
painter->setOpacity(Const::BAND_MARKER_OPACITY);
|
painter->setOpacity(Const::BAND_MARKER_OPACITY);
|
||||||
painter->fillRect(boundingRect(),m_color);
|
painter->fillRect(boundingRect(),m_color);
|
||||||
painter->setOpacity(1);
|
painter->setOpacity(1);
|
||||||
|
painter->setPen(QPen(QBrush(Qt::lightGray),2));
|
||||||
|
painter->fillRect(QRectF(
|
||||||
|
boundingRect().bottomLeft().x(),
|
||||||
|
boundingRect().bottomLeft().y()-4,
|
||||||
|
boundingRect().width(),4), Qt::lightGray
|
||||||
|
);
|
||||||
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
qreal size = (boundingRect().width()<boundingRect().height()) ? boundingRect().width() : boundingRect().height();
|
qreal size = (boundingRect().width()<boundingRect().height()) ? boundingRect().width() : boundingRect().height();
|
||||||
QRectF r = QRectF(0,0,size,size);
|
QRectF r = QRectF(0,0,size,size);
|
||||||
@ -62,6 +71,7 @@ void BandMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem* /**opt
|
|||||||
painter->setBrush(LimeReport::Const::SELECTION_COLOR);
|
painter->setBrush(LimeReport::Const::SELECTION_COLOR);
|
||||||
painter->drawEllipse(r.adjusted(7,7,-7,-7));
|
painter->drawEllipse(r.adjusted(7,7,-7,-7));
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +114,31 @@ void BandMarker::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||||||
m_band->contextMenuEvent(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) :
|
BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, QObject* owner, QGraphicsItem *parent) :
|
||||||
ItemsContainerDesignInft(xmlTypeName, owner,parent),
|
ItemsContainerDesignInft(xmlTypeName, owner,parent),
|
||||||
m_bandType(bandType),
|
m_bandType(bandType),
|
||||||
@ -140,6 +175,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
|
|||||||
if (parentItem) setWidth(parentItem->width());
|
if (parentItem) setWidth(parentItem->width());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setBackgroundMode(BGMode::TransparentMode);
|
||||||
|
setFillTransparentInDesignMode(false);
|
||||||
setHeight(100);
|
setHeight(100);
|
||||||
setFixedPos(true);
|
setFixedPos(true);
|
||||||
setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
||||||
@ -304,6 +341,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 +771,19 @@ BandDesignIntf* BandDesignIntf::findParentBand()
|
|||||||
return 0;
|
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 )
|
void BandDesignIntf::geometryChangedEvent(QRectF, QRectF )
|
||||||
{
|
{
|
||||||
if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){
|
if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){
|
||||||
QPointF sp = parentItem()->mapToScene(pos());
|
updateBandMarkerGeometry();
|
||||||
if (m_bandMarker){
|
|
||||||
m_bandMarker->setPos((sp.x()-m_bandMarker->boundingRect().width()),sp.y());
|
|
||||||
m_bandMarker->setHeight(rect().height());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||||
if (item->itemAlign()!=DesignedItemAlign){
|
if (item->itemAlign()!=DesignedItemAlign){
|
||||||
|
@ -62,8 +62,12 @@ public:
|
|||||||
qreal width(){return m_rect.width();}
|
qreal width(){return m_rect.width();}
|
||||||
qreal height(){return m_rect.height();}
|
qreal height(){return m_rect.height();}
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||||
|
|
||||||
|
void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
|
||||||
|
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
private:
|
private:
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
QColor m_color;
|
QColor m_color;
|
||||||
@ -142,6 +146,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 +255,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();
|
||||||
|
@ -52,7 +52,7 @@ namespace LimeReport
|
|||||||
|
|
||||||
BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, QGraphicsItem *parent) :
|
BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, QGraphicsItem *parent) :
|
||||||
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_selectionPenSize(Const::SELECTION_PEN_SIZE),
|
||||||
m_possibleResizeDirectionFlags(ResizeTop | ResizeBottom | ResizeLeft | ResizeRight),
|
m_possibleResizeDirectionFlags(ResizeTop | ResizeBottom | ResizeLeft | ResizeRight),
|
||||||
m_possibleMoveDirectionFlags(All),
|
m_possibleMoveDirectionFlags(All),
|
||||||
@ -69,8 +69,6 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
|
|||||||
m_storageTypeName(storageTypeName),
|
m_storageTypeName(storageTypeName),
|
||||||
m_itemMode(DesignMode),
|
m_itemMode(DesignMode),
|
||||||
m_objectState(ObjectCreated),
|
m_objectState(ObjectCreated),
|
||||||
m_selectionMarker(0),
|
|
||||||
m_joinMarker(0),
|
|
||||||
m_backgroundBrushStyle(SolidPattern),
|
m_backgroundBrushStyle(SolidPattern),
|
||||||
m_backgroundColor(Qt::white),
|
m_backgroundColor(Qt::white),
|
||||||
m_margin(4),
|
m_margin(4),
|
||||||
@ -81,7 +79,11 @@ 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),
|
||||||
|
m_joinMarkerOn(false),
|
||||||
|
m_selectionMarker(0),
|
||||||
|
m_fillTransparentInDesignMode(true)
|
||||||
{
|
{
|
||||||
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,8 +106,7 @@ QRectF BaseDesignIntf::boundingRect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseDesignIntf::~BaseDesignIntf(void) {
|
BaseDesignIntf::~BaseDesignIntf(void) {
|
||||||
delete m_selectionMarker;
|
|
||||||
delete m_joinMarker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseDesignIntf::setParentReportItem(const QString &value)
|
void BaseDesignIntf::setParentReportItem(const QString &value)
|
||||||
@ -390,10 +391,16 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
ppainter->save();
|
||||||
setupPainter(ppainter);
|
setupPainter(ppainter);
|
||||||
drawBorder(ppainter, rect());
|
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);
|
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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor calcColor(QColor color){
|
QColor calcColor(QColor color){
|
||||||
@ -424,7 +431,7 @@ void BaseDesignIntf::prepareRect(QPainter *painter, const QStyleOptionGraphicsIt
|
|||||||
qreal o = (itemMode() & DesignMode) ? 0.5 : qreal(m_opacity) / 100;
|
qreal o = (itemMode() & DesignMode) ? 0.5 : qreal(m_opacity) / 100;
|
||||||
painter->setOpacity(o);
|
painter->setOpacity(o);
|
||||||
painter->fillRect(r, brush);
|
painter->fillRect(r, brush);
|
||||||
} else if (itemMode() & DesignMode){
|
} else if ((itemMode() & DesignMode) && fillTransparentInDesignMode()){
|
||||||
painter->setOpacity(0.1);
|
painter->setOpacity(0.1);
|
||||||
painter->fillRect(r, QBrush(QPixmap(":/report/images/empty")));
|
painter->fillRect(r, QBrush(QPixmap(":/report/images/empty")));
|
||||||
}
|
}
|
||||||
@ -480,6 +487,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -561,6 +576,7 @@ void BaseDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
moveSelectedItems(tmpPos - pos());
|
moveSelectedItems(tmpPos - pos());
|
||||||
if (page()->selectedItems().count()==1 && (page()->magneticMovement()))
|
if (page()->selectedItems().count()==1 && (page()->magneticMovement()))
|
||||||
page()->itemMoved(this);
|
page()->itemMoved(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -661,8 +677,9 @@ QPointF BaseDesignIntf::modifyPosForAlignedItem(const QPointF& pos){
|
|||||||
|
|
||||||
void BaseDesignIntf::turnOnJoinMarker(bool value)
|
void BaseDesignIntf::turnOnJoinMarker(bool value)
|
||||||
{
|
{
|
||||||
|
m_joinMarkerOn = value;
|
||||||
if (value){
|
if (value){
|
||||||
m_joinMarker = new Marker(this);
|
m_joinMarker = new Marker(this, this);
|
||||||
m_joinMarker->setColor(Const::JOIN_COLOR);
|
m_joinMarker->setColor(Const::JOIN_COLOR);
|
||||||
m_joinMarker->setRect(rect());
|
m_joinMarker->setRect(rect());
|
||||||
m_joinMarker->setVisible(true);
|
m_joinMarker->setVisible(true);
|
||||||
@ -705,17 +722,14 @@ void BaseDesignIntf::updatePossibleDirectionFlags(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseDesignIntf::turnOnSelectionMarker(bool value)
|
bool BaseDesignIntf::fillTransparentInDesignMode() const
|
||||||
{
|
{
|
||||||
if (value && !m_selectionMarker){
|
return m_fillTransparentInDesignMode;
|
||||||
m_selectionMarker = new SelectionMarker(this);
|
}
|
||||||
m_selectionMarker->setColor(selectionMarkerColor());
|
|
||||||
updateSelectionMarker();
|
void BaseDesignIntf::setFillTransparentInDesignMode(bool fillTransparentInDesignMode)
|
||||||
m_selectionMarker->setVisible(true);
|
{
|
||||||
} else {
|
m_fillTransparentInDesignMode = fillTransparentInDesignMode;
|
||||||
delete m_selectionMarker;
|
|
||||||
m_selectionMarker = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseDesignIntf::fillInSecondPass() const
|
bool BaseDesignIntf::fillInSecondPass() const
|
||||||
@ -746,6 +760,30 @@ 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);
|
||||||
|
} else {
|
||||||
|
delete m_selectionMarker;
|
||||||
|
m_selectionMarker = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString BaseDesignIntf::patternName() const
|
QString BaseDesignIntf::patternName() const
|
||||||
{
|
{
|
||||||
return (m_patternName.isEmpty()) ? objectName() : m_patternName;
|
return (m_patternName.isEmpty()) ? objectName() : m_patternName;
|
||||||
@ -1105,20 +1143,32 @@ QPainterPath BaseDesignIntf::shape() const
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseDesignIntf::drawSelection(QPainter *painter, QRectF /*rect*/) const
|
void BaseDesignIntf::drawMarker(QPainter *painter, QColor color) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
// painter->setPen(QPen(Qt::red,m_selectionPenSize));
|
|
||||||
// painter->drawLine(QPointF(m_resizeHandleSize,0),QPointF(0,0));
|
QPen pen(color, m_selectionPenSize);
|
||||||
// painter->drawLine(QPointF(0,m_resizeHandleSize),QPointF(0,0));
|
painter->setPen(pen);
|
||||||
// painter->drawLine(rect.right()-m_resizeHandleSize,0,rect.right(),0);
|
painter->setBrush(QBrush(color));
|
||||||
// painter->drawLine(rect.right(),m_resizeHandleSize,rect.right(),0);
|
painter->setOpacity(1);
|
||||||
// painter->drawLine(0,rect.bottom(),0,rect.bottom()-10);
|
const int markerSize = Const::RESIZE_HANDLE_SIZE;
|
||||||
// painter->drawLine(0,rect.bottom(),m_resizeHandleSize,rect.bottom());
|
painter->drawRect(QRectF(-markerSize,-markerSize,markerSize*2,markerSize*2));
|
||||||
// painter->drawLine(rect.right()-m_resizeHandleSize,rect.bottom(),rect.right(),rect.bottom());
|
painter->drawRect(QRectF(rect().right()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2));
|
||||||
// painter->drawLine(rect.right(),rect.bottom()-m_resizeHandleSize,rect.right(),rect.bottom());
|
painter->drawRect(QRectF(rect().right()-markerSize,rect().top()-markerSize,markerSize*2,markerSize*2));
|
||||||
// painter->setOpacity(Consts::SELECTION_COLOR_OPACITY);
|
painter->drawRect(QRectF(rect().left()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2));
|
||||||
// painter->fillRect(rect,selectionColor());
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1166,8 +1216,7 @@ void BaseDesignIntf::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
QRectF newGeometry = geometry();
|
QRectF newGeometry = geometry();
|
||||||
if (newGeometry != m_oldGeometry) {
|
if (newGeometry != m_oldGeometry) {
|
||||||
geometryChangedEvent(newGeometry, m_oldGeometry);
|
geometryChangedEvent(newGeometry, m_oldGeometry);
|
||||||
updateSelectionMarker();
|
emit posChanged(this, newGeometry.topLeft(), m_oldGeometry.topLeft());
|
||||||
emit(posChanged(this, newGeometry.topLeft(), m_oldGeometry.topLeft()));
|
|
||||||
}
|
}
|
||||||
QGraphicsItem::mouseReleaseEvent(event);
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
@ -1296,17 +1345,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*/)
|
void BaseDesignIntf::drawResizeZone(QPainter* /*painter*/)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1549,43 +1587,23 @@ void BaseDesignIntf::notify(const QVector<QString>& propertyNames)
|
|||||||
emit propertyesChanged(propertyNames);
|
emit propertyesChanged(propertyNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectionMarker::SelectionMarker(QGraphicsItem *parent)//, QGraphicsScene *scene)
|
|
||||||
: Marker(parent)
|
QMap<QString, QString> BaseDesignIntf::getStringForTranslation(){
|
||||||
{
|
return QMap<QString,QString>();
|
||||||
setAcceptHoverEvents(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
QVariant BookmarkContainerDesignIntf::getBookMark(const QString& key)
|
||||||
{
|
{
|
||||||
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
|
if (m_bookmarks.contains(key))
|
||||||
if(baseItem) baseItem->hoverMoveEvent(event);
|
return m_bookmarks.value(key);
|
||||||
|
else return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void BookmarkContainerDesignIntf::copyBookmarks(BookmarkContainerDesignIntf* source)
|
||||||
{
|
{
|
||||||
parentItem()->setSelected(true);
|
foreach(QString key, source->bookmarks()){
|
||||||
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
|
addBookmark(key,source->getBookMark(key));
|
||||||
if(baseItem) baseItem->mousePressEvent(event);
|
}
|
||||||
QGraphicsItem::mousePressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SelectionMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
|
|
||||||
if(baseItem) baseItem->mouseReleaseEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SelectionMarker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
|
|
||||||
if(baseItem) baseItem->mouseDoubleClickEvent(event);
|
|
||||||
QGraphicsItem::mouseDoubleClickEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SelectionMarker::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
|
|
||||||
if(baseItem) baseItem->mouseMoveEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF Marker::boundingRect() const
|
QRectF Marker::boundingRect() const
|
||||||
@ -1593,7 +1611,7 @@ QRectF Marker::boundingRect() const
|
|||||||
return m_rect.adjusted(-15,-15,15,15);
|
return m_rect.adjusted(-15,-15,15,15);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = 5;
|
||||||
@ -1617,40 +1635,45 @@ void Marker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget
|
|||||||
painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize,
|
painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize,
|
||||||
rect().top()-markerSize,markerSize*2,markerSize*2));
|
rect().top()-markerSize,markerSize*2,markerSize*2));
|
||||||
painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize,
|
painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize,
|
||||||
rect().bottom()-markerSize,markerSize*2,markerSize*2));
|
rect().bottom()-markerSize,markerSize*2,markerSize*2));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF Marker::rect() const
|
SelectionMarker::SelectionMarker(QGraphicsItem* parent, BaseDesignIntf* owner)
|
||||||
|
: Marker(parent, owner)
|
||||||
{
|
{
|
||||||
return m_rect;
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor Marker::color() const
|
void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
return m_color;
|
if (owner()) owner()->hoverMoveEvent(event);
|
||||||
|
QGraphicsItem::hoverMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseDesignIntf *Marker::object() const
|
void SelectionMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
return m_object;
|
if (owner()){
|
||||||
}
|
owner()->setSelected(true);
|
||||||
|
owner()->mousePressEvent(event);
|
||||||
QMap<QString, QString> BaseDesignIntf::getStringForTranslation(){
|
|
||||||
return QMap<QString,QString>();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant BookmarkContainerDesignIntf::getBookMark(const QString& key)
|
|
||||||
{
|
|
||||||
if (m_bookmarks.contains(key))
|
|
||||||
return m_bookmarks.value(key);
|
|
||||||
else return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkContainerDesignIntf::copyBookmarks(BookmarkContainerDesignIntf* source)
|
|
||||||
{
|
|
||||||
foreach(QString key, source->bookmarks()){
|
|
||||||
addBookmark(key,source->getBookMark(key));
|
|
||||||
}
|
}
|
||||||
|
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
|
} //namespace LimeReport
|
||||||
|
@ -51,23 +51,23 @@ class BaseDesignIntf;
|
|||||||
|
|
||||||
class Marker : public QGraphicsItem{
|
class Marker : public QGraphicsItem{
|
||||||
public:
|
public:
|
||||||
Marker(QGraphicsItem* parent=0):QGraphicsItem(parent),m_object(NULL){}
|
Marker(QGraphicsItem* parent = 0, BaseDesignIntf* owner = 0): QGraphicsItem(parent), m_owner(owner){}
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
void setRect(QRectF rect){prepareGeometryChange();m_rect=rect;}
|
void setRect(QRectF rect){prepareGeometryChange();m_rect=rect;}
|
||||||
void setColor(QColor color){m_color=color;}
|
void setColor(QColor color){m_color=color;}
|
||||||
QRectF rect() const;
|
QRectF rect() const {return m_rect;}
|
||||||
QColor color() const;
|
QColor color() const {return m_color;}
|
||||||
BaseDesignIntf *object() const;
|
BaseDesignIntf* owner() const {return m_owner;}
|
||||||
private:
|
private:
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
QColor m_color;
|
QColor m_color;
|
||||||
BaseDesignIntf* m_object;
|
BaseDesignIntf* m_owner;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SelectionMarker : public Marker{
|
class SelectionMarker : public Marker{
|
||||||
public:
|
public:
|
||||||
SelectionMarker(QGraphicsItem* parent=0);
|
SelectionMarker(QGraphicsItem* parent=0, BaseDesignIntf* owner = 0);
|
||||||
protected:
|
protected:
|
||||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
@ -180,6 +180,7 @@ public:
|
|||||||
virtual QPainterPath shape() const;
|
virtual QPainterPath shape() const;
|
||||||
|
|
||||||
void setFixedPos(bool fixedPos);
|
void setFixedPos(bool fixedPos);
|
||||||
|
bool isFixedPos(){return m_fixedPos;}
|
||||||
int resizeHandleSize() const;
|
int resizeHandleSize() const;
|
||||||
|
|
||||||
void setMMFactor(qreal mmFactor);
|
void setMMFactor(qreal mmFactor);
|
||||||
@ -204,7 +205,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);
|
||||||
@ -281,7 +282,8 @@ public:
|
|||||||
void setFillInSecondPass(bool fillInSecondPass);
|
void setFillInSecondPass(bool fillInSecondPass);
|
||||||
bool isWatermark() const;
|
bool isWatermark() const;
|
||||||
virtual void setWatermark(bool watermark);
|
virtual void setWatermark(bool watermark);
|
||||||
|
void updateSelectionMarker();
|
||||||
|
void turnOnSelectionMarker(bool value);
|
||||||
Q_INVOKABLE QString setItemWidth(qreal width);
|
Q_INVOKABLE QString setItemWidth(qreal width);
|
||||||
Q_INVOKABLE QString setItemHeight(qreal height);
|
Q_INVOKABLE QString setItemHeight(qreal height);
|
||||||
Q_INVOKABLE qreal getItemWidth();
|
Q_INVOKABLE qreal getItemWidth();
|
||||||
@ -293,6 +295,9 @@ public:
|
|||||||
Q_INVOKABLE QString setItemPosX(qreal xValue);
|
Q_INVOKABLE QString setItemPosX(qreal xValue);
|
||||||
Q_INVOKABLE QString setItemPosY(qreal yValue);
|
Q_INVOKABLE QString setItemPosY(qreal yValue);
|
||||||
|
|
||||||
|
bool fillTransparentInDesignMode() const;
|
||||||
|
void setFillTransparentInDesignMode(bool fillTransparentInDesignMode);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//ICollectionContainer
|
//ICollectionContainer
|
||||||
@ -305,10 +310,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);
|
||||||
@ -331,7 +337,7 @@ protected:
|
|||||||
void drawDesignModeBorder(QPainter* painter, QRectF rect) const;
|
void drawDesignModeBorder(QPainter* painter, QRectF rect) const;
|
||||||
void drawRenderModeBorder(QPainter *painter, QRectF rect) const;
|
void drawRenderModeBorder(QPainter *painter, QRectF rect) const;
|
||||||
void drawResizeZone(QPainter*);
|
void drawResizeZone(QPainter*);
|
||||||
void drawSelection(QPainter* painter, QRectF) const;
|
void drawMarker(QPainter* painter, QColor color) const;
|
||||||
void drawPinArea(QPainter* painter) const;
|
void drawPinArea(QPainter* painter) const;
|
||||||
|
|
||||||
void initResizeZones();
|
void initResizeZones();
|
||||||
@ -358,12 +364,10 @@ protected:
|
|||||||
qreal calcAbsolutePosX(qreal currentOffset, BaseDesignIntf* item);
|
qreal calcAbsolutePosX(qreal currentOffset, BaseDesignIntf* item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateSelectionMarker();
|
|
||||||
int resizeDirectionFlags(QPointF position);
|
int resizeDirectionFlags(QPointF position);
|
||||||
void moveSelectedItems(QPointF delta);
|
void moveSelectedItems(QPointF delta);
|
||||||
Qt::CursorShape getPossibleCursor(int cursorFlags);
|
Qt::CursorShape getPossibleCursor(int cursorFlags);
|
||||||
void updatePossibleDirectionFlags();
|
void updatePossibleDirectionFlags();
|
||||||
void turnOnSelectionMarker(bool value);
|
|
||||||
private:
|
private:
|
||||||
QPointF m_startPos;
|
QPointF m_startPos;
|
||||||
int m_resizeHandleSize;
|
int m_resizeHandleSize;
|
||||||
@ -398,8 +402,6 @@ private:
|
|||||||
ItemMode m_itemMode;
|
ItemMode m_itemMode;
|
||||||
|
|
||||||
ObjectState m_objectState;
|
ObjectState m_objectState;
|
||||||
SelectionMarker* m_selectionMarker;
|
|
||||||
Marker* m_joinMarker;
|
|
||||||
|
|
||||||
BrushStyle m_backgroundBrushStyle;
|
BrushStyle m_backgroundBrushStyle;
|
||||||
QColor m_backgroundColor;
|
QColor m_backgroundColor;
|
||||||
@ -415,7 +417,11 @@ private:
|
|||||||
BaseDesignIntf* m_patternItem;
|
BaseDesignIntf* m_patternItem;
|
||||||
bool m_fillInSecondPass;
|
bool m_fillInSecondPass;
|
||||||
bool m_watermark;
|
bool m_watermark;
|
||||||
|
bool m_hovered;
|
||||||
|
bool m_joinMarkerOn;
|
||||||
|
SelectionMarker* m_selectionMarker;
|
||||||
|
Marker* m_joinMarker;
|
||||||
|
bool m_fillTransparentInDesignMode;
|
||||||
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);
|
||||||
|
@ -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;
|
||||||
|
@ -339,6 +339,15 @@ void PageDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
qreal posY = div(pageItem()->mapFromScene(event->scenePos()).y(), verticalGridStep()).quot * verticalGridStep();
|
qreal posY = div(pageItem()->mapFromScene(event->scenePos()).y(), verticalGridStep()).quot * verticalGridStep();
|
||||||
qreal posX = div(pageItem()->mapFromScene(event->scenePos()).x(), verticalGridStep()).quot * horizontalGridStep();
|
qreal posX = div(pageItem()->mapFromScene(event->scenePos()).x(), verticalGridStep()).quot * horizontalGridStep();
|
||||||
m_itemInsertRect->setPos(posX,posY);
|
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); }
|
else { if (m_insertMode) m_itemInsertRect->setVisible(false); }
|
||||||
|
|
||||||
@ -1102,9 +1111,53 @@ void PageDesignIntf::endUpdate()
|
|||||||
emit pageUpdateFinished(this);
|
emit pageUpdateFinished(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageDesignIntf::activateItemToJoin(QRectF itemRect, QList<ItemProjections>& 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)
|
void PageDesignIntf::itemMoved(BaseDesignIntf *item)
|
||||||
{
|
{
|
||||||
if (m_movedItem!=item){
|
if (m_movedItem!=item){
|
||||||
|
m_movedItem = item;
|
||||||
BaseDesignIntf* curItem = dynamic_cast<BaseDesignIntf*>(item->parentItem()); ;
|
BaseDesignIntf* curItem = dynamic_cast<BaseDesignIntf*>(item->parentItem()); ;
|
||||||
while (curItem){
|
while (curItem){
|
||||||
m_movedItemContainer = dynamic_cast<BandDesignIntf*>(curItem);
|
m_movedItemContainer = dynamic_cast<BandDesignIntf*>(curItem);
|
||||||
@ -1122,28 +1175,29 @@ void PageDesignIntf::itemMoved(BaseDesignIntf *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF r1(item->pos().x(),item->pos().y()-50,item->width(),item->height()+100);
|
activateItemToJoin(item->geometry(), m_projections);
|
||||||
QRectF r2(item->pos().x()-50,item->pos().y(),item->width()+100,item->height());
|
// QRectF r1(item->pos().x(),item->pos().y()-50,item->width(),item->height()+100);
|
||||||
qreal maxSquare = 0;
|
// QRectF r2(item->pos().x()-50,item->pos().y(),item->width()+100,item->height());
|
||||||
|
// qreal maxSquare = 0;
|
||||||
|
|
||||||
if (m_joinItem) {
|
// if (m_joinItem) {
|
||||||
m_joinItem->turnOnJoinMarker(false);
|
// m_joinItem->turnOnJoinMarker(false);
|
||||||
m_joinItem = 0;
|
// m_joinItem = 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
foreach(ItemProjections p, m_projections){
|
// foreach(ItemProjections p, m_projections){
|
||||||
qreal tmpSquare = qMax(p.square(r1)/item->width(),p.square(r2)/item->height());
|
// qreal tmpSquare = qMax(p.square(r1)/item->width(),p.square(r2)/item->height());
|
||||||
if (tmpSquare>maxSquare) {
|
// if (tmpSquare>maxSquare) {
|
||||||
maxSquare = tmpSquare;
|
// maxSquare = tmpSquare;
|
||||||
m_joinItem = p.item();
|
// m_joinItem = p.item();
|
||||||
if (p.square(r1)/item->width()>p.square(r2)/item->height())
|
// if (p.square(r1)/item->width()>p.square(r2)/item->height())
|
||||||
m_joinType = Width;
|
// m_joinType = Width;
|
||||||
else
|
// else
|
||||||
m_joinType = Height;
|
// m_joinType = Height;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (m_joinItem) m_joinItem->turnOnJoinMarker(true);
|
// if (m_joinItem) m_joinItem->turnOnJoinMarker(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2427,7 +2481,7 @@ CommandIf::Ptr BandMoveFromToCommand::create(PageDesignIntf* page, int from, int
|
|||||||
|
|
||||||
bool BandMoveFromToCommand::doIt()
|
bool BandMoveFromToCommand::doIt()
|
||||||
{
|
{
|
||||||
if (page() && from != to) {
|
if (page() && page()->pageItem() && from != to) {
|
||||||
page()->pageItem()->moveBandFromTo(from, to);
|
page()->pageItem()->moveBandFromTo(from, to);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,7 @@ namespace LimeReport {
|
|||||||
bool isUpdating(){return m_updating;}
|
bool isUpdating(){return m_updating;}
|
||||||
void endUpdate();
|
void endUpdate();
|
||||||
|
|
||||||
|
void rectMoved(QRectF itemRect, BaseDesignIntf* container = 0);
|
||||||
void itemMoved(BaseDesignIntf* item);
|
void itemMoved(BaseDesignIntf* item);
|
||||||
bool magneticMovement() const;
|
bool magneticMovement() const;
|
||||||
void setMagneticMovement(bool magneticMovement);
|
void setMagneticMovement(bool magneticMovement);
|
||||||
@ -175,6 +176,7 @@ namespace LimeReport {
|
|||||||
|
|
||||||
void setPropertyToSelectedItems(const char *name, const QVariant &value);
|
void setPropertyToSelectedItems(const char *name, const QVariant &value);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void keyPressEvent(QKeyEvent *event);
|
virtual void keyPressEvent(QKeyEvent *event);
|
||||||
@ -272,7 +274,7 @@ namespace LimeReport {
|
|||||||
const QVariant& oldPropertyValue,
|
const QVariant& oldPropertyValue,
|
||||||
const QVariant& newPropertyValue);
|
const QVariant& newPropertyValue);
|
||||||
void changeSelectedGroupProperty(const QString& name,const QVariant& value);
|
void changeSelectedGroupProperty(const QString& name,const QVariant& value);
|
||||||
|
void activateItemToJoin(QRectF itemRect, QList<ItemProjections>& items);
|
||||||
private:
|
private:
|
||||||
enum JoinType{Width, Height};
|
enum JoinType{Width, Height};
|
||||||
LimeReport::PageItemDesignIntf::Ptr m_pageItem;
|
LimeReport::PageItemDesignIntf::Ptr m_pageItem;
|
||||||
@ -312,6 +314,7 @@ namespace LimeReport {
|
|||||||
JoinType m_joinType;
|
JoinType m_joinType;
|
||||||
bool m_magneticMovement;
|
bool m_magneticMovement;
|
||||||
ReportSettings* m_reportSettings;
|
ReportSettings* m_reportSettings;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class AbstractPageCommand : public CommandIf{
|
class AbstractPageCommand : public CommandIf{
|
||||||
|
@ -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()){
|
||||||
@ -473,7 +479,7 @@ void PageItemDesignIntf::relocateBands()
|
|||||||
{
|
{
|
||||||
if (isLoading()) return;
|
if (isLoading()) return;
|
||||||
|
|
||||||
int bandSpace = (itemMode() & DesignMode)?4:0;
|
int bandSpace = (itemMode() & DesignMode)?0:0;
|
||||||
|
|
||||||
QVector<qreal> posByColumn;
|
QVector<qreal> posByColumn;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user