Merge branch 'develop' into feature/addNewTextInPreview

# Conflicts:
#	limereport/lrpagedesignintf.cpp
#	limereport/lrpagedesignintf.h
This commit is contained in:
Arin Alexander 2019-03-01 17:59:56 +03:00
commit ca57e5c195
14 changed files with 322 additions and 153 deletions

View File

@ -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
}
}

View File

@ -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;

View File

@ -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::lightGray),2));
painter->fillRect(QRectF(
boundingRect().bottomLeft().x(),
boundingRect().bottomLeft().y()-4,
boundingRect().width(),4), Qt::lightGray
);
painter->setRenderHint(QPainter::Antialiasing);
qreal size = (boundingRect().width()<boundingRect().height()) ? boundingRect().width() : boundingRect().height();
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->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),
@ -140,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);
@ -304,6 +341,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 +771,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){

View File

@ -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;
@ -142,6 +146,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 +255,8 @@ public:
void setBackgroundOpacity(int value);
int bootomSpace() const;
void setBootomSpace(int bootomSpace);
void updateBandMarkerGeometry();
signals:
void bandRendered(BandDesignIntf* band);
void preparedForRender();

View File

@ -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),
@ -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),
@ -81,7 +79,11 @@ 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),
m_joinMarkerOn(false),
m_selectionMarker(0),
m_fillTransparentInDesignMode(true)
{
setGeometry(QRectF(0, 0, m_width, m_height));
if (BaseDesignIntf *item = dynamic_cast<BaseDesignIntf *>(parent)) {
@ -104,8 +106,7 @@ QRectF BaseDesignIntf::boundingRect() const
}
BaseDesignIntf::~BaseDesignIntf(void) {
delete m_selectionMarker;
delete m_joinMarker;
}
void BaseDesignIntf::setParentReportItem(const QString &value)
@ -390,10 +391,16 @@ 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"));
}
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;
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")));
}
@ -480,6 +487,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();
}
@ -561,6 +576,7 @@ void BaseDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
moveSelectedItems(tmpPos - pos());
if (page()->selectedItems().count()==1 && (page()->magneticMovement()))
page()->itemMoved(this);
}
}
}
@ -661,8 +677,9 @@ QPointF BaseDesignIntf::modifyPosForAlignedItem(const QPointF& pos){
void BaseDesignIntf::turnOnJoinMarker(bool value)
{
m_joinMarkerOn = value;
if (value){
m_joinMarker = new Marker(this);
m_joinMarker = new Marker(this, this);
m_joinMarker->setColor(Const::JOIN_COLOR);
m_joinMarker->setRect(rect());
m_joinMarker->setVisible(true);
@ -705,17 +722,14 @@ void BaseDesignIntf::updatePossibleDirectionFlags(){
}
}
void BaseDesignIntf::turnOnSelectionMarker(bool value)
bool BaseDesignIntf::fillTransparentInDesignMode() const
{
if (value && !m_selectionMarker){
m_selectionMarker = new SelectionMarker(this);
m_selectionMarker->setColor(selectionMarkerColor());
updateSelectionMarker();
m_selectionMarker->setVisible(true);
} else {
delete m_selectionMarker;
m_selectionMarker = 0;
}
return m_fillTransparentInDesignMode;
}
void BaseDesignIntf::setFillTransparentInDesignMode(bool fillTransparentInDesignMode)
{
m_fillTransparentInDesignMode = fillTransparentInDesignMode;
}
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
{
return (m_patternName.isEmpty()) ? objectName() : m_patternName;
@ -1105,20 +1143,32 @@ 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(color, m_selectionPenSize);
painter->setPen(pen);
painter->setBrush(QBrush(color));
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));
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();
}
@ -1166,8 +1216,7 @@ 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()));
emit posChanged(this, newGeometry.topLeft(), m_oldGeometry.topLeft());
}
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*/)
{
@ -1549,43 +1587,23 @@ void BaseDesignIntf::notify(const QVector<QString>& propertyNames)
emit propertyesChanged(propertyNames);
}
SelectionMarker::SelectionMarker(QGraphicsItem *parent)//, QGraphicsScene *scene)
: Marker(parent)
{
setAcceptHoverEvents(true);
QMap<QString, QString> BaseDesignIntf::getStringForTranslation(){
return QMap<QString,QString>();
}
void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
QVariant BookmarkContainerDesignIntf::getBookMark(const QString& key)
{
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
if(baseItem) baseItem->hoverMoveEvent(event);
if (m_bookmarks.contains(key))
return m_bookmarks.value(key);
else return QVariant();
}
void SelectionMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
void BookmarkContainerDesignIntf::copyBookmarks(BookmarkContainerDesignIntf* source)
{
parentItem()->setSelected(true);
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
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);
foreach(QString key, source->bookmarks()){
addBookmark(key,source->getBookMark(key));
}
}
QRectF Marker::boundingRect() const
@ -1593,7 +1611,7 @@ QRectF Marker::boundingRect() const
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;
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,
rect().top()-markerSize,markerSize*2,markerSize*2));
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;
}
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));
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

