0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

Magnet feature has been added

This commit is contained in:
Arin Alex 2016-02-21 01:08:54 +03:00
parent 5108c3a49d
commit 59635e3216
15 changed files with 349 additions and 87 deletions

View File

@ -52,6 +52,7 @@ namespace Const{
double const SELECTED_RESIZE_ZONE_OPACITY = 0.6;
Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green;
Qt::GlobalColor const SELECTION_COLOR = Qt::red;
Qt::GlobalColor const JOIN_COLOR = Qt::blue;
double const SELECTION_COLOR_OPACITY = 0.6;
const qreal fontFACTOR = 3.5;
const int mmFACTOR = 10;

BIN
src/images/magnet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

View File

@ -163,6 +163,7 @@ public:
virtual bool isHeader() const {return false;}
virtual bool isGroupHeader() const {return false;}
virtual bool isData() const {return false;}
bool isBand(){return true;}
void setTryToKeepTogether(bool value);
bool tryToKeepTogether();

View File

@ -69,6 +69,7 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
m_itemMode(DesignMode),
m_objectState(ObjectCreated),
m_selectionMarker(0),
m_joinMarker(0),
m_backgroundBrush(Solid),
m_backgroundBrushcolor(Qt::white),
m_margin(4),
@ -82,9 +83,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
m_font = QFont("Arial",10);
}
initFlags();
m_selectionMarker = new SelectionMarker(this);
m_selectionMarker->setColor(Const::SELECTION_COLOR);
m_selectionMarker->setVisible(false);
//connect(this,SIGNAL(objectNameChanged(QString)),this,SLOT(slotObjectNameChanged(QString)));
}
@ -99,7 +99,10 @@ QRectF BaseDesignIntf::boundingRect() const
return m_boundingRect;
}
BaseDesignIntf::~BaseDesignIntf(void) {delete m_selectionMarker;}
BaseDesignIntf::~BaseDesignIntf(void) {
delete m_selectionMarker;
delete m_joinMarker;
}
void BaseDesignIntf::setParentReportItem(const QString &value)
{
@ -112,7 +115,7 @@ void BaseDesignIntf::setParentReportItem(const QString &value)
}
}
QString BaseDesignIntf::parentReportItem()
QString BaseDesignIntf::parentReportItemName()
{
BaseDesignIntf *parent = dynamic_cast<BaseDesignIntf *>(parentItem());
if (parent) return parent->objectName();
@ -292,7 +295,7 @@ void BaseDesignIntf::mousePressEvent(QGraphicsSceneMouseEvent *event)
m_startPos = pos();
m_oldGeometry = geometry();
QGraphicsItem::mousePressEvent(event);
QApplication::processEvents();
//QApplication::processEvents();
emit(itemSelected(this));
}
else QGraphicsItem::mousePressEvent(event);
@ -392,22 +395,10 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
void BaseDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
// if (!scene()->items(event->scenePos()).contains(parentItem())){
// BandDesignIntf* band = 0;
// PageItemDesignIntf* pageItem = 0;
// foreach (QGraphicsItem* item, scene()->items(event->scenePos())) {
// band = dynamic_cast<BandDesignIntf*>(item);
// if (band){
// break;
// }
// pageItem = dynamic_cast<PageItemDesignIntf*>(item);
// }
// if (band)
// qDebug()<<"band found"<<band->objectName();
// if (pageItem)
// qDebug()<<"page found"<<pageItem->objectName();
// }
if (!isSelected()){
QGraphicsItem::mouseMoveEvent(event);
return;
}
int hStep = dynamic_cast<PageDesignIntf*>(scene())->horizontalGridStep();
int vStep = dynamic_cast<PageDesignIntf*>(scene())->verticalGridStep();
@ -469,7 +460,11 @@ void BaseDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
};
setItemPos(m_startPos - delta);
moveSelectedItems(tmpPos - pos());
if (!isBand() && scene()->selectedItems().count()>1)
moveSelectedItems(tmpPos - pos());
if (scene()->selectedItems().count()==1 && (page()->magneticMovement()))
page()->itemMoved(this);
}
}
@ -571,6 +566,19 @@ QPointF BaseDesignIntf::modifyPosForAlignedItem(const QPointF& pos){
return result;
}
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;
}
}
void BaseDesignIntf::updateItemAlign(){
BaseDesignIntf* parent = dynamic_cast<BaseDesignIntf*>(parentItem());
PageItemDesignIntf* parentPage = dynamic_cast<PageItemDesignIntf*>(parentItem());
@ -604,6 +612,19 @@ void BaseDesignIntf::updatePosibleDirectionFlags(){
}
}
void BaseDesignIntf::turnOnSelectionMarker(bool value)
{
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;
}
}
void BaseDesignIntf::setItemAlign(const ItemAlign &itemAlign)
{
if (m_itemAlign != itemAlign){
@ -864,8 +885,7 @@ QVariant BaseDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, co
updateSelectionMarker();
}
if (change == QGraphicsItem::ItemSelectedChange) {
updateSelectionMarker();
m_selectionMarker->setVisible(value.toBool());
turnOnSelectionMarker(value.toBool());
}
if (change == QGraphicsItem::ItemParentHasChanged) {
parentChangedEvent(dynamic_cast<BaseDesignIntf*>(value.value<QGraphicsItem*>()));
@ -916,7 +936,7 @@ void BaseDesignIntf::moveSelectedItems(QPointF delta)
foreach(QGraphicsItem * item, selectedItems) {
if (item != this) {
selectedItem = dynamic_cast<BaseDesignIntf *>(item);
if (selectedItem) {
if (selectedItem && !selectedItem->isBand()) {
if (!selectedItem->m_fixedPos)
selectedItem->setItemPos(selectedItem->pos() - delta);
}
@ -1023,7 +1043,7 @@ void BaseDesignIntf::updateSelectionMarker()
if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker);
if (parentItem()) {
m_selectionMarker->setRect(rect());
m_selectionMarker->setPos(0,0/*parentItem()->mapToScene(pos())*/);
m_selectionMarker->setPos(0,0);
}
}
}
@ -1235,45 +1255,11 @@ void BaseDesignIntf::notify(const QVector<QString>& propertyNames)
}
SelectionMarker::SelectionMarker(QGraphicsItem *parent)//, QGraphicsScene *scene)
: QGraphicsItem(parent)//, scene)
: Marker(parent)
{
setAcceptHoverEvents(true);
}
QRectF SelectionMarker::boundingRect() const
{
return m_rect.adjusted(-15,-15,15,15);
}
void SelectionMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
QPen pen;
const int markerSize = 5;
pen.setColor(m_color);
pen.setWidth(2);
pen.setStyle(Qt::DotLine);
painter->setPen(pen);
painter->setOpacity(Const::SELECTION_COLOR_OPACITY);
painter->drawRect(m_rect);
painter->setBrush(m_color);
painter->setPen(Qt::transparent);
painter->setOpacity(1);
painter->drawRect(QRectF(-markerSize,-markerSize,markerSize*2,markerSize*2));
painter->drawRect(QRectF(m_rect.right()-markerSize,m_rect.bottom()-markerSize,markerSize*2,markerSize*2));
painter->drawRect(QRectF(m_rect.right()-markerSize,m_rect.top()-markerSize,markerSize*2,markerSize*2));
painter->drawRect(QRectF(m_rect.left()-markerSize,m_rect.bottom()-markerSize,markerSize*2,markerSize*2));
painter->drawRect(QRectF(m_rect.left()-markerSize,
m_rect.bottom()-m_rect.height()/2-markerSize,markerSize*2,markerSize*2));
painter->drawRect(QRectF(m_rect.right()-markerSize,
m_rect.bottom()-m_rect.height()/2-markerSize,markerSize*2,markerSize*2));
painter->drawRect(QRectF(m_rect.left()+m_rect.width()/2-markerSize,
m_rect.top()-markerSize,markerSize*2,markerSize*2));
painter->drawRect(QRectF(m_rect.left()+m_rect.width()/2-markerSize,
m_rect.bottom()-markerSize,markerSize*2,markerSize*2));
//painter->drawRect();
}
void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
@ -1307,6 +1293,53 @@ void SelectionMarker::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
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 = 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));
}
QRectF Marker::rect() const
{
return m_rect;
}
QColor Marker::color() const
{
return m_color;
}
BaseDesignIntf *Marker::object() const
{
return m_object;
}
}

