0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 16:44:39 +03:00

New scale method has been added

This commit is contained in:
fralx 2020-04-27 11:52:25 +03:00
parent e623978281
commit 318af3b221
40 changed files with 558 additions and 273 deletions

View File

@ -59,22 +59,29 @@ namespace Const{
int const DEFAULT_GRID_STEP = 1; int const DEFAULT_GRID_STEP = 1;
int const RESIZE_HANDLE_SIZE = 5; int const RESIZE_HANDLE_SIZE = 5;
int const SELECTION_PEN_SIZE = 1; 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;
double const SELECTED_RESIZE_ZONE_OPACITY = 0.6; double const SELECTED_RESIZE_ZONE_OPACITY = 0.6;
Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green; Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green;
Qt::GlobalColor const SELECTION_COLOR = Qt::red; Qt::GlobalColor const SELECTION_COLOR = Qt::red;
Qt::GlobalColor const JOIN_COLOR = Qt::blue; Qt::GlobalColor const JOIN_COLOR = Qt::blue;
double const SELECTION_COLOR_OPACITY = 0.6; double const SELECTION_COLOR_OPACITY = 0.6;
const qreal fontFACTOR = 3.5; const qreal FONT_FACTOR = 0.33;
const int mmFACTOR = 10; const int STORAGE_MM_FACTOR = 10;
const int itemPaleteIconSize = 24; const int DESIGNER_MM_FACTOR = 5;
const qreal minSpaceBorder = 10; const int OLD_MM_FACTOR = 10;
const QString bandTAG = "band"; const int DEFAULT_ITEM_WIDTH = 20;
const int DEFAULT_ITEM_HEIGHT = 5;
const int DEFAULT_BAND_HEIGHT = 10;
const int PPM_PERCENT_STEP = 20;
const int ITEM_PALETTE_ICON_SIZE = 24;
const qreal MIN_SPACE_BORDER = 10;
const QString BAND_TAG = "band";
const Qt::GlobalColor BAND_NAME_LABEL_COLOR = Qt::yellow; const Qt::GlobalColor BAND_NAME_LABEL_COLOR = Qt::yellow;
const Qt::GlobalColor BAND_NAME_BORDER_COLOR = Qt::darkYellow; const Qt::GlobalColor BAND_NAME_BORDER_COLOR = Qt::darkGray;
const qreal BAND_MARKER_OPACITY = 1; const qreal BAND_MARKER_SELECTED_OPACITY = 1;
const qreal BAND_MARKER_OPACITY = 0.3;
const qreal LAYOUT_MARKER_OPACITY = 0.3; const qreal LAYOUT_MARKER_OPACITY = 0.3;
const qreal BAND_NAME_AREA_OPACITY = 0.3; const qreal BAND_NAME_AREA_OPACITY = 0.3;
const qreal BAND_NAME_TEXT_OPACITY = 0.6; const qreal BAND_NAME_TEXT_OPACITY = 0.6;

View File

@ -49,17 +49,17 @@ LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesign
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag,
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::BAND_TAG),
createBand createBand
); );
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagHeader, xmlTagHeader,
LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::BAND_TAG),
createHeader createHeader
); );
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagFooter, xmlTagFooter,
LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::BAND_TAG),
createFooter createFooter
); );

View File

@ -42,7 +42,7 @@ LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignI
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagHeader, xmlTagHeader,
LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::BAND_TAG),
createHeader createHeader
); );
@ -52,7 +52,7 @@ LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesign
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagFooter, xmlTagFooter,
LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::BAND_TAG),
createFooter createFooter
); );

View File

@ -41,7 +41,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag,
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::BAND_TAG),
createBand createBand
); );
} }

View File

@ -44,7 +44,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag,
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::BAND_TAG),
createBand createBand
); );
} }

View File

@ -40,7 +40,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag,
LimeReport::ItemAttribs(QObject::tr("Report Footer"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Report Footer"),LimeReport::Const::BAND_TAG),
createBand createBand
); );
} }

View File

@ -39,7 +39,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag,
LimeReport::ItemAttribs(QObject::tr("Report Header"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Report Header"),LimeReport::Const::BAND_TAG),
createBand createBand
); );
} }

View File

@ -45,7 +45,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagBand, xmlTagBand,
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::BAND_TAG),
createBand createBand
); );
@ -55,7 +55,7 @@ LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesign
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagHeader, xmlTagHeader,
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::BAND_TAG),
createHeader createHeader
); );
@ -65,7 +65,7 @@ LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesign
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagFooter, xmlTagFooter,
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::BAND_TAG),
createFooter createFooter
); );

View File

@ -10,7 +10,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag,
LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::BAND_TAG),
createBand createBand
); );
} }

View File

@ -218,10 +218,10 @@ void AbstractLayout::collectionLoadFinished(const QString& collectionName)
} }
} }
void AbstractLayout::objectLoadFinished() void AbstractLayout::finishLoading()
{ {
layoutMarker()->setHeight(height()); layoutMarker()->setHeight(height());
LayoutDesignIntf::objectLoadFinished(); LayoutDesignIntf::finishLoading();
} }
bool AbstractLayout::isNeedUpdateSize(RenderPass pass) const bool AbstractLayout::isNeedUpdateSize(RenderPass pass) const

View File

@ -39,7 +39,7 @@ public:
int childrenCount(); int childrenCount();
int layoutSpacing() const; int layoutSpacing() const;
void setLayoutSpacing(int layoutSpacing); void setLayoutSpacing(int layoutSpacing);
qreal layoutSpacingMM(){ return m_layoutSpacing * Const::mmFACTOR;} qreal layoutSpacingMM(){ return m_layoutSpacing * ppm();}
protected: protected:
void beforeDelete(); void beforeDelete();
void childAddedEvent(BaseDesignIntf *child); void childAddedEvent(BaseDesignIntf *child);
@ -47,7 +47,7 @@ protected:
void initMode(ItemMode mode); void initMode(ItemMode mode);
void setBorderLinesFlags(BorderLines flags); void setBorderLinesFlags(BorderLines flags);
void collectionLoadFinished(const QString &collectionName); void collectionLoadFinished(const QString &collectionName);
void objectLoadFinished(); void finishLoading();
bool isNeedUpdateSize(RenderPass pass) const; bool isNeedUpdateSize(RenderPass pass) const;
QVariant itemChange(GraphicsItemChange change, const QVariant &value); QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight); void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);

View File

@ -47,7 +47,7 @@ LimeReport::BaseDesignIntf *createHLayout(QObject *owner, LimeReport::BaseDesign
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag,
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::BAND_TAG),
createHLayout createHLayout
); );
} }

View File

@ -160,7 +160,6 @@ void TextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* style, Q
Q_UNUSED(widget); Q_UNUSED(widget);
Q_UNUSED(style); Q_UNUSED(style);
TextPtr text = textDocument(); TextPtr text = textDocument();
painter->save(); painter->save();
@ -975,9 +974,9 @@ BaseDesignIntf *TextItem::cloneEmpty(int height, QObject *owner, QGraphicsItem *
return empty; return empty;
} }
void TextItem::objectLoadFinished() void TextItem::finishLoading()
{ {
ItemDesignIntf::objectLoadFinished(); ItemDesignIntf::finishLoading();
// if (itemMode() == DesignMode || !isNeedExpandContent()){ // if (itemMode() == DesignMode || !isNeedExpandContent()){
// if (autoHeight() && autoWidth()) // if (autoHeight() && autoWidth())
// initTextSizes(); // initTextSizes();

View File

@ -121,7 +121,7 @@ public:
BaseDesignIntf* cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent); BaseDesignIntf* cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent);
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0); BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
BaseDesignIntf* cloneEmpty(int height, QObject *owner, QGraphicsItem *parent); BaseDesignIntf* cloneEmpty(int height, QObject *owner, QGraphicsItem *parent);
void objectLoadFinished(); void finishLoading();
void setTextItemFont(QFont value); void setTextItemFont(QFont value);
QWidget* defaultEditor(); QWidget* defaultEditor();

View File

@ -13,7 +13,7 @@ LimeReport::BaseDesignIntf *createVLayout(QObject *owner, LimeReport::BaseDesign
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag,
LimeReport::ItemAttribs(QObject::tr("VLayout"), LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("VLayout"), LimeReport::Const::BAND_TAG),
createVLayout createVLayout
); );
} }

View File