View File

@ -51,23 +51,23 @@ class BaseDesignIntf;
class Marker : public QGraphicsItem{
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;
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;
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_object;
BaseDesignIntf* m_owner;
};
class SelectionMarker : public Marker{
public:
SelectionMarker(QGraphicsItem* parent=0);
SelectionMarker(QGraphicsItem* parent=0, BaseDesignIntf* owner = 0);
protected:
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
@ -180,6 +180,7 @@ public:
virtual QPainterPath shape() const;
void setFixedPos(bool fixedPos);
bool isFixedPos(){return m_fixedPos;}
int resizeHandleSize() const;
void setMMFactor(qreal mmFactor);
@ -204,7 +205,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);
@ -281,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();
@ -293,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
@ -305,10 +310,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);
@ -331,7 +337,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();
@ -358,12 +364,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;
@ -398,8 +402,6 @@ private:
ItemMode m_itemMode;
ObjectState m_objectState;
SelectionMarker* m_selectionMarker;
Marker* m_joinMarker;
BrushStyle m_backgroundBrushStyle;
QColor m_backgroundColor;
@ -415,7 +417,11 @@ private:
BaseDesignIntf* m_patternItem;
bool m_fillInSecondPass;
bool m_watermark;
bool m_hovered;
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);

View File

@ -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;

View File

@ -344,8 +344,17 @@ void PageDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
qreal posY = div(page->mapFromScene(event->scenePos()).y(), verticalGridStep()).quot * verticalGridStep();
qreal posX = div(page->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);
if (m_insertMode) m_itemInsertRect->setVisible(false);
}
QGraphicsScene::mouseMoveEvent(event);
@ -1119,9 +1128,53 @@ void PageDesignIntf::endUpdate()
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)
{
if (m_movedItem!=item){
m_movedItem = item;
BaseDesignIntf* curItem = dynamic_cast<BaseDesignIntf*>(item->parentItem()); ;
while (curItem){
m_movedItemContainer = dynamic_cast<BandDesignIntf*>(curItem);
@ -1139,28 +1192,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);
}
@ -2444,7 +2498,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;
}

View File

@ -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);
@ -275,7 +276,7 @@ namespace LimeReport {
const QVariant& oldPropertyValue,
const QVariant& newPropertyValue);
void changeSelectedGroupProperty(const QString& name,const QVariant& value);
void activateItemToJoin(QRectF itemRect, QList<ItemProjections>& items);
private:
enum JoinType{Width, Height};
LimeReport::PageItemDesignIntf::Ptr m_pageItem;

View File

@ -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()){
@ -473,7 +479,7 @@ void PageItemDesignIntf::relocateBands()
{
if (isLoading()) return;
int bandSpace = (itemMode() & DesignMode)?4:0;
int bandSpace = (itemMode() & DesignMode)?0:0;
QVector<qreal> posByColumn;

View File

@ -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;

View File

@ -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;
}
}

View File

@ -215,6 +215,7 @@ private:
QVector<BandDesignIntf*> m_columnedBandItems;
unsigned long long m_currentNameIndex;
bool m_newPageStarted;
bool m_lostHeadersMoved;
};
} // namespace LimeReport

View File

@ -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<BaseDesignIntf*>(m_patternLayout->at(i));
BaseDesignIntf* cloneItem = item->cloneItem(item->itemMode(), newRow, newRow);