mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-23 20:22:58 +03:00
Init commit
This commit is contained in:
parent
9bd392f4ac
commit
005e65f3e3
@ -52,8 +52,8 @@ namespace LimeReport {
|
||||
|
||||
|
||||
namespace Const{
|
||||
int const RESIZE_HANDLE_SIZE = 10;
|
||||
int const SELECTION_PEN_SIZE = 4;
|
||||
int const RESIZE_HANDLE_SIZE = 5;
|
||||
int const SELECTION_PEN_SIZE = 1;
|
||||
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE;
|
||||
double const RESIZE_ZONE_OPACITY = 0.5;
|
||||
|
@ -304,6 +304,12 @@ bool BandDesignIntf::isUnique() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void BandDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode)
|
||||
{
|
||||
ItemsContainerDesignInft::setItemMode(mode);
|
||||
updateBandMarkerGeometry();
|
||||
}
|
||||
|
||||
QString BandDesignIntf::datasourceName(){
|
||||
return m_dataSourceName;
|
||||
}
|
||||
@ -728,14 +734,19 @@ BandDesignIntf* BandDesignIntf::findParentBand()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BandDesignIntf::geometryChangedEvent(QRectF, QRectF )
|
||||
void BandDesignIntf::updateBandMarkerGeometry()
|
||||
{
|
||||
if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){
|
||||
if (parentItem() && m_bandMarker){
|
||||
QPointF sp = parentItem()->mapToScene(pos());
|
||||
if (m_bandMarker){
|
||||
m_bandMarker->setPos((sp.x()-m_bandMarker->boundingRect().width()),sp.y());
|
||||
m_bandMarker->setHeight(rect().height());
|
||||
}
|
||||
}
|
||||
|
||||
void BandDesignIntf::geometryChangedEvent(QRectF, QRectF )
|
||||
{
|
||||
if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){
|
||||
updateBandMarkerGeometry();
|
||||
}
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
if (item->itemAlign()!=DesignedItemAlign){
|
||||
|
@ -142,6 +142,7 @@ public:
|
||||
virtual QString bandTitle() const;
|
||||
virtual QIcon bandIcon() const;
|
||||
virtual bool isUnique() const;
|
||||
void setItemMode(BaseDesignIntf::ItemMode mode);
|
||||
void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0);
|
||||
void restoreItems();
|
||||
void recalcItems(DataSourceManager* dataManager);
|
||||
@ -250,6 +251,8 @@ public:
|
||||
void setBackgroundOpacity(int value);
|
||||
int bootomSpace() const;
|
||||
void setBootomSpace(int bootomSpace);
|
||||
void updateBandMarkerGeometry();
|
||||
|
||||
signals:
|
||||
void bandRendered(BandDesignIntf* band);
|
||||
void preparedForRender();
|
||||
|
@ -81,7 +81,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
|
||||
m_patternName(""),
|
||||
m_patternItem(0),
|
||||
m_fillInSecondPass(false),
|
||||
m_watermark(false)
|
||||
m_watermark(false),
|
||||
m_hovered(false)
|
||||
{
|
||||
setGeometry(QRectF(0, 0, m_width, m_height));
|
||||
if (BaseDesignIntf *item = dynamic_cast<BaseDesignIntf *>(parent)) {
|
||||
@ -104,7 +105,7 @@ QRectF BaseDesignIntf::boundingRect() const
|
||||
}
|
||||
|
||||
BaseDesignIntf::~BaseDesignIntf(void) {
|
||||
delete m_selectionMarker;
|
||||
//delete m_selectionMarker;
|
||||
delete m_joinMarker;
|
||||
}
|
||||
|
||||
@ -394,6 +395,9 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
|
||||
drawBorder(ppainter, rect());
|
||||
if (isSelected()) {drawSelection(ppainter, rect());}
|
||||
drawResizeZone(ppainter);
|
||||
// if (m_hovered) ppainter->drawImage(
|
||||
// QRectF(QPointF(rect().topRight().x()-24, rect().bottomLeft().y()-24),
|
||||
// QSizeF(24, 24)),QImage(":/items/images/settings.png"));
|
||||
}
|
||||
|
||||
QColor calcColor(QColor color){
|
||||
@ -480,6 +484,14 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
|
||||
m_resizeDirectionFlags = 0;
|
||||
scene()->update(sceneBoundingRect());
|
||||
m_resizeAreas.clear();
|
||||
m_hovered = false;
|
||||
update();
|
||||
}
|
||||
|
||||
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
m_hovered = true;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -710,6 +722,7 @@ void BaseDesignIntf::turnOnSelectionMarker(bool value)
|
||||
if (value && !m_selectionMarker){
|
||||
m_selectionMarker = new SelectionMarker(this);
|
||||
m_selectionMarker->setColor(selectionMarkerColor());
|
||||
m_selectionMarker->setZValue(zValue()-1);
|
||||
updateSelectionMarker();
|
||||
m_selectionMarker->setVisible(true);
|
||||
} else {
|
||||
@ -1119,6 +1132,28 @@ void BaseDesignIntf::drawSelection(QPainter *painter, QRectF /*rect*/) const
|
||||
// painter->drawLine(rect.right(),rect.bottom()-m_resizeHandleSize,rect.right(),rect.bottom());
|
||||
// painter->setOpacity(Consts::SELECTION_COLOR_OPACITY);
|
||||
// painter->fillRect(rect,selectionColor());
|
||||
|
||||
QPen pen(Qt::red,m_selectionPenSize);
|
||||
painter->setPen(pen);
|
||||
painter->setBrush(QBrush(Qt::red));
|
||||
const int markerSize = Const::RESIZE_HANDLE_SIZE;
|
||||
painter->drawRect(QRectF(-markerSize,-markerSize,markerSize*2,markerSize*2));
|
||||
painter->drawRect(QRectF(rect().right()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2));
|
||||
painter->drawRect(QRectF(rect().right()-markerSize,rect().top()-markerSize,markerSize*2,markerSize*2));
|
||||
painter->drawRect(QRectF(rect().left()-markerSize,rect().bottom()-markerSize,markerSize*2,markerSize*2));
|
||||
painter->drawRect(QRectF(rect().left()-markerSize,
|
||||
rect().bottom()-rect().height()/2-markerSize,markerSize*2,markerSize*2));
|
||||
painter->drawRect(QRectF(rect().right()-markerSize,
|
||||
rect().bottom()-rect().height()/2-markerSize,markerSize*2,markerSize*2));
|
||||
painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize,
|
||||
rect().top()-markerSize,markerSize*2,markerSize*2));
|
||||
painter->drawRect(QRectF(rect().left()+rect().width()/2-markerSize,
|
||||
rect().bottom()-markerSize,markerSize*2,markerSize*2));
|
||||
|
||||
pen.setStyle(Qt::DotLine);
|
||||
painter->setPen(pen);
|
||||
painter->setBrush(QBrush(Qt::transparent));
|
||||
painter->drawRect(rect());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
@ -1298,13 +1333,13 @@ void BaseDesignIntf::setMarginSize(int value)
|
||||
|
||||
void BaseDesignIntf::updateSelectionMarker()
|
||||
{
|
||||
if (m_selectionMarker && (itemMode() & DesignMode || itemMode() & EditMode)) {
|
||||
if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker);
|
||||
if (parentItem()) {
|
||||
m_selectionMarker->setRect(rect());
|
||||
m_selectionMarker->setPos(0,0);
|
||||
}
|
||||
}
|
||||
// if (m_selectionMarker && (itemMode() & DesignMode || itemMode() & EditMode)) {
|
||||
// if ((!m_selectionMarker->scene()) && scene()) scene()->addItem(m_selectionMarker);
|
||||
// if (parentItem()) {
|
||||
// m_selectionMarker->setRect(rect());
|
||||
// m_selectionMarker->setPos(0,0);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void BaseDesignIntf::drawResizeZone(QPainter* /*painter*/)
|
||||
@ -1561,6 +1596,18 @@ void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||
if(baseItem) baseItem->hoverMoveEvent(event);
|
||||
}
|
||||
|
||||
void SelectionMarker::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
|
||||
if (baseItem) baseItem->hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
void SelectionMarker::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(parentItem());
|
||||
if (baseItem) baseItem->hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
void SelectionMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
parentItem()->setSelected(true);
|
||||
@ -1596,7 +1643,7 @@ QRectF Marker::boundingRect() const
|
||||
void Marker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
||||
{
|
||||
QPen pen;
|
||||
const int markerSize = 5;
|
||||
const int markerSize = Const::RESIZE_HANDLE_SIZE;
|
||||
pen.setColor(color());
|
||||
pen.setWidth(2);
|
||||
pen.setStyle(Qt::DotLine);
|
||||
|
@ -70,6 +70,8 @@ public:
|
||||
SelectionMarker(QGraphicsItem* parent=0);
|
||||
protected:
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||
@ -204,7 +206,7 @@ public:
|
||||
void setItemPos(const QPointF &newPos);
|
||||
void setItemPos(qreal x, qreal y);
|
||||
|
||||
void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode);
|
||||
virtual void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode);
|
||||
ItemMode itemMode() const {return m_itemMode;}
|
||||
|
||||
virtual void setBorderLinesFlags(LimeReport::BaseDesignIntf::BorderLines flags);
|
||||
@ -305,10 +307,11 @@ protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
//void virtual hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||
|
||||
virtual void geometryChangedEvent(QRectF newRect, QRectF oldRect);
|
||||
@ -415,7 +418,7 @@ private:
|
||||
BaseDesignIntf* m_patternItem;
|
||||
bool m_fillInSecondPass;
|
||||
bool m_watermark;
|
||||
|
||||
bool m_hovered;
|
||||
signals:
|
||||
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
|
||||
void posChanging(QObject* object, QPointF newPos, QPointF oldPos);
|
||||
|
@ -52,8 +52,8 @@ namespace LimeReport {
|
||||
|
||||
|
||||
namespace Const{
|
||||
int const RESIZE_HANDLE_SIZE = 10;
|
||||
int const SELECTION_PEN_SIZE = 4;
|
||||
int const RESIZE_HANDLE_SIZE = 5;
|
||||
int const SELECTION_PEN_SIZE = 1;
|
||||
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE;
|
||||
double const RESIZE_ZONE_OPACITY = 0.5;
|
||||
|
@ -164,6 +164,12 @@ QRectF PageItemDesignIntf::boundingRect() const
|
||||
}
|
||||
}
|
||||
|
||||
void PageItemDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode)
|
||||
{
|
||||
ItemsContainerDesignInft::setItemMode(mode);
|
||||
relocateBands();
|
||||
}
|
||||
|
||||
void PageItemDesignIntf::clear()
|
||||
{
|
||||
foreach(QGraphicsItem* item, childItems()){
|
||||
|
@ -90,6 +90,7 @@ public:
|
||||
virtual QColor pageBorderColor() const;
|
||||
virtual QColor gridColor() const;
|
||||
virtual QRectF boundingRect() const;
|
||||
void setItemMode(LimeReport::BaseDesignIntf::ItemMode mode);
|
||||
void clear();
|
||||
const BandsList& childBands() const {return m_bands;}
|
||||
BandDesignIntf * bandByType(BandDesignIntf::BandsType bandType) const;
|
||||
|
Loading…
Reference in New Issue
Block a user