mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-25 00:54:39 +03:00
Fix: #37 Add possibility to move data bands when having many
Fix: #37 Add possibility to move data bands when having many
This commit is contained in:
parent
6a507e5b61
commit
7311f84b0e
@ -245,6 +245,16 @@ void BandDesignIntf::setBandIndex(int value)
|
|||||||
m_bandIndex=value;
|
m_bandIndex=value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BandDesignIntf::changeBandIndex(int value)
|
||||||
|
{
|
||||||
|
int indexOffset = value - m_bandIndex;
|
||||||
|
foreach(BandDesignIntf* band, childBands()){
|
||||||
|
int newIndex = band->bandIndex()+indexOffset;
|
||||||
|
band->changeBandIndex(newIndex);
|
||||||
|
}
|
||||||
|
setBandIndex(value);
|
||||||
|
}
|
||||||
|
|
||||||
bool BandDesignIntf::isUnique() const
|
bool BandDesignIntf::isUnique() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -822,6 +832,11 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
|
|||||||
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BandDesignIntf::updateBandNameLabel()
|
||||||
|
{
|
||||||
|
if (m_bandNameLabel) m_bandNameLabel->updateLabel();
|
||||||
|
}
|
||||||
|
|
||||||
QColor BandDesignIntf::selectionColor() const
|
QColor BandDesignIntf::selectionColor() const
|
||||||
{
|
{
|
||||||
return Qt::yellow;
|
return Qt::yellow;
|
||||||
@ -840,16 +855,19 @@ BandNameLabel::BandNameLabel(BandDesignIntf *band, QGraphicsItem *parent)
|
|||||||
|
|
||||||
void BandNameLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void BandNameLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
|
painter->save();
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
painter->setFont(QFont("Arial",7*Const::fontFACTOR,-1,true));
|
painter->setFont(QFont("Arial",7*Const::fontFACTOR,-1,true));
|
||||||
painter->setOpacity(1);
|
painter->setOpacity(1);
|
||||||
QPen pen(Const::BAND_NAME_BORDER_COLOR);
|
QPen pen(Const::BAND_NAME_BORDER_COLOR);
|
||||||
pen.setWidth(2);
|
//pen.setWidth(2);
|
||||||
painter->setBrush(Qt::yellow);
|
painter->setBrush(Qt::yellow);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
painter->drawRect(m_rect);
|
painter->drawRoundedRect(m_rect,8,8);
|
||||||
painter->setOpacity(0.8);
|
painter->setOpacity(0.8);
|
||||||
painter->setPen(Qt::black);
|
painter->setPen(Qt::black);
|
||||||
painter->drawText(m_rect,Qt::AlignCenter,m_band->bandTitle());
|
painter->drawText(m_rect,Qt::AlignCenter,m_band->bandTitle());
|
||||||
|
painter->restore();
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
}
|
}
|
||||||
|
@ -125,11 +125,12 @@ public:
|
|||||||
virtual QIcon bandIcon() const;
|
virtual QIcon bandIcon() const;
|
||||||
virtual bool isUnique() const;
|
virtual bool isUnique() const;
|
||||||
void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0);
|
void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0);
|
||||||
|
void updateBandNameLabel();
|
||||||
|
|
||||||
virtual QColor selectionColor() const;
|
virtual QColor selectionColor() const;
|
||||||
int bandIndex() const;
|
int bandIndex() const;
|
||||||
void setBandIndex(int value);
|
void setBandIndex(int value);
|
||||||
|
void changeBandIndex(int value);
|
||||||
void setBandType(BandsType value){m_bandType=value;}
|
void setBandType(BandsType value){m_bandType=value;}
|
||||||
|
|
||||||
QString datasourceName();
|
QString datasourceName();
|
||||||
@ -232,7 +233,6 @@ protected:
|
|||||||
void checkEmptyTable();
|
void checkEmptyTable();
|
||||||
void setColumnsCount(int value);
|
void setColumnsCount(int value);
|
||||||
void setColumnsFillDirection(BandColumnsLayoutType value);
|
void setColumnsFillDirection(BandColumnsLayoutType value);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void childBandDeleted(QObject* band);
|
void childBandDeleted(QObject* band);
|
||||||
private:
|
private:
|
||||||
|
@ -341,7 +341,6 @@ void PageItemDesignIntf::relocateBands()
|
|||||||
posByColumn[0]+=m_bands[0]->height()+bandSpace;
|
posByColumn[0]+=m_bands[0]->height()+bandSpace;
|
||||||
}
|
}
|
||||||
if(m_bands.count()>1){
|
if(m_bands.count()>1){
|
||||||
|
|
||||||
for(int i=0;i<(m_bands.count()-1);i++){
|
for(int i=0;i<(m_bands.count()-1);i++){
|
||||||
if ((m_bands[i+1]->bandType()!=BandDesignIntf::PageFooter) || (itemMode() & DesignMode)){
|
if ((m_bands[i+1]->bandType()!=BandDesignIntf::PageFooter) || (itemMode() & DesignMode)){
|
||||||
if (m_bands[i+1]->columnsCount()>1 &&
|
if (m_bands[i+1]->columnsCount()>1 &&
|
||||||
@ -360,7 +359,9 @@ void PageItemDesignIntf::relocateBands()
|
|||||||
posByColumn[m_bands[i+1]->columnIndex()] += m_bands[i+1]->height()+bandSpace;
|
posByColumn[m_bands[i+1]->columnIndex()] += m_bands[i+1]->height()+bandSpace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
foreach(BandDesignIntf* band, m_bands){
|
||||||
|
if (band->isSelected()) band->updateBandNameLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -515,8 +516,37 @@ void PageItemDesignIntf::bandDeleted(QObject *band)
|
|||||||
relocateBands();
|
relocateBands();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageItemDesignIntf::bandGeometryChanged(QObject *, QRectF /*newGeometry*/, QRectF /*oldGeometry*/)
|
void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry)
|
||||||
{
|
{
|
||||||
|
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(object);
|
||||||
|
int curIndex = band->bandIndex();
|
||||||
|
BandDesignIntf* bandToSwap = 0;
|
||||||
|
foreach(BandDesignIntf* curBand, bands()){
|
||||||
|
if (newGeometry.y()>oldGeometry.y()) {
|
||||||
|
if (curBand->bandType() == band->bandType()
|
||||||
|
&& curIndex<curBand->bandIndex()
|
||||||
|
&& (curBand->pos().y()+(curBand->height()/2))<newGeometry.y()
|
||||||
|
&& curBand->parentBand() == band->parentBand())
|
||||||
|
{
|
||||||
|
curIndex = curBand->bandIndex();
|
||||||
|
bandToSwap = curBand;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (curBand->bandType() == band->bandType()
|
||||||
|
&& curIndex>curBand->bandIndex()
|
||||||
|
&& (curBand->pos().y()+(curBand->height()/2))>newGeometry.y()
|
||||||
|
&& curBand->parentBand() == band->parentBand())
|
||||||
|
{
|
||||||
|
curIndex = curBand->bandIndex();
|
||||||
|
bandToSwap = curBand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (curIndex != band->bandIndex()){
|
||||||
|
bandToSwap->changeBandIndex(band->bandIndex());
|
||||||
|
band->changeBandIndex(curIndex);
|
||||||
|
}
|
||||||
|
|
||||||
relocateBands();
|
relocateBands();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public:
|
|||||||
bool canContainChildren(){ return true;}
|
bool canContainChildren(){ return true;}
|
||||||
protected slots:
|
protected slots:
|
||||||
void bandDeleted(QObject* band);
|
void bandDeleted(QObject* band);
|
||||||
void bandGeometryChanged(QObject* /*object*/, QRectF newGeometry, QRectF oldGeometry);
|
void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
|
||||||
protected:
|
protected:
|
||||||
void collectionLoadFinished(const QString& collectionName);
|
void collectionLoadFinished(const QString& collectionName);
|
||||||
QRectF& pageRect(){return m_pageRect;}
|
QRectF& pageRect(){return m_pageRect;}
|
||||||
|
Loading…
Reference in New Issue
Block a user