mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 00:33:02 +03:00
New scale method has been added
This commit is contained in:
parent
e623978281
commit
318af3b221
@ -59,22 +59,29 @@ namespace Const{
|
||||
int const DEFAULT_GRID_STEP = 1;
|
||||
int const RESIZE_HANDLE_SIZE = 5;
|
||||
int const SELECTION_PEN_SIZE = 1;
|
||||
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_WIDTH = 2 * RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_HEIGHT = 2 * RESIZE_HANDLE_SIZE;
|
||||
double const RESIZE_ZONE_OPACITY = 0.5;
|
||||
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;
|
||||
const int itemPaleteIconSize = 24;
|
||||
const qreal minSpaceBorder = 10;
|
||||
const QString bandTAG = "band";
|
||||
const qreal FONT_FACTOR = 0.33;
|
||||
const int STORAGE_MM_FACTOR = 10;
|
||||
const int DESIGNER_MM_FACTOR = 5;
|
||||
const int OLD_MM_FACTOR = 10;
|
||||
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_BORDER_COLOR = Qt::darkYellow;
|
||||
const qreal BAND_MARKER_OPACITY = 1;
|
||||
const Qt::GlobalColor BAND_NAME_BORDER_COLOR = Qt::darkGray;
|
||||
const qreal BAND_MARKER_SELECTED_OPACITY = 1;
|
||||
const qreal BAND_MARKER_OPACITY = 0.3;
|
||||
const qreal LAYOUT_MARKER_OPACITY = 0.3;
|
||||
const qreal BAND_NAME_AREA_OPACITY = 0.3;
|
||||
const qreal BAND_NAME_TEXT_OPACITY = 0.6;
|
||||
|
@ -49,17 +49,17 @@ LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesign
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::BAND_TAG),
|
||||
createBand
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::BAND_TAG),
|
||||
createHeader
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::BAND_TAG),
|
||||
createFooter
|
||||
);
|
||||
|
||||
|
@ -42,7 +42,7 @@ LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignI
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::BAND_TAG),
|
||||
createHeader
|
||||
);
|
||||
|
||||
@ -52,7 +52,7 @@ LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesign
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::BAND_TAG),
|
||||
createFooter
|
||||
);
|
||||
|
||||
|
@ -41,7 +41,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::BAND_TAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::BAND_TAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Report Footer"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Report Footer"),LimeReport::Const::BAND_TAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Report Header"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Report Header"),LimeReport::Const::BAND_TAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagBand,
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::BAND_TAG),
|
||||
createBand
|
||||
);
|
||||
|
||||
@ -55,7 +55,7 @@ LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesign
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::BAND_TAG),
|
||||
createHeader
|
||||
);
|
||||
|
||||
@ -65,7 +65,7 @@ LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesign
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::BAND_TAG),
|
||||
createFooter
|
||||
);
|
||||
|
||||
|
@ -10,7 +10,7 @@ LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIn
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::BAND_TAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
|
@ -218,10 +218,10 @@ void AbstractLayout::collectionLoadFinished(const QString& collectionName)
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::objectLoadFinished()
|
||||
void AbstractLayout::finishLoading()
|
||||
{
|
||||
layoutMarker()->setHeight(height());
|
||||
LayoutDesignIntf::objectLoadFinished();
|
||||
LayoutDesignIntf::finishLoading();
|
||||
}
|
||||
|
||||
bool AbstractLayout::isNeedUpdateSize(RenderPass pass) const
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
int childrenCount();
|
||||
int layoutSpacing() const;
|
||||
void setLayoutSpacing(int layoutSpacing);
|
||||
qreal layoutSpacingMM(){ return m_layoutSpacing * Const::mmFACTOR;}
|
||||
qreal layoutSpacingMM(){ return m_layoutSpacing * ppm();}
|
||||
protected:
|
||||
void beforeDelete();
|
||||
void childAddedEvent(BaseDesignIntf *child);
|
||||
@ -47,7 +47,7 @@ protected:
|
||||
void initMode(ItemMode mode);
|
||||
void setBorderLinesFlags(BorderLines flags);
|
||||
void collectionLoadFinished(const QString &collectionName);
|
||||
void objectLoadFinished();
|
||||
void finishLoading();
|
||||
bool isNeedUpdateSize(RenderPass pass) const;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
|
@ -47,7 +47,7 @@ LimeReport::BaseDesignIntf *createHLayout(QObject *owner, LimeReport::BaseDesign
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::BAND_TAG),
|
||||
createHLayout
|
||||
);
|
||||
}
|
||||
|
@ -160,7 +160,6 @@ void TextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* style, Q
|
||||
Q_UNUSED(widget);
|
||||
Q_UNUSED(style);
|
||||
|
||||
|
||||
TextPtr text = textDocument();
|
||||
|
||||
painter->save();
|
||||
@ -975,9 +974,9 @@ BaseDesignIntf *TextItem::cloneEmpty(int height, QObject *owner, QGraphicsItem *
|
||||
return empty;
|
||||
}
|
||||
|
||||
void TextItem::objectLoadFinished()
|
||||
void TextItem::finishLoading()
|
||||
{
|
||||
ItemDesignIntf::objectLoadFinished();
|
||||
ItemDesignIntf::finishLoading();
|
||||
// if (itemMode() == DesignMode || !isNeedExpandContent()){
|
||||
// if (autoHeight() && autoWidth())
|
||||
// initTextSizes();
|
||||
|
@ -121,7 +121,7 @@ public:
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent);
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
BaseDesignIntf* cloneEmpty(int height, QObject *owner, QGraphicsItem *parent);
|
||||
void objectLoadFinished();
|
||||
void finishLoading();
|
||||
|
||||
void setTextItemFont(QFont value);
|
||||
QWidget* defaultEditor();
|
||||
|
@ -13,7 +13,7 @@ LimeReport::BaseDesignIntf *createVLayout(QObject *owner, LimeReport::BaseDesign
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("VLayout"), LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("VLayout"), LimeReport::Const::BAND_TAG),
|
||||
createVLayout
|
||||
);
|
||||
}
|
||||
|
@ -38,7 +38,10 @@
|
||||
namespace LimeReport {
|
||||
|
||||
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);
|
||||
}
|
||||
@ -51,27 +54,34 @@ QRectF BandMarker::boundingRect() const
|
||||
void BandMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem* /**option*/, QWidget* /*widget*/)
|
||||
{
|
||||
painter->save();
|
||||
painter->setOpacity(Const::BAND_MARKER_OPACITY);
|
||||
painter->fillRect(boundingRect(),m_color);
|
||||
painter->setOpacity(Const::BAND_MARKER_SELECTED_OPACITY);
|
||||
painter->fillRect(boundingRect(), m_color);
|
||||
painter->setOpacity(1);
|
||||
painter->setPen(QPen(QBrush(Qt::lightGray),2));
|
||||
painter->fillRect(QRectF(
|
||||
boundingRect().bottomLeft().x(),
|
||||
boundingRect().bottomLeft().y()-4,
|
||||
boundingRect().width(),4), Qt::lightGray
|
||||
);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
qreal size = (boundingRect().width()<boundingRect().height()) ? boundingRect().width() : boundingRect().height();
|
||||
QRectF r = QRectF(0,0,size,size);
|
||||
painter->setBrush(Qt::white);
|
||||
painter->setPen(Qt::white);
|
||||
painter->drawEllipse(r.adjusted(5,5,-5,-5));
|
||||
if (m_band->isSelected()){
|
||||
painter->setBrush(LimeReport::Const::SELECTION_COLOR);
|
||||
painter->drawEllipse(r.adjusted(7,7,-7,-7));
|
||||
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(
|
||||
boundingRect().bottomLeft().x(),
|
||||
boundingRect().bottomLeft().y() - 2,
|
||||
boundingRect().width(),2), Qt::white
|
||||
);
|
||||
}
|
||||
|
||||
if (m_band->isSelected()){
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
qreal size = (boundingRect().width() < boundingRect().height()) ? boundingRect().width() : boundingRect().height();
|
||||
QRectF r = QRectF(0,0,size,size);
|
||||
painter->setBrush(Qt::white);
|
||||
painter->setPen(Qt::white);
|
||||
painter->drawEllipse(r.adjusted(3,3,-3,-3));
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
@ -106,6 +116,10 @@ void BandMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
m_band->scene()->clearSelection();
|
||||
m_band->setSelected(true);
|
||||
m_oldBandPos = m_band->pos();
|
||||
if (!hasCursor()){
|
||||
m_isMoving = true;
|
||||
m_band->setIsChangingPos(true);
|
||||
}
|
||||
update(0,0,boundingRect().width(),boundingRect().width());
|
||||
}
|
||||
}
|
||||
@ -138,6 +152,8 @@ void BandMarker::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||
void BandMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
m_isMoving = false;
|
||||
m_band->setIsChangingPos(false);
|
||||
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_useAlternateBackgroundColor(false),
|
||||
m_bottomSpace(0),
|
||||
m_shiftItems(0)
|
||||
m_shiftItems(0),
|
||||
m_paddingTop(0),
|
||||
m_paddingBottom(0)
|
||||
{
|
||||
setPossibleResizeDirectionFlags(ResizeBottom);
|
||||
setPossibleMoveFlags(TopBotom);
|
||||
@ -180,7 +198,7 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
|
||||
|
||||
setBackgroundMode(BaseDesignIntf::TransparentMode);
|
||||
setFillTransparentInDesignMode(false);
|
||||
setHeight(100);
|
||||
setHeight(Const::DEFAULT_BAND_HEIGHT * Const::STORAGE_MM_FACTOR);
|
||||
setFixedPos(true);
|
||||
setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
||||
m_bandMarker = new BandMarker(this);
|
||||
@ -249,6 +267,12 @@ bool BandDesignIntf::isNeedUpdateSize(RenderPass pass) const{
|
||||
return false;
|
||||
}
|
||||
|
||||
void BandDesignIntf::setPpm(int ppm)
|
||||
{
|
||||
ItemsContainerDesignInft::setPpm(ppm);
|
||||
updateBandMarkerGeometry(QRectF(pos(),size()));
|
||||
}
|
||||
|
||||
void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
prepareRect(painter, option, widget);
|
||||
@ -256,7 +280,7 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
if (itemMode() & DesignMode){
|
||||
painter->save();
|
||||
QString bandText = bandTitle();
|
||||
QFont font("Arial", 7 * Const::fontFACTOR, -1, true);
|
||||
QFont font("Arial", 6 * Const::FONT_FACTOR * ppm(), -1, true);
|
||||
QFontMetrics fontMetrics(font);
|
||||
|
||||
QVector<QRectF> bandNameRects;
|
||||
@ -272,10 +296,10 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
for (int i=0;i<bandNameRects.count();i++){
|
||||
QRectF labelRect = bandNameRects[i].adjusted(-2,-2,2,2);
|
||||
if ((labelRect.height())<height() && (childBaseItems().isEmpty()) && !isSelected()){
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
//painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setBrush(bandColor());
|
||||
painter->setOpacity(Const::BAND_NAME_AREA_OPACITY);
|
||||
painter->drawRoundedRect(labelRect,8,8);
|
||||
painter->drawRect(labelRect);
|
||||
painter->setOpacity(Const::BAND_NAME_TEXT_OPACITY);
|
||||
painter->setPen(Qt::black);
|
||||
painter->drawText(bandNameRects[i],Qt::AlignHCenter,bandText);
|
||||
@ -286,10 +310,10 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
BaseDesignIntf::paint(painter,option,widget);
|
||||
}
|
||||
|
||||
QRectF BandDesignIntf::boundingRect() const
|
||||
{
|
||||
return ItemsContainerDesignInft::boundingRect().adjusted(0,-4,0,4);
|
||||
}
|
||||
//QRectF BandDesignIntf::boundingRect() const
|
||||
//{
|
||||
// return ItemsContainerDesignInft::boundingRect().adjusted(0,-4,0,4);
|
||||
//}
|
||||
|
||||
void BandDesignIntf::translateBandsName()
|
||||
{
|
||||
@ -359,7 +383,7 @@ bool BandDesignIntf::isUnique() const
|
||||
void BandDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode)
|
||||
{
|
||||
ItemsContainerDesignInft::setItemMode(mode);
|
||||
updateBandMarkerGeometry();
|
||||
updateBandMarkerGeometry(QRectF(pos(),size()));
|
||||
}
|
||||
|
||||
QString BandDesignIntf::datasourceName(){
|
||||
@ -741,10 +765,10 @@ void BandDesignIntf::parentObjectLoadFinished()
|
||||
setParentBand(findParentBand());
|
||||
}
|
||||
|
||||
void BandDesignIntf::objectLoadFinished()
|
||||
void BandDesignIntf::finishLoading()
|
||||
{
|
||||
m_bandMarker->setHeight(height());
|
||||
BaseDesignIntf::objectLoadFinished();
|
||||
BaseDesignIntf::finishLoading();
|
||||
}
|
||||
|
||||
void BandDesignIntf::emitBandRendered(BandDesignIntf* band)
|
||||
@ -804,18 +828,19 @@ BandDesignIntf* BandDesignIntf::findParentBand()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BandDesignIntf::updateBandMarkerGeometry()
|
||||
void BandDesignIntf::updateBandMarkerGeometry(QRectF geometry)
|
||||
{
|
||||
if (parentItem() && m_bandMarker){
|
||||
m_bandMarker->setPos(pos().x()-m_bandMarker->width(),pos().y());
|
||||
m_bandMarker->setHeight(rect().height());
|
||||
m_bandMarker->setWidth(3 * ppm());
|
||||
m_bandMarker->setHeight(geometry.height());
|
||||
m_bandMarker->setPos(geometry.x()-m_bandMarker->width(),geometry.y());
|
||||
}
|
||||
}
|
||||
|
||||
void BandDesignIntf::geometryChangedEvent(QRectF, QRectF )
|
||||
{
|
||||
if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){
|
||||
updateBandMarkerGeometry();
|
||||
updateBandMarkerGeometry(QRectF(pos(), size()));
|
||||
}
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
if (item->itemAlign()!=DesignedItemAlign){
|
||||
@ -827,10 +852,7 @@ void BandDesignIntf::geometryChangedEvent(QRectF, QRectF )
|
||||
QVariant BandDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if ((change==ItemPositionChange)&&((itemMode()&DesignMode)||(itemMode()&EditMode))){
|
||||
if (m_bandMarker){
|
||||
m_bandMarker->setPos((value.toPointF().x()-m_bandMarker->boundingRect().width()),
|
||||
value.toPointF().y());
|
||||
}
|
||||
updateBandMarkerGeometry(QRectF(value.toPointF(),size()));
|
||||
}
|
||||
if (change==ItemSelectedChange){
|
||||
if (m_bandMarker){
|
||||
@ -923,6 +945,31 @@ void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QStrin
|
||||
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
|
||||
{
|
||||
return m_shiftItems;
|
||||
@ -1120,7 +1167,7 @@ void BandDesignIntf::setKeepFooterTogether(bool value)
|
||||
|
||||
void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||
{
|
||||
qreal spaceBorder = 0;
|
||||
qreal spaceBorder = m_paddingBottom+1;
|
||||
if (keepBottomSpace()) spaceBorder = bottomSpace();
|
||||
spaceBorder = spaceBorder > 0 ? spaceBorder : 0;
|
||||
if (borderLines() != 0){
|
||||
@ -1134,7 +1181,7 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
|
||||
arrangeSubItems(pass, dataManager);
|
||||
if (autoHeight()){
|
||||
if (!keepTopSpace()) {
|
||||
qreal minTop = findMinTop() + m_shiftItems;
|
||||
qreal minTop = findMinTop() + m_shiftItems - m_paddingTop;
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
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)
|
||||
{
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setFont(QFont("Arial",7*Const::fontFACTOR,-1,true));
|
||||
//painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setFont(QFont("Arial", 6 * Const::FONT_FACTOR * m_band->ppm(), -1, true));
|
||||
painter->setOpacity(1);
|
||||
QPen pen(Const::BAND_NAME_BORDER_COLOR);
|
||||
//pen.setWidth(2);
|
||||
painter->setBrush(Qt::yellow);
|
||||
painter->setPen(pen);
|
||||
painter->drawRoundedRect(m_rect,8,8);
|
||||
painter->drawRect(m_rect);
|
||||
painter->setOpacity(0.8);
|
||||
painter->setPen(Qt::black);
|
||||
painter->drawText(m_rect,Qt::AlignCenter,m_band->bandTitle());
|
||||
@ -1206,13 +1253,13 @@ QRectF BandNameLabel::boundingRect() const
|
||||
|
||||
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);
|
||||
prepareGeometryChange();
|
||||
m_rect = QRectF(
|
||||
m_band->pos().x()+10,
|
||||
m_band->pos().x()+6,
|
||||
m_band->pos().y()-(fontMetrics.height()+10),
|
||||
fontMetrics.width(bandName)+20,fontMetrics.height()+10
|
||||
fontMetrics.width(bandName)+40,fontMetrics.height()+10
|
||||
);
|
||||
update();
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ class BandDesignIntf;
|
||||
|
||||
class BandMarker : public QGraphicsItem{
|
||||
public:
|
||||
friend BandDesignIntf;
|
||||
explicit BandMarker(BandDesignIntf* band, QGraphicsItem *parent=0);
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
@ -64,7 +65,6 @@ public:
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
@ -73,6 +73,7 @@ private:
|
||||
QColor m_color;
|
||||
BandDesignIntf* m_band;
|
||||
QPointF m_oldBandPos;
|
||||
bool m_isMoving;
|
||||
};
|
||||
|
||||
class BandNameLabel : public QGraphicsItem{
|
||||
@ -114,6 +115,8 @@ class BandDesignIntf : public ItemsContainerDesignInft
|
||||
Q_PROPERTY(BGMode backgroundMode READ backgroundMode WRITE setBackgroundModeProperty)
|
||||
Q_PROPERTY(int backgroundOpacity READ opacity WRITE setBackgroundOpacity)
|
||||
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 BandNameLabel;
|
||||
friend class ReportRender;
|
||||
@ -148,7 +151,7 @@ public:
|
||||
~BandDesignIntf();
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
QRectF boundingRect() const;
|
||||
//QRectF boundingRect() const;
|
||||
void translateBandsName();
|
||||
virtual BandsType bandType() const;
|
||||
virtual QString bandTitle() const;
|
||||
@ -214,7 +217,7 @@ public:
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
|
||||
void parentObjectLoadFinished();
|
||||
void objectLoadFinished();
|
||||
void finishLoading();
|
||||
void emitBandRendered(BandDesignIntf *band);
|
||||
|
||||
bool isSplittable() const {return m_splitable;}
|
||||
@ -266,11 +269,18 @@ public:
|
||||
void setBackgroundOpacity(int value);
|
||||
int bootomSpace() const;
|
||||
void setBootomSpace(int bootomSpace);
|
||||
void updateBandMarkerGeometry();
|
||||
void updateBandMarkerGeometry(QRectF geometry);
|
||||
int shiftItems() const;
|
||||
void setShiftItems(int shiftItems);
|
||||
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:
|
||||
void bandRendered(BandDesignIntf* band);
|
||||
void preparedForRender();
|
||||
@ -334,6 +344,8 @@ private:
|
||||
int m_bottomSpace;
|
||||
QMap<QString,QVariant> m_bookmarks;
|
||||
int m_shiftItems;
|
||||
int m_paddingTop;
|
||||
int m_paddingBottom;
|
||||
};
|
||||
|
||||
class DataBandDesignIntf : public BandDesignIntf{
|
||||
|
@ -51,7 +51,7 @@ QStringList BandsManager::bandNames()
|
||||
<<QObject::tr("Data")<<QObject::tr("SubDetail");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ QStringList BandsManager::bandNames()
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
|
||||
m_fillTransparentInDesignMode(true),
|
||||
m_unitType(Millimeters),
|
||||
m_itemGeometryLocked(false),
|
||||
m_isChangingPos(false)
|
||||
m_isChangingPos(false),
|
||||
m_ppm(Const::STORAGE_MM_FACTOR)
|
||||
{
|
||||
setGeometry(QRectF(0, 0, m_width, m_height));
|
||||
if (BaseDesignIntf *item = dynamic_cast<BaseDesignIntf *>(parent)) {
|
||||
@ -98,13 +99,15 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
|
||||
|
||||
QRectF BaseDesignIntf::boundingRect() const
|
||||
{
|
||||
qreal halfpw = pen().widthF() / 2;
|
||||
halfpw += 2;
|
||||
return rect().adjusted(-halfpw, -halfpw, halfpw, halfpw);
|
||||
//qreal halfpw = pen().widthF() / 2;
|
||||
// halfpw += 2;
|
||||
//return rect().adjusted(-halfpw, -halfpw, halfpw, halfpw);
|
||||
return rect();
|
||||
}
|
||||
|
||||
BaseDesignIntf::~BaseDesignIntf(void) {
|
||||
|
||||
if (m_selectionMarker)
|
||||
delete m_selectionMarker;
|
||||
}
|
||||
|
||||
void BaseDesignIntf::setParentReportItem(const QString &value)
|
||||
@ -253,7 +256,7 @@ QString BaseDesignIntf::setItemPosY(qreal yValue)
|
||||
QFont BaseDesignIntf::transformToSceneFont(const QFont& value) const
|
||||
{
|
||||
QFont f = value;
|
||||
f.setPixelSize(f.pointSize()*Const::fontFACTOR);
|
||||
f.setPixelSize(f.pointSize() * Const::FONT_FACTOR * ppm());
|
||||
return f;
|
||||
}
|
||||
|
||||
@ -287,7 +290,7 @@ void BaseDesignIntf::setupPainter(QPainter *painter) const
|
||||
if (!painter) {
|
||||
return;
|
||||
}
|
||||
painter->setFont(m_font);
|
||||
painter->setFont(transformToSceneFont(m_font));
|
||||
painter->setPen(m_fontColor);
|
||||
}
|
||||
|
||||
@ -335,17 +338,17 @@ QSizeF BaseDesignIntf::size() const
|
||||
|
||||
QSizeF BaseDesignIntf::sizeMM() const
|
||||
{
|
||||
return QSizeF(width() / Const::mmFACTOR, height() / Const::mmFACTOR);
|
||||
return QSizeF(width() / ppm(), height() / ppm());
|
||||
}
|
||||
|
||||
qreal BaseDesignIntf::widthMM() const
|
||||
{
|
||||
return width() / Const::mmFACTOR;
|
||||
return width() / ppm();
|
||||
}
|
||||
|
||||
qreal BaseDesignIntf::heightMM() const
|
||||
{
|
||||
return height() / Const::mmFACTOR;
|
||||
return height() / ppm();
|
||||
}
|
||||
|
||||
//void BaseDesignIntf::setUnitFactor(qreal unitFactor)
|
||||
@ -356,8 +359,8 @@ qreal BaseDesignIntf::heightMM() const
|
||||
qreal BaseDesignIntf::unitFactor() const
|
||||
{
|
||||
if (m_unitType == Millimeters)
|
||||
return Const::mmFACTOR;
|
||||
else return Const::mmFACTOR * 2.54;
|
||||
return ppm();
|
||||
else return ppm() * 2.54;
|
||||
}
|
||||
|
||||
void BaseDesignIntf::setUnitType(BaseDesignIntf::UnitType value)
|
||||
@ -374,7 +377,7 @@ BaseDesignIntf::UnitType BaseDesignIntf::unitType()
|
||||
|
||||
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
|
||||
@ -515,7 +518,7 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
|
||||
update();
|
||||
}
|
||||
|
||||
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent /**event*/)
|
||||
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/)
|
||||
{
|
||||
m_hovered = true;
|
||||
update();
|
||||
@ -676,8 +679,8 @@ QPointF BaseDesignIntf::modifyPosForAlignedItem(const QPointF& pos){
|
||||
BaseDesignIntf* parent = dynamic_cast<BaseDesignIntf*>(parentItem());
|
||||
PageItemDesignIntf* parentPage = dynamic_cast<PageItemDesignIntf*>(parentItem());
|
||||
if (parent){
|
||||
qreal leftBorder = parentPage ? parentPage->leftMargin() * Const::mmFACTOR : 0;
|
||||
qreal rightBorder = parentPage ? parentPage->rightMargin() * Const::mmFACTOR : 0;
|
||||
qreal leftBorder = parentPage ? parentPage->leftMargin() * ppm() : 0;
|
||||
qreal rightBorder = parentPage ? parentPage->rightMargin() * ppm() : 0;
|
||||
qreal avaibleSpace = parent->width()-(leftBorder+rightBorder);
|
||||
|
||||
switch(m_itemAlign){
|
||||
@ -718,8 +721,8 @@ void BaseDesignIntf::updateItemAlign(){
|
||||
PageItemDesignIntf* parentPage = dynamic_cast<PageItemDesignIntf*>(parentItem());
|
||||
m_changingItemAlign = true;
|
||||
if (parent){
|
||||
qreal leftBorder = parentPage ? parentPage->leftMargin() * Const::mmFACTOR : 0;
|
||||
qreal rightBorder = parentPage ? parentPage->rightMargin() * Const::mmFACTOR : 0;
|
||||
qreal leftBorder = parentPage ? parentPage->leftMargin() * ppm() : 0;
|
||||
qreal rightBorder = parentPage ? parentPage->rightMargin() * ppm() : 0;
|
||||
qreal aviableSpace = parent->width()-(leftBorder+rightBorder);
|
||||
setPos(modifyPosForAlignedItem(pos()));
|
||||
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
|
||||
{
|
||||
return m_isChangingPos;
|
||||
@ -833,7 +849,7 @@ void BaseDesignIntf::updateSelectionMarker()
|
||||
if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker);
|
||||
if (parentItem()) {
|
||||
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)
|
||||
{
|
||||
if (value && !m_selectionMarker){
|
||||
m_selectionMarker = new SelectionMarker(this, this);
|
||||
m_selectionMarker = new SelectionMarker(this->parentItem(), this);
|
||||
m_selectionMarker->setColor(selectionMarkerColor());
|
||||
updateSelectionMarker();
|
||||
m_selectionMarker->setVisible(true);
|
||||
} else {
|
||||
scene()->removeItem(m_selectionMarker);
|
||||
delete m_selectionMarker;
|
||||
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_leftRect = QRectF(0-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();
|
||||
if (!isLoading()){
|
||||
if (!isLoading() && !isPpmChanging()){
|
||||
geometryChangedEvent(geometry(), m_oldGeometry);
|
||||
emit geometryChanged(this, geometry(), m_oldGeometry);
|
||||
}
|
||||
@ -1168,7 +1185,8 @@ QVariant BaseDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, co
|
||||
|
||||
if (change == QGraphicsItem::ItemPositionHasChanged) {
|
||||
updateSelectionMarker();
|
||||
emit geometryChanged(this, geometry(), geometry());
|
||||
if (!isLoading() && !isPpmChanging())
|
||||
emit geometryChanged(this, geometry(), geometry());
|
||||
}
|
||||
|
||||
if (change == QGraphicsItem::ItemSelectedChange) {
|
||||
@ -1530,19 +1548,19 @@ BaseDesignIntf *BaseDesignIntf::cloneItemWOChild(ItemMode mode, QObject *owner,
|
||||
BaseDesignIntf *clone = createSameTypeItem(owner, parent);
|
||||
clone->setObjectName(this->objectName());
|
||||
clone->setItemMode(mode);
|
||||
clone->objectLoadStarted();
|
||||
clone->startLoading();
|
||||
clone->setReportSettings(this->reportSettings());
|
||||
for (int i = 0; i < clone->metaObject()->propertyCount(); i++) {
|
||||
if (clone->metaObject()->property(i).isWritable())
|
||||
clone->setProperty(clone->metaObject()->property(i).name(), property(clone->metaObject()->property(i).name()));
|
||||
}
|
||||
clone->objectLoadFinished();
|
||||
clone->finishLoading();
|
||||
return clone;
|
||||
}
|
||||
|
||||
void BaseDesignIntf::initFromItem(BaseDesignIntf *source)
|
||||
{
|
||||
objectLoadStarted();
|
||||
startLoading();
|
||||
for (int i = 0; i < metaObject()->propertyCount(); i++) {
|
||||
if (strcmp(metaObject()->property(i).name(),"objectName")!=0)
|
||||
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()));
|
||||
}
|
||||
}
|
||||
objectLoadFinished();
|
||||
finishLoading();
|
||||
}
|
||||
|
||||
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;}
|
||||
|
||||
|
||||
void BaseDesignIntf::objectLoadStarted()
|
||||
void BaseDesignIntf::startLoading()
|
||||
{
|
||||
m_objectState = ObjectLoading;
|
||||
}
|
||||
|
||||
void BaseDesignIntf::objectLoadFinished()
|
||||
void BaseDesignIntf::finishLoading()
|
||||
{
|
||||
m_objectState = ObjectLoaded;
|
||||
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()
|
||||
{}
|
||||
{
|
||||
m_objectState = ObjectLoaded;
|
||||
}
|
||||
|
||||
QList<BaseDesignIntf *> BaseDesignIntf::childBaseItems() const
|
||||
{
|
||||
@ -1683,9 +1723,9 @@ QRectF Marker::boundingRect() const
|
||||
void Marker::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
|
||||
{
|
||||
QPen pen;
|
||||
const int markerSize = 5;
|
||||
const int markerSize = 3;
|
||||
pen.setColor(color());
|
||||
pen.setWidth(2);
|
||||
pen.setWidth(1);
|
||||
pen.setStyle(Qt::DotLine);
|
||||
painter->setPen(pen);
|
||||
painter->setOpacity(Const::SELECTION_COLOR_OPACITY);
|
||||
@ -1750,7 +1790,6 @@ void SelectionMarker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
||||
void SelectionMarker::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
qDebug() << "mouse move";
|
||||
if (owner()) owner()->mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,9 @@ class DataSourceManager;
|
||||
class ReportRender;
|
||||
|
||||
class BaseDesignIntf :
|
||||
public QObject, public QGraphicsItem, public ICollectionContainer, public ObjectLoadingStateIntf {
|
||||
public QObject, public QGraphicsItem, public ICollectionContainer,
|
||||
public ObjectLoadingStateIntf, public ObjectSavingStateIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
Q_FLAGS(BorderLines)
|
||||
@ -99,49 +101,65 @@ class BaseDesignIntf :
|
||||
public:
|
||||
enum BGMode { TransparentMode, OpaqueMode};
|
||||
|
||||
enum BrushStyle{
|
||||
NoBrush,
|
||||
SolidPattern,
|
||||
Dense1Pattern,
|
||||
Dense2Pattern,
|
||||
Dense3Pattern,
|
||||
Dense4Pattern,
|
||||
Dense5Pattern,
|
||||
Dense6Pattern,
|
||||
Dense7Pattern,
|
||||
HorPattern,
|
||||
VerPattern,
|
||||
CrossPattern,
|
||||
BDiagPattern,
|
||||
FDiagPattern
|
||||
};
|
||||
|
||||
enum BrushStyle{ NoBrush,
|
||||
SolidPattern,
|
||||
Dense1Pattern,
|
||||
Dense2Pattern,
|
||||
Dense3Pattern,
|
||||
Dense4Pattern,
|
||||
Dense5Pattern,
|
||||
Dense6Pattern,
|
||||
Dense7Pattern,
|
||||
HorPattern,
|
||||
VerPattern,
|
||||
CrossPattern,
|
||||
BDiagPattern,
|
||||
FDiagPattern };
|
||||
enum ResizeFlags {
|
||||
Fixed = 0,
|
||||
ResizeLeft = 1,
|
||||
ResizeRight = 2,
|
||||
ResizeTop = 4,
|
||||
ResizeBottom = 8,
|
||||
AllDirections = 15
|
||||
};
|
||||
|
||||
|
||||
enum ResizeFlags { Fixed = 0,
|
||||
ResizeLeft = 1,
|
||||
ResizeRight = 2,
|
||||
ResizeTop = 4,
|
||||
ResizeBottom = 8,
|
||||
AllDirections = 15
|
||||
};
|
||||
|
||||
enum MoveFlags { None = 0,
|
||||
LeftRight=1,
|
||||
TopBotom=2,
|
||||
All=3
|
||||
};
|
||||
enum MoveFlags {
|
||||
None = 0,
|
||||
LeftRight=1,
|
||||
TopBotom=2,
|
||||
All=3
|
||||
};
|
||||
|
||||
enum BorderSide {
|
||||
NoLine = 0,
|
||||
TopLine = 1,
|
||||
BottomLine = 2,
|
||||
LeftLine = 4,
|
||||
RightLine = 8,
|
||||
AllLines = 15
|
||||
};
|
||||
NoLine = 0,
|
||||
TopLine = 1,
|
||||
BottomLine = 2,
|
||||
LeftLine = 4,
|
||||
RightLine = 8,
|
||||
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};
|
||||
#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* cloneEmpty(int height, QObject* owner=0, QGraphicsItem* parent=0);
|
||||
|
||||
bool isLoaded(){return m_objectState==ObjectLoaded;}
|
||||
bool isLoading(){return m_objectState==ObjectLoading;}
|
||||
void objectLoadStarted();
|
||||
void objectLoadFinished();
|
||||
bool isLoaded(){return m_objectState == ObjectLoaded;}
|
||||
bool isLoading(){return m_objectState == ObjectLoading;}
|
||||
bool isSaving(){return m_objectState == ObjectSaving;}
|
||||
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 beforeDelete();
|
||||
|
||||
@ -334,6 +361,9 @@ public:
|
||||
bool isChangingPos() const;
|
||||
void setIsChangingPos(bool isChangingPos);
|
||||
|
||||
int ppm() const;
|
||||
virtual void setPpm(int ppm);
|
||||
|
||||
protected:
|
||||
|
||||
//ICollectionContainer
|
||||
@ -346,7 +376,7 @@ protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent* );
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||
@ -423,7 +453,7 @@ private:
|
||||
int m_borderLineSize;
|
||||
|
||||
QRectF m_rect;
|
||||
mutable QRectF m_boundingRect;
|
||||
//mutable QRectF m_boundingRect;
|
||||
|
||||
QRectF m_oldGeometry;
|
||||
BGMode m_BGMode;
|
||||
@ -464,6 +494,7 @@ private:
|
||||
UnitType m_unitType;
|
||||
bool m_itemGeometryLocked;
|
||||
bool m_isChangingPos;
|
||||
int m_ppm;
|
||||
signals:
|
||||
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
|
||||
void posChanging(QObject* object, QPointF newPos, QPointF oldPos);
|
||||
|
@ -160,7 +160,7 @@ void initReportItems(){
|
||||
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"HLayout",
|
||||
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::BAND_TAG),
|
||||
createHLayout
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
@ -183,58 +183,58 @@ void initReportItems(){
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"Data",
|
||||
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::BAND_TAG),
|
||||
createDataBand
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"DataHeader",
|
||||
LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::BAND_TAG),
|
||||
createHeaderDataBand
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"DataFooter",
|
||||
LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::BAND_TAG),
|
||||
createFooterDataBand
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"GroupHeader",
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::BAND_TAG),
|
||||
createGroupHeaderBand
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"GroupFooter",
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::BAND_TAG),
|
||||
createGroupFooterBand
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"PageFooter",
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::BAND_TAG),
|
||||
createPageFooterBand
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"PageHeader",
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::BAND_TAG),
|
||||
createPageHeaderBand
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"SubDetail",
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::BAND_TAG),
|
||||
createSubDetailBand
|
||||
);
|
||||
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"SubDetailHeader",
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::BAND_TAG),
|
||||
createSubDetailHeaderBand
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"SubDetailFooter",
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::BAND_TAG),
|
||||
createSubDetailFooterBand
|
||||
);
|
||||
DesignElementsFactory::instance().registerCreator(
|
||||
"TearOffBand",
|
||||
LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::bandTAG),
|
||||
LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::BAND_TAG),
|
||||
createTearOffBand
|
||||
);
|
||||
|
||||
|
@ -59,22 +59,29 @@ namespace Const{
|
||||
int const DEFAULT_GRID_STEP = 1;
|
||||
int const RESIZE_HANDLE_SIZE = 5;
|
||||
int const SELECTION_PEN_SIZE = 1;
|
||||
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_WIDTH = 2 * RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_HEIGHT = 2 * RESIZE_HANDLE_SIZE;
|
||||
double const RESIZE_ZONE_OPACITY = 0.5;
|
||||
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;
|
||||
const int itemPaleteIconSize = 24;
|
||||
const qreal minSpaceBorder = 10;
|
||||
const QString bandTAG = "band";
|
||||
const qreal FONT_FACTOR = 0.33;
|
||||
const int STORAGE_MM_FACTOR = 10;
|
||||
const int DESIGNER_MM_FACTOR = 5;
|
||||
const int OLD_MM_FACTOR = 10;
|
||||
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_BORDER_COLOR = Qt::darkYellow;
|
||||
const qreal BAND_MARKER_OPACITY = 1;
|
||||
const Qt::GlobalColor BAND_NAME_BORDER_COLOR = Qt::darkGray;
|
||||
const qreal BAND_MARKER_SELECTED_OPACITY = 1;
|
||||
const qreal BAND_MARKER_OPACITY = 0.3;
|
||||
const qreal LAYOUT_MARKER_OPACITY = 0.3;
|
||||
const qreal BAND_NAME_AREA_OPACITY = 0.3;
|
||||
const qreal BAND_NAME_TEXT_OPACITY = 0.6;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <QApplication>
|
||||
#include <qmath.h>
|
||||
|
||||
#include "lrpagedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
GraphicsViewZoomer::GraphicsViewZoomer(QGraphicsView* view)
|
||||
@ -15,7 +17,13 @@ GraphicsViewZoomer::GraphicsViewZoomer(QGraphicsView* view)
|
||||
}
|
||||
|
||||
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);
|
||||
QPointF delta_viewport_pos = m_targetViewportPos - QPointF(m_view->viewport()->width() / 2.0,
|
||||
m_view->viewport()->height() / 2.0);
|
||||
@ -25,7 +33,7 @@ void GraphicsViewZoomer::gentleZoom(double factor) {
|
||||
}
|
||||
|
||||
void GraphicsViewZoomer::setModifiers(Qt::KeyboardModifiers modifiers) {
|
||||
m_modifiers = modifiers;
|
||||
m_modifiers = modifiers;
|
||||
}
|
||||
|
||||
void GraphicsViewZoomer::setZoomFactorBase(double value) {
|
||||
|
@ -239,11 +239,16 @@ void PageDesignIntf::startInsertMode(const QString &ItemType)
|
||||
emit insertModeStarted();
|
||||
m_insertMode = true;
|
||||
m_insertItemType = ItemType;
|
||||
m_itemInsertRect = this->addRect(0, 0, 200, 50);
|
||||
m_itemInsertRect->setVisible(false);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void PageDesignIntf::startEditMode()
|
||||
@ -268,10 +273,10 @@ void PageDesignIntf::setPageItem(PageItemDesignIntf::Ptr pageItem)
|
||||
}
|
||||
m_pageItem = pageItem;
|
||||
m_pageItem->setItemMode(itemMode());
|
||||
setSceneRect(pageItem->rect().adjusted(-10 * Const::mmFACTOR,
|
||||
-10 * Const::mmFACTOR,
|
||||
10 * Const::mmFACTOR,
|
||||
10 * Const::mmFACTOR));
|
||||
setSceneRect(pageItem->rect().adjusted(-10 * pageItem->ppm(),
|
||||
-10 * pageItem->ppm(),
|
||||
10 * pageItem->ppm(),
|
||||
10 * pageItem->ppm()));
|
||||
addItem(m_pageItem.data());
|
||||
registerItem(m_pageItem.data());
|
||||
}
|
||||
@ -295,10 +300,11 @@ void PageDesignIntf::setPageItems(QList<PageItemDesignIntf::Ptr> pages)
|
||||
curHeight+=pageItem->height()+20;
|
||||
if (curWidth<pageItem->width()) curWidth=pageItem->width();
|
||||
}
|
||||
setSceneRect(QRectF( 0, 0, curWidth,curHeight).adjusted( -10 * Const::mmFACTOR,
|
||||
-10 * Const::mmFACTOR,
|
||||
10 * Const::mmFACTOR,
|
||||
10 * Const::mmFACTOR));
|
||||
if (!pages.isEmpty())
|
||||
setSceneRect(QRectF( 0, 0, curWidth,curHeight).adjusted( -10 * pages.at(0)->ppm(),
|
||||
-10 * pages.at(0)->ppm(),
|
||||
10 * pages.at(0)->ppm(),
|
||||
10 * pages.at(0)->ppm()));
|
||||
if (m_reportPages.count()>0)
|
||||
m_currentPage = m_reportPages.at(0).data();
|
||||
|
||||
@ -314,9 +320,19 @@ void PageDesignIntf::removePageItem(PageItemDesignIntf::Ptr pageItem)
|
||||
|
||||
void PageDesignIntf::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (m_insertMode) {
|
||||
if (m_insertMode && pageItem()) {
|
||||
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);
|
||||
emit itemInserted(this, event->scenePos(), m_insertItemType);
|
||||
}
|
||||
@ -470,6 +486,8 @@ BaseDesignIntf *PageDesignIntf::internalAddBand(T bandType)
|
||||
|
||||
band->setObjectName(genObjectName(*band));
|
||||
band->setItemTypeName("Band");
|
||||
band->setHeight((band->height()/Const::STORAGE_MM_FACTOR)*pageItem()->ppm());
|
||||
band->setPpm(pageItem()->ppm());
|
||||
|
||||
BandDesignIntf* pb = 0;
|
||||
if (selectedItems().count() > 0) {
|
||||
@ -721,12 +739,12 @@ bool PageDesignIntf::isLoading()
|
||||
return m_isLoading;
|
||||
}
|
||||
|
||||
void PageDesignIntf::objectLoadStarted()
|
||||
void PageDesignIntf::startLoading()
|
||||
{
|
||||
m_isLoading=true;
|
||||
}
|
||||
|
||||
void PageDesignIntf::objectLoadFinished()
|
||||
void PageDesignIntf::finishLoading()
|
||||
{
|
||||
m_isLoading=false;
|
||||
}
|
||||
@ -767,7 +785,8 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event)
|
||||
(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);
|
||||
QString data = event->mimeData()->text().remove(0,event->mimeData()->text().indexOf(":")+1);
|
||||
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
|
||||
{
|
||||
return m_reportSettings;
|
||||
@ -1931,7 +1974,9 @@ CommandIf::Ptr InsertItemCommand::create(PageDesignIntf *page, const QString &it
|
||||
|
||||
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();
|
||||
return item != 0;
|
||||
}
|
||||
@ -1942,21 +1987,16 @@ void InsertItemCommand::undoIt()
|
||||
if (item){
|
||||
page()->removeReportItem(item,false);
|
||||
}
|
||||
// page()->removeItem(item);
|
||||
// delete item;
|
||||
}
|
||||
|
||||
CommandIf::Ptr DeleteItemCommand::create(PageDesignIntf *page, BaseDesignIntf *item)
|
||||
{
|
||||
DeleteItemCommand *command = new DeleteItemCommand();
|
||||
//QScopedPointer<ItemsWriterIntf> writer(new XMLWriter());
|
||||
//writer->putItem(item);
|
||||
command->setPage(page);
|
||||
command->setItem(item);
|
||||
LayoutDesignIntf* layout = dynamic_cast<LayoutDesignIntf*>(item->parent());
|
||||
if (layout)
|
||||
command->m_layoutName = layout->objectName();
|
||||
//command->m_itemXML = writer->saveToString();
|
||||
return CommandIf::Ptr(command);
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ namespace LimeReport {
|
||||
|
||||
PageItemDesignIntf* getCurrentPage() const;
|
||||
void setCurrentPage(PageItemDesignIntf* currentPage);
|
||||
|
||||
void setPpm(int ppm);
|
||||
protected:
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *event);
|
||||
@ -199,8 +199,8 @@ namespace LimeReport {
|
||||
bool isExistsObjectName (const QString& objectName, QList<QGraphicsItem *> &itemsList) const;
|
||||
|
||||
bool isLoading();
|
||||
void objectLoadStarted();
|
||||
void objectLoadFinished();
|
||||
void startLoading();
|
||||
void finishLoading();
|
||||
|
||||
HorizontalLayout* internalAddHLayout();
|
||||
VerticalLayout* internalAddVLayout();
|
||||
|
@ -350,6 +350,46 @@ void PageItemDesignIntf::setPrintBehavior(const 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
|
||||
{
|
||||
return m_printBehavior;
|
||||
@ -682,8 +722,8 @@ QSizeF PageItemDesignIntf::getRectByPageSize(const PageSize& size)
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setOrientation((QPrinter::Orientation)pageOrientation());
|
||||
printer.setPaperSize((QPrinter::PageSize)size);
|
||||
return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * 10,
|
||||
printer.paperSize(QPrinter::Millimeter).height() * 10);
|
||||
return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * ppm(),
|
||||
printer.paperSize(QPrinter::Millimeter).height() * ppm());
|
||||
}
|
||||
|
||||
else {
|
||||
@ -913,6 +953,8 @@ void PageItemDesignIntf::bandPositionChanged(QObject* object, QPointF newPos, QP
|
||||
void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry)
|
||||
{
|
||||
bandPositionChanged(object, newGeometry.topLeft(), oldGeometry.topLeft());
|
||||
if (newGeometry.size() != oldGeometry.size())
|
||||
relocateBands();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (collectionName.compare("children",Qt::CaseInsensitive)==0){
|
||||
@ -948,10 +1000,10 @@ void PageItemDesignIntf::collectionLoadFinished(const QString &collectionName)
|
||||
void PageItemDesignIntf::updateMarginRect()
|
||||
{
|
||||
m_pageRect = rect();
|
||||
m_pageRect.adjust( leftMargin() * Const::mmFACTOR,
|
||||
topMargin() * Const::mmFACTOR,
|
||||
-rightMargin() * Const::mmFACTOR,
|
||||
-bottomMargin() * Const::mmFACTOR
|
||||
m_pageRect.adjust( leftMargin() * ppm(),
|
||||
topMargin() * ppm(),
|
||||
-rightMargin() * ppm(),
|
||||
-bottomMargin() * ppm()
|
||||
);
|
||||
|
||||
foreach(BandDesignIntf* band,m_bands){
|
||||
@ -972,26 +1024,26 @@ void PageItemDesignIntf::paintGrid(QPainter *ppainter, QRectF rect)
|
||||
ppainter->setPen(QPen(gridColor()));
|
||||
ppainter->setOpacity(0.5);
|
||||
for (int i = 0; i <= (rect.height() - 5 * unitFactor()) / (10 * unitFactor()); ++i){
|
||||
if (i * 10 * unitFactor() + 5 * unitFactor() >= topMargin() * Const::mmFACTOR)
|
||||
ppainter->drawLine(rect.x(), (i * 10 * unitFactor()) + ( (rect.y() + 5 * unitFactor()) - (topMargin() * Const::mmFACTOR)),
|
||||
rect.right(), i * 10 * unitFactor() +( (rect.y() + 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() * ppm())),
|
||||
rect.right(), i * 10 * unitFactor() +( (rect.y() + 5 * unitFactor()) - (topMargin() * ppm())));
|
||||
};
|
||||
for (int i=0; i<=((rect.width() - 5 * unitFactor()) / (10 * unitFactor())); ++i){
|
||||
if (i * 10 * unitFactor() + 5 * unitFactor() >= leftMargin() * Const::mmFACTOR)
|
||||
ppainter->drawLine(i * 10 * unitFactor() + ((rect.x() + 5 * unitFactor()) - (leftMargin() * Const::mmFACTOR)), rect.y(),
|
||||
i * 10 * unitFactor() + ((rect.x() + 5 * unitFactor()) - (leftMargin() * Const::mmFACTOR)), rect.bottom());
|
||||
if (i * 10 * unitFactor() + 5 * unitFactor() >= leftMargin() * ppm())
|
||||
ppainter->drawLine(i * 10 * unitFactor() + ((rect.x() + 5 * unitFactor()) - (leftMargin() * ppm())), rect.y(),
|
||||
i * 10 * unitFactor() + ((rect.x() + 5 * unitFactor()) - (leftMargin() * ppm())), rect.bottom());
|
||||
};
|
||||
ppainter->setPen(QPen(gridColor()));
|
||||
ppainter->setOpacity(1);
|
||||
for (int i = 0; i <= (rect.width() / (10 * unitFactor())); ++i){
|
||||
if (i * 10 * unitFactor() >= leftMargin() * Const::mmFACTOR)
|
||||
ppainter->drawLine(i * 10 * unitFactor() + (rect.x() - (leftMargin() * Const::mmFACTOR)), rect.y(),
|
||||
i * 10 * unitFactor() + (rect.x() - (leftMargin() * Const::mmFACTOR)), rect.bottom());
|
||||
if (i * 10 * unitFactor() >= leftMargin() * ppm())
|
||||
ppainter->drawLine(i * 10 * unitFactor() + (rect.x() - (leftMargin() * ppm())), rect.y(),
|
||||
i * 10 * unitFactor() + (rect.x() - (leftMargin() * ppm())), rect.bottom());
|
||||
};
|
||||
for (int i = 0; i <= rect.height() / (10 * unitFactor()); ++i){
|
||||
if (i * 10 * unitFactor() >= topMargin() * Const::mmFACTOR)
|
||||
ppainter->drawLine(rect.x(), i * 10 * unitFactor() + (rect.y() - (topMargin() * Const::mmFACTOR)),
|
||||
rect.right(), i * 10 * unitFactor() + (rect.y() - (topMargin() * Const::mmFACTOR)));
|
||||
if (i * 10 * unitFactor() >= topMargin() * ppm())
|
||||
ppainter->drawLine(rect.x(), i * 10 * unitFactor() + (rect.y() - (topMargin() * ppm())),
|
||||
rect.right(), i * 10 * unitFactor() + (rect.y() - (topMargin() * ppm())));
|
||||
};
|
||||
ppainter->drawRect(rect);
|
||||
ppainter->restore();
|
||||
@ -1016,9 +1068,9 @@ int PageItemDesignIntf::gridStep()
|
||||
else return Const::DEFAULT_GRID_STEP;
|
||||
}
|
||||
|
||||
void PageItemDesignIntf::objectLoadFinished()
|
||||
void PageItemDesignIntf::finishLoading()
|
||||
{
|
||||
BaseDesignIntf::objectLoadFinished();
|
||||
BaseDesignIntf::finishLoading();
|
||||
updateMarginRect();
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ public:
|
||||
QList<BandDesignIntf *>& bands();
|
||||
void setGridStep(int value);
|
||||
int gridStep();
|
||||
void objectLoadFinished();
|
||||
void finishLoading();
|
||||
bool fullPage() const;
|
||||
void setFullPage(bool fullPage);
|
||||
|
||||
@ -177,6 +177,10 @@ public:
|
||||
PrintBehavior printBehavior() const;
|
||||
void setPrintBehavior(const PrintBehavior &printBehavior);
|
||||
|
||||
void setPpm(int ppm);
|
||||
QRectF transformFromStorageToScenePpm(const QRectF& rect);
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
signals:
|
||||
void beforeFirstPageRendered();
|
||||
void afterLastPageRendered();
|
||||
@ -186,6 +190,7 @@ protected slots:
|
||||
void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
|
||||
void setUnitTypeProperty(BaseDesignIntf::UnitType value);
|
||||
protected:
|
||||
QRectF changeRectPpm(const QRectF& rect, int oldPpm, int newPpm);
|
||||
void collectionLoadFinished(const QString& collectionName);
|
||||
QRectF& pageRect(){return m_pageRect;}
|
||||
void updateMarginRect();
|
||||
|
@ -160,14 +160,14 @@ void PreviewReportWidget::setErrorsMesagesVisible(bool visible)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void PreviewReportWidget::zoomOut()
|
||||
{
|
||||
if (d_ptr->m_scalePercent>0)
|
||||
d_ptr->m_scalePercent = (d_ptr->m_scalePercent / 10) * 10 - 10;
|
||||
if (d_ptr->m_scalePercent > 20)
|
||||
d_ptr->m_scalePercent = (d_ptr->m_scalePercent / 20) * 20 - Const::PPM_PERCENT_STEP;
|
||||
setScalePercent(d_ptr->m_scalePercent);
|
||||
}
|
||||
|
||||
@ -311,8 +311,21 @@ void PreviewReportWidget::setScalePercent(int percent)
|
||||
{
|
||||
ui->graphicsView->resetMatrix();
|
||||
d_ptr->m_scalePercent = percent;
|
||||
qreal scaleSize = percent/100.0;
|
||||
ui->graphicsView->scale(scaleSize, scaleSize);
|
||||
|
||||
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;
|
||||
ui->graphicsView->scale(scaleSize, scaleSize);
|
||||
}
|
||||
|
||||
emit scalePercentChanged(percent);
|
||||
if (percent == 100){
|
||||
m_scaleType = OneToOne;
|
||||
|
@ -14,7 +14,7 @@ class PreviewReportWidgetPrivate
|
||||
public:
|
||||
PreviewReportWidgetPrivate(PreviewReportWidget* previewReportWidget):
|
||||
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) {}
|
||||
bool pageIsVisible();
|
||||
QRectF calcPageShift();
|
||||
|
@ -420,7 +420,7 @@ ItemsReaderIntf *PreviewReportWindow::reader()
|
||||
|
||||
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->setCurrentIndex(4);
|
||||
|
@ -293,7 +293,7 @@ PageView* ReportDesignWidget::createPageView(PageDesignIntf* page){
|
||||
view->setFrameShape(QFrame::NoFrame);
|
||||
view->setScene(page);
|
||||
view->setPageItem(page->pageItem());
|
||||
view->scale(0.5, 0.5);
|
||||
page->pageItem()->setPpm(5);
|
||||
view->centerOn(0, 0);
|
||||
return view;
|
||||
}
|
||||
@ -513,12 +513,6 @@ bool ReportDesignWidget::save()
|
||||
bool ReportDesignWidget::loadFromFile(const QString &fileName)
|
||||
{
|
||||
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;
|
||||
} else {
|
||||
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()) activeView()->scale(sx,sy);
|
||||
if (activeView()) {
|
||||
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()
|
||||
@ -1058,8 +1064,10 @@ bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event)
|
||||
if (event->type() == QEvent::Wheel){
|
||||
QWheelEvent* we = dynamic_cast<QWheelEvent*>(event);
|
||||
if (QApplication::keyboardModifiers()==Qt::ControlModifier){
|
||||
if(we->delta()<0) scale(1.2,1.2);
|
||||
else scale(1/1.2,1/1.2);
|
||||
//if(we->delta()<0) scale(1.2,1.2);
|
||||
//else scale(1/1.2,1/1.2);
|
||||
if (we->delta() < 0) zoomIn();
|
||||
else zoomOut();
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(target,event);
|
||||
|
@ -144,7 +144,10 @@ public:
|
||||
QGraphicsView* activeView();
|
||||
QList<QGraphicsItem *> selectedItems();
|
||||
QStringList datasourcesNames();
|
||||
void scale( qreal sx, qreal sy);
|
||||
//void scale( qreal sx, qreal sy);
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
ReportEnginePrivateInterface* report(){return m_report;}
|
||||
QString reportFileName();
|
||||
bool isNeedToSave();
|
||||
|
@ -1189,12 +1189,12 @@ void ReportDesignWindow::slotLoadReport()
|
||||
|
||||
void ReportDesignWindow::slotZoomIn()
|
||||
{
|
||||
m_reportDesignWidget->scale(1.2,1.2);
|
||||
m_reportDesignWidget->zoomIn();
|
||||
}
|
||||
|
||||
void ReportDesignWindow::slotZoomOut()
|
||||
{
|
||||
m_reportDesignWidget->scale(1/1.2,1/1.2);
|
||||
m_reportDesignWidget->zoomOut();
|
||||
}
|
||||
|
||||
void ReportDesignWindow::slotEditMode()
|
||||
|
@ -687,6 +687,7 @@ bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName)
|
||||
reader->setPassPhrase(m_passPhrase);
|
||||
if (reader->first()){
|
||||
if (reader->readItem(this)){
|
||||
|
||||
m_fileName=fileName;
|
||||
QFileInfo fi(fileName);
|
||||
m_reportName = fi.fileName();
|
||||
@ -706,6 +707,7 @@ bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName)
|
||||
EASY_BLOCK("Connect auto connections")
|
||||
dataManager()->connectAutoConnections();
|
||||
EASY_END_BLOCK;
|
||||
|
||||
dropChanges();
|
||||
|
||||
if ( hasActivePreview() )
|
||||
@ -1240,7 +1242,7 @@ void ReportEnginePrivate::paintByExternalPainter(const QString& objectName, QPai
|
||||
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());
|
||||
if (watermark){
|
||||
@ -1283,7 +1285,6 @@ ReportPages ReportEnginePrivate::renderToPages()
|
||||
m_reportRender->setScriptContext(scriptContext());
|
||||
clearRenderingPages();
|
||||
foreach (PageDesignIntf* page, m_pages) {
|
||||
|
||||
QVector<BaseDesignIntf*> watermarks;
|
||||
if (!m_watermarks.isEmpty()){
|
||||
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());
|
||||
|
||||
page->pageItem()->setPpm(savePpm);
|
||||
|
||||
qDeleteAll(watermarks.begin(),watermarks.end());
|
||||
watermarks.clear();
|
||||
|
||||
m_renderingPages.append(rp);
|
||||
scriptContext()->baseDesignIntfToScript(rp->objectName(), rp);
|
||||
|
||||
}
|
||||
|
||||
scriptContext()->qobjectToScript("engine",this);
|
||||
@ -1802,6 +1806,8 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
|
||||
|
||||
QPointF backupPagePos = page->pos();
|
||||
page->setPos(0,0);
|
||||
int currentPpm = page->ppm();
|
||||
page->setPpm(Const::STORAGE_MM_FACTOR);
|
||||
m_renderPage.setPageItem(page);
|
||||
m_renderPage.setSceneRect(m_renderPage.pageItem()->mapToScene(m_renderPage.pageItem()->rect()).boundingRect());
|
||||
initPrinter(m_renderPage.pageItem());
|
||||
@ -1849,6 +1855,7 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
|
||||
m_renderPage.render(m_painter);
|
||||
}
|
||||
page->setPos(backupPagePos);
|
||||
page->setPpm(currentPpm);
|
||||
m_renderPage.removePageItem(page);
|
||||
if (backupPage) backupPage->reactivatePageItem(page);
|
||||
return true;
|
||||
@ -2051,7 +2058,7 @@ qreal WatermarkHelper::valueToPixels(qreal value)
|
||||
{
|
||||
switch (m_watermark.geometry().type()) {
|
||||
case LimeReport::ItemGeometry::Millimeters:
|
||||
return value * Const::mmFACTOR;
|
||||
return value * m_ppm;
|
||||
case LimeReport::ItemGeometry::Pixels:
|
||||
return value;
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ class ReportExporterInterface;
|
||||
|
||||
class WatermarkHelper{
|
||||
public:
|
||||
WatermarkHelper(const WatermarkSetting& watermark)
|
||||
: m_watermark(watermark){}
|
||||
WatermarkHelper(const WatermarkSetting& watermark, int ppm)
|
||||
: m_watermark(watermark), m_ppm(ppm){}
|
||||
qreal sceneX();
|
||||
qreal sceneY();
|
||||
qreal sceneWidth();
|
||||
@ -72,6 +72,7 @@ private:
|
||||
qreal valueToPixels(qreal value);
|
||||
private:
|
||||
const WatermarkSetting& m_watermark;
|
||||
int m_ppm;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1300,7 +1300,7 @@ void ReportRender::startNewPage(bool isFirst)
|
||||
|
||||
m_renderPageItem->setObjectName(QLatin1String("ReportPage")+QString::number(m_pageCount));
|
||||
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;
|
||||
|
||||
if (isFirst) {
|
||||
@ -1537,7 +1537,7 @@ void ReportRender::savePage(bool isLast)
|
||||
pageHeight += band->height();
|
||||
}
|
||||
m_renderPageItem->setHeight(pageHeight + 10 +
|
||||
(m_patternPageItem->topMargin() + m_patternPageItem->bottomMargin()) * Const::mmFACTOR);
|
||||
(m_patternPageItem->topMargin() + m_patternPageItem->bottomMargin()) * m_patternPageItem->ppm());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<height>301</height>
|
||||
<height>317</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@ -90,7 +90,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="verticalGridStep">
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -104,7 +104,7 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="horizontalGridStep">
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -216,7 +216,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<height>301</height>
|
||||
<height>317</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@ -305,7 +305,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<height>301</height>
|
||||
<height>317</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
|
@ -39,7 +39,7 @@ QString MarginPropItem::displayValue() const
|
||||
return QString("%1 %2").arg(propertyValue().toDouble(), 0, 'f', 2)
|
||||
.arg(QObject::tr("mm"));
|
||||
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("''"));
|
||||
}
|
||||
}
|
||||
@ -72,7 +72,7 @@ qreal MarginPropItem::valueInUnits(qreal value) const
|
||||
case LimeReport::BaseDesignIntf::Millimeters:
|
||||
return value;
|
||||
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:
|
||||
return value;
|
||||
case LimeReport::BaseDesignIntf::Inches:
|
||||
return (value * (item->unitFactor() * 10)) / Const::mmFACTOR;
|
||||
|
||||
return (value * (item->unitFactor() * 10)) / item->ppm();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,15 @@ namespace LimeReport{
|
||||
class ObjectLoadingStateIntf{
|
||||
public:
|
||||
virtual bool isLoading() = 0;
|
||||
virtual void objectLoadStarted() = 0;
|
||||
virtual void objectLoadFinished() = 0;
|
||||
virtual void startLoading() = 0;
|
||||
virtual void finishLoading() = 0;
|
||||
};
|
||||
|
||||
class ObjectSavingStateIntf{
|
||||
public:
|
||||
virtual bool isSaving() = 0;
|
||||
virtual void startSaving() = 0;
|
||||
virtual void finishSaving() = 0;
|
||||
};
|
||||
|
||||
class ItemsWriterIntf
|
||||
|
@ -116,7 +116,7 @@ void XMLReader::readItemFromNode(QObject* item,QDomElement *node)
|
||||
{
|
||||
EASY_BLOCK("readItemFromNode");
|
||||
ObjectLoadingStateIntf* lf = dynamic_cast<ObjectLoadingStateIntf*>(item);
|
||||
if(lf) lf->objectLoadStarted();
|
||||
if(lf) lf->startLoading();
|
||||
for (int i=0;i<node->childNodes().count();i++){
|
||||
QDomElement currentNode =node->childNodes().at(i).toElement();
|
||||
if (currentNode.attribute("Type")=="Object"){
|
||||
@ -128,7 +128,7 @@ void XMLReader::readItemFromNode(QObject* item,QDomElement *node)
|
||||
readTranslation(item,¤tNode);
|
||||
} else readProperty(item,¤tNode);
|
||||
}
|
||||
if (lf) lf->objectLoadFinished();
|
||||
if (lf) lf->finishLoading();
|
||||
|
||||
BaseDesignIntf* baseObj = dynamic_cast<BaseDesignIntf*>(item);
|
||||
if(baseObj) {
|
||||
|
Loading…
Reference in New Issue
Block a user