Skip to content

Commit

Permalink
Finish 1.4.79
Browse files Browse the repository at this point in the history
  • Loading branch information
fralx committed Apr 24, 2018
2 parents b9774f6 + 36f75b0 commit 8fd072c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
3 changes: 1 addition & 2 deletions limereport/items/lrsubitemparentpropitem.cpp
Expand Up @@ -77,8 +77,8 @@ void LimeReport::ItemLocationPropItem::setPropertyEditorData(QWidget *propertyEd
}

void LimeReport::ItemLocationPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index){
object()->setProperty(propertyName().toLatin1(),stringToLocation(qobject_cast<ComboBoxEditor*>(propertyEditor)->text()));
model->setData(index,object()->property(propertyName().toLatin1()));
setValueToObject(propertyName(), propertyValue());
}

QString LimeReport::ItemLocationPropItem::locationToString(LimeReport::ItemDesignIntf::LocationType location) const{
Expand All @@ -92,6 +92,5 @@ LimeReport::ItemDesignIntf::LocationType LimeReport::ItemLocationPropItem::strin
void LimeReport::ItemLocationPropItem::slotLocationChanged(const QString &text){
if ( locationToString(object()->property(propertyName().toLatin1()).toInt())!=text){
object()->setProperty(propertyName().toLatin1(),stringToLocation(text));
dynamic_cast<ComboBoxEditor*>(sender())->setTextValue(locationToString(object()->property(propertyName().toLatin1()).toInt()));
}
}
29 changes: 25 additions & 4 deletions limereport/objectsbrowser/lrobjectbrowser.cpp
Expand Up @@ -35,7 +35,8 @@
namespace LimeReport{

ObjectBrowser::ObjectBrowser(QWidget *parent)
:QWidget(parent), m_report(NULL), m_mainWindow(NULL), m_changingItemSelection(false)
:QWidget(parent), m_report(NULL), m_mainWindow(NULL),
m_changingItemSelection(false), m_movingItem(false)
{
QVBoxLayout *layout = new QVBoxLayout(this);
setLayout(layout);
Expand Down Expand Up @@ -86,18 +87,19 @@ void ObjectBrowser::slotClear()
}

void ObjectBrowser::fillNode(QTreeWidgetItem* parentNode, BaseDesignIntf* reportItem, BaseDesignIntf *ignoredItem){

foreach (BaseDesignIntf* item, reportItem->childBaseItems()) {
if (item != ignoredItem){
ObjectBrowserNode* treeItem = new ObjectBrowserNode(parentNode);
treeItem->setText(0,item->objectName());
treeItem->setObject(item);
treeItem->setIcon(0,QIcon(":/items/"+extractClassName(item->metaObject()->className())));
connect(item, SIGNAL(propertyObjectNameChanged(QString,QString)),
this, SLOT(slotPropertyObjectNameChanged(QString,QString)));
this, SLOT(slotPropertyObjectNameChanged(QString,QString)), Qt::UniqueConnection);
ItemDesignIntf* i = dynamic_cast<ItemDesignIntf*>(item);
if (i){
connect(i, SIGNAL(itemLocationChanged(BaseDesignIntf*,BaseDesignIntf*)),
this, SLOT(slotItemParentChanged(BaseDesignIntf*,BaseDesignIntf*)));
this, SLOT(slotItemParentChanged(BaseDesignIntf*,BaseDesignIntf*)), Qt::UniqueConnection);
}
m_itemsMap.insert(item,treeItem);
parentNode->addChild(treeItem);
Expand Down Expand Up @@ -283,7 +285,9 @@ void ObjectBrowser::slotActivePageUpdated(LimeReport::PageDesignIntf *)
buildTree();
}

void ObjectBrowser::slotItemParentChanged(BaseDesignIntf* item, BaseDesignIntf* parent)


void ObjectBrowser::moveItemNode(BaseDesignIntf* item, BaseDesignIntf* parent)
{
if (m_itemsMap.contains(item) && m_itemsMap.contains(parent)){
m_itemsMap.value(item)->parent()->removeChild(m_itemsMap.value(item));
Expand All @@ -293,7 +297,24 @@ void ObjectBrowser::slotItemParentChanged(BaseDesignIntf* item, BaseDesignIntf*
item->setSelected(true);
m_changingItemSelection = false;
}
}

void ObjectBrowser::slotItemParentChanged(BaseDesignIntf* item, BaseDesignIntf* parent)
{
if (!m_movingItem){
m_movingItem = true;
moveItemNode(item, parent);
m_movingItem = false;
foreach(QObject* di, m_defferedItems){
BaseDesignIntf* b = dynamic_cast<BaseDesignIntf*>(di);
if (b)
moveItemNode(b, parent);
}
m_defferedItems.clear();
} else {
if (!m_defferedItems.contains(item))
m_defferedItems.append(item);
}
}

void ObjectBrowserNode::setObject(QObject *value)
Expand Down
3 changes: 3 additions & 0 deletions limereport/objectsbrowser/lrobjectbrowser.h
Expand Up @@ -60,6 +60,7 @@ class ObjectBrowser :public QWidget
void buildTree(BaseDesignIntf *ignoredItem = 0);
void removeItem(BaseDesignIntf* item);
void findAndRemove(QTreeWidgetItem *node, BaseDesignIntf *item);
void moveItemNode(BaseDesignIntf* item, BaseDesignIntf* parent);
private slots:
// void slotObjectNameChanged(const QString& objectName);
void slotPropertyObjectNameChanged(const QString& oldName, const QString& newName);
Expand All @@ -82,6 +83,8 @@ private slots:
QTreeWidget* m_treeView;
QMap<QObject*, ObjectBrowserNode*> m_itemsMap;
bool m_changingItemSelection;
bool m_movingItem;
QList<QObject*> m_defferedItems;
};

} //namespace LimeReport
Expand Down

0 comments on commit 8fd072c

Please sign in to comment.