@ -38,7 +38,10 @@
namespace LimeReport { 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, 3 * band->ppm(), 3 * band->ppm() ),
m_band(band),
m_isMoving(false)
{ {
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
} }
@ -51,27 +54,34 @@ QRectF BandMarker::boundingRect() const
void BandMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem* /**option*/, QWidget* /*widget*/) void BandMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem* /**option*/, QWidget* /*widget*/)
{ {
painter->save(); painter->save();
painter->setOpacity(Const::BAND_MARKER_OPACITY); painter->setOpacity(Const::BAND_MARKER_SELECTED_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->setPen(QPen(QBrush(Qt::lightGray),2));
if (m_band->ppm() >= 5){
int startPos = (boundingRect().width() - 10) / 2;
for (int i = 0; i<3; i++){
painter->fillRect(QRectF(startPos, boundingRect().height() - 6, 2, 2), Qt::white);
startPos += 4;
}
painter->setPen(Qt::white);
painter->drawLine(0, boundingRect().height()-1, boundingRect().width(), boundingRect().height()-1);
} else {
painter->fillRect(QRectF( painter->fillRect(QRectF(
boundingRect().bottomLeft().x(), boundingRect().bottomLeft().x(),
boundingRect().bottomLeft().y()-4, boundingRect().bottomLeft().y() - 2,
boundingRect().width(),4), Qt::lightGray boundingRect().width(),2), Qt::white
); );
}
if (m_band->isSelected()){
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);
painter->setBrush(Qt::white); painter->setBrush(Qt::white);
painter->setPen(Qt::white); painter->setPen(Qt::white);
painter->drawEllipse(r.adjusted(5,5,-5,-5)); painter->drawEllipse(r.adjusted(3,3,-3,-3));
if (m_band->isSelected()){
painter->setBrush(LimeReport::Const::SELECTION_COLOR);
painter->drawEllipse(r.adjusted(7,7,-7,-7));
} }
painter->restore(); painter->restore();
} }
@ -106,6 +116,10 @@ void BandMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
m_band->scene()->clearSelection(); m_band->scene()->clearSelection();
m_band->setSelected(true); m_band->setSelected(true);
m_oldBandPos = m_band->pos(); m_oldBandPos = m_band->pos();
if (!hasCursor()){
m_isMoving = true;
m_band->setIsChangingPos(true);
}
update(0,0,boundingRect().width(),boundingRect().width()); update(0,0,boundingRect().width(),boundingRect().width());
} }
} }
@ -138,6 +152,8 @@ void BandMarker::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
void BandMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) void BandMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
m_isMoving = false;
m_band->setIsChangingPos(false);
m_band->posChanged(m_band, m_band->pos(), m_oldBandPos); m_band->posChanged(m_band, m_band->pos(), m_oldBandPos);
} }
@ -168,7 +184,9 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
m_repeatOnEachRow(false), m_repeatOnEachRow(false),
m_useAlternateBackgroundColor(false), m_useAlternateBackgroundColor(false),
m_bottomSpace(0), m_bottomSpace(0),
m_shiftItems(0) m_shiftItems(0),
m_paddingTop(0),
m_paddingBottom(0)
{ {
setPossibleResizeDirectionFlags(ResizeBottom); setPossibleResizeDirectionFlags(ResizeBottom);
setPossibleMoveFlags(TopBotom); setPossibleMoveFlags(TopBotom);
@ -180,7 +198,7 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
setBackgroundMode(BaseDesignIntf::TransparentMode); setBackgroundMode(BaseDesignIntf::TransparentMode);
setFillTransparentInDesignMode(false); setFillTransparentInDesignMode(false);
setHeight(100); setHeight(Const::DEFAULT_BAND_HEIGHT * Const::STORAGE_MM_FACTOR);
setFixedPos(true); setFixedPos(true);
setFlag(QGraphicsItem::ItemClipsChildrenToShape); setFlag(QGraphicsItem::ItemClipsChildrenToShape);
m_bandMarker = new BandMarker(this); m_bandMarker = new BandMarker(this);
@ -249,6 +267,12 @@ bool BandDesignIntf::isNeedUpdateSize(RenderPass pass) const{
return false; return false;
} }
void BandDesignIntf::setPpm(int ppm)
{
ItemsContainerDesignInft::setPpm(ppm);
updateBandMarkerGeometry(QRectF(pos(),size()));
}
void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
prepareRect(painter, option, widget); prepareRect(painter, option, widget);
@ -256,7 +280,7 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
if (itemMode() & DesignMode){ if (itemMode() & DesignMode){
painter->save(); painter->save();
QString bandText = bandTitle(); QString bandText = bandTitle();
QFont font("Arial", 7 * Const::fontFACTOR, -1, true); QFont font("Arial", 6 * Const::FONT_FACTOR * ppm(), -1, true);
QFontMetrics fontMetrics(font); QFontMetrics fontMetrics(font);
QVector<QRectF> bandNameRects; QVector<QRectF> bandNameRects;
@ -272,10 +296,10 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
for (int i=0;i<bandNameRects.count();i++){ for (int i=0;i<bandNameRects.count();i++){
QRectF labelRect = bandNameRects[i].adjusted(-2,-2,2,2); QRectF labelRect = bandNameRects[i].adjusted(-2,-2,2,2);
if ((labelRect.height())<height() && (childBaseItems().isEmpty()) && !isSelected()){ if ((labelRect.height())<height() && (childBaseItems().isEmpty()) && !isSelected()){
painter->setRenderHint(QPainter::Antialiasing); //painter->setRenderHint(QPainter::Antialiasing);
painter->setBrush(bandColor()); painter->setBrush(bandColor());
painter->setOpacity(Const::BAND_NAME_AREA_OPACITY); painter->setOpacity(Const::BAND_NAME_AREA_OPACITY);
painter->drawRoundedRect(labelRect,8,8); painter->drawRect(labelRect);
painter->setOpacity(Const::BAND_NAME_TEXT_OPACITY); painter->setOpacity(Const::BAND_NAME_TEXT_OPACITY);
painter->setPen(Qt::black); painter->setPen(Qt::black);
painter->drawText(bandNameRects[i],Qt::AlignHCenter,bandText); painter->drawText(bandNameRects[i],Qt::AlignHCenter,bandText);
@ -286,10 +310,10 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
BaseDesignIntf::paint(painter,option,widget); BaseDesignIntf::paint(painter,option,widget);
} }
QRectF BandDesignIntf::boundingRect() const //QRectF BandDesignIntf::boundingRect() const
{ //{
return ItemsContainerDesignInft::boundingRect().adjusted(0,-4,0,4); // return ItemsContainerDesignInft::boundingRect().adjusted(0,-4,0,4);
} //}
void BandDesignIntf::translateBandsName() void BandDesignIntf::translateBandsName()
{ {
@ -359,7 +383,7 @@ bool BandDesignIntf::isUnique() const
void BandDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode) void BandDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode)
{ {
ItemsContainerDesignInft::setItemMode(mode); ItemsContainerDesignInft::setItemMode(mode);
updateBandMarkerGeometry(); updateBandMarkerGeometry(QRectF(pos(),size()));
} }
QString BandDesignIntf::datasourceName(){ QString BandDesignIntf::datasourceName(){
@ -741,10 +765,10 @@ void BandDesignIntf::parentObjectLoadFinished()
setParentBand(findParentBand()); setParentBand(findParentBand());
} }
void BandDesignIntf::objectLoadFinished() void BandDesignIntf::finishLoading()
{ {
m_bandMarker->setHeight(height()); m_bandMarker->setHeight(height());
BaseDesignIntf::objectLoadFinished(); BaseDesignIntf::finishLoading();
} }
void BandDesignIntf::emitBandRendered(BandDesignIntf* band) void BandDesignIntf::emitBandRendered(BandDesignIntf* band)
@ -804,18 +828,19 @@ BandDesignIntf* BandDesignIntf::findParentBand()
return 0; return 0;
} }
void BandDesignIntf::updateBandMarkerGeometry() void BandDesignIntf::updateBandMarkerGeometry(QRectF geometry)
{ {
if (parentItem() && m_bandMarker){ if (parentItem() && m_bandMarker){
m_bandMarker->setPos(pos().x()-m_bandMarker->width(),pos().y()); m_bandMarker->setWidth(3 * ppm());
m_bandMarker->setHeight(rect().height()); m_bandMarker->setHeight(geometry.height());
m_bandMarker->setPos(geometry.x()-m_bandMarker->width(),geometry.y());
} }
} }
void BandDesignIntf::geometryChangedEvent(QRectF, QRectF ) void BandDesignIntf::geometryChangedEvent(QRectF, QRectF )
{ {
if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){ if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){
updateBandMarkerGeometry(); updateBandMarkerGeometry(QRectF(pos(), size()));
} }
foreach (BaseDesignIntf* item, childBaseItems()) { foreach (BaseDesignIntf* item, childBaseItems()) {
if (item->itemAlign()!=DesignedItemAlign){ if (item->itemAlign()!=DesignedItemAlign){
@ -827,10 +852,7 @@ void BandDesignIntf::geometryChangedEvent(QRectF, QRectF )
QVariant BandDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant BandDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if ((change==ItemPositionChange)&&((itemMode()&DesignMode)||(itemMode()&EditMode))){ if ((change==ItemPositionChange)&&((itemMode()&DesignMode)||(itemMode()&EditMode))){
if (m_bandMarker){ updateBandMarkerGeometry(QRectF(value.toPointF(),size()));
m_bandMarker->setPos((value.toPointF().x()-m_bandMarker->boundingRect().width()),
value.toPointF().y());
}
} }
if (change==ItemSelectedChange){ if (change==ItemSelectedChange){
if (m_bandMarker){ if (m_bandMarker){
@ -923,6 +945,31 @@ void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QStrin
m_bandNameLabel->updateLabel(newName); m_bandNameLabel->updateLabel(newName);
} }
int BandDesignIntf::paddingBottom() const
{
return m_paddingBottom;
}
void BandDesignIntf::setPaddingBottom(int paddingBottom)
{
m_paddingBottom = paddingBottom;
}
QRectF BandDesignIntf::boundingRect() const
{
return ItemsContainerDesignInft::boundingRect().adjusted(0,0,0,1);
}
int BandDesignIntf::paddingTop() const
{
return m_paddingTop;
}
void BandDesignIntf::setPaddingTop(int paddingTop)
{
m_paddingTop = paddingTop;
}
int BandDesignIntf::shiftItems() const int BandDesignIntf::shiftItems() const
{ {
return m_shiftItems; return m_shiftItems;
@ -1120,7 +1167,7 @@ void BandDesignIntf::setKeepFooterTogether(bool value)
void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{ {
qreal spaceBorder = 0; qreal spaceBorder = m_paddingBottom+1;
if (keepBottomSpace()) spaceBorder = bottomSpace(); if (keepBottomSpace()) spaceBorder = bottomSpace();
spaceBorder = spaceBorder > 0 ? spaceBorder : 0; spaceBorder = spaceBorder > 0 ? spaceBorder : 0;
if (borderLines() != 0){ if (borderLines() != 0){
@ -1134,7 +1181,7 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
arrangeSubItems(pass, dataManager); arrangeSubItems(pass, dataManager);
if (autoHeight()){ if (autoHeight()){
if (!keepTopSpace()) { if (!keepTopSpace()) {
qreal minTop = findMinTop() + m_shiftItems; qreal minTop = findMinTop() + m_shiftItems - m_paddingTop;
foreach (BaseDesignIntf* item, childBaseItems()) { foreach (BaseDesignIntf* item, childBaseItems()) {
item->setY(item->y() - minTop); item->setY(item->y() - minTop);
} }
@ -1183,14 +1230,14 @@ BandNameLabel::BandNameLabel(BandDesignIntf *band, QGraphicsItem *parent)
void BandNameLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void BandNameLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing); //painter->setRenderHint(QPainter::Antialiasing);
painter->setFont(QFont("Arial",7*Const::fontFACTOR,-1,true)); painter->setFont(QFont("Arial", 6 * Const::FONT_FACTOR * m_band->ppm(), -1, true));
painter->setOpacity(1); painter->setOpacity(1);
QPen pen(Const::BAND_NAME_BORDER_COLOR); QPen pen(Const::BAND_NAME_BORDER_COLOR);
//pen.setWidth(2); //pen.setWidth(2);
painter->setBrush(Qt::yellow); painter->setBrush(Qt::yellow);
painter->setPen(pen); painter->setPen(pen);
painter->drawRoundedRect(m_rect,8,8); painter->drawRect(m_rect);
painter->setOpacity(0.8); painter->setOpacity(0.8);
painter->setPen(Qt::black); painter->setPen(Qt::black);
painter->drawText(m_rect,Qt::AlignCenter,m_band->bandTitle()); painter->drawText(m_rect,Qt::AlignCenter,m_band->bandTitle());
@ -1206,13 +1253,13 @@ QRectF BandNameLabel::boundingRect() const
void BandNameLabel::updateLabel(const QString& bandName) void BandNameLabel::updateLabel(const QString& bandName)
{ {
QFont font("Arial",7*Const::fontFACTOR,-1,true); QFont font("Arial", 6 * Const::FONT_FACTOR * m_band->ppm(), -1, true);
QFontMetrics fontMetrics(font); QFontMetrics fontMetrics(font);
prepareGeometryChange(); prepareGeometryChange();
m_rect = QRectF( m_rect = QRectF(
m_band->pos().x()+10, m_band->pos().x()+6,
m_band->pos().y()-(fontMetrics.height()+10), m_band->pos().y()-(fontMetrics.height()+10),
fontMetrics.width(bandName)+20,fontMetrics.height()+10 fontMetrics.width(bandName)+40,fontMetrics.height()+10
); );
update(); update();
} }

View File

@ -53,6 +53,7 @@ class BandDesignIntf;
class BandMarker : public QGraphicsItem{ class BandMarker : public QGraphicsItem{
public: public:
friend BandDesignIntf;
explicit BandMarker(BandDesignIntf* band, QGraphicsItem *parent=0); explicit BandMarker(BandDesignIntf* band, QGraphicsItem *parent=0);
QRectF boundingRect() const; QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *); void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
@ -64,7 +65,6 @@ public:
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
void hoverMoveEvent(QGraphicsSceneHoverEvent* event); void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
@ -73,6 +73,7 @@ private:
QColor m_color; QColor m_color;
BandDesignIntf* m_band; BandDesignIntf* m_band;
QPointF m_oldBandPos; QPointF m_oldBandPos;
bool m_isMoving;
}; };
class BandNameLabel : public QGraphicsItem{ class BandNameLabel : public QGraphicsItem{
@ -114,6 +115,8 @@ class BandDesignIntf : public ItemsContainerDesignInft
Q_PROPERTY(BGMode backgroundMode READ backgroundMode WRITE setBackgroundModeProperty) Q_PROPERTY(BGMode backgroundMode READ backgroundMode WRITE setBackgroundModeProperty)
Q_PROPERTY(int backgroundOpacity READ opacity WRITE setBackgroundOpacity) Q_PROPERTY(int backgroundOpacity READ opacity WRITE setBackgroundOpacity)
Q_PROPERTY(int shiftItems READ shiftItems WRITE setShiftItems) Q_PROPERTY(int shiftItems READ shiftItems WRITE setShiftItems)
Q_PROPERTY(int paddingTop READ paddingTop WRITE setPaddingTop)
Q_PROPERTY(int paddingBottom READ paddingBottom WRITE setPaddingBottom)
friend class BandMarker; friend class BandMarker;
friend class BandNameLabel; friend class BandNameLabel;
friend class ReportRender; friend class ReportRender;
@ -148,7 +151,7 @@ public:
~BandDesignIntf(); ~BandDesignIntf();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QRectF boundingRect() const; //QRectF boundingRect() const;
void translateBandsName(); void translateBandsName();
virtual BandsType bandType() const; virtual BandsType bandType() const;
virtual QString bandTitle() const; virtual QString bandTitle() const;
@ -214,7 +217,7 @@ public:
BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0); BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0); BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
void parentObjectLoadFinished(); void parentObjectLoadFinished();
void objectLoadFinished(); void finishLoading();
void emitBandRendered(BandDesignIntf *band); void emitBandRendered(BandDesignIntf *band);
bool isSplittable() const {return m_splitable;} bool isSplittable() const {return m_splitable;}
@ -266,11 +269,18 @@ 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(); void updateBandMarkerGeometry(QRectF geometry);
int shiftItems() const; int shiftItems() const;
void setShiftItems(int shiftItems); void setShiftItems(int shiftItems);
bool isNeedUpdateSize(RenderPass) const; bool isNeedUpdateSize(RenderPass) const;
void setPpm(int ppm);
int paddingTop() const;
void setPaddingTop(int paddingTop);
int paddingBottom() const;
void setPaddingBottom(int paddingBottom);
QRectF boundingRect() const;
signals: signals:
void bandRendered(BandDesignIntf* band); void bandRendered(BandDesignIntf* band);
void preparedForRender(); void preparedForRender();
@ -334,6 +344,8 @@ private:
int m_bottomSpace; int m_bottomSpace;
QMap<QString,QVariant> m_bookmarks; QMap<QString,QVariant> m_bookmarks;
int m_shiftItems; int m_shiftItems;
int m_paddingTop;
int m_paddingBottom;
}; };
class DataBandDesignIntf : public BandDesignIntf{ class DataBandDesignIntf : public BandDesignIntf{

View File

@ -51,7 +51,7 @@ QStringList BandsManager::bandNames()
<<QObject::tr("Data")<<QObject::tr("SubDetail"); <<QObject::tr("Data")<<QObject::tr("SubDetail");
foreach(ItemAttribs attr,LimeReport::DesignElementsFactory::instance().attribsMap().values()){ foreach(ItemAttribs attr,LimeReport::DesignElementsFactory::instance().attribsMap().values()){
if ((attr.m_tag==LimeReport::Const::bandTAG)&&(!bandsList.contains(attr.m_alias))) if ((attr.m_tag==LimeReport::Const::BAND_TAG)&&(!bandsList.contains(attr.m_alias)))
bandsList.append(attr.m_alias); bandsList.append(attr.m_alias);
} }
@ -60,7 +60,7 @@ QStringList BandsManager::bandNames()
BandDesignIntf* BandsManager::createBand(const QString &type, QObject *owner, LimeReport::BaseDesignIntf *parent) BandDesignIntf* BandsManager::createBand(const QString &type, QObject *owner, LimeReport::BaseDesignIntf *parent)
{ {
QString identity = LimeReport::DesignElementsFactory::instance().attribsMap().key(LimeReport::ItemAttribs(type,LimeReport::Const::bandTAG)); QString identity = LimeReport::DesignElementsFactory::instance().attribsMap().key(LimeReport::ItemAttribs(type,LimeReport::Const::BAND_TAG));
return dynamic_cast<LimeReport::BandDesignIntf*>(LimeReport::DesignElementsFactory::instance().objectCreator(identity)(owner,parent)); return dynamic_cast<LimeReport::BandDesignIntf*>(LimeReport::DesignElementsFactory::instance().objectCreator(identity)(owner,parent));
} }

View File

@ -85,7 +85,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
m_fillTransparentInDesignMode(true), m_fillTransparentInDesignMode(true),
m_unitType(Millimeters), m_unitType(Millimeters),
m_itemGeometryLocked(false), m_itemGeometryLocked(false),
m_isChangingPos(false) m_isChangingPos(false),
m_ppm(Const::STORAGE_MM_FACTOR)
{ {
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)) {
@ -98,13 +99,15 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
QRectF BaseDesignIntf::boundingRect() const QRectF BaseDesignIntf::boundingRect() const
{ {
qreal halfpw = pen().widthF() / 2; //qreal halfpw = pen().widthF() / 2;
halfpw += 2; // halfpw += 2;
return rect().adjusted(-halfpw, -halfpw, halfpw, halfpw); //return rect().adjusted(-halfpw, -halfpw, halfpw, halfpw);
return rect();
} }
BaseDesignIntf::~BaseDesignIntf(void) { BaseDesignIntf::~BaseDesignIntf(void) {
if (m_selectionMarker)
delete m_selectionMarker;
} }
void BaseDesignIntf::setParentReportItem(const QString &value) void BaseDesignIntf::setParentReportItem(const QString &value)
@ -253,7 +256,7 @@ QString BaseDesignIntf::setItemPosY(qreal yValue)
QFont BaseDesignIntf::transformToSceneFont(const QFont& value) const QFont BaseDesignIntf::transformToSceneFont(const QFont& value) const
{ {
QFont f = value; QFont f = value;
f.setPixelSize(f.pointSize()*Const::fontFACTOR); f.setPixelSize(f.pointSize() * Const::FONT_FACTOR * ppm());
return f; return f;
} }
@ -287,7 +290,7 @@ void BaseDesignIntf::setupPainter(QPainter *painter) const
if (!painter) { if (!painter) {
return; return;
} }
painter->setFont(m_font); painter->setFont(transformToSceneFont(m_font));
painter->setPen(m_fontColor); painter->setPen(m_fontColor);
} }
@ -335,17 +338,17 @@ QSizeF BaseDesignIntf::size() const
QSizeF BaseDesignIntf::sizeMM() const QSizeF BaseDesignIntf::sizeMM() const
{ {
return QSizeF(width() / Const::mmFACTOR, height() / Const::mmFACTOR); return QSizeF(width() / ppm(), height() / ppm());
} }
qreal BaseDesignIntf::widthMM() const qreal BaseDesignIntf::widthMM() const
{ {
return width() / Const::mmFACTOR; return width() / ppm();
} }
qreal BaseDesignIntf::heightMM() const qreal BaseDesignIntf::heightMM() const
{ {
return height() / Const::mmFACTOR; return height() / ppm();
} }
//void BaseDesignIntf::setUnitFactor(qreal unitFactor) //void BaseDesignIntf::setUnitFactor(qreal unitFactor)
@ -356,8 +359,8 @@ qreal BaseDesignIntf::heightMM() const
qreal BaseDesignIntf::unitFactor() const qreal BaseDesignIntf::unitFactor() const
{ {
if (m_unitType == Millimeters) if (m_unitType == Millimeters)
return Const::mmFACTOR; return ppm();
else return Const::mmFACTOR * 2.54; else return ppm() * 2.54;
} }
void BaseDesignIntf::setUnitType(BaseDesignIntf::UnitType value) void BaseDesignIntf::setUnitType(BaseDesignIntf::UnitType value)
@ -374,7 +377,7 @@ BaseDesignIntf::UnitType BaseDesignIntf::unitType()
QPointF BaseDesignIntf::posMM() const QPointF BaseDesignIntf::posMM() const
{ {
return QPointF(pos().x() / Const::mmFACTOR, pos().y() / Const::mmFACTOR); return QPointF(pos().x() / ppm(), pos().y() / ppm());
} }
QRectF BaseDesignIntf::rect() const QRectF BaseDesignIntf::rect() const
@ -515,7 +518,7 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
update(); update();
} }
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent /**event*/) void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/)
{ {
m_hovered = true; m_hovered = true;
update(); update();
@ -676,8 +679,8 @@ QPointF BaseDesignIntf::modifyPosForAlignedItem(const QPointF& pos){
BaseDesignIntf* parent = dynamic_cast<BaseDesignIntf*>(parentItem()); BaseDesignIntf* parent = dynamic_cast<BaseDesignIntf*>(parentItem());
PageItemDesignIntf* parentPage = dynamic_cast<PageItemDesignIntf*>(parentItem()); PageItemDesignIntf* parentPage = dynamic_cast<PageItemDesignIntf*>(parentItem());
if (parent){ if (parent){
qreal leftBorder = parentPage ? parentPage->leftMargin() * Const::mmFACTOR : 0; qreal leftBorder = parentPage ? parentPage->leftMargin() * ppm() : 0;
qreal rightBorder = parentPage ? parentPage->rightMargin() * Const::mmFACTOR : 0; qreal rightBorder = parentPage ? parentPage->rightMargin() * ppm() : 0;
qreal avaibleSpace = parent->width()-(leftBorder+rightBorder); qreal avaibleSpace = parent->width()-(leftBorder+rightBorder);
switch(m_itemAlign){ switch(m_itemAlign){
@ -718,8 +721,8 @@ void BaseDesignIntf::updateItemAlign(){
PageItemDesignIntf* parentPage = dynamic_cast<PageItemDesignIntf*>(parentItem()); PageItemDesignIntf* parentPage = dynamic_cast<PageItemDesignIntf*>(parentItem());
m_changingItemAlign = true; m_changingItemAlign = true;
if (parent){ if (parent){
qreal leftBorder = parentPage ? parentPage->leftMargin() * Const::mmFACTOR : 0; qreal leftBorder = parentPage ? parentPage->leftMargin() * ppm() : 0;
qreal rightBorder = parentPage ? parentPage->rightMargin() * Const::mmFACTOR : 0; qreal rightBorder = parentPage ? parentPage->rightMargin() * ppm() : 0;
qreal aviableSpace = parent->width()-(leftBorder+rightBorder); qreal aviableSpace = parent->width()-(leftBorder+rightBorder);
setPos(modifyPosForAlignedItem(pos())); setPos(modifyPosForAlignedItem(pos()));
if (m_itemAlign == ParentWidthItemAlign) if (m_itemAlign == ParentWidthItemAlign)
@ -745,6 +748,19 @@ void BaseDesignIntf::updatePossibleDirectionFlags(){
} }
} }
int BaseDesignIntf::ppm() const
{
return m_ppm;
}
void BaseDesignIntf::setPpm(int ppm)
{
if (m_ppm != ppm){
m_ppm = ppm;
update();
}
}
bool BaseDesignIntf::isChangingPos() const bool BaseDesignIntf::isChangingPos() const
{ {
return m_isChangingPos; return m_isChangingPos;
@ -833,7 +849,7 @@ void BaseDesignIntf::updateSelectionMarker()
if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker); if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker);
if (parentItem()) { if (parentItem()) {
m_selectionMarker->setRect(rect()); m_selectionMarker->setRect(rect());
m_selectionMarker->setPos(0,0); m_selectionMarker->setPos(mapToItem(parentItem(), QPoint(0,0)));
} }
} }
} }
@ -841,11 +857,12 @@ void BaseDesignIntf::updateSelectionMarker()
void BaseDesignIntf::turnOnSelectionMarker(bool value) void BaseDesignIntf::turnOnSelectionMarker(bool value)
{ {
if (value && !m_selectionMarker){ if (value && !m_selectionMarker){
m_selectionMarker = new SelectionMarker(this, this); m_selectionMarker = new SelectionMarker(this->parentItem(), this);
m_selectionMarker->setColor(selectionMarkerColor()); m_selectionMarker->setColor(selectionMarkerColor());
updateSelectionMarker(); updateSelectionMarker();
m_selectionMarker->setVisible(true); m_selectionMarker->setVisible(true);
} else { } else {
scene()->removeItem(m_selectionMarker);
delete m_selectionMarker; delete m_selectionMarker;
m_selectionMarker = 0; m_selectionMarker = 0;
} }
@ -1079,9 +1096,9 @@ void BaseDesignIntf::setGeometry(QRectF rect)
m_bottomRect = QRectF(0-resizeHandleSize(), height() - resizeHandleSize(), width()+resizeHandleSize()*2, resizeHandleSize()*2); m_bottomRect = QRectF(0-resizeHandleSize(), height() - resizeHandleSize(), width()+resizeHandleSize()*2, resizeHandleSize()*2);
m_leftRect = QRectF(0-resizeHandleSize(), 0-resizeHandleSize(), resizeHandleSize()*2, height()+resizeHandleSize()*2); m_leftRect = QRectF(0-resizeHandleSize(), 0-resizeHandleSize(), resizeHandleSize()*2, height()+resizeHandleSize()*2);
m_rightRect = QRectF(width() - resizeHandleSize(), 0-resizeHandleSize(), resizeHandleSize()*2, height()+resizeHandleSize()*2); m_rightRect = QRectF(width() - resizeHandleSize(), 0-resizeHandleSize(), resizeHandleSize()*2, height()+resizeHandleSize()*2);
m_boundingRect = QRectF(); //m_boundingRect = QRectF();
updateSelectionMarker(); updateSelectionMarker();
if (!isLoading()){ if (!isLoading() && !isPpmChanging()){
geometryChangedEvent(geometry(), m_oldGeometry); geometryChangedEvent(geometry(), m_oldGeometry);
emit geometryChanged(this, geometry(), m_oldGeometry); emit geometryChanged(this, geometry(), m_oldGeometry);
} }
@ -1168,6 +1185,7 @@ QVariant BaseDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, co
if (change == QGraphicsItem::ItemPositionHasChanged) { if (change == QGraphicsItem::ItemPositionHasChanged) {
updateSelectionMarker(); updateSelectionMarker();
if (!isLoading() && !isPpmChanging())
emit geometryChanged(this, geometry(), geometry()); emit geometryChanged(this, geometry(), geometry());
} }
@ -1530,19 +1548,19 @@ BaseDesignIntf *BaseDesignIntf::cloneItemWOChild(ItemMode mode, QObject *owner,
BaseDesignIntf *clone = createSameTypeItem(owner, parent); BaseDesignIntf *clone = createSameTypeItem(owner, parent);
clone->setObjectName(this->objectName()); clone->setObjectName(this->objectName());
clone->setItemMode(mode); clone->setItemMode(mode);
clone->objectLoadStarted(); clone->startLoading();
clone->setReportSettings(this->reportSettings()); clone->setReportSettings(this->reportSettings());
for (int i = 0; i < clone->metaObject()->propertyCount(); i++) { for (int i = 0; i < clone->metaObject()->propertyCount(); i++) {
if (clone->metaObject()->property(i).isWritable()) if (clone->metaObject()->property(i).isWritable())
clone->setProperty(clone->metaObject()->property(i).name(), property(clone->metaObject()->property(i).name())); clone->setProperty(clone->metaObject()->property(i).name(), property(clone->metaObject()->property(i).name()));
} }
clone->objectLoadFinished(); clone->finishLoading();
return clone; return clone;
} }
void BaseDesignIntf::initFromItem(BaseDesignIntf *source) void BaseDesignIntf::initFromItem(BaseDesignIntf *source)
{ {
objectLoadStarted(); startLoading();
for (int i = 0; i < metaObject()->propertyCount(); i++) { for (int i = 0; i < metaObject()->propertyCount(); i++) {
if (strcmp(metaObject()->property(i).name(),"objectName")!=0) if (strcmp(metaObject()->property(i).name(),"objectName")!=0)
if (source->property(metaObject()->property(i).name()).isValid()) { if (source->property(metaObject()->property(i).name()).isValid()) {
@ -1550,7 +1568,7 @@ void BaseDesignIntf::initFromItem(BaseDesignIntf *source)
setProperty(metaObject()->property(i).name(), source->property(metaObject()->property(i).name())); setProperty(metaObject()->property(i).name(), source->property(metaObject()->property(i).name()));
} }
} }
objectLoadFinished(); finishLoading();
} }
bool BaseDesignIntf::canBeSplitted(int height) const bool BaseDesignIntf::canBeSplitted(int height) const
@ -1569,19 +1587,41 @@ BaseDesignIntf *BaseDesignIntf::cloneEmpty(int height, QObject *owner, QGraphics
{Q_UNUSED(height); Q_UNUSED(owner); Q_UNUSED(parent); return 0;} {Q_UNUSED(height); Q_UNUSED(owner); Q_UNUSED(parent); return 0;}
void BaseDesignIntf::objectLoadStarted() void BaseDesignIntf::startLoading()
{ {
m_objectState = ObjectLoading; m_objectState = ObjectLoading;
} }
void BaseDesignIntf::objectLoadFinished() void BaseDesignIntf::finishLoading()
{ {
m_objectState = ObjectLoaded; m_objectState = ObjectLoaded;
emit objectLoaded(this); emit objectLoaded(this);
} }
void BaseDesignIntf::startSaving()
{
m_objectState = ObjectSaving;
}
void BaseDesignIntf::finishSaving()
{
m_objectState = ObjectSaved;
}
void BaseDesignIntf::startChangingPpm()
{
m_objectState = ObjectPpmChanging;
}
void BaseDesignIntf::finishChangingPpm()
{
m_objectState = ObjectPpmChanged;
}
void BaseDesignIntf::parentObjectLoadFinished() void BaseDesignIntf::parentObjectLoadFinished()
{} {
m_objectState = ObjectLoaded;
}
QList<BaseDesignIntf *> BaseDesignIntf::childBaseItems() const QList<BaseDesignIntf *> BaseDesignIntf::childBaseItems() const
{ {
@ -1683,9 +1723,9 @@ QRectF Marker::boundingRect() const
void Marker::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) void Marker::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
{ {
QPen pen; QPen pen;
const int markerSize = 5; const int markerSize = 3;
pen.setColor(color()); pen.setColor(color());
pen.setWidth(2); pen.setWidth(1);
pen.setStyle(Qt::DotLine); pen.setStyle(Qt::DotLine);
painter->setPen(pen); painter->setPen(pen);
painter->setOpacity(Const::SELECTION_COLOR_OPACITY); painter->setOpacity(Const::SELECTION_COLOR_OPACITY);
@ -1750,7 +1790,6 @@ void SelectionMarker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void SelectionMarker::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void SelectionMarker::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
qDebug() << "mouse move";
if (owner()) owner()->mouseMoveEvent(event); if (owner()) owner()->mouseMoveEvent(event);
} }

View File

@ -81,7 +81,9 @@ class DataSourceManager;
class ReportRender; class ReportRender;
class BaseDesignIntf : class BaseDesignIntf :
public QObject, public QGraphicsItem, public ICollectionContainer, public ObjectLoadingStateIntf { public QObject, public QGraphicsItem, public ICollectionContainer,
public ObjectLoadingStateIntf, public ObjectSavingStateIntf
{
Q_OBJECT Q_OBJECT
Q_INTERFACES(QGraphicsItem) Q_INTERFACES(QGraphicsItem)
Q_FLAGS(BorderLines) Q_FLAGS(BorderLines)
@ -99,8 +101,8 @@ class BaseDesignIntf :
public: public:
enum BGMode { TransparentMode, OpaqueMode}; enum BGMode { TransparentMode, OpaqueMode};
enum BrushStyle{
enum BrushStyle{ NoBrush, NoBrush,
SolidPattern, SolidPattern,
Dense1Pattern, Dense1Pattern,
Dense2Pattern, Dense2Pattern,
@ -113,10 +115,11 @@ public:
VerPattern, VerPattern,
CrossPattern, CrossPattern,
BDiagPattern, BDiagPattern,
FDiagPattern }; FDiagPattern
};
enum ResizeFlags {
enum ResizeFlags { Fixed = 0, Fixed = 0,
ResizeLeft = 1, ResizeLeft = 1,
ResizeRight = 2, ResizeRight = 2,
ResizeTop = 4, ResizeTop = 4,
@ -124,7 +127,8 @@ public:
AllDirections = 15 AllDirections = 15
}; };
enum MoveFlags { None = 0, enum MoveFlags {
None = 0,
LeftRight=1, LeftRight=1,
TopBotom=2, TopBotom=2,
All=3 All=3
@ -139,9 +143,23 @@ public:
AllLines = 15 AllLines = 15
}; };
enum ObjectState {ObjectLoading, ObjectLoaded, ObjectCreated}; enum ObjectState {
ObjectLoading,
ObjectLoaded,
ObjectCreated,
ObjectSaving,
ObjectSaved,
ObjectPpmChanging,
ObjectPpmChanged
};
enum ItemAlign {LeftItemAlign,RightItemAlign,CenterItemAlign,ParentWidthItemAlign,DesignedItemAlign}; enum ItemAlign {
LeftItemAlign,
RightItemAlign,
CenterItemAlign,
ParentWidthItemAlign,
DesignedItemAlign
};
enum UnitType {Millimeters, Inches}; enum UnitType {Millimeters, Inches};
#if (QT_VERSION >= QT_VERSION_CHECK(5,5, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5,5, 0))
@ -258,10 +276,19 @@ public:
virtual BaseDesignIntf* cloneBottomPart(int height, QObject* owner=0, QGraphicsItem* parent=0); virtual BaseDesignIntf* cloneBottomPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
virtual BaseDesignIntf* cloneEmpty(int height, QObject* owner=0, QGraphicsItem* parent=0); virtual BaseDesignIntf* cloneEmpty(int height, QObject* owner=0, QGraphicsItem* parent=0);
bool isLoaded(){return m_objectState==ObjectLoaded;} bool isLoaded(){return m_objectState == ObjectLoaded;}
bool isLoading(){return m_objectState==ObjectLoading;} bool isLoading(){return m_objectState == ObjectLoading;}
void objectLoadStarted(); bool isSaving(){return m_objectState == ObjectSaving;}
void objectLoadFinished(); bool isSaved(){return m_objectState == ObjectSaved;}
bool isPpmChanging() {return m_objectState == ObjectPpmChanging;}
void startLoading();
void finishLoading();
void startSaving();
void finishSaving();
void startChangingPpm();
void finishChangingPpm();
virtual void parentObjectLoadFinished(); virtual void parentObjectLoadFinished();
virtual void beforeDelete(); virtual void beforeDelete();
@ -334,6 +361,9 @@ public:
bool isChangingPos() const; bool isChangingPos() const;
void setIsChangingPos(bool isChangingPos); void setIsChangingPos(bool isChangingPos);
int ppm() const;
virtual void setPpm(int ppm);
protected: protected:
//ICollectionContainer //ICollectionContainer
@ -346,7 +376,7 @@ 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 hoverEnterEvent(QGraphicsSceneHoverEvent); void hoverEnterEvent(QGraphicsSceneHoverEvent* );
void mouseMoveEvent(QGraphicsSceneMouseEvent* event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
@ -423,7 +453,7 @@ private:
int m_borderLineSize; int m_borderLineSize;
QRectF m_rect; QRectF m_rect;
mutable QRectF m_boundingRect; //mutable QRectF m_boundingRect;
QRectF m_oldGeometry; QRectF m_oldGeometry;
BGMode m_BGMode; BGMode m_BGMode;
@ -464,6 +494,7 @@ private:
UnitType m_unitType; UnitType m_unitType;
bool m_itemGeometryLocked; bool m_itemGeometryLocked;
bool m_isChangingPos; bool m_isChangingPos;
int m_ppm;
signals: signals:
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
void posChanging(QObject* object, QPointF newPos, QPointF oldPos); void posChanging(QObject* object, QPointF newPos, QPointF oldPos);

View File

@ -160,7 +160,7 @@ void initReportItems(){
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"HLayout", "HLayout",
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::BAND_TAG),
createHLayout createHLayout
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
@ -183,58 +183,58 @@ void initReportItems(){
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"Data", "Data",
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::BAND_TAG),
createDataBand createDataBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"DataHeader", "DataHeader",
LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::BAND_TAG),
createHeaderDataBand createHeaderDataBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"DataFooter", "DataFooter",
LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::BAND_TAG),
createFooterDataBand createFooterDataBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"GroupHeader", "GroupHeader",
LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::BAND_TAG),
createGroupHeaderBand createGroupHeaderBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"GroupFooter", "GroupFooter",
LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::BAND_TAG),
createGroupFooterBand createGroupFooterBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"PageFooter", "PageFooter",
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::BAND_TAG),
createPageFooterBand createPageFooterBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"PageHeader", "PageHeader",
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::BAND_TAG),
createPageHeaderBand createPageHeaderBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"SubDetail", "SubDetail",
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::BAND_TAG),
createSubDetailBand createSubDetailBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"SubDetailHeader", "SubDetailHeader",
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::BAND_TAG),
createSubDetailHeaderBand createSubDetailHeaderBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"SubDetailFooter", "SubDetailFooter",
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::BAND_TAG),
createSubDetailFooterBand createSubDetailFooterBand
); );
DesignElementsFactory::instance().registerCreator( DesignElementsFactory::instance().registerCreator(
"TearOffBand", "TearOffBand",
LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::BAND_TAG),
createTearOffBand createTearOffBand
); );

View File

@ -59,22 +59,29 @@ namespace Const{
int const DEFAULT_GRID_STEP = 1; int const DEFAULT_GRID_STEP = 1;
int const RESIZE_HANDLE_SIZE = 5; int const RESIZE_HANDLE_SIZE = 5;
int const SELECTION_PEN_SIZE = 1; 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;
double const SELECTED_RESIZE_ZONE_OPACITY = 0.6; double const SELECTED_RESIZE_ZONE_OPACITY = 0.6;
Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green; Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green;
Qt::GlobalColor const SELECTION_COLOR = Qt::red; Qt::GlobalColor const SELECTION_COLOR = Qt::red;
Qt::GlobalColor const JOIN_COLOR = Qt::blue; Qt::GlobalColor const JOIN_COLOR = Qt::blue;
double const SELECTION_COLOR_OPACITY = 0.6; double const SELECTION_COLOR_OPACITY = 0.6;
const qreal fontFACTOR = 3.5; const qreal FONT_FACTOR = 0.33;
const int mmFACTOR = 10; const int STORAGE_MM_FACTOR = 10;
const int itemPaleteIconSize = 24; const int DESIGNER_MM_FACTOR = 5;
const qreal minSpaceBorder = 10; const int OLD_MM_FACTOR = 10;
const QString bandTAG = "band"; const int DEFAULT_ITEM_WIDTH = 20;
const int DEFAULT_ITEM_HEIGHT = 5;
const int DEFAULT_BAND_HEIGHT = 10;
const int PPM_PERCENT_STEP = 20;
const int ITEM_PALETTE_ICON_SIZE = 24;
const qreal MIN_SPACE_BORDER = 10;
const QString BAND_TAG = "band";
const Qt::GlobalColor BAND_NAME_LABEL_COLOR = Qt::yellow; const Qt::GlobalColor BAND_NAME_LABEL_COLOR = Qt::yellow;
const Qt::GlobalColor BAND_NAME_BORDER_COLOR = Qt::darkYellow; const Qt::GlobalColor BAND_NAME_BORDER_COLOR = Qt::darkGray;
const qreal BAND_MARKER_OPACITY = 1; const qreal BAND_MARKER_SELECTED_OPACITY = 1;
const qreal BAND_MARKER_OPACITY = 0.3;
const qreal LAYOUT_MARKER_OPACITY = 0.3; const qreal LAYOUT_MARKER_OPACITY = 0.3;
const qreal BAND_NAME_AREA_OPACITY = 0.3; const qreal BAND_NAME_AREA_OPACITY = 0.3;
const qreal BAND_NAME_TEXT_OPACITY = 0.6; const qreal BAND_NAME_TEXT_OPACITY = 0.6;

View File

@ -3,6 +3,8 @@
#include <QApplication> #include <QApplication>
#include <qmath.h> #include <qmath.h>
#include "lrpagedesignintf.h"
namespace LimeReport{ namespace LimeReport{
GraphicsViewZoomer::GraphicsViewZoomer(QGraphicsView* view) GraphicsViewZoomer::GraphicsViewZoomer(QGraphicsView* view)
@ -15,7 +17,13 @@ GraphicsViewZoomer::GraphicsViewZoomer(QGraphicsView* view)
} }
void GraphicsViewZoomer::gentleZoom(double factor) { void GraphicsViewZoomer::gentleZoom(double factor) {
m_view->scale(factor, factor); PageDesignIntf* page = dynamic_cast<PageDesignIntf*>(m_view->scene());
if (page){
if(factor > 1)
page->pageItem()->zoomIn();
else
page->pageItem()->zoomOut();
}
m_view->centerOn(m_targetScenePos); m_view->centerOn(m_targetScenePos);
QPointF delta_viewport_pos = m_targetViewportPos - QPointF(m_view->viewport()->width() / 2.0, QPointF delta_viewport_pos = m_targetViewportPos - QPointF(m_view->viewport()->width() / 2.0,
m_view->viewport()->height() / 2.0); m_view->viewport()->height() / 2.0);

View File

@ -239,11 +239,16 @@ void PageDesignIntf::startInsertMode(const QString &ItemType)
emit insertModeStarted(); emit insertModeStarted();
m_insertMode = true; m_insertMode = true;
m_insertItemType = ItemType; m_insertItemType = ItemType;
m_itemInsertRect = this->addRect(0, 0, 200, 50);
m_itemInsertRect->setVisible(false);
PageItemDesignIntf* page = pageItem() ? pageItem() : getCurrentPage(); PageItemDesignIntf* page = pageItem() ? pageItem() : getCurrentPage();
if (page) if (page){
m_itemInsertRect = this->addRect(0, 0,
Const::DEFAULT_ITEM_WIDTH * page->ppm(),
Const::DEFAULT_ITEM_HEIGHT * page->ppm()
);
m_itemInsertRect->setVisible(false);
m_itemInsertRect->setParentItem(page); m_itemInsertRect->setParentItem(page);
}
} }
void PageDesignIntf::startEditMode() void PageDesignIntf::startEditMode()
@ -268,10 +273,10 @@ void PageDesignIntf::setPageItem(PageItemDesignIntf::Ptr pageItem)
} }
m_pageItem = pageItem; m_pageItem = pageItem;
m_pageItem->setItemMode(itemMode()); m_pageItem->setItemMode(itemMode());
setSceneRect(pageItem->rect().adjusted(-10 * Const::mmFACTOR, setSceneRect(pageItem->rect().adjusted(-10 * pageItem->ppm(),
-10 * Const::mmFACTOR, -10 * pageItem->ppm(),
10 * Const::mmFACTOR, 10 * pageItem->ppm(),
10 * Const::mmFACTOR)); 10 * pageItem->ppm()));
addItem(m_pageItem.data()); addItem(m_pageItem.data());
registerItem(m_pageItem.data()); registerItem(m_pageItem.data());
} }
@ -295,10 +300,11 @@ void PageDesignIntf::setPageItems(QList<PageItemDesignIntf::Ptr> pages)
curHeight+=pageItem->height()+20; curHeight+=pageItem->height()+20;
if (curWidth<pageItem->width()) curWidth=pageItem->width(); if (curWidth<pageItem->width()) curWidth=pageItem->width();
} }
setSceneRect(QRectF( 0, 0, curWidth,curHeight).adjusted( -10 * Const::mmFACTOR, if (!pages.isEmpty())
-10 * Const::mmFACTOR, setSceneRect(QRectF( 0, 0, curWidth,curHeight).adjusted( -10 * pages.at(0)->ppm(),
10 * Const::mmFACTOR, -10 * pages.at(0)->ppm(),
10 * Const::mmFACTOR)); 10 * pages.at(0)->ppm(),
10 * pages.at(0)->ppm()));
if (m_reportPages.count()>0) if (m_reportPages.count()>0)
m_currentPage = m_reportPages.at(0).data(); m_currentPage = m_reportPages.at(0).data();
@ -314,9 +320,19 @@ void PageDesignIntf::removePageItem(PageItemDesignIntf::Ptr pageItem)
void PageDesignIntf::mousePressEvent(QGraphicsSceneMouseEvent *event) void PageDesignIntf::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (m_insertMode) { if (m_insertMode && pageItem()) {
finalizeInsertMode(); finalizeInsertMode();
CommandIf::Ptr command = InsertItemCommand::create(this, m_insertItemType, event->scenePos(), QSize(200, 50)); CommandIf::Ptr command = InsertItemCommand::create(
this, m_insertItemType,
QPointF(
(event->scenePos().x()/pageItem()->ppm())*Const::STORAGE_MM_FACTOR,
(event->scenePos().y()/pageItem()->ppm())*Const::STORAGE_MM_FACTOR
),
QSize(
Const::DEFAULT_ITEM_WIDTH * Const::STORAGE_MM_FACTOR,
Const::DEFAULT_ITEM_HEIGHT * Const::STORAGE_MM_FACTOR
)
);
saveCommand(command); saveCommand(command);
emit itemInserted(this, event->scenePos(), m_insertItemType); emit itemInserted(this, event->scenePos(), m_insertItemType);
} }
@ -470,6 +486,8 @@ BaseDesignIntf *PageDesignIntf::internalAddBand(T bandType)
band->setObjectName(genObjectName(*band)); band->setObjectName(genObjectName(*band));
band->setItemTypeName("Band"); band->setItemTypeName("Band");
band->setHeight((band->height()/Const::STORAGE_MM_FACTOR)*pageItem()->ppm());
band->setPpm(pageItem()->ppm());
BandDesignIntf* pb = 0; BandDesignIntf* pb = 0;
if (selectedItems().count() > 0) { if (selectedItems().count() > 0) {
@ -721,12 +739,12 @@ bool PageDesignIntf::isLoading()
return m_isLoading; return m_isLoading;
} }
void PageDesignIntf::objectLoadStarted() void PageDesignIntf::startLoading()
{ {
m_isLoading=true; m_isLoading=true;
} }
void PageDesignIntf::objectLoadFinished() void PageDesignIntf::finishLoading()
{ {
m_isLoading=false; m_isLoading=false;
} }
@ -767,7 +785,8 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event)
(event->mimeData()->text().indexOf("variable:")==0)) (event->mimeData()->text().indexOf("variable:")==0))
){ ){
bool isVar = event->mimeData()->text().indexOf("variable:")==0; bool isVar = event->mimeData()->text().indexOf("variable:")==0;
BaseDesignIntf* item = addReportItem("TextItem",event->scenePos(),QSize(250, 50)); BaseDesignIntf* item = addReportItem("TextItem",event->scenePos(),QSize(25 * Const::DESIGNER_MM_FACTOR, 5 * Const::DESIGNER_MM_FACTOR));
item->setPpm(pageItem()->ppm());
TextItem* ti = dynamic_cast<TextItem*>(item); TextItem* ti = dynamic_cast<TextItem*>(item);
QString data = event->mimeData()->text().remove(0,event->mimeData()->text().indexOf(":")+1); QString data = event->mimeData()->text().remove(0,event->mimeData()->text().indexOf(":")+1);
if (isVar) data = data.remove(QRegExp(" \\[.*\\]")); if (isVar) data = data.remove(QRegExp(" \\[.*\\]"));
@ -1109,6 +1128,30 @@ void PageDesignIntf::setCurrentPage(PageItemDesignIntf* currentPage)
} }
} }
void PageDesignIntf::setPpm(int ppm)
{
int curHeight = 0;
int curWidth = 0;
foreach(PageItemDesignIntf::Ptr page, m_reportPages){
page->setPpm(ppm);
curHeight += page->height()+ 2 * ppm;
if (curWidth < page->width()) curWidth = page->width();
}
if (!m_reportPages.isEmpty())
setSceneRect(
QRectF( 0, 0, curWidth,curHeight)
.adjusted(
-10 * ppm,
-10 * ppm,
10 * ppm,
10 * ppm
)
);
}
ReportSettings *PageDesignIntf::getReportSettings() const ReportSettings *PageDesignIntf::getReportSettings() const
{ {
return m_reportSettings; return m_reportSettings;
@ -1931,7 +1974,9 @@ CommandIf::Ptr InsertItemCommand::create(PageDesignIntf *page, const QString &it
bool InsertItemCommand::doIt() bool InsertItemCommand::doIt()
{ {
BaseDesignIntf *item = page()->addReportItem(m_itemType, m_pos, m_size); QRectF rect = page()->pageItem()->transformFromStorageToScenePpm(QRectF(m_pos,m_size));
BaseDesignIntf *item = page()->addReportItem(m_itemType, QPoint(rect.x(),rect.y()), rect.size());
item->setPpm(page()->pageItem()->ppm());
if (item) m_itemName = item->objectName(); if (item) m_itemName = item->objectName();
return item != 0; return item != 0;
} }
@ -1942,21 +1987,16 @@ void InsertItemCommand::undoIt()
if (item){ if (item){
page()->removeReportItem(item,false); page()->removeReportItem(item,false);
} }
// page()->removeItem(item);
// delete item;
} }
CommandIf::Ptr DeleteItemCommand::create(PageDesignIntf *page, BaseDesignIntf *item) CommandIf::Ptr DeleteItemCommand::create(PageDesignIntf *page, BaseDesignIntf *item)
{ {
DeleteItemCommand *command = new DeleteItemCommand(); DeleteItemCommand *command = new DeleteItemCommand();
//QScopedPointer<ItemsWriterIntf> writer(new XMLWriter());
//writer->putItem(item);
command->setPage(page); command->setPage(page);
command->setItem(item); command->setItem(item);
LayoutDesignIntf* layout = dynamic_cast<LayoutDesignIntf*>(item->parent()); LayoutDesignIntf* layout = dynamic_cast<LayoutDesignIntf*>(item->parent());
if (layout) if (layout)
command->m_layoutName = layout->objectName(); command->m_layoutName = layout->objectName();
//command->m_itemXML = writer->saveToString();
return CommandIf::Ptr(command); return CommandIf::Ptr(command);
} }

View File

@ -179,7 +179,7 @@ namespace LimeReport {
PageItemDesignIntf* getCurrentPage() const; PageItemDesignIntf* getCurrentPage() const;
void setCurrentPage(PageItemDesignIntf* currentPage); void setCurrentPage(PageItemDesignIntf* currentPage);
void setPpm(int ppm);
protected: protected:
virtual void keyPressEvent(QKeyEvent *event); virtual void keyPressEvent(QKeyEvent *event);
@ -199,8 +199,8 @@ namespace LimeReport {
bool isExistsObjectName (const QString& objectName, QList<QGraphicsItem *> &itemsList) const; bool isExistsObjectName (const QString& objectName, QList<QGraphicsItem *> &itemsList) const;
bool isLoading(); bool isLoading();
void objectLoadStarted(); void startLoading();
void objectLoadFinished(); void finishLoading();
HorizontalLayout* internalAddHLayout(); HorizontalLayout* internalAddHLayout();
VerticalLayout* internalAddVLayout(); VerticalLayout* internalAddVLayout();

View File

@ -350,6 +350,46 @@ void PageItemDesignIntf::setPrintBehavior(const PrintBehavior &printBehavior)
m_printBehavior = printBehavior; m_printBehavior = printBehavior;
} }
QRectF PageItemDesignIntf::transformFromStorageToScenePpm(const QRectF &rect)
{
return changeRectPpm(rect, Const::STORAGE_MM_FACTOR, ppm());
}
void PageItemDesignIntf::zoomIn()
{
setPpm(ppm()+1);
}
void PageItemDesignIntf::zoomOut()
{
if (ppm() > 1)
setPpm(ppm()-1);
}
void PageItemDesignIntf::setPpm(int ppm)
{
if (this->ppm() != ppm){
startChangingPpm();
QRectF rect = changeRectPpm(QRectF(this->pos(), this->size()), this->ppm(), ppm);
setPos(rect.topLeft());
setSize(rect.size());
foreach(QGraphicsItem * item, allChildBaseItems()) {
BaseDesignIntf *ri = dynamic_cast<BaseDesignIntf *>(item);
if (ri) {
rect = changeRectPpm(QRectF(ri->pos(), ri->size()), ri->ppm(), ppm);
ri->startChangingPpm();
ri->setPos(rect.topLeft());
ri->setSize(rect.size());
ri->setPpm(ppm);
ri->finishChangingPpm();
}
}
BaseDesignIntf::setPpm(ppm);
updateMarginRect();
finishChangingPpm();
}
}
PageItemDesignIntf::PrintBehavior PageItemDesignIntf::printBehavior() const PageItemDesignIntf::PrintBehavior PageItemDesignIntf::printBehavior() const
{ {
return m_printBehavior; return m_printBehavior;
@ -682,8 +722,8 @@ QSizeF PageItemDesignIntf::getRectByPageSize(const PageSize& size)
printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOrientation((QPrinter::Orientation)pageOrientation()); printer.setOrientation((QPrinter::Orientation)pageOrientation());
printer.setPaperSize((QPrinter::PageSize)size); printer.setPaperSize((QPrinter::PageSize)size);
return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * 10, return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * ppm(),
printer.paperSize(QPrinter::Millimeter).height() * 10); printer.paperSize(QPrinter::Millimeter).height() * ppm());
} }
else { else {
@ -913,6 +953,8 @@ void PageItemDesignIntf::bandPositionChanged(QObject* object, QPointF newPos, QP
void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry) void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry)
{ {
bandPositionChanged(object, newGeometry.topLeft(), oldGeometry.topLeft()); bandPositionChanged(object, newGeometry.topLeft(), oldGeometry.topLeft());
if (newGeometry.size() != oldGeometry.size())
relocateBands();
} }
void PageItemDesignIntf::setUnitTypeProperty(BaseDesignIntf::UnitType value) void PageItemDesignIntf::setUnitTypeProperty(BaseDesignIntf::UnitType value)
@ -927,6 +969,16 @@ void PageItemDesignIntf::setUnitTypeProperty(BaseDesignIntf::UnitType value)
} }
} }
QRectF PageItemDesignIntf::changeRectPpm(const QRectF &rect, int oldPpm, int newPpm)
{
return QRectF(
(rect.x()/oldPpm)*newPpm,
(rect.y()/oldPpm)*newPpm,
(rect.width()/oldPpm)*newPpm,
(rect.height()/oldPpm)*newPpm
);
}
void PageItemDesignIntf::collectionLoadFinished(const QString &collectionName) void PageItemDesignIntf::collectionLoadFinished(const QString &collectionName)
{ {
if (collectionName.compare("children",Qt::CaseInsensitive)==0){ if (collectionName.compare("children",Qt::CaseInsensitive)==0){
@ -948,10 +1000,10 @@ void PageItemDesignIntf::collectionLoadFinished(const QString &collectionName)
void PageItemDesignIntf::updateMarginRect() void PageItemDesignIntf::updateMarginRect()
{ {
m_pageRect = rect(); m_pageRect = rect();
m_pageRect.adjust( leftMargin() * Const::mmFACTOR, m_pageRect.adjust( leftMargin() * ppm(),
topMargin() * Const::mmFACTOR, topMargin() * ppm(),
-rightMargin() * Const::mmFACTOR, -rightMargin() * ppm(),
-bottomMargin() * Const::mmFACTOR -bottomMargin() * ppm()
); );
foreach(BandDesignIntf* band,m_bands){ foreach(BandDesignIntf* band,m_bands){
@ -972,26 +1024,26 @@ void PageItemDesignIntf::paintGrid(QPainter *ppainter, QRectF rect)
ppainter->setPen(QPen(gridColor())); ppainter->setPen(QPen(gridColor()));
ppainter->setOpacity(0.5); ppainter->setOpacity(0.5);
for (int i = 0; i <= (rect.height() - 5 * unitFactor()) / (10 * unitFactor()); ++i){ for (int i = 0; i <= (rect.height() - 5 * unitFactor()) / (10 * unitFactor()); ++i){
if (i * 10 * unitFactor() + 5 * unitFactor() >= topMargin() * Const::mmFACTOR) if (i * 10 * unitFactor() + 5 * unitFactor() >= topMargin() * ppm())
ppainter->drawLine(rect.x(), (i * 10 * unitFactor()) + ( (rect.y() + 5 * unitFactor()) - (topMargin() * Const::mmFACTOR)), ppainter->drawLine(rect.x(), (i * 10 * unitFactor()) + ( (rect.y() + 5 * unitFactor()) - (topMargin() * ppm())),
rect.right(), i * 10 * unitFactor() +( (rect.y() + 5 * unitFactor()) - (topMargin() * Const::mmFACTOR))); rect.right(), i * 10 * unitFactor() +( (rect.y() + 5 * unitFactor()) - (topMargin() * ppm())));
}; };
for (int i=0; i<=((rect.width() - 5 * unitFactor()) / (10 * unitFactor())); ++i){ for (int i=0; i<=((rect.width() - 5 * unitFactor()) / (10 * unitFactor())); ++i){
if (i * 10 * unitFactor() + 5 * unitFactor() >= leftMargin() * Const::mmFACTOR) if (i * 10 * unitFactor() + 5 * unitFactor() >= leftMargin() * ppm())
ppainter->drawLine(i * 10 * unitFactor() + ((rect.x() + 5 * unitFactor()) - (leftMargin() * Const::mmFACTOR)), rect.y(), ppainter->drawLine(i * 10 * unitFactor() + ((rect.x() + 5 * unitFactor()) - (leftMargin() * ppm())), rect.y(),
i * 10 * unitFactor() + ((rect.x() + 5 * unitFactor()) - (leftMargin() * Const::mmFACTOR)), rect.bottom()); i * 10 * unitFactor() + ((rect.x() + 5 * unitFactor()) - (leftMargin() * ppm())), rect.bottom());
}; };
ppainter->setPen(QPen(gridColor())); ppainter->setPen(QPen(gridColor()));
ppainter->setOpacity(1); ppainter->setOpacity(1);
for (int i = 0; i <= (rect.width() / (10 * unitFactor())); ++i){ for (int i = 0; i <= (rect.width() / (10 * unitFactor())); ++i){
if (i * 10 * unitFactor() >= leftMargin() * Const::mmFACTOR) if (i * 10 * unitFactor() >= leftMargin() * ppm())
ppainter->drawLine(i * 10 * unitFactor() + (rect.x() - (leftMargin() * Const::mmFACTOR)), rect.y(), ppainter->drawLine(i * 10 * unitFactor() + (rect.x() - (leftMargin() * ppm())), rect.y(),
i * 10 * unitFactor() + (rect.x() - (leftMargin() * Const::mmFACTOR)), rect.bottom()); i * 10 * unitFactor() + (rect.x() - (leftMargin() * ppm())), rect.bottom());
}; };
for (int i = 0; i <= rect.height() / (10 * unitFactor()); ++i){ for (int i = 0; i <= rect.height() / (10 * unitFactor()); ++i){
if (i * 10 * unitFactor() >= topMargin() * Const::mmFACTOR) if (i * 10 * unitFactor() >= topMargin() * ppm())
ppainter->drawLine(rect.x(), i * 10 * unitFactor() + (rect.y() - (topMargin() * Const::mmFACTOR)), ppainter->drawLine(rect.x(), i * 10 * unitFactor() + (rect.y() - (topMargin() * ppm())),
rect.right(), i * 10 * unitFactor() + (rect.y() - (topMargin() * Const::mmFACTOR))); rect.right(), i * 10 * unitFactor() + (rect.y() - (topMargin() * ppm())));
}; };
ppainter->drawRect(rect); ppainter->drawRect(rect);
ppainter->restore(); ppainter->restore();
@ -1016,9 +1068,9 @@ int PageItemDesignIntf::gridStep()
else return Const::DEFAULT_GRID_STEP; else return Const::DEFAULT_GRID_STEP;
} }
void PageItemDesignIntf::objectLoadFinished() void PageItemDesignIntf::finishLoading()
{ {
BaseDesignIntf::objectLoadFinished(); BaseDesignIntf::finishLoading();
updateMarginRect(); updateMarginRect();
} }

View File

@ -136,7 +136,7 @@ public:
QList<BandDesignIntf *>& bands(); QList<BandDesignIntf *>& bands();
void setGridStep(int value); void setGridStep(int value);
int gridStep(); int gridStep();
void objectLoadFinished(); void finishLoading();
bool fullPage() const; bool fullPage() const;
void setFullPage(bool fullPage); void setFullPage(bool fullPage);
@ -177,6 +177,10 @@ public:
PrintBehavior printBehavior() const; PrintBehavior printBehavior() const;
void setPrintBehavior(const PrintBehavior &printBehavior); void setPrintBehavior(const PrintBehavior &printBehavior);
void setPpm(int ppm);
QRectF transformFromStorageToScenePpm(const QRectF& rect);
void zoomIn();
void zoomOut();
signals: signals:
void beforeFirstPageRendered(); void beforeFirstPageRendered();
void afterLastPageRendered(); void afterLastPageRendered();
@ -186,6 +190,7 @@ protected slots:
void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
void setUnitTypeProperty(BaseDesignIntf::UnitType value); void setUnitTypeProperty(BaseDesignIntf::UnitType value);
protected: protected:
QRectF changeRectPpm(const QRectF& rect, int oldPpm, int newPpm);
void collectionLoadFinished(const QString& collectionName); void collectionLoadFinished(const QString& collectionName);
QRectF& pageRect(){return m_pageRect;} QRectF& pageRect(){return m_pageRect;}
void updateMarginRect(); void updateMarginRect();

View File

@ -160,14 +160,14 @@ void PreviewReportWidget::setErrorsMesagesVisible(bool visible)
void PreviewReportWidget::zoomIn() void PreviewReportWidget::zoomIn()
{ {
d_ptr->m_scalePercent = (d_ptr->m_scalePercent / 10) * 10 + 10; d_ptr->m_scalePercent = (d_ptr->m_scalePercent / 20) * 20 + Const::PPM_PERCENT_STEP;
setScalePercent(d_ptr->m_scalePercent); setScalePercent(d_ptr->m_scalePercent);
} }
void PreviewReportWidget::zoomOut() void PreviewReportWidget::zoomOut()
{ {
if (d_ptr->m_scalePercent>0) if (d_ptr->m_scalePercent > 20)
d_ptr->m_scalePercent = (d_ptr->m_scalePercent / 10) * 10 - 10; d_ptr->m_scalePercent = (d_ptr->m_scalePercent / 20) * 20 - Const::PPM_PERCENT_STEP;
setScalePercent(d_ptr->m_scalePercent); setScalePercent(d_ptr->m_scalePercent);
} }
@ -311,8 +311,21 @@ void PreviewReportWidget::setScalePercent(int percent)
{ {
ui->graphicsView->resetMatrix(); ui->graphicsView->resetMatrix();
d_ptr->m_scalePercent = percent; d_ptr->m_scalePercent = percent;
PageDesignIntf* page = dynamic_cast<PageDesignIntf*>(ui->graphicsView->scene());
if ((percent % Const::PPM_PERCENT_STEP) == 0){
if (page){
ui->graphicsView->scale(1,1);
page->setPpm(percent / Const::PPM_PERCENT_STEP);
}
} else {
if (page){
page->setPpm(Const::DESIGNER_MM_FACTOR);
}
qreal scaleSize = percent/100.0; qreal scaleSize = percent/100.0;
ui->graphicsView->scale(scaleSize, scaleSize); ui->graphicsView->scale(scaleSize, scaleSize);
}
emit scalePercentChanged(percent); emit scalePercentChanged(percent);
if (percent == 100){ if (percent == 100){
m_scaleType = OneToOne; m_scaleType = OneToOne;

View File

@ -14,7 +14,7 @@ class PreviewReportWidgetPrivate
public: public:
PreviewReportWidgetPrivate(PreviewReportWidget* previewReportWidget): PreviewReportWidgetPrivate(PreviewReportWidget* previewReportWidget):
m_previewPage(NULL), m_report(NULL), m_zoomer(NULL), m_previewPage(NULL), m_report(NULL), m_zoomer(NULL),
m_currentPage(1), m_changingPage(false), m_priorScrolValue(0), m_scalePercent(50), m_currentPage(1), m_changingPage(false), m_priorScrolValue(0), m_scalePercent(100),
q_ptr(previewReportWidget), m_previePageColor(Qt::white) {} q_ptr(previewReportWidget), m_previePageColor(Qt::white) {}
bool pageIsVisible(); bool pageIsVisible();
QRectF calcPageShift(); QRectF calcPageShift();

View File

@ -420,7 +420,7 @@ ItemsReaderIntf *PreviewReportWindow::reader()
void PreviewReportWindow::initPercentCombobox() void PreviewReportWindow::initPercentCombobox()
{ {
for (int i = 10; i<310; i+=10){ for (int i = 20; i<320; i+=20){
m_scalePercent->addItem(QString("%1%").arg(i)); m_scalePercent->addItem(QString("%1%").arg(i));
} }
m_scalePercent->setCurrentIndex(4); m_scalePercent->setCurrentIndex(4);

View File

@ -293,7 +293,7 @@ PageView* ReportDesignWidget::createPageView(PageDesignIntf* page){
view->setFrameShape(QFrame::NoFrame); view->setFrameShape(QFrame::NoFrame);
view->setScene(page); view->setScene(page);
view->setPageItem(page->pageItem()); view->setPageItem(page->pageItem());
view->scale(0.5, 0.5); page->pageItem()->setPpm(5);
view->centerOn(0, 0); view->centerOn(0, 0);
return view; return view;
} }
@ -513,12 +513,6 @@ bool ReportDesignWidget::save()
bool ReportDesignWidget::loadFromFile(const QString &fileName) bool ReportDesignWidget::loadFromFile(const QString &fileName)
{ {
if (m_report->loadFromFile(fileName,false)){ if (m_report->loadFromFile(fileName,false)){
// QByteArray editorState = m_scriptEditor->saveState();
// createTabs();
// m_scriptEditor->setPlainText(m_report->scriptContext()->initScript());
// m_scriptEditor->restoreState(editorState);
// emit loaded();
// m_dialogChanged = false;
return true; return true;
} else { } else {
QMessageBox::critical(this,tr("Error"),tr("Wrong file format")); QMessageBox::critical(this,tr("Error"),tr("Wrong file format"));
@ -526,10 +520,22 @@ bool ReportDesignWidget::loadFromFile(const QString &fileName)
} }
} }
void ReportDesignWidget::scale(qreal sx, qreal sy) void ReportDesignWidget::zoomIn()
{ {
//m_view->scale(sx,sy); if (activeView()) {
if (activeView()) activeView()->scale(sx,sy); PageDesignIntf* page = dynamic_cast<PageDesignIntf*>(activeView()->scene());
if (page)
page->pageItem()->zoomIn();
}
}
void ReportDesignWidget::zoomOut()
{
if (activeView()) {
PageDesignIntf* page = dynamic_cast<PageDesignIntf*>(activeView()->scene());
if (page)
page->pageItem()->zoomOut();
}
} }
QString ReportDesignWidget::reportFileName() QString ReportDesignWidget::reportFileName()
@ -1058,8 +1064,10 @@ bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event)
if (event->type() == QEvent::Wheel){ if (event->type() == QEvent::Wheel){
QWheelEvent* we = dynamic_cast<QWheelEvent*>(event); QWheelEvent* we = dynamic_cast<QWheelEvent*>(event);
if (QApplication::keyboardModifiers()==Qt::ControlModifier){ if (QApplication::keyboardModifiers()==Qt::ControlModifier){
if(we->delta()<0) scale(1.2,1.2); //if(we->delta()<0) scale(1.2,1.2);
else scale(1/1.2,1/1.2); //else scale(1/1.2,1/1.2);
if (we->delta() < 0) zoomIn();
else zoomOut();
} }
} }
return QWidget::eventFilter(target,event); return QWidget::eventFilter(target,event);

View File

@ -144,7 +144,10 @@ public:
QGraphicsView* activeView(); QGraphicsView* activeView();
QList<QGraphicsItem *> selectedItems(); QList<QGraphicsItem *> selectedItems();
QStringList datasourcesNames(); QStringList datasourcesNames();
void scale( qreal sx, qreal sy); //void scale( qreal sx, qreal sy);
void zoomIn();
void zoomOut();
ReportEnginePrivateInterface* report(){return m_report;} ReportEnginePrivateInterface* report(){return m_report;}
QString reportFileName(); QString reportFileName();
bool isNeedToSave(); bool isNeedToSave();

View File

@ -1189,12 +1189,12 @@ void ReportDesignWindow::slotLoadReport()
void ReportDesignWindow::slotZoomIn() void ReportDesignWindow::slotZoomIn()
{ {
m_reportDesignWidget->scale(1.2,1.2); m_reportDesignWidget->zoomIn();
} }
void ReportDesignWindow::slotZoomOut() void ReportDesignWindow::slotZoomOut()
{ {
m_reportDesignWidget->scale(1/1.2,1/1.2); m_reportDesignWidget->zoomOut();
} }
void ReportDesignWindow::slotEditMode() void ReportDesignWindow::slotEditMode()

View File

@ -687,6 +687,7 @@ bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName)
reader->setPassPhrase(m_passPhrase); reader->setPassPhrase(m_passPhrase);
if (reader->first()){ if (reader->first()){
if (reader->readItem(this)){ if (reader->readItem(this)){
m_fileName=fileName; m_fileName=fileName;
QFileInfo fi(fileName); QFileInfo fi(fileName);
m_reportName = fi.fileName(); m_reportName = fi.fileName();
@ -706,6 +707,7 @@ bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName)
EASY_BLOCK("Connect auto connections") EASY_BLOCK("Connect auto connections")
dataManager()->connectAutoConnections(); dataManager()->connectAutoConnections();
EASY_END_BLOCK; EASY_END_BLOCK;
dropChanges(); dropChanges();
if ( hasActivePreview() ) if ( hasActivePreview() )
@ -1240,7 +1242,7 @@ void ReportEnginePrivate::paintByExternalPainter(const QString& objectName, QPai
BaseDesignIntf* ReportEnginePrivate::createWatermark(PageDesignIntf* page, WatermarkSetting watermarkSetting) BaseDesignIntf* ReportEnginePrivate::createWatermark(PageDesignIntf* page, WatermarkSetting watermarkSetting)
{ {
WatermarkHelper watermarkHelper(watermarkSetting); WatermarkHelper watermarkHelper(watermarkSetting, page->pageItem()->ppm());
BaseDesignIntf* watermark = page->addReportItem("TextItem", watermarkHelper.mapToPage(*page->pageItem()), watermarkHelper.sceneSize()); BaseDesignIntf* watermark = page->addReportItem("TextItem", watermarkHelper.mapToPage(*page->pageItem()), watermarkHelper.sceneSize());
if (watermark){ if (watermark){
@ -1283,7 +1285,6 @@ ReportPages ReportEnginePrivate::renderToPages()
m_reportRender->setScriptContext(scriptContext()); m_reportRender->setScriptContext(scriptContext());
clearRenderingPages(); clearRenderingPages();
foreach (PageDesignIntf* page, m_pages) { foreach (PageDesignIntf* page, m_pages) {
QVector<BaseDesignIntf*> watermarks; QVector<BaseDesignIntf*> watermarks;
if (!m_watermarks.isEmpty()){ if (!m_watermarks.isEmpty()){
foreach(WatermarkSetting watermarkSetting, m_watermarks){ foreach(WatermarkSetting watermarkSetting, m_watermarks){
@ -1291,14 +1292,17 @@ ReportPages ReportEnginePrivate::renderToPages()
} }
} }
int savePpm = page->pageItem()->ppm();
page->pageItem()->setPpm(Const::STORAGE_MM_FACTOR);
PageItemDesignIntf* rp = createRenderingPage(page->pageItem()); PageItemDesignIntf* rp = createRenderingPage(page->pageItem());
page->pageItem()->setPpm(savePpm);
qDeleteAll(watermarks.begin(),watermarks.end()); qDeleteAll(watermarks.begin(),watermarks.end());
watermarks.clear(); watermarks.clear();
m_renderingPages.append(rp); m_renderingPages.append(rp);
scriptContext()->baseDesignIntfToScript(rp->objectName(), rp); scriptContext()->baseDesignIntfToScript(rp->objectName(), rp);
} }
scriptContext()->qobjectToScript("engine",this); scriptContext()->qobjectToScript("engine",this);
@ -1802,6 +1806,8 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
QPointF backupPagePos = page->pos(); QPointF backupPagePos = page->pos();
page->setPos(0,0); page->setPos(0,0);
int currentPpm = page->ppm();
page->setPpm(Const::STORAGE_MM_FACTOR);
m_renderPage.setPageItem(page); m_renderPage.setPageItem(page);
m_renderPage.setSceneRect(m_renderPage.pageItem()->mapToScene(m_renderPage.pageItem()->rect()).boundingRect()); m_renderPage.setSceneRect(m_renderPage.pageItem()->mapToScene(m_renderPage.pageItem()->rect()).boundingRect());
initPrinter(m_renderPage.pageItem()); initPrinter(m_renderPage.pageItem());
@ -1849,6 +1855,7 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
m_renderPage.render(m_painter); m_renderPage.render(m_painter);
} }
page->setPos(backupPagePos); page->setPos(backupPagePos);
page->setPpm(currentPpm);
m_renderPage.removePageItem(page); m_renderPage.removePageItem(page);
if (backupPage) backupPage->reactivatePageItem(page); if (backupPage) backupPage->reactivatePageItem(page);
return true; return true;
@ -2051,7 +2058,7 @@ qreal WatermarkHelper::valueToPixels(qreal value)
{ {
switch (m_watermark.geometry().type()) { switch (m_watermark.geometry().type()) {
case LimeReport::ItemGeometry::Millimeters: case LimeReport::ItemGeometry::Millimeters:
return value * Const::mmFACTOR; return value * m_ppm;
case LimeReport::ItemGeometry::Pixels: case LimeReport::ItemGeometry::Pixels:
return value; return value;
} }

View File

@ -59,8 +59,8 @@ class ReportExporterInterface;
class WatermarkHelper{ class WatermarkHelper{
public: public:
WatermarkHelper(const WatermarkSetting& watermark) WatermarkHelper(const WatermarkSetting& watermark, int ppm)
: m_watermark(watermark){} : m_watermark(watermark), m_ppm(ppm){}
qreal sceneX(); qreal sceneX();
qreal sceneY(); qreal sceneY();
qreal sceneWidth(); qreal sceneWidth();
@ -72,6 +72,7 @@ private:
qreal valueToPixels(qreal value); qreal valueToPixels(qreal value);
private: private:
const WatermarkSetting& m_watermark; const WatermarkSetting& m_watermark;
int m_ppm;
}; };

View File

@ -1300,7 +1300,7 @@ void ReportRender::startNewPage(bool isFirst)
m_renderPageItem->setObjectName(QLatin1String("ReportPage")+QString::number(m_pageCount)); m_renderPageItem->setObjectName(QLatin1String("ReportPage")+QString::number(m_pageCount));
m_maxHeightByColumn[m_currentColumn] = m_renderPageItem->pageRect().height(); m_maxHeightByColumn[m_currentColumn] = m_renderPageItem->pageRect().height();
m_currentStartDataPos[m_currentColumn] = m_patternPageItem->topMargin() * Const::mmFACTOR; m_currentStartDataPos[m_currentColumn] = m_patternPageItem->topMargin() * m_patternPageItem->ppm();
m_currentIndex = 0; m_currentIndex = 0;
if (isFirst) { if (isFirst) {
@ -1537,7 +1537,7 @@ void ReportRender::savePage(bool isLast)
pageHeight += band->height(); pageHeight += band->height();
} }
m_renderPageItem->setHeight(pageHeight + 10 + m_renderPageItem->setHeight(pageHeight + 10 +
(m_patternPageItem->topMargin() + m_patternPageItem->bottomMargin()) * Const::mmFACTOR); (m_patternPageItem->topMargin() + m_patternPageItem->bottomMargin()) * m_patternPageItem->ppm());
} }
} }

View File

@ -31,7 +31,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>503</width> <width>503</width>
<height>301</height> <height>317</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@ -90,7 +90,7 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSpinBox" name="verticalGridStep"> <widget class="QSpinBox" name="verticalGridStep">
<property name="value"> <property name="value">
<number>10</number> <number>5</number>
</property> </property>
</widget> </widget>
</item> </item>
@ -104,7 +104,7 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="QSpinBox" name="horizontalGridStep"> <widget class="QSpinBox" name="horizontalGridStep">
<property name="value"> <property name="value">
<number>10</number> <number>5</number>
</property> </property>
</widget> </widget>
</item> </item>
@ -216,7 +216,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>503</width> <width>503</width>
<height>301</height> <height>317</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@ -305,7 +305,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>503</width> <width>503</width>
<height>301</height> <height>317</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">

View File

@ -39,7 +39,7 @@ QString MarginPropItem::displayValue() const
return QString("%1 %2").arg(propertyValue().toDouble(), 0, 'f', 2) return QString("%1 %2").arg(propertyValue().toDouble(), 0, 'f', 2)
.arg(QObject::tr("mm")); .arg(QObject::tr("mm"));
case LimeReport::BaseDesignIntf::Inches: case LimeReport::BaseDesignIntf::Inches:
return QString("%1 %2").arg((propertyValue().toDouble() * Const::mmFACTOR) / (item->unitFactor() * 10), 0, 'f', 2) return QString("%1 %2").arg((propertyValue().toDouble() * item->ppm()) / (item->unitFactor() * 10), 0, 'f', 2)
.arg(QObject::tr("''")); .arg(QObject::tr("''"));
} }
} }
@ -72,7 +72,7 @@ qreal MarginPropItem::valueInUnits(qreal value) const
case LimeReport::BaseDesignIntf::Millimeters: case LimeReport::BaseDesignIntf::Millimeters:
return value; return value;
case LimeReport::BaseDesignIntf::Inches: case LimeReport::BaseDesignIntf::Inches:
return (value * Const::mmFACTOR) / (item->unitFactor() * 10); return (value * item->ppm()) / (item->unitFactor() * 10);
} }
} }
@ -83,8 +83,7 @@ qreal MarginPropItem::valueInReportUnits(qreal value) const
case LimeReport::BaseDesignIntf::Millimeters: case LimeReport::BaseDesignIntf::Millimeters:
return value; return value;
case LimeReport::BaseDesignIntf::Inches: case LimeReport::BaseDesignIntf::Inches:
return (value * (item->unitFactor() * 10)) / Const::mmFACTOR; return (value * (item->unitFactor() * 10)) / item->ppm();
} }
} }