View File

@ -48,23 +48,31 @@ class ReportEnginePrivate;
class PageDesignIntf;
class BaseDesignIntf;
class SelectionMarker : public QGraphicsItem{
class Marker : public QGraphicsItem{
public:
SelectionMarker(QGraphicsItem* parent=0);//, QGraphicsScene* scene=0);
Marker(QGraphicsItem* parent=0):QGraphicsItem(parent){}
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 mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
private:
QRectF m_rect;
QColor m_color;
BaseDesignIntf* m_object;
};
class DataSourceManager;
@ -82,7 +90,7 @@ class BaseDesignIntf :
Q_PROPERTY(ACollectionProperty children READ fakeCollectionReader DESIGNABLE false)
Q_PROPERTY(qreal zOrder READ zValue WRITE setZValueProperty DESIGNABLE false)
Q_PROPERTY(BorderLines borders READ borderLines WRITE setBorderLinesFlags)
Q_PROPERTY(QString parentName READ parentReportItem WRITE setParentReportItem DESIGNABLE false)
Q_PROPERTY(QString parentName READ parentReportItemName WRITE setParentReportItem DESIGNABLE false)
Q_PROPERTY(int borderLineSize READ borderLineSize WRITE setBorderLineSize)
Q_PROPERTY(bool isVisible READ isVisible WRITE setVisible DESIGNABLE false)
@ -115,7 +123,7 @@ public:
virtual ~BaseDesignIntf();
void setParentReportItem(const QString& value);
QString parentReportItem();
QString parentReportItemName();
BrushMode backgroundBrushMode(){return m_backgroundBrush;}
void setBackgroundBrushMode(BrushMode value);
@ -231,6 +239,8 @@ public:
virtual void setItemAlign(const ItemAlign &itemAlign);
void updateItemAlign();
QPointF modifyPosForAlignedItem(const QPointF &pos);
void turnOnJoinMarker(bool value);
virtual bool isBand(){return false;}
protected:
//ICollectionContainer
@ -277,7 +287,7 @@ protected:
RenderPass currentRenderPass(){return m_currentPass;}
virtual bool drawDesignBorders() const {return true;}
SelectionMarker* selectionMarker() {return m_selectionMarker;}
virtual QColor selectionMarkerColor(){ return Const::SELECTION_COLOR;}
private:
void updateSelectionMarker();
int resizeDirectionFlags(QPointF position);
@ -285,6 +295,7 @@ private:
Qt::CursorShape getPosibleCursor(int cursorFlags);
void setZValueProperty(qreal value);
void updatePosibleDirectionFlags();
void turnOnSelectionMarker(bool value);
private:
QPointF m_startPos;
//QPointF m_startScenePos;
@ -321,6 +332,7 @@ private:
ObjectState m_objectState;
SelectionMarker* m_selectionMarker;
Marker* m_joinMarker;
BrushMode m_backgroundBrush;
QColor m_backgroundBrushcolor;

View File

@ -52,6 +52,7 @@ namespace Const{
double const SELECTED_RESIZE_ZONE_OPACITY = 0.6;
Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green;
Qt::GlobalColor const SELECTION_COLOR = Qt::red;
Qt::GlobalColor const JOIN_COLOR = Qt::blue;
double const SELECTION_COLOR_OPACITY = 0.6;
const qreal fontFACTOR = 3.5;
const int mmFACTOR = 10;

View File

@ -89,7 +89,10 @@ PageDesignIntf::PageDesignIntf(QObject *parent):
m_horizontalGridStep(2),
m_updating(false),
m_currentObjectIndex(1),
m_multiSelectStarted(false)
m_multiSelectStarted(false),
m_movedItem(0),
m_joinItem(0),
m_magneticMovement(false)
{
m_reportEditor = dynamic_cast<ReportEnginePrivate *>(parent);
updatePageRect();
@ -315,11 +318,7 @@ void PageDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
if (event->button() & Qt::LeftButton && event->modifiers()==0){
}
if (event->buttons() & Qt::LeftButton && m_multiSelectStarted/*event->modifiers()==Qt::ShiftModifier*/){
if (event->buttons() & Qt::LeftButton && m_multiSelectStarted){
if (!m_selectionRect){
m_selectionRect = new QGraphicsRectItem();
QBrush brush(QColor(140,190,30,50));
@ -350,6 +349,35 @@ void PageDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void PageDesignIntf::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if ( (event->button() == Qt::LeftButton)) {
if (m_joinItem && selectedItems().count()==1){
BaseDesignIntf* selectedItem = dynamic_cast<BaseDesignIntf*>(selectedItems().at(0));
if (m_magneticMovement){
if (m_joinType == Width){
QPointF tmpPos;
if (selectedItem->pos().y()>m_joinItem->pos().y())
tmpPos = QPointF(m_joinItem->x(),m_joinItem->pos().y()+m_joinItem->height());
else
tmpPos = QPointF(m_joinItem->x(),m_joinItem->pos().y()-selectedItem->height());
selectedItem->setPos(tmpPos);
selectedItem->setWidth(m_joinItem->width());
} else {
QPointF tmpPos;
if (selectedItem->pos().x()>m_joinItem->pos().x())
tmpPos = QPointF(m_joinItem->x()+m_joinItem->width(),m_joinItem->pos().y());
else
tmpPos = QPointF(m_joinItem->x()-selectedItem->width(),m_joinItem->pos().y());
selectedItem->setPos(tmpPos);
selectedItem->setHeight(m_joinItem->height());
}
}
m_joinItem->turnOnJoinMarker(false);
m_joinItem = 0;
}
checkSizeOrPosChanges();
}
if (m_selectionRect) {
@ -1016,6 +1044,16 @@ void PageDesignIntf::changeSelectedGroupProperty(const QString &name, const QVar
}
}
bool PageDesignIntf::magneticMovement() const
{
return m_magneticMovement;
}
void PageDesignIntf::setMagneticMovement(bool magneticMovement)
{
m_magneticMovement = magneticMovement;
}
int PageDesignIntf::horizontalGridStep() const
{
return m_horizontalGridStep;
@ -1032,6 +1070,51 @@ void PageDesignIntf::endUpdate()
emit pageUpdateFinished(this);
}
void PageDesignIntf::itemMoved(BaseDesignIntf *item)
{
if (m_movedItem!=item){
BaseDesignIntf* curItem = dynamic_cast<BaseDesignIntf*>(item->parentItem()); ;
while (curItem){
m_movedItemContainer = dynamic_cast<BandDesignIntf*>(curItem);
if (!m_movedItemContainer)
m_movedItemContainer = dynamic_cast<PageItemDesignIntf*>(curItem);
if (m_movedItemContainer) break;
else curItem = dynamic_cast<BaseDesignIntf*>(curItem->parentItem());
}
if (m_movedItemContainer){
m_projections.clear();
foreach(BaseDesignIntf* bi, m_movedItemContainer->childBaseItems()){
if (bi != item)
m_projections.append(ItemProjections(bi));
}
}
}
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;
}
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);
}
int PageDesignIntf::verticalGridStep() const
{
return m_verticalGridStep;
@ -1907,12 +1990,12 @@ void CommandGroup::undoIt()
void CommandGroup::addCommand(CommandIf::Ptr command, bool execute)
{
if (execute)
if (execute){
if (command->doIt())
m_commands.append(command);
else
}else{
m_commands.append(command);
}
}
PrintRange::PrintRange(QAbstractPrintDialog::PrintRange rangeType, int fromPage, int toPage)
@ -2023,10 +2106,6 @@ bool PropertyItemAlignChangedCommand::doIt()
{
BaseDesignIntf *reportItem = page()->reportItemByName(m_objectName);
//if (m_oldValue == BaseDesignIntf::DesignedItemAlign){
// m_savedPos = reportItem->pos();
//}
if (reportItem && (reportItem->property(m_propertyName.toLatin1()) != m_newValue)) {
reportItem->setProperty(m_propertyName.toLatin1(), m_newValue);
}
@ -2046,5 +2125,64 @@ void PropertyItemAlignChangedCommand::undoIt()
}
}
bool Projection::intersect(Projection projection)
{
if (
(projection.start()>=start() && projection.start()<=end()) ||
(projection.end()>=start() && projection.end()<=end()) ||
(projection.start()<=start() && projection.end()>=end())
) return true;
return false;
}
qreal Projection::start() const
{
return m_start;
}
qreal Projection::end() const
{
return m_end;
}
bool ItemProjections::intersect(QRectF rect)
{
Projection xProjection(rect.x(),rect.x()+rect.width());
Projection yProjection(rect.y(),rect.y()+rect.height());
if (m_xProjection.intersect(xProjection) && m_yProjection.intersect(yProjection))
return true;
return false;
}
bool ItemProjections::intersect(BaseDesignIntf *item)
{
return intersect(QRectF(item->pos().x(), item->pos().y(), item->width(), item->height()));
}
qreal lineLength(qreal start, qreal end, Projection p){
qreal result = 0;
if (start>=p.start() && end<=p.end())
result = end - start;
if (start>=p.start() && start<=p.end())
result = p.end() - start;
else if (end>=p.start() && end<=p.end())
result = end-p.start();
else if (start<=p.start() && end>=p.end())
result = p.end() - p.start();
return result;
}
qreal ItemProjections::square(QRectF rect)
{
qreal a = lineLength(rect.left(),rect.right(),m_xProjection);
qreal b = lineLength(rect.top(),rect.bottom(),m_yProjection);
return a*b;
}
qreal ItemProjections::square(BaseDesignIntf *item)
{
return square(QRectF(item->pos().x(),item->pos().y(),item->width(),item->height()));
}
}

View File

@ -66,6 +66,36 @@ namespace LimeReport {
QSizeF size;
};
class Projection{
public:
Projection(qreal start, qreal end)
:m_start(start),m_end(end){}
bool intersect(Projection projection);
qreal start() const;
qreal end() const;
private:
qreal m_start;
qreal m_end;
};
class ItemProjections{
public:
ItemProjections(BaseDesignIntf* item)
:m_xProjection(item->pos().x(), item->pos().x()+item->width()),
m_yProjection(item->pos().y(), item->pos().y()+item->height()),
m_item(item)
{}
bool intersect(QRectF rect);
bool intersect(BaseDesignIntf* item);
qreal square(QRectF rect);
qreal square(BaseDesignIntf* item);
BaseDesignIntf* item(){return m_item;}
private:
Projection m_xProjection;
Projection m_yProjection;
BaseDesignIntf* m_item;
};
class PageDesignIntf : public QGraphicsScene, public ObjectLoadingStateIntf{
Q_OBJECT
Q_PROPERTY(QObject* pageItem READ pageItem())
@ -143,6 +173,11 @@ namespace LimeReport {
void beginUpdate(){m_updating = true;}
bool isUpdating(){return m_updating;}
void endUpdate();
void itemMoved(BaseDesignIntf* item);
bool magneticMovement() const;
void setMagneticMovement(bool magneticMovement);
protected:
virtual void keyPressEvent(QKeyEvent *event);
@ -233,6 +268,7 @@ namespace LimeReport {
void changeSelectedGroupProperty(const QString& name,const QVariant& value);
private:
enum JoinType{Width, Height};
PageSize m_pageSize;
QSizeF m_pageSizeValue;
Orientation m_orientation;
@ -267,6 +303,12 @@ namespace LimeReport {
bool m_updating;
int m_currentObjectIndex;
bool m_multiSelectStarted;
QList<ItemProjections> m_projections;
BaseDesignIntf* m_movedItem;
BaseDesignIntf* m_movedItemContainer;
BaseDesignIntf* m_joinItem;
JoinType m_joinType;
bool m_magneticMovement;
};
class AbstractPageCommand : public CommandIf{

View File

@ -52,7 +52,6 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
setFixedPos(true);
setPosibleResizeDirectionFlags(Fixed);
initPageSize(m_pageSize);
selectionMarker()->setColor(Qt::transparent);
}
PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &rect, QObject *owner, QGraphicsItem *parent) :

View File

@ -113,6 +113,7 @@ protected:
QSizeF getRectByPageSize(const PageSize &size);
void initPageSize(const PageSize &size);
void initPageSize(const QSizeF &size);
QColor selectionMarkerColor(){return Qt::transparent;}
private:
void paintGrid(QPainter *ppainter);
void initColumnsPos(QVector<qreal>&posByColumns, qreal pos, int columnCount);

View File

@ -134,6 +134,19 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow
#endif
}
bool ReportDesignWidget::useMagnet() const
{
return m_useMagnet;
}
void ReportDesignWidget::setUseMagnet(bool useMagnet)
{
m_useMagnet = useMagnet;
for (int i=0;i<m_report->pageCount();++i){
m_report->pageAt(i)->setMagneticMovement(useMagnet);
}
}
void ReportDesignWidget::saveState(QSettings* settings)
{
settings->beginGroup("DesignerWidget");

View File

@ -99,6 +99,8 @@ public:
void applySettings();
void applyUseGrid();
bool useGrid(){ return m_useGrid;}
bool useMagnet() const;
void setUseMagnet(bool useMagnet);
public slots:
void saveToFile(const QString&);
@ -161,6 +163,7 @@ private:
int m_verticalGridStep;
int m_horizontalGridStep;
bool m_useGrid;
bool m_useMagnet;
// static ReportDesignWidget* m_instance;
};

View File

@ -136,7 +136,15 @@ void ReportDesignWindow::createActions()
m_useGridAction = new QAction(tr("Use grid"),this);
m_useGridAction->setIcon(QIcon(":/report/images/grid"));
m_useGridAction->setCheckable(true);
m_useGridAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
connect(m_useGridAction,SIGNAL(toggled(bool)),this,SLOT(slotUseGrid(bool)));
m_useMagnetAction = new QAction(tr("Use magnet"),this);
m_useMagnetAction->setIcon(QIcon(":/report/images/magnet"));
m_useMagnetAction->setCheckable(true);
m_useMagnetAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
connect(m_useMagnetAction,SIGNAL(toggled(bool)),this,SLOT(slotUseMagnet(bool)));
m_newTextItemAction = new QAction(tr("Text Item"),this);
m_newTextItemAction->setIcon(QIcon(":/items/TextItem"));
@ -281,6 +289,8 @@ void ReportDesignWindow::createToolBars()
m_itemsAlignmentEditorBar->setIconSize(m_mainToolBar->iconSize());
m_itemsAlignmentEditorBar->setObjectName("itemsAlignmentTools");
m_itemsAlignmentEditorBar->insertAction(m_itemsAlignmentEditorBar->actions().at(0),m_useGridAction);
m_itemsAlignmentEditorBar->insertAction(m_itemsAlignmentEditorBar->actions().at(1),m_useMagnetAction);
m_itemsAlignmentEditorBar->insertSeparator(m_itemsAlignmentEditorBar->actions().at(2));
addToolBar(m_itemsAlignmentEditorBar);
m_itemsBordersEditorBar = new ItemsBordersEditorWidget(m_reportDesignWidget,tr("Borders"),this);
m_itemsBordersEditorBar->setIconSize(m_mainToolBar->iconSize());
@ -1035,6 +1045,11 @@ void ReportDesignWindow::slotUseGrid(bool value)
m_reportDesignWidget->setUseGrid(value);
}
void ReportDesignWindow::slotUseMagnet(bool value)
{
m_reportDesignWidget->setUseMagnet(value);
}
void ReportDesignWindow::slotLoadRecentFile(const QString fileName)
{
if (checkNeedToSave()){

View File

@ -111,6 +111,7 @@ private slots:
void slotHideRightPanel(bool value);
void slotEditSettings();
void slotUseGrid(bool value);
void slotUseMagnet(bool value);
void slotLoadRecentFile(const QString fileName);
protected:
void closeEvent(QCloseEvent *event);
@ -170,6 +171,7 @@ private:
QAction* m_cutAction;
QAction* m_settingsAction;
QAction* m_useGridAction;
QAction* m_useMagnetAction;
QAction* m_newPageHeader;
QAction* m_newPageFooter;

View File

@ -19,7 +19,7 @@
<file alias="/images/hourglass">images/Hourglass_80.png</file>
<file alias="/images/closebox">images/closebox.png</file>
<file alias="/images/designBig">images/design.png</file>
<file alias="ImageItem">images/barcode.png</file>
<file alias="/images/ImageItem">images/barcode.png</file>
<file alias="/images/addBarcode">images/barcode2.png</file>
<file>images/edit_pecil2.png</file>
<file>images/undo1.png</file>
@ -154,11 +154,12 @@
<file>images/logo.png</file>
<file alias="/images/copyright">images/cpyright_logo.png</file>
<file>images/logo_100.png</file>
<file alias="empty">images/empty.png</file>
<file alias="/images/empty">images/empty.png</file>
<file alias="/images/hideLeftPanel">images/hideLeftPanel.png</file>
<file alias="/images/hideRightPanel">images/hideRightPanel.png</file>
<file alias="/images/pdf">images/PDF2.png</file>
<file alias="/images/settings">images/settings.png</file>
<file alias="/images/grid">images/grid.png</file>
<file alias="/images/magnet">images/magnet.png</file>
</qresource>
</RCC>