void CopyPasteController::CopyControls(const HierarchyTreeController::SELECTEDCONTROLNODES& items) { if (!items.size()) return; Clear(); // If at least one subcontrol is selected - block copy, see pls DF-2684. if (SubcontrolsSelected(items)) { return; } for (HierarchyTreeController::SELECTEDCONTROLNODES::const_iterator iter = items.begin(); iter != items.end(); ++iter) { //HierarchyTreeNode* item = (*iter); const HierarchyTreeControlNode* control = (*iter); if (!control) continue; if (ControlIsChild(items, control)) continue; this->items.push_back(control->CreateControlCopy(NULL)); } if (this->items.size()) copyType = CopyTypeControl; }
void HierarchyTreeWidget::OnSelectedControlNodesChanged(const HierarchyTreeController::SELECTEDCONTROLNODES &selectedControls) { if (internalSelectionChanged) return; internalSelectionChanged = true; ResetSelection(); TREEITEMS items = GetAllItems(); for (HierarchyTreeController::SELECTEDCONTROLNODES::const_iterator iter = selectedControls.begin(); iter != selectedControls.end(); ++iter) { const HierarchyTreeControlNode* node = (*iter); TREEITEMS::iterator itemIter = items.find(node->GetId()); if (itemIter != items.end()) { QTreeWidgetItem* item = itemIter->second; item->setSelected(true); // Force show selected item QTreeWidgetItem* parentItem = item->parent(); while (parentItem) { parentItem->setExpanded(true); parentItem = parentItem->parent(); } } } internalSelectionChanged = false; }
void CopyPasteController::CopyControls(const HierarchyTreeController::SELECTEDCONTROLNODES& items) { if (!items.size()) return; Clear(); for (HierarchyTreeController::SELECTEDCONTROLNODES::const_iterator iter = items.begin(); iter != items.end(); ++iter) { //HierarchyTreeNode* item = (*iter); const HierarchyTreeControlNode* control = (*iter); if (!control) continue; if (ControlIsChild(items, control)) continue; HierarchyTreeControlNode* copy = NULL; const HierarchyTreeAggregatorControlNode* aggregatorControl = dynamic_cast<const HierarchyTreeAggregatorControlNode*>(control); if (aggregatorControl) copy = new HierarchyTreeAggregatorControlNode(NULL, aggregatorControl); else copy = new HierarchyTreeControlNode(NULL, control); this->items.push_back(copy); } if (this->items.size()) copyType = CopyTypeControl; }
bool CopyPasteController::SubcontrolsSelected(const HierarchyTreeController::SELECTEDCONTROLNODES& items) { for (HierarchyTreeController::SELECTEDCONTROLNODES::const_iterator iter = items.begin(); iter != items.end(); ++iter) { HierarchyTreeControlNode* control = (*iter); if (control && SubcontrolsHelper::ControlIsSubcontrol(control->GetUIObject())) { return true; } } return false; }
bool CopyPasteController::ControlIsChild(const HierarchyTreeController::SELECTEDCONTROLNODES& items, const HierarchyTreeControlNode* control) const { bool isChild = false; //skip child control when copy parent for (HierarchyTreeController::SELECTEDCONTROLNODES::const_iterator iter = items.begin(); iter != items.end(); ++iter) { const HierarchyTreeControlNode* parent = (*iter); if (parent->IsHasChild(control)) { isChild = true; break; } } return isChild; }
void PropertyGridContainerWidget::BuildPropertiesGridList() { // Need to understand which Metadata we need. Since multiple controls of different // type might be selected, we are looking for the most common Metadata. const HierarchyTreeController::SELECTEDCONTROLNODES activeNodes = PropertiesGridController::Instance()->GetActiveTreeNodesList(); BaseMetadata* metaData = GetActiveMetadata(activeNodes); METADATAPARAMSVECT params; for (HierarchyTreeController::SELECTEDCONTROLNODES::const_iterator iter = activeNodes.begin(); iter != activeNodes.end(); iter ++) { const HierarchyTreeControlNode* controlNode = *iter; BaseMetadataParams controlNodeParam(controlNode->GetId(), controlNode->GetUIObject()); params.push_back(controlNodeParam); } BuildPropertiesGrid(metaData, params); }
ControlsPositionData ControlsAdjustSizeCommand::ApplyAjustedSize(HierarchyTreeController::SELECTEDCONTROLNODES& controls) { ControlsPositionData resultData; for (HierarchyTreeController::SELECTEDCONTROLNODES::iterator iter = controls.begin(); iter != controls.end(); ++iter) { HierarchyTreeControlNode* control = (*iter); UIControl* uiControl = control->GetUIObject(); int32 nodeId = control->GetId(); if (uiControl) { // Get sprite Sprite* sprite = uiControl->GetSprite(); Rect prevRect = uiControl->GetRect(); Rect updatedRect = prevRect; if (sprite) { // Save control size data for undo resultData.AddControl(uiControl); // Set new size of updated rect updatedRect.dx = sprite->GetWidth(); updatedRect.dy = sprite->GetHeight(); BaseMetadata* baseMetadata = GetMetadataForTreeNode(nodeId); // This command is NOT state-aware and contains one and only param. baseMetadata->SetActiveParamID(0); baseMetadata->ApplyResize(prevRect, updatedRect); SAFE_DELETE(baseMetadata); } } } return resultData; }