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

92 lines
3.2 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"
2020-03-03 05:19:59 +03:00
#include <QtGlobal>
2018-06-21 14:29:00 +03:00
namespace LimeReport {
class AbstractLayout: public LayoutDesignIntf {
2018-06-21 14:29:00 +03:00
Q_OBJECT
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
};
2021-08-24 10:22:30 +03:00
#if QT_VERSION >= 0x050500
Q_ENUM(LayoutType)
2020-03-03 05:19:59 +03:00
#else
Q_ENUMS(LayoutType)
#endif
AbstractLayout(QString xmlTag, QObject* owner = 0, QGraphicsItem* parent = 0);
2018-06-21 14:29:00 +03:00
~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 removeChild(BaseDesignIntf* item);
void restoreChild(BaseDesignIntf* item);
2018-06-21 14:29:00 +03:00
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);
int childrenCount();
int layoutSpacing() const;
void setLayoutSpacing(int layoutSpacing);
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);
2018-06-21 14:29:00 +03:00
void geometryChangedEvent(QRectF newRect, QRectF);
void initMode(ItemMode mode);
void setBorderLinesFlags(BorderLines flags);
void collectionLoadFinished(const QString& collectionName);
2018-06-21 14:29:00 +03:00
void objectLoadFinished();
bool isNeedUpdateSize(RenderPass pass) const;
QVariant itemChange(GraphicsItemChange change, const QVariant& value);
2018-06-21 14:29:00 +03:00
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
2019-02-02 00:28:30 +03:00
void rebuildChildrenIfNeeded();
2022-02-06 17:14:04 +03:00
void connectToLayout(BaseDesignIntf* item);
void disconnectFromLayout(BaseDesignIntf* item);
2024-07-25 18:32:30 +03:00
virtual void insertItemInLayout(BaseDesignIntf* item);
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;
virtual BaseDesignIntf* findNext(BaseDesignIntf* item);
virtual BaseDesignIntf* findPrior(BaseDesignIntf* item);
2018-06-21 14:29:00 +03:00
virtual void placeItemInLayout(BaseDesignIntf* item) = 0;
2024-07-25 18:32:30 +03:00
2018-06-21 14:29:00 +03:00
private slots:
void slotOnChildDestroy(QObject* child);
void slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, QRectF oldGeometry);
2018-06-21 14:29:00 +03:00
void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
void slotOnChildVisibleHasChanged(BaseDesignIntf*);
void slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value);
2018-06-21 14:29:00 +03:00
private:
QList<BaseDesignIntf*> m_children;
2018-06-21 14:29:00 +03:00
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