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

113 lines
5.1 KiB
C
Raw Normal View History

2016-02-17 10:11:00 +03:00
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
****************************************************************************/
#ifndef LRHORIZONTALLAYOUT_H
#define LRHORIZONTALLAYOUT_H
#include "lritemdesignintf.h"
namespace LimeReport
{
class HorizontalLayout;
class LayoutMarker : public QGraphicsItem{
public:
explicit LayoutMarker(HorizontalLayout* layout, QGraphicsItem *parent=0);
virtual QRectF boundingRect() const{return m_rect;}
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
void setHeight(qreal height);
void setWidth(qreal width);
void setColor(QColor color);
qreal width(){return m_rect.width();}
qreal height(){return m_rect.height();}
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:
QRectF m_rect;
QColor m_color;
HorizontalLayout* m_layout;
};
class HorizontalLayout : public LayoutDesignIntf
{
Q_OBJECT
2016-02-17 10:28:27 +03:00
Q_ENUMS(LayoutType)
Q_PROPERTY(LayoutType layoutType READ layoutType WRITE setLayoutType)
2016-02-17 10:11:00 +03:00
public:
2016-02-17 10:28:27 +03:00
friend class LayoutMarker;
enum LayoutType{Layout,Table};
2016-02-17 10:11:00 +03:00
HorizontalLayout(QObject *owner = 0, QGraphicsItem *parent = 0);
~HorizontalLayout();
BaseDesignIntf *createSameTypeItem(QObject *owner = 0, QGraphicsItem *parent = 0);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void geometryChangedEvent(QRectF newRect, QRectF);
void addChild(BaseDesignIntf *item,bool updateSize=true);
friend class BaseDesignIntf;
void restoreChild(BaseDesignIntf *item);
bool isEmpty() const;
2016-02-17 10:28:27 +03:00
LayoutType layoutType() const;
void setLayoutType(const LayoutType &layoutType);
2016-02-17 10:11:00 +03:00
protected:
void collectionLoadFinished(const QString &collectionName);
void objectLoadFinished();
void updateLayoutSize();
void relocateChildren();
2016-02-17 10:28:27 +03:00
BaseDesignIntf *findNext(BaseDesignIntf *item);
BaseDesignIntf *findPrior(BaseDesignIntf *item);
2016-02-17 10:11:00 +03:00
void beforeDelete();
2016-02-17 10:28:27 +03:00
void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
2016-02-17 10:11:00 +03:00
bool isNeedUpdateSize(RenderPass pass) const;
void childAddedEvent(BaseDesignIntf *child);
void setChildVisibility(bool value);
int childrenCount();
void initMode(ItemMode mode);
bool canBeSplitted(int height) const;
BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
2016-02-17 10:28:27 +03:00
void setItemAlign(const ItemAlign &itemAlign);
2016-02-17 10:11:00 +03:00
private slots:
void slotOnChildDestroy(QObject *child);
2016-02-17 10:28:27 +03:00
void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry);
void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
2016-02-17 10:11:00 +03:00
//void slotOnPosChanged(QObject*, QPointF newPos, QPointF );
2016-02-17 10:28:27 +03:00
private:
void divideSpace();
2016-02-17 10:11:00 +03:00
private:
QList<BaseDesignIntf *> m_children;
bool m_isRelocating;
LayoutMarker* m_layoutMarker;
2016-02-17 10:28:27 +03:00
LayoutType m_layoutType;
2016-02-17 10:11:00 +03:00
};
} //namespace LimeReport
#endif // LRHORIZONTALLAYOUT_H