0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-26 01:24:39 +03:00
LimeReport/limereport/items/lrabstractlayout.h

77 lines
2.9 KiB
C
Raw Normal View History

2018-06-21 14:29:00 +03:00
#ifndef LRABSTRACTLAYOUT_H
#define LRABSTRACTLAYOUT_H
#include "lritemdesignintf.h"
#include "lrlayoutmarker.h"
namespace LimeReport{
class AbstractLayout: public LayoutDesignIntf
{
Q_OBJECT
Q_ENUMS(LayoutType)
Q_PROPERTY(bool hideEmptyItems READ hideEmptyItems WRITE setHideEmptyItems)
Q_PROPERTY(int layoutSpacing READ layoutSpacing WRITE setLayoutSpacing)
2018-06-21 14:29:00 +03:00
public:
enum LayoutType{Layout,Table};
AbstractLayout(QString xmlTag, QObject *owner = 0, QGraphicsItem *parent = 0);
~AbstractLayout();
QList<BaseDesignIntf*>& layoutsChildren();
LayoutMarker* layoutMarker() const;
bool isRelocating() const;
void setIsRelocating(bool isRelocating);
LayoutType layoutType() const;
void setLayoutType(const LayoutType& layoutType);
void addChild(BaseDesignIntf *item,bool updateSize=true);
void restoreChild(BaseDesignIntf *item);
bool isEmpty() const;
2019-01-15 13:59:00 +03:00
void paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter);
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
2018-06-21 14:29:00 +03:00
bool hideEmptyItems() const;
void setHideEmptyItems(bool hideEmptyItems);
2019-02-04 19:40:29 +03:00
Q_INVOKABLE QObject* at(int index);
2018-06-21 14:29:00 +03:00
int childrenCount();
int layoutSpacing() const;
void setLayoutSpacing(int layoutSpacing);
2019-09-09 21:25:08 +03:00
qreal layoutSpacingMM(){ return m_layoutSpacing * Const::mmFACTOR;}
2019-02-04 19:40:29 +03:00
protected:
2018-06-21 14:29:00 +03:00
void beforeDelete();
void childAddedEvent(BaseDesignIntf *child);
void geometryChangedEvent(QRectF newRect, QRectF);
void initMode(ItemMode mode);
void setBorderLinesFlags(BorderLines flags);
void collectionLoadFinished(const QString &collectionName);
void objectLoadFinished();
bool isNeedUpdateSize(RenderPass pass) const;
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
2019-02-02 00:28:30 +03:00
void rebuildChildrenIfNeeded();
2018-06-21 14:29:00 +03:00
private:
2019-02-02 00:28:30 +03:00
virtual void sortChildren() = 0;
2018-06-21 14:29:00 +03:00
virtual void divideSpace() = 0;
virtual void updateLayoutSize() = 0;
virtual void relocateChildren() = 0;
2019-02-02 00:28:30 +03:00
virtual BaseDesignIntf* findNext(BaseDesignIntf *item);
virtual BaseDesignIntf* findPrior(BaseDesignIntf *item);
2018-06-21 14:29:00 +03:00
virtual void placeItemInLayout(BaseDesignIntf* item) = 0;
virtual void insertItemInLayout(BaseDesignIntf* item) = 0;
private slots:
void slotOnChildDestroy(QObject *child);
void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry);
void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
void slotOnChildVisibleHasChanged(BaseDesignIntf*);
void slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value);
private:
QList<BaseDesignIntf *> m_children;
bool m_isRelocating;
LayoutMarker* m_layoutMarker;
LayoutType m_layoutType;
bool m_hideEmptyItems;
int m_layoutSpacing;
2018-06-21 14:29:00 +03:00
};
} // namespace LimeReport
#endif // LRABSTRACTLAYOUT_H