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. *
|
|
|
|
****************************************************************************/
|
|
|
|
#include "lrbanddesignintf.h"
|
|
|
|
#include "lritemdesignintf.h"
|
|
|
|
#include "lrglobal.h"
|
2016-10-03 21:56:48 +03:00
|
|
|
#include <algorithm>
|
2016-02-17 10:11:00 +03:00
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include <QGraphicsSceneMouseEvent>
|
2017-02-24 07:13:43 +03:00
|
|
|
#include <QMenu>
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
namespace LimeReport {
|
|
|
|
|
|
|
|
BandMarker::BandMarker(BandDesignIntf *band, QGraphicsItem* parent)
|
|
|
|
:QGraphicsItem(parent),m_rect(0,0,30,30),m_band(band)
|
|
|
|
{}
|
|
|
|
|
|
|
|
QRectF BandMarker::boundingRect() const
|
|
|
|
{
|
|
|
|
return m_rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem* /**option*/, QWidget* /*widget*/)
|
|
|
|
{
|
|
|
|
painter->save();
|
2016-02-17 10:19:50 +03:00
|
|
|
painter->setOpacity(Const::BAND_MARKER_OPACITY);
|
2016-02-17 10:11:00 +03:00
|
|
|
painter->fillRect(boundingRect(),m_color);
|
|
|
|
painter->setOpacity(1);
|
|
|
|
painter->setRenderHint(QPainter::Antialiasing);
|
|
|
|
qreal size = (boundingRect().width()<boundingRect().height()) ? boundingRect().width() : boundingRect().height();
|
|
|
|
QRectF r = QRectF(0,0,size,size);
|
|
|
|
painter->setBrush(Qt::white);
|
|
|
|
painter->setPen(Qt::white);
|
|
|
|
painter->drawEllipse(r.adjusted(5,5,-5,-5));
|
|
|
|
if (m_band->isSelected()){
|
2016-02-17 10:39:17 +03:00
|
|
|
painter->setBrush(LimeReport::Const::SELECTION_COLOR);
|
2016-02-17 10:11:00 +03:00
|
|
|
painter->drawEllipse(r.adjusted(7,7,-7,-7));
|
|
|
|
}
|
|
|
|
painter->restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandMarker::setHeight(qreal height)
|
|
|
|
{
|
|
|
|
if (m_rect.height()!=height){
|
|
|
|
prepareGeometryChange();
|
|
|
|
m_rect.setHeight(height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandMarker::setWidth(qreal width)
|
|
|
|
{
|
|
|
|
if (m_rect.width()!=width){
|
|
|
|
prepareGeometryChange();
|
|
|
|
m_rect.setWidth(width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandMarker::setColor(QColor color)
|
|
|
|
{
|
|
|
|
if (m_color!=color){
|
|
|
|
m_color = color;
|
|
|
|
update(boundingRect());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|
|
|
{
|
|
|
|
if (event->button()==Qt::LeftButton) {
|
|
|
|
if (!(event->modifiers() & Qt::ControlModifier))
|
|
|
|
m_band->scene()->clearSelection();
|
|
|
|
m_band->setSelected(true);
|
|
|
|
update(0,0,boundingRect().width(),boundingRect().width());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, QObject* owner, QGraphicsItem *parent) :
|
2017-04-05 00:58:04 +03:00
|
|
|
ItemsContainerDesignInft(xmlTypeName, owner,parent),
|
2016-02-17 10:11:00 +03:00
|
|
|
m_bandType(bandType),
|
|
|
|
m_bandIndex(static_cast<int>(bandType)),
|
|
|
|
m_dataSourceName(""),
|
|
|
|
m_autoHeight(true),
|
|
|
|
m_keepBottomSpace(false),
|
|
|
|
m_parentBand(0),
|
|
|
|
m_parentBandName(""),
|
|
|
|
m_bandMarker(0),
|
|
|
|
m_tryToKeepTogether(false),
|
|
|
|
m_splitable(false),
|
|
|
|
m_keepFooterTogether(false),
|
|
|
|
m_maxScalePercent(0),
|
|
|
|
m_sliceLastRow(false),
|
2016-02-17 10:28:27 +03:00
|
|
|
m_printIfEmpty(false),
|
|
|
|
m_columnsCount(1),
|
|
|
|
m_columnIndex(0),
|
2016-02-17 10:39:17 +03:00
|
|
|
m_columnsFillDirection(Horizontal),
|
|
|
|
m_reprintOnEachPage(false),
|
2016-05-31 15:07:57 +03:00
|
|
|
m_startNewPage(false),
|
2016-07-21 00:14:39 +03:00
|
|
|
m_startFromNewPage(false),
|
2016-07-27 00:41:24 +03:00
|
|
|
m_printAlways(false),
|
2017-08-14 22:39:38 +03:00
|
|
|
m_repeatOnEachRow(false),
|
|
|
|
m_bottomSpace()
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2016-09-16 02:02:32 +03:00
|
|
|
setPossibleResizeDirectionFlags(ResizeBottom);
|
|
|
|
setPossibleMoveFlags(TopBotom);
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
BaseDesignIntf* parentItem = dynamic_cast<BaseDesignIntf*>(parent);
|
|
|
|
if (parentItem) setWidth(parentItem->width());
|
|
|
|
}
|
|
|
|
|
|
|
|
setHeight(100);
|
|
|
|
setFixedPos(true);
|
|
|
|
setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
|
|
|
m_bandMarker = new BandMarker(this);
|
|
|
|
m_bandMarker->setColor(Qt::magenta);
|
|
|
|
m_bandMarker->setHeight(height());
|
|
|
|
m_bandMarker->setPos(pos().x()-m_bandMarker->width(),pos().y());
|
|
|
|
if (scene()) scene()->addItem(m_bandMarker);
|
2016-02-17 10:19:50 +03:00
|
|
|
|
|
|
|
m_bandNameLabel = new BandNameLabel(this);
|
|
|
|
m_bandNameLabel->setVisible(false);
|
|
|
|
if (scene()) scene()->addItem(m_bandNameLabel);
|
2016-10-18 13:58:26 +03:00
|
|
|
m_alternateBackgroundColor = backgroundColor();
|
2017-06-30 13:21:16 +03:00
|
|
|
connect(this, SIGNAL(propertyObjectNameChanged(QString, QString)),
|
|
|
|
this, SLOT(slotPropertyObjectNameChanged(const QString&,const QString&)));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BandDesignIntf::~BandDesignIntf()
|
|
|
|
{
|
|
|
|
// if (itemMode()&DesignMode){
|
|
|
|
// foreach(BandDesignIntf* band,childBands()) {
|
|
|
|
// removeChildBand(band);
|
|
|
|
// delete band;
|
|
|
|
// }
|
|
|
|
// }
|
2016-02-18 21:09:00 +03:00
|
|
|
delete m_bandMarker;
|
|
|
|
delete m_bandNameLabel;
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2017-06-29 02:32:42 +03:00
|
|
|
int extractItemIndex(const BaseDesignIntf* item){
|
|
|
|
QString objectName = extractClassName(item->metaObject()->className());
|
|
|
|
QString value = item->objectName().right(item->objectName().size() - objectName.size());
|
|
|
|
return value.toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString BandDesignIntf::translateBandName(const BaseDesignIntf* item) const{
|
2017-06-30 13:21:16 +03:00
|
|
|
QString defaultBandName = extractClassName(item->metaObject()->className()).toLatin1()+QString::number(extractItemIndex(item));
|
|
|
|
if (item->objectName().compare(defaultBandName) == 0){
|
|
|
|
return tr(extractClassName(item->metaObject()->className()).toLatin1())+QString::number(extractItemIndex(item));
|
|
|
|
} else {
|
|
|
|
return item->objectName();
|
|
|
|
}
|
2017-06-29 02:32:42 +03:00
|
|
|
}
|
|
|
|
|
2016-12-21 22:09:10 +03:00
|
|
|
void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2016-12-21 22:09:10 +03:00
|
|
|
|
|
|
|
if ( !(backgroundColor() == Qt::white && backgroundBrushStyle() == SolidPattern) ) {
|
|
|
|
QBrush brush(backgroundColor(), static_cast<Qt::BrushStyle>(backgroundBrushStyle()));
|
|
|
|
brush.setTransform(painter->worldTransform().inverted());
|
|
|
|
painter->fillRect(rect(), brush);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2016-12-21 22:09:10 +03:00
|
|
|
|
|
|
|
if (itemMode() & DesignMode){
|
|
|
|
painter->save();
|
2017-06-29 02:32:42 +03:00
|
|
|
QString bandText = bandTitle();
|
2016-12-21 22:09:10 +03:00
|
|
|
QFont font("Arial", 7 * Const::fontFACTOR, -1, true);
|
2016-02-17 10:11:00 +03:00
|
|
|
QFontMetrics fontMetrics(font);
|
|
|
|
|
|
|
|
QVector<QRectF> bandNameRects;
|
|
|
|
bandNameRects.push_back(QRectF(8,8,fontMetrics.width(" "+bandText+" "),fontMetrics.height()));
|
|
|
|
//bandNameRects.push_back(QRectF(width()-fontMetrics.width(" "+bandText+" "),2,fontMetrics.width(" "+bandText+" "),fontMetrics.height()));
|
|
|
|
//bandNameRects.push_back(QRectF(2,height()-fontMetrics.height(),fontMetrics.width(" "+bandText+" "),fontMetrics.height()));
|
|
|
|
//bandNameRects.push_back(QRectF(width()-fontMetrics.width(" "+bandText+" "),height()-fontMetrics.height(),fontMetrics.width(" "+bandText+" "),fontMetrics.height()));
|
|
|
|
//if (bandNameRects[0].intersects(bandNameRects[2])) bandNameRects.remove(2,2);
|
|
|
|
//if (isSelected()) ppainter->setPen(QColor(167,244,167));
|
|
|
|
// else ppainter->setPen(QColor(220,220,220));
|
|
|
|
|
2016-12-21 22:09:10 +03:00
|
|
|
painter->setFont(font);
|
2016-02-17 10:11:00 +03:00
|
|
|
for (int i=0;i<bandNameRects.count();i++){
|
|
|
|
QRectF labelRect = bandNameRects[i].adjusted(-2,-2,2,2);
|
2016-02-17 10:19:50 +03:00
|
|
|
if ((labelRect.height())<height() && (childBaseItems().isEmpty()) && !isSelected()){
|
2016-12-21 22:09:10 +03:00
|
|
|
painter->setRenderHint(QPainter::Antialiasing);
|
|
|
|
painter->setBrush(bandColor());
|
|
|
|
painter->setOpacity(Const::BAND_NAME_AREA_OPACITY);
|
|
|
|
painter->drawRoundedRect(labelRect,8,8);
|
|
|
|
painter->setOpacity(Const::BAND_NAME_TEXT_OPACITY);
|
|
|
|
painter->setPen(Qt::black);
|
|
|
|
painter->drawText(bandNameRects[i],Qt::AlignHCenter,bandText);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
2016-12-21 22:09:10 +03:00
|
|
|
painter->restore();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2016-12-21 22:09:10 +03:00
|
|
|
BaseDesignIntf::paint(painter,option,widget);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2017-06-29 02:32:42 +03:00
|
|
|
void BandDesignIntf::translateBandsName()
|
|
|
|
{
|
|
|
|
tr("DataBand");
|
|
|
|
tr("DataHeaderBand");
|
|
|
|
tr("DataFooterBand");
|
|
|
|
tr("ReportHeader");
|
|
|
|
tr("ReportFooter");
|
|
|
|
tr("PageHeader");
|
|
|
|
tr("PageFooter");
|
|
|
|
tr("SubDetailBand");
|
|
|
|
tr("SubDetailHeaderBand");
|
|
|
|
tr("SubDetailFooterBand");
|
|
|
|
tr("GroupBandHeader");
|
|
|
|
tr("GroupBandFooter");
|
|
|
|
tr("TearOffBand");
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
BandDesignIntf::BandsType BandDesignIntf::bandType() const
|
|
|
|
{
|
|
|
|
return m_bandType;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString BandDesignIntf::bandTitle() const
|
|
|
|
{
|
2017-06-29 02:32:42 +03:00
|
|
|
QString result = translateBandName(this);
|
|
|
|
if (parentBand()) result +=tr(" connected to ") + translateBandName(parentBand());
|
2016-02-17 10:19:50 +03:00
|
|
|
return result;
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
QIcon BandDesignIntf::bandIcon() const
|
|
|
|
{
|
|
|
|
return QIcon();
|
|
|
|
}
|
|
|
|
|
|
|
|
int BandDesignIntf::bandIndex() const
|
|
|
|
{
|
|
|
|
return m_bandIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setBandIndex(int value)
|
|
|
|
{
|
|
|
|
m_bandIndex=value;
|
|
|
|
}
|
|
|
|
|
2017-06-29 00:55:16 +03:00
|
|
|
void BandDesignIntf::changeBandIndex(int value, bool firstTime)
|
2016-06-24 17:36:25 +03:00
|
|
|
{
|
2017-06-29 00:55:16 +03:00
|
|
|
int indexOffset;
|
|
|
|
|
|
|
|
if (firstTime && bandHeader())
|
|
|
|
value += 1;
|
|
|
|
|
|
|
|
indexOffset = value - m_bandIndex;
|
|
|
|
|
2016-06-24 17:36:25 +03:00
|
|
|
foreach(BandDesignIntf* band, childBands()){
|
|
|
|
int newIndex = band->bandIndex()+indexOffset;
|
|
|
|
band->changeBandIndex(newIndex);
|
|
|
|
}
|
|
|
|
setBandIndex(value);
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
bool BandDesignIntf::isUnique() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString BandDesignIntf::datasourceName(){
|
|
|
|
return m_dataSourceName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setDataSourceName(const QString &datasource){
|
|
|
|
m_dataSourceName=datasource;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::addChildBand(BandDesignIntf *band)
|
|
|
|
{
|
|
|
|
m_childBands.append(band);
|
|
|
|
connect(band,SIGNAL(destroyed(QObject*)),this,SLOT(childBandDeleted(QObject*)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::removeChildBand(BandDesignIntf *band)
|
|
|
|
{
|
|
|
|
m_childBands.removeAt(m_childBands.indexOf(band));
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setParentBand(BandDesignIntf *band)
|
|
|
|
{
|
|
|
|
m_parentBand=band;
|
|
|
|
if (band){
|
|
|
|
if (parentBandName().compare(band->objectName(),Qt::CaseInsensitive)!=0)
|
|
|
|
setParentBandName(band->objectName());
|
|
|
|
band->addChildBand(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setParentBandName(const QString &parentBandName)
|
|
|
|
{
|
|
|
|
m_parentBandName=parentBandName;
|
|
|
|
if (itemMode()&DesignMode && !m_parentBandName.isEmpty()){
|
2016-09-09 20:49:46 +03:00
|
|
|
if ((parentBand() == 0 )||(parentBand()->objectName()!= parentBandName))
|
|
|
|
setParentBand(findParentBand());
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-09 20:49:46 +03:00
|
|
|
QString BandDesignIntf::parentBandName(){
|
|
|
|
if (!m_parentBand) return m_parentBandName;
|
|
|
|
else return m_parentBand->objectName();
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
bool BandDesignIntf::isConnectedToBand(BandDesignIntf::BandsType bandType) const
|
|
|
|
{
|
|
|
|
foreach(BandDesignIntf* band,childBands()) if (band->bandType()==bandType) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-29 00:55:16 +03:00
|
|
|
int BandDesignIntf::maxChildIndex(BandDesignIntf::BandsType bandType) const{
|
|
|
|
int curIndex = bandIndex();
|
|
|
|
foreach(BandDesignIntf* childBand, childBands()){
|
|
|
|
if ( (childBand->bandIndex() > bandIndex()) && (childBand->bandType() < bandType) ){
|
|
|
|
curIndex = std::max(curIndex,childBand->maxChildIndex());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return curIndex;
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:18:19 +03:00
|
|
|
int BandDesignIntf::maxChildIndex(QSet<BandDesignIntf::BandsType> ignoredBands) const{
|
|
|
|
int curIndex = bandIndex();
|
|
|
|
foreach(BandDesignIntf* childBand, childBands()){
|
2016-02-17 10:39:17 +03:00
|
|
|
if (!ignoredBands.contains(childBand->bandType()) && childBand->bandIndex()>bandIndex()){
|
2016-02-17 10:18:19 +03:00
|
|
|
curIndex = std::max(curIndex,childBand->maxChildIndex(ignoredBands));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
2016-02-17 10:18:19 +03:00
|
|
|
return curIndex;
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2016-02-17 10:18:19 +03:00
|
|
|
int BandDesignIntf::minChildIndex(BandDesignIntf::BandsType bandType){
|
|
|
|
int curIndex = bandIndex();
|
|
|
|
foreach(BandDesignIntf* childBand, childBands()){
|
|
|
|
if (curIndex>childBand->bandIndex() && (childBand->bandType()>bandType)){
|
|
|
|
curIndex = childBand->bandIndex();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
2016-02-17 10:18:19 +03:00
|
|
|
return curIndex;
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
QList<BandDesignIntf *> BandDesignIntf::childrenByType(BandDesignIntf::BandsType type)
|
|
|
|
{
|
|
|
|
QList<BandDesignIntf*> resList;
|
|
|
|
foreach(BandDesignIntf* item,childBands()){
|
|
|
|
if (item->bandType()==type) resList<<item;
|
|
|
|
}
|
|
|
|
qSort(resList.begin(),resList.end(),bandIndexLessThen);
|
|
|
|
return resList;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BandDesignIntf::canBeSplitted(int height) const
|
|
|
|
{
|
|
|
|
if (isSplittable()){
|
|
|
|
foreach(QGraphicsItem* qgItem,childItems()){
|
|
|
|
BaseDesignIntf* item=dynamic_cast<BaseDesignIntf*>(qgItem);
|
|
|
|
if (item)
|
|
|
|
if ((item->minHeight()>height) && (item->minHeight()>(this->height()-height))) return false;
|
|
|
|
}
|
|
|
|
}
|
2016-02-17 10:19:50 +03:00
|
|
|
return isSplittable();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BandDesignIntf::isEmpty() const
|
|
|
|
{
|
2016-12-20 01:33:58 +03:00
|
|
|
if (!isVisible()) return true;
|
2016-02-17 10:11:00 +03:00
|
|
|
foreach(QGraphicsItem* qgItem,childItems()){
|
|
|
|
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(qgItem);
|
|
|
|
if ((item)&&(!item->isEmpty())) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BandDesignIntf::isNeedRender() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setTryToKeepTogether(bool value)
|
|
|
|
{
|
|
|
|
m_tryToKeepTogether=value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BandDesignIntf::tryToKeepTogether()
|
|
|
|
{
|
|
|
|
return m_tryToKeepTogether;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::checkEmptyTable(){
|
|
|
|
bool isEmpty = true;
|
|
|
|
bool allItemsIsText = true;
|
|
|
|
foreach (QGraphicsItem* qgItem, childItems()) {
|
|
|
|
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(qgItem);
|
|
|
|
if (item && !item->isEmpty()) isEmpty = false;
|
|
|
|
if (!item) allItemsIsText = false;
|
|
|
|
}
|
|
|
|
if (isEmpty && allItemsIsText){
|
|
|
|
foreach (QGraphicsItem* qgItem, childItems()) {
|
|
|
|
ContentItemDesignIntf* item = dynamic_cast<ContentItemDesignIntf*>(qgItem);
|
|
|
|
item->setHeight(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
void BandDesignIntf::setColumnsCount(int value)
|
|
|
|
{
|
|
|
|
if (m_columnsCount!=value && value>0){
|
|
|
|
qreal oldValue = m_columnsCount;
|
|
|
|
qreal fullWidth = m_columnsCount * width();
|
|
|
|
m_columnsCount = value;
|
|
|
|
if (!isLoading()){
|
|
|
|
setWidth(fullWidth/m_columnsCount);
|
|
|
|
notify("columnsCount",oldValue,value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setColumnsFillDirection(BandDesignIntf::BandColumnsLayoutType value)
|
|
|
|
{
|
|
|
|
if (m_columnsFillDirection!=value){
|
|
|
|
qreal oldValue = m_columnsFillDirection;
|
|
|
|
m_columnsFillDirection = value;
|
|
|
|
if (!isLoading())
|
|
|
|
notify("columnsFillDirection",oldValue,value);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-07-25 14:07:42 +03:00
|
|
|
void BandDesignIntf::moveItemsDown(qreal startPos, qreal offset){
|
|
|
|
foreach (QGraphicsItem* item, childItems()){
|
|
|
|
if (item->pos().y()>=startPos)
|
|
|
|
item->setPos(item->x(),item->y()+offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-24 07:13:43 +03:00
|
|
|
void BandDesignIntf::preparePopUpMenu(QMenu &menu)
|
|
|
|
{
|
|
|
|
foreach (QAction* action, menu.actions()) {
|
|
|
|
if (action->text().compare(tr("Bring to top")) == 0 ||
|
|
|
|
action->text().compare(tr("Send to back")) == 0 )
|
|
|
|
action->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.addSeparator();
|
|
|
|
QAction* autoHeightAction = menu.addAction(tr("Auto height"));
|
|
|
|
autoHeightAction->setCheckable(true);
|
|
|
|
autoHeightAction->setChecked(autoHeight());
|
|
|
|
|
|
|
|
QAction* autoSplittableAction = menu.addAction(tr("Splittable"));
|
|
|
|
autoSplittableAction->setCheckable(true);
|
|
|
|
autoSplittableAction->setChecked(isSplittable());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::processPopUpAction(QAction *action)
|
|
|
|
{
|
|
|
|
if (action->text().compare(tr("Auto height")) == 0){
|
|
|
|
setProperty("autoHeight",action->isChecked());
|
|
|
|
}
|
|
|
|
if (action->text().compare(tr("Splittable")) == 0){
|
|
|
|
setProperty("splittable",action->isChecked());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent)
|
|
|
|
{
|
|
|
|
int maxBottom = 0;
|
|
|
|
BandDesignIntf* upperPart = dynamic_cast<BandDesignIntf*>(createSameTypeItem(owner,parent));
|
2017-08-14 22:39:38 +03:00
|
|
|
upperPart->m_bottomSpace = this->bottomSpace();
|
|
|
|
BaseDesignIntf* upperItem = 0;
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
upperPart->initFromItem(this);
|
|
|
|
|
|
|
|
foreach(QGraphicsItem* qgItem,childItems()){
|
|
|
|
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(qgItem);
|
|
|
|
if (item){
|
|
|
|
if (item->geometry().bottom()<=height){
|
|
|
|
upperItem = item->cloneItem(item->itemMode(),upperPart,upperPart);
|
|
|
|
if (maxBottom<upperItem->geometry().bottom()) maxBottom = upperItem->geometry().bottom();
|
|
|
|
}
|
|
|
|
else if ((item->geometry().top()<height) && (item->geometry().bottom()>height)){
|
|
|
|
int sliceHeight = height-item->geometry().top();
|
|
|
|
if (!item->isSplittable()){
|
|
|
|
if (sliceHeight>(this->height()-sliceHeight)){
|
|
|
|
upperItem = item->cloneItem(item->itemMode(),upperPart,upperPart);
|
|
|
|
upperItem->setHeight(height);
|
|
|
|
} else {
|
|
|
|
item->cloneEmpty(sliceHeight,upperPart,upperPart); //for table
|
2016-07-25 14:07:42 +03:00
|
|
|
//qgItem->setPos(item->pos().x(),item->pos().y()+((height+1)-item->geometry().top()));
|
|
|
|
moveItemsDown(item->pos().y(),(height+1)-item->geometry().top());
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
} else if (item->canBeSplitted(sliceHeight)){
|
|
|
|
upperItem = item->cloneUpperPart(sliceHeight,upperPart,upperPart);
|
|
|
|
if (maxBottom<upperItem->geometry().bottom()) maxBottom = upperItem->geometry().bottom();
|
2016-08-08 15:50:44 +03:00
|
|
|
m_slicedItems.insert(upperItem->objectName(),upperItem);
|
2016-02-17 10:11:00 +03:00
|
|
|
} else {
|
|
|
|
item->cloneEmpty(sliceHeight,upperPart,upperPart); //for table
|
2016-08-08 15:50:44 +03:00
|
|
|
moveItemsDown(item->pos().y(),(height+1)-item->geometry().top());
|
|
|
|
//qgItem->setPos(item->pos().x(),item->pos().y()+((height+1)-item->geometry().top()));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
upperPart->setHeight(height);
|
|
|
|
height = maxBottom;
|
|
|
|
return upperPart;
|
|
|
|
}
|
|
|
|
|
2016-08-08 15:50:44 +03:00
|
|
|
bool itemLessThen(QGraphicsItem* i1, QGraphicsItem* i2){
|
|
|
|
return i1->pos().y()<i2->pos().y();
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
BaseDesignIntf *BandDesignIntf::cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent)
|
|
|
|
{
|
|
|
|
BandDesignIntf* bottomPart = dynamic_cast<BandDesignIntf*>(createSameTypeItem(owner,parent));
|
2017-08-14 22:39:38 +03:00
|
|
|
bottomPart->m_bottomSpace = this->bottomSpace();
|
2016-02-17 10:11:00 +03:00
|
|
|
bottomPart->initFromItem(this);
|
|
|
|
|
2016-08-08 15:50:44 +03:00
|
|
|
QList<QGraphicsItem*> bandItems;
|
|
|
|
bandItems = childItems();
|
|
|
|
std::sort(bandItems.begin(),bandItems.end(), itemLessThen);
|
|
|
|
|
|
|
|
foreach(QGraphicsItem* qgItem, bandItems){
|
2016-02-17 10:11:00 +03:00
|
|
|
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(qgItem);
|
|
|
|
|
|
|
|
if (item){
|
|
|
|
if (item->geometry().top()>height){
|
|
|
|
BaseDesignIntf* tmpItem = item->cloneItem(item->itemMode(),bottomPart,bottomPart);
|
|
|
|
tmpItem->setPos(tmpItem->pos().x(),tmpItem->pos().y()-height);
|
|
|
|
}
|
|
|
|
else if ((item->geometry().top()<height) && (item->geometry().bottom()>height)){
|
|
|
|
int sliceHeight = height-item->geometry().top();
|
2017-08-14 22:39:38 +03:00
|
|
|
if (item->isSplittable() && item->canBeSplitted(sliceHeight)) {
|
2016-02-17 10:11:00 +03:00
|
|
|
BaseDesignIntf* tmpItem=item->cloneBottomPart(sliceHeight,bottomPart,bottomPart);
|
|
|
|
tmpItem->setPos(tmpItem->pos().x(),0);
|
|
|
|
if (tmpItem->pos().y()<0) tmpItem->setPos(tmpItem->pos().x(),0);
|
2017-08-14 22:39:38 +03:00
|
|
|
BaseDesignIntf* slicedItem = m_slicedItems.value(tmpItem->objectName());
|
|
|
|
if (slicedItem){
|
|
|
|
qreal sizeOffset = (slicedItem->height()+tmpItem->height()) - item->height();
|
|
|
|
qreal bottomOffset = (height - slicedItem->pos().y())-m_slicedItems.value(tmpItem->objectName())->height();
|
|
|
|
moveItemsDown(item->pos().y()+item->height(), sizeOffset + bottomOffset);
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
} else {
|
|
|
|
if ((item->geometry().bottom()-height)>height){
|
|
|
|
BaseDesignIntf* tmpItem = item->cloneItem(item->itemMode(),bottomPart,bottomPart);
|
|
|
|
tmpItem->setPos(tmpItem->pos().x(),0);
|
|
|
|
tmpItem->setHeight((this->height()-height));
|
|
|
|
} else {
|
|
|
|
BaseDesignIntf* tmpItem = item->cloneEmpty((this->height()-height),bottomPart,bottomPart);
|
|
|
|
if (tmpItem)
|
|
|
|
tmpItem->setPos(tmpItem->pos().x(),0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bottomPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::parentObjectLoadFinished()
|
|
|
|
{
|
|
|
|
if (!parentBandName().isEmpty())
|
|
|
|
setParentBand(findParentBand());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::objectLoadFinished()
|
|
|
|
{
|
|
|
|
m_bandMarker->setHeight(height());
|
|
|
|
BaseDesignIntf::objectLoadFinished();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::emitBandRendered(BandDesignIntf* band)
|
|
|
|
{
|
|
|
|
emit bandRendered(band);
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
void BandDesignIntf::setSplittable(bool value){
|
|
|
|
if (m_splitable!=value){
|
|
|
|
bool oldValue = m_splitable;
|
|
|
|
m_splitable = value;
|
|
|
|
if (!isLoading())
|
|
|
|
notify("splittable",oldValue,value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
bool bandIndexLessThen(const BandDesignIntf* b1, const BandDesignIntf* b2)
|
|
|
|
{
|
|
|
|
return b1->bandIndex()<b2->bandIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::trimToMaxHeight(int maxHeight)
|
|
|
|
{
|
|
|
|
foreach(BaseDesignIntf* item,childBaseItems()){
|
|
|
|
if (item->height()>maxHeight) item->setHeight(maxHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:19:50 +03:00
|
|
|
void BandDesignIntf::setBandTypeText(const QString &value){
|
|
|
|
m_bandTypeText=value;
|
2017-06-30 13:21:16 +03:00
|
|
|
m_bandNameLabel->updateLabel(bandTitle());
|
2016-02-17 10:19:50 +03:00
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
QSet<BandDesignIntf::BandsType> BandDesignIntf::groupBands()
|
|
|
|
{
|
|
|
|
QSet<BandDesignIntf::BandsType> result;
|
|
|
|
result<<GroupHeader<<GroupFooter;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
QSet<BandDesignIntf::BandsType> BandDesignIntf::subdetailBands()
|
|
|
|
{
|
|
|
|
QSet<BandDesignIntf::BandsType> result;
|
|
|
|
result<<SubDetailBand<<SubDetailHeader<<SubDetailFooter;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
BandDesignIntf* BandDesignIntf::findParentBand()
|
|
|
|
{
|
|
|
|
if (parent()&&(!dynamic_cast<BaseDesignIntf*>(parent())->isLoading())){
|
|
|
|
foreach(QObject* item, parent()->children()){
|
|
|
|
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
|
|
|
|
if(band&&(band->objectName().compare(parentBandName(),Qt::CaseInsensitive)==0))
|
|
|
|
return band;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::geometryChangedEvent(QRectF, QRectF )
|
|
|
|
{
|
|
|
|
if (((itemMode()&DesignMode) || (itemMode()&EditMode))&&parentItem()){
|
|
|
|
QPointF sp = parentItem()->mapToScene(pos());
|
|
|
|
if (m_bandMarker){
|
|
|
|
m_bandMarker->setPos((sp.x()-m_bandMarker->boundingRect().width()),sp.y());
|
|
|
|
m_bandMarker->setHeight(rect().height());
|
|
|
|
}
|
|
|
|
}
|
2016-04-21 12:09:28 +03:00
|
|
|
foreach (BaseDesignIntf* item, childBaseItems()) {
|
|
|
|
if (item->itemAlign()!=DesignedItemAlign){
|
|
|
|
item->updateItemAlign();
|
|
|
|
}
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
QVariant BandDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
|
|
|
{
|
|
|
|
if ((change==ItemPositionChange)&&((itemMode()&DesignMode)||(itemMode()&EditMode))){
|
|
|
|
if (m_bandMarker){
|
|
|
|
m_bandMarker->setPos((value.toPointF().x()-m_bandMarker->boundingRect().width()),
|
|
|
|
value.toPointF().y());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (change==ItemSelectedChange){
|
|
|
|
if (m_bandMarker){
|
|
|
|
m_bandMarker->update(0,0,
|
|
|
|
m_bandMarker->boundingRect().width(),
|
|
|
|
m_bandMarker->boundingRect().width());
|
2017-06-30 13:21:16 +03:00
|
|
|
m_bandNameLabel->updateLabel(bandTitle());
|
2016-02-17 10:19:50 +03:00
|
|
|
m_bandNameLabel->setVisible(value.toBool());
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
2016-02-17 10:39:17 +03:00
|
|
|
if (change==ItemChildAddedChange || change==ItemChildRemovedChange){
|
|
|
|
update(rect());
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
return BaseDesignIntf::itemChange(change,value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::initMode(ItemMode mode)
|
|
|
|
{
|
|
|
|
BaseDesignIntf::initMode(mode);
|
|
|
|
if ((mode==PreviewMode)||(mode==PrintMode)){
|
|
|
|
m_bandMarker->setVisible(false);
|
2016-06-10 18:05:18 +03:00
|
|
|
} else {
|
|
|
|
if (!m_bandMarker->scene() && this->scene()){
|
|
|
|
this->scene()->addItem(m_bandMarker);
|
|
|
|
m_bandMarker->setParentItem(this->parentItem());
|
|
|
|
m_bandMarker->setHeight(this->height());
|
|
|
|
}
|
|
|
|
m_bandMarker->setVisible(true);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor BandDesignIntf::bandColor() const
|
|
|
|
{
|
|
|
|
return Qt::darkBlue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setMarkerColor(QColor color)
|
|
|
|
{
|
|
|
|
if (m_bandMarker) m_bandMarker->setColor(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::childBandDeleted(QObject *band)
|
|
|
|
{
|
|
|
|
m_childBands.removeAt(m_childBands.indexOf(reinterpret_cast<BandDesignIntf*>(band)));
|
|
|
|
}
|
2016-02-17 10:18:19 +03:00
|
|
|
|
2016-10-18 13:58:26 +03:00
|
|
|
QColor BandDesignIntf::alternateBackgroundColor() const
|
|
|
|
{
|
2016-11-01 22:31:48 +03:00
|
|
|
if (metaObject()->indexOfProperty("alternateBackgroundColor")!=-1)
|
|
|
|
return m_alternateBackgroundColor;
|
|
|
|
else
|
|
|
|
return backgroundColor();
|
2016-10-18 13:58:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setAlternateBackgroundColor(const QColor &alternateBackgroundColor)
|
|
|
|
{
|
|
|
|
m_alternateBackgroundColor = alternateBackgroundColor;
|
|
|
|
}
|
|
|
|
|
2017-08-14 22:39:38 +03:00
|
|
|
qreal BandDesignIntf::bottomSpace() const
|
|
|
|
{
|
|
|
|
return m_bottomSpace.isValid() ? m_bottomSpace.value() : height()-findMaxBottom();
|
|
|
|
}
|
|
|
|
|
2017-06-30 13:21:16 +03:00
|
|
|
void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QString& newName)
|
|
|
|
{
|
|
|
|
update();
|
|
|
|
if (m_bandNameLabel)
|
|
|
|
m_bandNameLabel->updateLabel(newName);
|
|
|
|
}
|
|
|
|
|
2016-07-27 00:41:24 +03:00
|
|
|
bool BandDesignIntf::repeatOnEachRow() const
|
|
|
|
{
|
|
|
|
return m_repeatOnEachRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setRepeatOnEachRow(bool repeatOnEachRow)
|
|
|
|
{
|
|
|
|
m_repeatOnEachRow = repeatOnEachRow;
|
|
|
|
}
|
|
|
|
|
2016-07-21 00:14:39 +03:00
|
|
|
bool BandDesignIntf::printAlways() const
|
|
|
|
{
|
|
|
|
return m_printAlways;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setPrintAlways(bool printAlways)
|
|
|
|
{
|
|
|
|
m_printAlways = printAlways;
|
|
|
|
}
|
|
|
|
|
2016-05-31 15:07:57 +03:00
|
|
|
bool BandDesignIntf::startFromNewPage() const
|
|
|
|
{
|
|
|
|
return m_startFromNewPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setStartFromNewPage(bool startWithNewPage)
|
|
|
|
{
|
|
|
|
m_startFromNewPage = startWithNewPage;
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:39:17 +03:00
|
|
|
bool BandDesignIntf::startNewPage() const
|
|
|
|
{
|
|
|
|
return m_startNewPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setStartNewPage(bool startNewPage)
|
|
|
|
{
|
|
|
|
m_startNewPage = startNewPage;
|
|
|
|
}
|
|
|
|
|
2017-02-24 07:13:43 +03:00
|
|
|
void BandDesignIntf::setAutoHeight(bool value){
|
|
|
|
if (m_autoHeight != value){
|
|
|
|
m_autoHeight=value;
|
|
|
|
if (!isLoading())
|
|
|
|
notify("autoHeight",!value,value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:39:17 +03:00
|
|
|
bool BandDesignIntf::reprintOnEachPage() const
|
|
|
|
{
|
|
|
|
return m_reprintOnEachPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setReprintOnEachPage(bool reprintOnEachPage)
|
|
|
|
{
|
|
|
|
m_reprintOnEachPage = reprintOnEachPage;
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
int BandDesignIntf::columnIndex() const
|
|
|
|
{
|
|
|
|
return m_columnIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setColumnIndex(int columnIndex)
|
|
|
|
{
|
|
|
|
m_columnIndex = columnIndex;
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
bool BandDesignIntf::printIfEmpty() const
|
|
|
|
{
|
|
|
|
return m_printIfEmpty;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setPrintIfEmpty(bool printIfEmpty)
|
|
|
|
{
|
|
|
|
m_printIfEmpty = printIfEmpty;
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:18:19 +03:00
|
|
|
BandDesignIntf *BandDesignIntf::bandHeader()
|
|
|
|
{
|
|
|
|
foreach (BandDesignIntf* band, childBands()) {
|
2016-02-17 10:39:17 +03:00
|
|
|
if (band->isHeader() && !band->isGroupHeader())
|
|
|
|
return band;
|
2016-02-17 10:18:19 +03:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BandDesignIntf *BandDesignIntf::bandFooter()
|
|
|
|
{
|
|
|
|
foreach (BandDesignIntf* band, childBands()) {
|
|
|
|
if (band->isFooter()) return band;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
bool BandDesignIntf::sliceLastRow() const
|
|
|
|
{
|
|
|
|
return m_sliceLastRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setSliceLastRow(bool sliceLastRow)
|
|
|
|
{
|
|
|
|
m_sliceLastRow = sliceLastRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
int BandDesignIntf::maxScalePercent() const
|
|
|
|
{
|
|
|
|
return m_maxScalePercent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandDesignIntf::setMaxScalePercent(int maxScalePercent)
|
|
|
|
{
|
|
|
|
m_maxScalePercent = maxScalePercent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BandDesignIntf::keepFooterTogether() const
|
|
|
|
{
|
|
|
|
return m_keepFooterTogether;
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
void BandDesignIntf::setKeepFooterTogether(bool value)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2016-02-17 10:28:27 +03:00
|
|
|
if (m_keepFooterTogether!=value){
|
|
|
|
bool oldValue = m_keepFooterTogether;
|
|
|
|
m_keepFooterTogether = value;
|
|
|
|
if (!isLoading())
|
|
|
|
notify("keepFooterTogether",oldValue,value);
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
|
|
|
qreal spaceBorder=0;
|
2017-08-14 22:39:38 +03:00
|
|
|
if (keepBottomSpaceOption()) spaceBorder = bottomSpace();
|
2016-04-20 19:59:33 +03:00
|
|
|
if (borderLines()!=0){
|
|
|
|
spaceBorder += borderLineSize();
|
|
|
|
}
|
2016-11-04 01:11:45 +03:00
|
|
|
restoreLinks();
|
2016-02-17 10:11:00 +03:00
|
|
|
snapshotItemsLayout();
|
2016-02-17 10:28:27 +03:00
|
|
|
arrangeSubItems(pass, dataManager);
|
2016-02-17 10:39:17 +03:00
|
|
|
if (autoHeight()){
|
|
|
|
//if keepBottomSpace()&& height()<findMaxBottom()
|
|
|
|
setHeight(findMaxBottom()+spaceBorder);
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
if ((maxHeight>0)&&(height()>maxHeight)){
|
|
|
|
trimToMaxHeight(maxHeight);
|
|
|
|
setHeight(maxHeight);
|
|
|
|
}
|
2016-02-17 10:28:27 +03:00
|
|
|
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2016-06-24 17:36:25 +03:00
|
|
|
void BandDesignIntf::updateBandNameLabel()
|
|
|
|
{
|
2017-06-30 13:21:16 +03:00
|
|
|
if (m_bandNameLabel) m_bandNameLabel->updateLabel(bandTitle());
|
2016-06-24 17:36:25 +03:00
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
QColor BandDesignIntf::selectionColor() const
|
|
|
|
{
|
|
|
|
return Qt::yellow;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataBandDesignIntf::DataBandDesignIntf(BandDesignIntf::BandsType bandType, QString xmlTypeName, QObject *owner, QGraphicsItem *parent)
|
|
|
|
:BandDesignIntf(bandType,xmlTypeName,owner,parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:19:50 +03:00
|
|
|
BandNameLabel::BandNameLabel(BandDesignIntf *band, QGraphicsItem *parent)
|
|
|
|
:QGraphicsItem(parent),m_rect(5,5,30,30),m_band(band)
|
|
|
|
{
|
|
|
|
setAcceptHoverEvents(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandNameLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
|
|
{
|
2016-06-24 17:36:25 +03:00
|
|
|
painter->save();
|
|
|
|
painter->setRenderHint(QPainter::Antialiasing);
|
2016-02-17 10:19:50 +03:00
|
|
|
painter->setFont(QFont("Arial",7*Const::fontFACTOR,-1,true));
|
|
|
|
painter->setOpacity(1);
|
|
|
|
QPen pen(Const::BAND_NAME_BORDER_COLOR);
|
2016-06-24 17:36:25 +03:00
|
|
|
//pen.setWidth(2);
|
2016-02-17 10:19:50 +03:00
|
|
|
painter->setBrush(Qt::yellow);
|
|
|
|
painter->setPen(pen);
|
2016-06-24 17:36:25 +03:00
|
|
|
painter->drawRoundedRect(m_rect,8,8);
|
2016-02-17 10:19:50 +03:00
|
|
|
painter->setOpacity(0.8);
|
|
|
|
painter->setPen(Qt::black);
|
|
|
|
painter->drawText(m_rect,Qt::AlignCenter,m_band->bandTitle());
|
2016-06-24 17:36:25 +03:00
|
|
|
painter->restore();
|
2016-02-17 10:19:50 +03:00
|
|
|
Q_UNUSED(option)
|
|
|
|
Q_UNUSED(widget)
|
|
|
|
}
|
|
|
|
|
|
|
|
QRectF BandNameLabel::boundingRect() const
|
|
|
|
{
|
|
|
|
return m_rect;
|
|
|
|
}
|
|
|
|
|
2017-06-30 13:21:16 +03:00
|
|
|
void BandNameLabel::updateLabel(const QString& bandName)
|
2016-02-17 10:19:50 +03:00
|
|
|
{
|
|
|
|
QFont font("Arial",7*Const::fontFACTOR,-1,true);
|
|
|
|
QFontMetrics fontMetrics(font);
|
|
|
|
prepareGeometryChange();
|
|
|
|
m_rect = QRectF(
|
|
|
|
m_band->pos().x()+10,
|
|
|
|
m_band->pos().y()-(fontMetrics.height()+10),
|
2017-06-30 13:21:16 +03:00
|
|
|
fontMetrics.width(bandName)+20,fontMetrics.height()+10
|
2016-02-17 10:19:50 +03:00
|
|
|
);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BandNameLabel::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|
|
|
{
|
|
|
|
setVisible(false);
|
|
|
|
Q_UNUSED(event)
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|