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 LRBANDDESIGNINTF_H
|
|
|
|
#define LRBANDDESIGNINTF_H
|
|
|
|
#include "lrbasedesignintf.h"
|
2016-02-17 10:28:27 +03:00
|
|
|
#include "lrdatasourcemanager.h"
|
2017-04-05 00:58:04 +03:00
|
|
|
#include "lritemscontainerdesignitf.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
namespace LimeReport {
|
|
|
|
|
2016-02-17 10:18:19 +03:00
|
|
|
class IGroupBand
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-02-17 10:28:27 +03:00
|
|
|
virtual void startGroup(DataSourceManager* dataManager) = 0;
|
|
|
|
virtual bool isNeedToClose(DataSourceManager* dataManager) = 0;
|
|
|
|
virtual bool isStarted() = 0;
|
|
|
|
virtual void closeGroup() = 0;
|
|
|
|
virtual int index() = 0;
|
2016-02-17 10:39:17 +03:00
|
|
|
virtual bool startNewPage() const = 0 ;
|
|
|
|
virtual bool resetPageNumber() const = 0 ;
|
2016-02-17 10:18:19 +03:00
|
|
|
virtual ~IGroupBand(){}
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class BandDesignIntf;
|
|
|
|
|
|
|
|
class BandMarker : public QGraphicsItem{
|
|
|
|
public:
|
|
|
|
explicit BandMarker(BandDesignIntf* band, QGraphicsItem *parent=0);
|
2016-02-17 10:19:50 +03:00
|
|
|
QRectF boundingRect() const;
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
|
2016-02-17 10:11:00 +03:00
|
|
|
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;
|
|
|
|
BandDesignIntf* m_band;
|
|
|
|
};
|
|
|
|
|
2016-02-17 10:19:50 +03:00
|
|
|
class BandNameLabel : public QGraphicsItem{
|
|
|
|
public:
|
|
|
|
explicit BandNameLabel(BandDesignIntf* band, QGraphicsItem* parent=0);
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
|
|
|
QRectF boundingRect() const;
|
|
|
|
void updateLabel();
|
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
private:
|
|
|
|
QRectF m_rect;
|
|
|
|
QColor m_color;
|
|
|
|
BandDesignIntf* m_band;
|
|
|
|
};
|
|
|
|
|
2017-04-05 00:58:04 +03:00
|
|
|
class BandDesignIntf : public ItemsContainerDesignInft
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(bool autoHeight READ autoHeight WRITE setAutoHeight )
|
|
|
|
Q_PROPERTY(int bandIndex READ bandIndex WRITE setBandIndex DESIGNABLE false )
|
|
|
|
Q_PROPERTY(bool keepBottomSpace READ keepBottomSpaceOption WRITE setKeepBottomSpaceOption )
|
|
|
|
Q_PROPERTY(QString parentBand READ parentBandName WRITE setParentBandName DESIGNABLE false )
|
|
|
|
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
|
2016-12-21 22:09:10 +03:00
|
|
|
Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle)
|
2016-02-17 10:11:00 +03:00
|
|
|
Q_PROPERTY(bool printIfEmpty READ printIfEmpty WRITE setPrintIfEmpty)
|
2016-02-17 10:28:27 +03:00
|
|
|
Q_ENUMS(BandColumnsLayoutType)
|
2016-02-17 10:11:00 +03:00
|
|
|
friend class BandMarker;
|
2016-02-17 10:19:50 +03:00
|
|
|
friend class BandNameLabel;
|
2016-02-17 10:11:00 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
enum BandsType {
|
|
|
|
PageHeader=0,
|
|
|
|
ReportHeader=1,
|
2016-02-17 10:18:19 +03:00
|
|
|
DataHeader=2,
|
|
|
|
GroupHeader=3,
|
2016-02-17 10:11:00 +03:00
|
|
|
Data=4,
|
|
|
|
SubDetailHeader=5,
|
|
|
|
SubDetailBand=6,
|
|
|
|
SubDetailFooter=7,
|
|
|
|
GroupFooter=8,
|
2016-02-17 10:18:19 +03:00
|
|
|
DataFooter=9,
|
|
|
|
ReportFooter=10,
|
2016-10-04 03:21:22 +03:00
|
|
|
TearOffBand=11,
|
|
|
|
PageFooter=12
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
enum BandColumnsLayoutType{
|
2016-02-17 10:39:17 +03:00
|
|
|
Horizontal, Vertical, VerticalUniform
|
2016-02-17 10:28:27 +03:00
|
|
|
};
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
BandDesignIntf(BandsType bandType, const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0);
|
|
|
|
~BandDesignIntf();
|
|
|
|
|
2016-12-21 22:09:10 +03:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
2016-02-17 10:11:00 +03:00
|
|
|
virtual BandsType bandType() const;
|
|
|
|
virtual QString bandTitle() const;
|
|
|
|
virtual QIcon bandIcon() const;
|
|
|
|
virtual bool isUnique() const;
|
2016-02-17 10:39:17 +03:00
|
|
|
void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0);
|
2016-06-24 17:36:25 +03:00
|
|
|
void updateBandNameLabel();
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
virtual QColor selectionColor() const;
|
|
|
|
int bandIndex() const;
|
|
|
|
void setBandIndex(int value);
|
2016-06-24 17:36:25 +03:00
|
|
|
void changeBandIndex(int value);
|
2016-02-17 10:11:00 +03:00
|
|
|
void setBandType(BandsType value){m_bandType=value;}
|
|
|
|
|
|
|
|
QString datasourceName();
|
|
|
|
void setDataSourceName(const QString& datasourceName);
|
|
|
|
|
|
|
|
void setKeepBottomSpaceOption(bool value){m_keepBottomSpace=value;}
|
|
|
|
bool keepBottomSpaceOption() const {return m_keepBottomSpace;}
|
|
|
|
|
|
|
|
void addChildBand(BandDesignIntf* band);
|
|
|
|
bool hasChildren(){return !m_childBands.isEmpty();}
|
|
|
|
void removeChildBand(BandDesignIntf* band);
|
|
|
|
void setParentBand(BandDesignIntf* band);
|
|
|
|
|
|
|
|
void setParentBandName(const QString& parentBandName);
|
2016-09-09 20:49:46 +03:00
|
|
|
QString parentBandName();
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
bool isConnectedToBand(BandDesignIntf::BandsType bandType) const;
|
|
|
|
|
2016-02-17 10:18:19 +03:00
|
|
|
int minChildIndex(BandsType bandType);
|
|
|
|
int maxChildIndex(QSet<BandsType> ignoredBands = QSet<BandDesignIntf::BandsType>()) const;
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
BandDesignIntf* parentBand() const {return m_parentBand;}
|
|
|
|
|
|
|
|
QList<BandDesignIntf*> childBands() const{return m_childBands;}
|
|
|
|
QList<BandDesignIntf*> childrenByType(BandDesignIntf::BandsType type);
|
|
|
|
|
2016-02-17 10:39:17 +03:00
|
|
|
bool canBeSplitted(int height) const;
|
|
|
|
bool isEmpty() const;
|
2016-02-17 10:11:00 +03:00
|
|
|
virtual bool isNeedRender() const;
|
|
|
|
virtual bool isFooter() const {return false;}
|
2016-02-17 10:18:19 +03:00
|
|
|
virtual bool isHeader() const {return false;}
|
2016-02-17 10:39:17 +03:00
|
|
|
virtual bool isGroupHeader() const {return false;}
|
2016-02-17 10:11:00 +03:00
|
|
|
virtual bool isData() const {return false;}
|
2016-02-21 01:08:54 +03:00
|
|
|
bool isBand(){return true;}
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
void setTryToKeepTogether(bool value);
|
|
|
|
bool tryToKeepTogether();
|
|
|
|
|
|
|
|
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 emitBandRendered(BandDesignIntf *band);
|
|
|
|
|
|
|
|
bool isSplittable() const {return m_splitable;}
|
2016-02-17 10:28:27 +03:00
|
|
|
void setSplittable(bool value);
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
bool keepFooterTogether() const;
|
2016-02-17 10:28:27 +03:00
|
|
|
void setKeepFooterTogether(bool value);
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
int maxScalePercent() const;
|
|
|
|
void setMaxScalePercent(int maxScalePercent);
|
|
|
|
|
|
|
|
bool sliceLastRow() const;
|
|
|
|
void setSliceLastRow(bool sliceLastRow);
|
|
|
|
|
|
|
|
bool printIfEmpty() const;
|
|
|
|
void setPrintIfEmpty(bool printIfEmpty);
|
|
|
|
|
2016-02-17 10:18:19 +03:00
|
|
|
virtual BandDesignIntf* bandHeader();
|
|
|
|
virtual BandDesignIntf* bandFooter();
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
int columnsCount() const {return m_columnsCount;}
|
|
|
|
BandColumnsLayoutType columnsFillDirection(){ return m_columnsFillDirection;}
|
|
|
|
int columnIndex() const;
|
|
|
|
void setColumnIndex(int columnIndex);
|
|
|
|
|
2016-02-17 10:39:17 +03:00
|
|
|
bool reprintOnEachPage() const;
|
|
|
|
void setReprintOnEachPage(bool reprintOnEachPage);
|
|
|
|
|
|
|
|
bool startNewPage() const;
|
|
|
|
void setStartNewPage(bool startNewPage);
|
|
|
|
|
2017-02-24 07:13:43 +03:00
|
|
|
void setAutoHeight(bool value);
|
2016-05-17 21:52:53 +03:00
|
|
|
bool autoHeight(){return m_autoHeight;}
|
|
|
|
|
2016-05-31 15:07:57 +03:00
|
|
|
bool startFromNewPage() const;
|
|
|
|
void setStartFromNewPage(bool startFromNewPage);
|
2016-06-01 19:37:51 +03:00
|
|
|
bool canContainChildren(){ return true;}
|
2016-07-21 00:14:39 +03:00
|
|
|
bool printAlways() const;
|
|
|
|
void setPrintAlways(bool printAlways);
|
2016-07-27 00:41:24 +03:00
|
|
|
bool repeatOnEachRow() const;
|
|
|
|
void setRepeatOnEachRow(bool repeatOnEachRow);
|
2016-10-18 13:58:26 +03:00
|
|
|
QColor alternateBackgroundColor() const;
|
|
|
|
void setAlternateBackgroundColor(const QColor &alternateBackgroundColor);
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
signals:
|
|
|
|
void bandRendered(BandDesignIntf* band);
|
|
|
|
protected:
|
|
|
|
void trimToMaxHeight(int maxHeight);
|
2016-05-17 21:52:53 +03:00
|
|
|
void setBandTypeText(const QString& value);
|
2016-02-17 10:11:00 +03:00
|
|
|
QString bandTypeText(){return m_bandTypeText;}
|
2016-02-17 10:39:17 +03:00
|
|
|
void moveDown(){}
|
|
|
|
void moveUp(){}
|
2016-02-17 10:11:00 +03:00
|
|
|
QSet<BandsType> groupBands();
|
|
|
|
QSet<BandsType> subdetailBands();
|
|
|
|
BandDesignIntf *findParentBand();
|
2016-02-17 10:39:17 +03:00
|
|
|
void geometryChangedEvent(QRectF, QRectF);
|
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
|
|
|
void initMode(ItemMode mode);
|
2016-02-17 10:11:00 +03:00
|
|
|
virtual QColor bandColor() const;
|
|
|
|
void setMarkerColor(QColor color);
|
|
|
|
void checkEmptyTable();
|
2016-02-17 10:28:27 +03:00
|
|
|
void setColumnsCount(int value);
|
2016-07-25 14:07:42 +03:00
|
|
|
void setColumnsFillDirection(BandColumnsLayoutType value);
|
|
|
|
void moveItemsDown(qreal startPos, qreal offset);
|
2017-02-24 07:13:43 +03:00
|
|
|
void preparePopUpMenu(QMenu &menu);
|
|
|
|
void processPopUpAction(QAction *action);
|
2016-02-17 10:11:00 +03:00
|
|
|
private slots:
|
|
|
|
void childBandDeleted(QObject* band);
|
|
|
|
private:
|
|
|
|
QString m_bandTypeText;
|
|
|
|
BandsType m_bandType;
|
|
|
|
int m_bandIndex;
|
|
|
|
QString m_dataSourceName;
|
|
|
|
bool m_autoHeight;
|
|
|
|
bool m_keepBottomSpace;
|
|
|
|
BandDesignIntf* m_parentBand;
|
|
|
|
QString m_parentBandName;
|
|
|
|
QList<BandDesignIntf*> m_childBands;
|
|
|
|
QVector<PItemSortContainer> m_bandItems;
|
|
|
|
BandMarker* m_bandMarker;
|
|
|
|
bool m_tryToKeepTogether;
|
|
|
|
bool m_splitable;
|
|
|
|
bool m_keepFooterTogether;
|
|
|
|
int m_maxScalePercent;
|
|
|
|
bool m_sliceLastRow;
|
|
|
|
bool m_printIfEmpty;
|
2016-02-17 10:19:50 +03:00
|
|
|
BandNameLabel* m_bandNameLabel;
|
2016-02-17 10:28:27 +03:00
|
|
|
int m_columnsCount;
|
|
|
|
int m_columnIndex;
|
|
|
|
BandColumnsLayoutType m_columnsFillDirection;
|
2016-02-17 10:39:17 +03:00
|
|
|
bool m_reprintOnEachPage;
|
|
|
|
bool m_startNewPage;
|
2016-05-31 15:07:57 +03:00
|
|
|
bool m_startFromNewPage;
|
2016-07-21 00:14:39 +03:00
|
|
|
bool m_printAlways;
|
2016-07-27 00:41:24 +03:00
|
|
|
bool m_repeatOnEachRow;
|
2016-08-08 15:50:44 +03:00
|
|
|
QMap<QString,BaseDesignIntf*> m_slicedItems;
|
2016-10-18 13:58:26 +03:00
|
|
|
QColor m_alternateBackgroundColor;
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class DataBandDesignIntf : public BandDesignIntf{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QString datasource READ datasourceName WRITE setDataSourceName )
|
|
|
|
public:
|
|
|
|
DataBandDesignIntf(BandsType bandType, QString xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0);
|
|
|
|
};
|
|
|
|
|
|
|
|
bool bandIndexLessThen(const BandDesignIntf* b1, const BandDesignIntf* b2);
|
|
|
|
|
2017-04-05 00:58:04 +03:00
|
|
|
} // namespace LimeReport
|
2016-02-17 10:11:00 +03:00
|
|
|
#endif // LRBANDDESIGNINTF_H
|