0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-10-02 03:53:19 +03:00

Define code style and format all source file using clang-format-14

except those placed in 3rdparty directories.
This commit is contained in:
Андрей Лухнов
2024-09-04 17:31:16 +03:00
parent c5b9ac265d
commit 0fca7169d3
285 changed files with 19120 additions and 17875 deletions

View File

@@ -2,9 +2,12 @@
namespace LimeReport {
AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* parent)
: LayoutDesignIntf(xmlTag, owner, parent), m_isRelocating(false), m_layoutType(Layout),
m_hideEmptyItems(false), m_layoutSpacing(0)
AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* parent):
LayoutDesignIntf(xmlTag, owner, parent),
m_isRelocating(false),
m_layoutType(Layout),
m_hideEmptyItems(false),
m_layoutSpacing(0)
{
setPossibleResizeDirectionFlags(AllDirections);
m_layoutMarker = new LayoutMarker(this);
@@ -17,38 +20,25 @@ AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* pa
AbstractLayout::~AbstractLayout()
{
if (m_layoutMarker) {
delete m_layoutMarker; m_layoutMarker=0;
delete m_layoutMarker;
m_layoutMarker = 0;
}
}
QList<BaseDesignIntf*>& AbstractLayout::layoutsChildren()
{
return m_children;
}
QList<BaseDesignIntf*>& AbstractLayout::layoutsChildren() { return m_children; }
bool AbstractLayout::isRelocating() const
{
return m_isRelocating;
}
bool AbstractLayout::isRelocating() const { return m_isRelocating; }
void AbstractLayout::setIsRelocating(bool isRelocating)
{
m_isRelocating = isRelocating;
}
void AbstractLayout::setIsRelocating(bool isRelocating) { m_isRelocating = isRelocating; }
AbstractLayout::LayoutType AbstractLayout::layoutType() const
{
return m_layoutType;
}
AbstractLayout::LayoutType AbstractLayout::layoutType() const { return m_layoutType; }
void AbstractLayout::setLayoutType(const LayoutType& layoutType)
{
m_layoutType = layoutType;
}
void AbstractLayout::setLayoutType(const LayoutType& layoutType) { m_layoutType = layoutType; }
void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
{
if (updateSize) placeItemInLayout(item);
if (updateSize)
placeItemInLayout(item);
m_children.append(item);
item->setParentItem(this);
@@ -58,13 +48,13 @@ void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
connectToLayout(item);
if (updateSize){
if (updateSize) {
relocateChildren();
updateLayoutSize();
}
}
void AbstractLayout::removeChild(BaseDesignIntf *item)
void AbstractLayout::removeChild(BaseDesignIntf* item)
{
if (!item) {
return;
@@ -75,8 +65,9 @@ void AbstractLayout::removeChild(BaseDesignIntf *item)
void AbstractLayout::restoreChild(BaseDesignIntf* item)
{
if (m_children.contains(item)) return;
m_isRelocating=true;
if (m_children.contains(item))
return;
m_isRelocating = true;
insertItemInLayout(item);
@@ -88,7 +79,7 @@ void AbstractLayout::restoreChild(BaseDesignIntf* item)
item->setParentItem(this);
updateLayoutSize();
m_isRelocating=false;
m_isRelocating = false;
}
bool AbstractLayout::isEmpty() const
@@ -97,54 +88,49 @@ bool AbstractLayout::isEmpty() const
bool allItemsIsText = true;
foreach (QGraphicsItem* qgItem, childItems()) {
ContentItemDesignIntf* item = dynamic_cast<ContentItemDesignIntf*>(qgItem);
if (item && !item->content().isEmpty()) isEmpty = false;
if (item && !item->content().isEmpty())
isEmpty = false;
if (!item && dynamic_cast<BaseDesignIntf*>(qgItem))
allItemsIsText = false;
}
return (isEmpty && allItemsIsText);
}
void AbstractLayout::paintChild(BaseDesignIntf *child, QPointF parentPos, QPainter *painter)
void AbstractLayout::paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter)
{
if (!child->childBaseItems().isEmpty()){
if (!child->childBaseItems().isEmpty()) {
foreach (BaseDesignIntf* item, child->childBaseItems()) {
paintChild(item, child->pos(),painter);
paintChild(item, child->pos(), painter);
}
}
painter->drawRect(
QRectF(parentPos.x()+child->pos().x(), parentPos.y()+child->pos().y(),
child->rect().bottomRight().rx(),
child->rect().bottomRight().ry()
)
);
painter->drawRect(QRectF(parentPos.x() + child->pos().x(), parentPos.y() + child->pos().y(),
child->rect().bottomRight().rx(), child->rect().bottomRight().ry()));
}
void AbstractLayout::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
void AbstractLayout::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
QWidget* widget)
{
if (isSelected()){
if (isSelected()) {
painter->save();
painter->setPen(Qt::red);
foreach( BaseDesignIntf* item, m_children){
paintChild(item, QPointF(0,0), painter);
foreach (BaseDesignIntf* item, m_children) {
paintChild(item, QPointF(0, 0), painter);
}
painter->restore();
}
LayoutDesignIntf::paint(painter, option, widget);
}
int AbstractLayout::childrenCount()
{
return m_children.size();
}
int AbstractLayout::childrenCount() { return m_children.size(); }
void AbstractLayout::beforeDelete()
{
#ifdef HAVE_QT5
foreach (QObject *item, children()) {
foreach (QObject* item, children()) {
#else
foreach (QObject *item, QObject::children()) {
foreach (QObject* item, QObject::children()) {
#endif
BaseDesignIntf *bi = dynamic_cast<BaseDesignIntf*>(item);
BaseDesignIntf* bi = dynamic_cast<BaseDesignIntf*>(item);
if (bi) {
bi->disconnect(this);
bi->setParentItem(parentItem());
@@ -158,16 +144,13 @@ void AbstractLayout::beforeDelete()
m_children.clear();
}
void AbstractLayout::childAddedEvent(BaseDesignIntf* child)
{
addChild(child,false);
}
void AbstractLayout::childAddedEvent(BaseDesignIntf* child) { addChild(child, false); }
void AbstractLayout::geometryChangedEvent(QRectF newRect, QRectF)
{
layoutMarker()->setHeight(newRect.height());
relocateChildren();
if (!isRelocating()){
if (!isRelocating()) {
divideSpace();
}
}
@@ -175,7 +158,7 @@ void AbstractLayout::geometryChangedEvent(QRectF newRect, QRectF)
void AbstractLayout::initMode(BaseDesignIntf::ItemMode mode)
{
BaseDesignIntf::initMode(mode);
if ((mode==PreviewMode)||(mode==PrintMode)){
if ((mode == PreviewMode) || (mode == PrintMode)) {
layoutMarker()->setVisible(false);
} else {
layoutMarker()->setVisible(true);
@@ -185,22 +168,22 @@ void AbstractLayout::initMode(BaseDesignIntf::ItemMode mode)
void AbstractLayout::setBorderLinesFlags(BaseDesignIntf::BorderLines flags)
{
BaseDesignIntf::setBorderLinesFlags(flags);
if (flags!=0)
if (flags != 0)
relocateChildren();
}
void AbstractLayout::collectionLoadFinished(const QString& collectionName)
{
ItemDesignIntf::collectionLoadFinished(collectionName);
if (collectionName.compare("children",Qt::CaseInsensitive)==0){
if (collectionName.compare("children", Qt::CaseInsensitive) == 0) {
#ifdef HAVE_QT5
foreach(QObject* obj, children()){
foreach (QObject* obj, children()) {
#else
foreach(QObject* obj,QObject::children()){
foreach (QObject* obj, QObject::children()) {
#endif
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(obj);
if (item) {
addChild(item,false);
addChild(item, false);
}
}
}
@@ -220,9 +203,9 @@ bool AbstractLayout::isNeedUpdateSize(RenderPass pass) const
QVariant AbstractLayout::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value)
{
if (change == QGraphicsItem::ItemSelectedHasChanged){
if (change == QGraphicsItem::ItemSelectedHasChanged) {
setIsRelocating(true);
foreach(BaseDesignIntf* item, layoutsChildren()){
foreach (BaseDesignIntf* item, layoutsChildren()) {
item->setVisible(!value.toBool());
}
setIsRelocating(false);
@@ -234,7 +217,7 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p
{
setIsRelocating(true);
ItemDesignIntf::updateItemSize(dataManager, pass, maxHeight);
foreach(QGraphicsItem *child, childItems()){
foreach (QGraphicsItem* child, childItems()) {
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(child);
if (item && item->isNeedUpdateSize(pass))
item->updateItemSize(dataManager, pass, maxHeight);
@@ -245,8 +228,9 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
}
void AbstractLayout::rebuildChildrenIfNeeded(){
if (layoutsChildren().count() < childItems().size()-1){
void AbstractLayout::rebuildChildrenIfNeeded()
{
if (layoutsChildren().count() < childItems().size() - 1) {
layoutsChildren().clear();
foreach (BaseDesignIntf* childItem, childBaseItems()) {
layoutsChildren().append(childItem);
@@ -255,89 +239,75 @@ void AbstractLayout::rebuildChildrenIfNeeded(){
}
}
void AbstractLayout::connectToLayout(BaseDesignIntf *item)
void AbstractLayout::connectToLayout(BaseDesignIntf* item)
{
connect(
item, SIGNAL(destroyed(QObject*)),
this, SLOT(slotOnChildDestroy(QObject*))
);
connect(
item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))
);
connect(
item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),
this, SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))
);
connect(
item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*,bool)),
this, SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*,bool))
);
connect(
item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,const ItemAlign&,const ItemAlign&))
);
connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(slotOnChildDestroy(QObject*)));
connect(item, SIGNAL(geometryChanged(QObject*, QRectF, QRectF)), this,
SLOT(slotOnChildGeometryChanged(QObject*, QRectF, QRectF)));
connect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)), this,
SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*)));
connect(item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*, bool)), this,
SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*, bool)));
connect(item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
this,
SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)));
}
void AbstractLayout::disconnectFromLayout(BaseDesignIntf *item)
void AbstractLayout::disconnectFromLayout(BaseDesignIntf* item)
{
disconnect(item, SIGNAL(destroyed(QObject*)), this, SLOT(slotOnChildDestroy(QObject*)));
disconnect(item, SIGNAL(geometryChanged(QObject*, QRectF, QRectF)), this,
SLOT(slotOnChildGeometryChanged(QObject*, QRectF, QRectF)));
disconnect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)), this,
SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*)));
disconnect(item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*, bool)), this,
SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*, bool)));
disconnect(
item, SIGNAL(destroyed(QObject*)),
this, SLOT(slotOnChildDestroy(QObject*))
);
disconnect(
item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))
);
disconnect(
item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),
this, SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))
);
disconnect(
item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*,bool)),
this, SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*,bool))
);
disconnect(
item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,const ItemAlign&,const ItemAlign&))
);
item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)), this,
SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)));
}
BaseDesignIntf *AbstractLayout::findNext(BaseDesignIntf *item)
BaseDesignIntf* AbstractLayout::findNext(BaseDesignIntf* item)
{
rebuildChildrenIfNeeded();
for (int i=0; i<layoutsChildren().count();++i){
if (layoutsChildren()[i]==item && layoutsChildren().size()>i+1){ return layoutsChildren()[i+1];}
for (int i = 0; i < layoutsChildren().count(); ++i) {
if (layoutsChildren()[i] == item && layoutsChildren().size() > i + 1) {
return layoutsChildren()[i + 1];
}
}
return 0;
}
BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item)
BaseDesignIntf* AbstractLayout::findPrior(BaseDesignIntf* item)
{
rebuildChildrenIfNeeded();
for (int i=0; i<layoutsChildren().count();++i){
if (layoutsChildren()[i]==item && i!=0){ return layoutsChildren()[i-1];}
for (int i = 0; i < layoutsChildren().count(); ++i) {
if (layoutsChildren()[i] == item && i != 0) {
return layoutsChildren()[i - 1];
}
}
return 0;
}
void AbstractLayout::insertItemInLayout(BaseDesignIntf *item){
void AbstractLayout::insertItemInLayout(BaseDesignIntf* item)
{
bool inserted = false;
for (int i=0; i<layoutsChildren().length(); ++i){
for (int i = 0; i < layoutsChildren().length(); ++i) {
BaseDesignIntf* child = layoutsChildren()[i];
if (child->pos() == item->pos()){
if (child->pos() == item->pos()) {
layoutsChildren().insert(i, item);
inserted = true;
break;
}
}
if (!inserted) layoutsChildren().append(item);
if (!inserted)
layoutsChildren().append(item);
}
void AbstractLayout::slotOnChildDestroy(QObject* child)
{
m_children.removeAll(static_cast<BaseDesignIntf*>(child));
if (m_children.count() < 2 && !static_cast<LayoutDesignIntf*>(child)){
if (m_children.count() < 2 && !static_cast<LayoutDesignIntf*>(child)) {
beforeDelete();
} else {
relocateChildren();
@@ -345,19 +315,20 @@ void AbstractLayout::slotOnChildDestroy(QObject* child)
}
}
void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, QRectF oldGeometry)
void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry,
QRectF oldGeometry)
{
if (!m_isRelocating && !isLoading()){
if (m_layoutType == Layout){
if (!m_isRelocating && !isLoading()) {
if (m_layoutType == Layout) {
relocateChildren();
updateLayoutSize();
} else {
m_isRelocating = true;
qreal delta = newGeometry.width()-oldGeometry.width();
qreal delta = newGeometry.width() - oldGeometry.width();
BaseDesignIntf* resizingItem = findNext(dynamic_cast<BaseDesignIntf*>(item));
if (resizingItem) {
resizingItem->setWidth(resizingItem->width()-delta);
resizingItem->setPos(resizingItem->pos().x()+delta,resizingItem->pos().y());
resizingItem->setWidth(resizingItem->width() - delta);
resizingItem->setPos(resizingItem->pos().x() + delta, resizingItem->pos().y());
}
updateLayoutSize();
m_isRelocating = false;
@@ -365,7 +336,8 @@ void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometr
}
}
void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&)
void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&,
const ItemAlign&)
{
item->setPossibleResizeDirectionFlags(ResizeBottom | ResizeRight);
}
@@ -373,28 +345,25 @@ void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const Ite
void AbstractLayout::slotOnChildVisibleHasChanged(BaseDesignIntf*)
{
relocateChildren();
if (m_layoutType == Table && !m_isRelocating){
if (m_layoutType == Table && !m_isRelocating) {
divideSpace();
}
}
void AbstractLayout::slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value)
{
item->setZValue(value ? item->zValue()+1 : item->zValue()-1);
item->setZValue(value ? item->zValue() + 1 : item->zValue() - 1);
}
int AbstractLayout::layoutSpacing() const
{
return m_layoutSpacing;
}
int AbstractLayout::layoutSpacing() const { return m_layoutSpacing; }
void AbstractLayout::setLayoutSpacing(int layoutSpacing)
{
if (m_layoutSpacing != layoutSpacing){
if (m_layoutSpacing != layoutSpacing) {
int oldValue = m_layoutSpacing;
m_layoutSpacing = layoutSpacing;
if (!isLoading()){
int delta = (m_layoutSpacing - oldValue) * (m_children.count()-1);
if (!isLoading()) {
int delta = (m_layoutSpacing - oldValue) * (m_children.count() - 1);
notify("layoutSpacing", oldValue, m_layoutSpacing);
setWidth(width() + delta);
}
@@ -402,16 +371,13 @@ void AbstractLayout::setLayoutSpacing(int layoutSpacing)
}
}
bool AbstractLayout::hideEmptyItems() const
{
return m_hideEmptyItems;
}
bool AbstractLayout::hideEmptyItems() const { return m_hideEmptyItems; }
void AbstractLayout::setHideEmptyItems(bool hideEmptyItems)
{
m_hideEmptyItems = hideEmptyItems;
if (m_hideEmptyItems != hideEmptyItems){
if (m_hideEmptyItems != hideEmptyItems) {
m_hideEmptyItems = hideEmptyItems;
notify("hideEmptyItems", !m_hideEmptyItems, m_hideEmptyItems);
}
@@ -420,13 +386,11 @@ void AbstractLayout::setHideEmptyItems(bool hideEmptyItems)
QObject* AbstractLayout::at(int index)
{
rebuildChildrenIfNeeded();
if (layoutsChildren().size() > index) return layoutsChildren()[index];
if (layoutsChildren().size() > index)
return layoutsChildren()[index];
return 0;
}
LayoutMarker* AbstractLayout::layoutMarker() const
{
return m_layoutMarker;
}
LayoutMarker* AbstractLayout::layoutMarker() const { return m_layoutMarker; }
} // namespace LimeReport