diff --git a/limereport/lritemdesignintf.cpp b/limereport/lritemdesignintf.cpp index 5987086..167ac27 100644 --- a/limereport/lritemdesignintf.cpp +++ b/limereport/lritemdesignintf.cpp @@ -59,6 +59,7 @@ void ItemDesignIntf::setItemLocation(LocationType location) setParentItem(parentBand); setParent(dynamic_cast(parentBand)); setPos(parentPos); + emit itemLocationChanged(this, dynamic_cast(parentBand)); } else { m_itemLocation=Page; } @@ -69,6 +70,7 @@ void ItemDesignIntf::setItemLocation(LocationType location) setParentItem(page); setParent(page); setPos(parentPos); + emit itemLocationChanged(this, page); } } notify("locationType",oldValue,location); @@ -95,8 +97,8 @@ BaseDesignIntf *ItemDesignIntf::cloneEmpty(int height, QObject *owner, QGraphics QGraphicsItem * ItemDesignIntf::bandByPos() { - foreach(QGraphicsItem *item,collidingItems()){ - if (dynamic_cast(item)){ + foreach(QGraphicsItem *item, scene()->items()){ + if (dynamic_cast(item) && item->collidesWithItem(this)){ return item; } } diff --git a/limereport/lritemdesignintf.h b/limereport/lritemdesignintf.h index a9c8d7a..808666c 100644 --- a/limereport/lritemdesignintf.h +++ b/limereport/lritemdesignintf.h @@ -50,6 +50,8 @@ public: void setStretchToMaxHeight(bool value); bool stretchToMaxHeight(){return m_stretchToMaxHeight;} BaseDesignIntf* cloneEmpty(int height, QObject *owner, QGraphicsItem *parent); +signals: + void itemLocationChanged(BaseDesignIntf* item, BaseDesignIntf* parent); protected: QGraphicsItem* bandByPos(); virtual void initFlags(); diff --git a/limereport/objectsbrowser/lrobjectbrowser.cpp b/limereport/objectsbrowser/lrobjectbrowser.cpp index 5eff56d..e657a81 100644 --- a/limereport/objectsbrowser/lrobjectbrowser.cpp +++ b/limereport/objectsbrowser/lrobjectbrowser.cpp @@ -94,6 +94,11 @@ void ObjectBrowser::fillNode(QTreeWidgetItem* parentNode, BaseDesignIntf* report treeItem->setIcon(0,QIcon(":/items/"+extractClassName(item->metaObject()->className()))); connect(item, SIGNAL(propertyObjectNameChanged(QString,QString)), this, SLOT(slotPropertyObjectNameChanged(QString,QString))); + ItemDesignIntf* i = dynamic_cast(item); + if (i){ + connect(i, SIGNAL(itemLocationChanged(BaseDesignIntf*,BaseDesignIntf*)), + this, SLOT(slotItemParentChanged(BaseDesignIntf*,BaseDesignIntf*))); + } m_itemsMap.insert(item,treeItem); parentNode->addChild(treeItem); if (!item->childBaseItems().isEmpty()) @@ -278,6 +283,19 @@ void ObjectBrowser::slotActivePageUpdated(LimeReport::PageDesignIntf *) buildTree(); } +void ObjectBrowser::slotItemParentChanged(BaseDesignIntf* item, BaseDesignIntf* parent) +{ + if (m_itemsMap.contains(item) && m_itemsMap.contains(parent)){ + m_itemsMap.value(item)->parent()->removeChild(m_itemsMap.value(item)); + m_itemsMap.value(parent)->addChild(m_itemsMap.value(item)); + m_changingItemSelection = true; + m_itemsMap.value(item)->setSelected(true); + item->setSelected(true); + m_changingItemSelection = false; + } + +} + void ObjectBrowserNode::setObject(QObject *value) { m_object = value; diff --git a/limereport/objectsbrowser/lrobjectbrowser.h b/limereport/objectsbrowser/lrobjectbrowser.h index ceddbec..4bdcb52 100644 --- a/limereport/objectsbrowser/lrobjectbrowser.h +++ b/limereport/objectsbrowser/lrobjectbrowser.h @@ -75,6 +75,7 @@ private slots: void slotMultiItemSelected(); void slotItemDoubleClicked(QTreeWidgetItem* item,int); void slotActivePageUpdated(LimeReport::PageDesignIntf*); + void slotItemParentChanged(BaseDesignIntf* item, BaseDesignIntf* parent); private: ReportDesignWidget* m_report; QMainWindow* m_mainWindow;