Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace hal
void updateGroupIndex(PortTreeItem* groupItem);

// helper functions for dnd for more clarity
void dndGroupOnGroup(BaseTreeItem* droppedGroup, BaseTreeItem* onDroppedGroup);
void dndGroupOnGroup(BaseTreeItem* droppedGroup, BaseTreeItem* onDroppedGroup, int row=-1);
void dndGroupBetweenGroup(PortTreeItem* droppedGroup, int row);
void dndPinOnGroup(PortTreeItem* droppedPin, BaseTreeItem* onDroppedGroup);
void dndPinBetweenPin(PortTreeItem* droppedPin, BaseTreeItem* onDroppedParent, int row);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace hal
if (!m)
return;

mPortModel->clear();
mPortModel->setModule(m);
mModuleID = moduleID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ namespace hal

auto droppedItem = (type == "group") ? static_cast<PortTreeItem*>(mIdToGroupItem.value(id)) : static_cast<PortTreeItem*>(mIdToPinItem.value(id));
//auto droppedParentItem = droppedItem->getParent();
auto parentItem = getItemFromIndex(parent);
auto dropPositionItem = getItemFromIndex(parent);

// perhaps helper functions?
// 1. group on group (between group)
Expand All @@ -180,42 +180,51 @@ namespace hal

if(type == "group")
{
if(!parentItem)
if(!dropPositionItem)
{
// debug pingroup qDebug() << "group was dropped between groups... with row: " << row; //check in canDropMine if its not an adjacent row?
dndGroupBetweenGroup(droppedItem, row);
}
else
{
// debug pingroup qDebug() << "group was dropped on a group?";
dndGroupOnGroup(droppedItem, parentItem);
PortTreeItem* pitem = dynamic_cast<PortTreeItem*>(dropPositionItem);
if (pitem && pitem->itemType() == PortTreeItem::Pin)
{
// debug pingroup qDebug() << "group was dropped on a pin...";
PortTreeItem* parentGroupItem = static_cast<PortTreeItem*>(pitem->getParent());
row = getIndexFromItem(pitem).row();
dndGroupOnGroup(droppedItem, parentGroupItem, row);
}
else
// debug pingroup qDebug() << "group was dropped on a group?";
dndGroupOnGroup(droppedItem, dropPositionItem);
}
}
else
{
if(!parentItem)
if(!dropPositionItem)
{
// debug pingroup qDebug() << "pin was dropped between groups on row " << row;
dndPinBetweenGroup(droppedItem, row);
}
else if(row != -1)
{
// debug pingroup qDebug() << "pin was dropped between pins";
dndPinBetweenPin(droppedItem, parentItem, row);
dndPinBetweenPin(droppedItem, dropPositionItem, row);
}
else
{
PortTreeItem* pitem = dynamic_cast<PortTreeItem*>(parentItem);
PortTreeItem* pitem = dynamic_cast<PortTreeItem*>(dropPositionItem);
if (pitem && pitem->itemType() == PortTreeItem::Pin)
{
// debug pingroup qDebug() << "pin was dropped on a pin...";
PortTreeItem* ppitem = static_cast<PortTreeItem*>(pitem->getParent());
PortTreeItem* parentGroupItem = static_cast<PortTreeItem*>(pitem->getParent());
row = getIndexFromItem(pitem).row();
dndPinBetweenPin(droppedItem, ppitem, row);
dndPinBetweenPin(droppedItem, parentGroupItem, row);
}
else
// debug pingroup qDebug() << "pin was dropped on a group...";
dndPinOnGroup(droppedItem, parentItem);
dndPinOnGroup(droppedItem, dropPositionItem);
}
}

Expand Down Expand Up @@ -288,7 +297,6 @@ namespace hal

void ModulePinsTreeModel::setModule(Module* m)
{
clear();
mModule = m;
beginResetModel();

Expand Down Expand Up @@ -576,7 +584,7 @@ namespace hal
}
}

void ModulePinsTreeModel::dndGroupOnGroup(BaseTreeItem *droppedGroup, BaseTreeItem *onDroppedGroup)
void ModulePinsTreeModel::dndGroupOnGroup(BaseTreeItem *droppedGroup, BaseTreeItem *onDroppedGroup, int row)
{
// SPECIFY: 1) create completely new group, all pins in that, delete old 2 groups
// 2) just add all pins from dropped group to "ondroppedgroup", then rename?
Expand All @@ -590,8 +598,7 @@ namespace hal

auto tgtgroup = mModule->get_pin_group_by_id(static_cast<PortTreeItem*>(onDroppedGroup)->id());

ActionPingroup* act = ActionPingroup::addPinsToExistingGroup(mModule,tgtgroup->get_id(),pins);
act->setObject(UserActionObject(mModule->get_id(),UserActionObjectType::Module));
ActionPingroup* act = ActionPingroup::addPinsToExistingGroup(mModule,tgtgroup->get_id(),pins,row);
if (act) act->exec();

// too keep the order, ActionAddItemsToObject cannot be executed with all pins, but a ComAction must be created
Expand Down
Loading