View File

@ -40,8 +40,15 @@ namespace LimeReport{
class ObjectLoadingStateIntf{ class ObjectLoadingStateIntf{
public: public:
virtual bool isLoading() = 0; virtual bool isLoading() = 0;
virtual void objectLoadStarted() = 0; virtual void startLoading() = 0;
virtual void objectLoadFinished() = 0; virtual void finishLoading() = 0;
};
class ObjectSavingStateIntf{
public:
virtual bool isSaving() = 0;
virtual void startSaving() = 0;
virtual void finishSaving() = 0;
}; };
class ItemsWriterIntf class ItemsWriterIntf

View File

@ -116,7 +116,7 @@ void XMLReader::readItemFromNode(QObject* item,QDomElement *node)
{ {
EASY_BLOCK("readItemFromNode"); EASY_BLOCK("readItemFromNode");
ObjectLoadingStateIntf* lf = dynamic_cast<ObjectLoadingStateIntf*>(item); ObjectLoadingStateIntf* lf = dynamic_cast<ObjectLoadingStateIntf*>(item);
if(lf) lf->objectLoadStarted(); if(lf) lf->startLoading();
for (int i=0;i<node->childNodes().count();i++){ for (int i=0;i<node->childNodes().count();i++){
QDomElement currentNode =node->childNodes().at(i).toElement(); QDomElement currentNode =node->childNodes().at(i).toElement();
if (currentNode.attribute("Type")=="Object"){ if (currentNode.attribute("Type")=="Object"){
@ -128,7 +128,7 @@ void XMLReader::readItemFromNode(QObject* item,QDomElement *node)
readTranslation(item,&currentNode); readTranslation(item,&currentNode);
} else readProperty(item,&currentNode); } else readProperty(item,&currentNode);
} }
if (lf) lf->objectLoadFinished(); if (lf) lf->finishLoading();
BaseDesignIntf* baseObj = dynamic_cast<BaseDesignIntf*>(item); BaseDesignIntf* baseObj = dynamic_cast<BaseDesignIntf*>(item);
if(baseObj) { if(baseObj) {