void DataTreeView::showPopup(const QPoint & pos) { DataTreeViewItem * item = 0 ; auto items = selectedItems (); if(items.count() == 0) return; QMenu menu(this); QMenu addMenu(this); vector<Action*> actions; if(items.count() == 1) { item = static_cast<DataTreeViewItem*>(items.back()); uint guid = item->getGuid(); serialization::Node* pNode = m_pDataBase->getNode(guid); if(pNode == nullptr) { const phantom::data& d = m_pDataBase->getData(guid); reflection::Class* pClass = d.type()->asClass(); const phantom::data& owner = m_pDataBase->getComponentDataOwner(d); if(owner.isNull()) { // Data directly removed from a Node //menu.addAction(new RemoveDataAction(&menu, m_pDataBase->getNode(d), d)); } else { // Data first removed from its owner o_assert(owner.type()->asClass()); } // Display/Hide action /*if (d.type()->isKindOf(phantom::typeOf<physic::CollisionShape>())) { menu.addAction(new DisplayDataAction(&menu, d, this)); menu.addAction(new HideDataAction(&menu, d, this)); }*/ } else { if(pNode->getState() == serialization::Node::e_Loaded) { addMenu.setTitle("add"); addMenu.setIcon(QIcon("resources/icons/famfamfam/add.png")); menu.addMenu(&addMenu); Action* pAction = o_new(AddNodeAction)(this, pNode, m_AddNodeActionDelegate, this); addMenu.addAction(pAction); actions.push_back(pAction); if(pNode != m_pDataBase->rootNode()) { addMenu.addSeparator(); for(auto it = phantom::beginModules(); it != phantom::endModules(); ++it) { reflection::Module* pModule = it->second; for(auto it = pModule->beginPackages(); it != pModule->endPackages(); ++it) { QMenu* packageMenu = new QMenu; reflection::Package* pPackage = *it; for(auto it = pPackage->beginSources(); it != pPackage->endSources(); ++it) { reflection::Source* pSource = *it; for(auto it = pSource->beginElements(); it != pSource->endElements(); ++it) { packageMenu->setTitle(pPackage->getName().c_str()); reflection::Class* pClass = (*it)->asClass(); if(pClass AND pClass->isPublic() AND NOT(pClass->testModifiers(o_private_visibility)) AND NOT(pClass->isAbstract()) AND pClass->isDefaultConstructible() AND pClass->getSingleton() == nullptr) { Action* pAction = o_new(AddDataAction)(this, pNode, pClass, m_AddDataActionDelegate, packageMenu); packageMenu->addAction(pAction); actions.push_back(pAction); } } } if(!packageMenu->isEmpty()) { addMenu.addMenu(packageMenu); } } } menu.addSeparator(); if(pNode->getParentNode()) // If it's not the root node { Action* pAction = o_new(UnloadNodeAction)(this, pNode, m_UnloadNodeActionDelegate, &menu); menu.addAction(pAction); actions.push_back(pAction); } } } else if(pNode->getState() == serialization::Node::e_Unloaded) { Action* pAction = o_new(LoadNodeAction)(this, pNode, m_LoadNodeActionDelegate, &menu); menu.addAction(pAction); actions.push_back(pAction); pAction = o_new(LoadNodeAction)(this, pNode, m_RecursiveLoadNodeActionDelegate, &menu); menu.addAction(pAction); actions.push_back(pAction); } } } { vector<uint> guids; for(auto it = items.begin(); it != items.end(); ++it) { guids.push_back(((DataTreeViewItem*)(*it))->getGuid()); } RemoveDataAction* pRemoveDataAction = o_new(RemoveDataAction)(this, guids, m_RemoveDataActionDelegate, &menu) ; menu.addAction(pRemoveDataAction); actions.push_back(pRemoveDataAction); } if(NOT(menu.isEmpty())) { menu.exec(QCursor::pos()); } for(auto it = actions.begin(); it != actions.end(); ++it) { o_dynamic_delete *it; } }
void ClassTypeVisualizerNode::expand( VariableNode* a_pParentNode, const vector<reflection::Expression*>& a_LeftExpressions) const { reflection::ClassType* pClassType = as<reflection::ClassType*>(a_pParentNode->getValueType()); o_assert(pClassType); expand(a_pParentNode, a_LeftExpressions, pClassType); }
UndoCommand* ComponentVariableNodeDelegate::createValueSetUndoCommand( const void* a_pValue ) const { string newValueStr; string newValueDisplayStr; vector<string> newValueStrs; reflection::ComponentClass* pComponentClass = m_pVariableNode->getValueType()->removeConstReference()->asComponentClass(); VariableModel* pVariableModel = m_pVariableNode->getVariableModel(); serialization::DataBase* pDataBase = pVariableModel->getDataBase(); UndoCommand* pGroup = o_new(phantom::qt::UndoCommand); void* pNewValue = *((void* const*)a_pValue); reflection::Class* pNewClass = nullptr; if(pNewValue) { pNewClass = as<reflection::Class*>(pNewValue); o_assert(pNewClass); } size_t count = m_pVariableNode->getExpressionCount(); for(size_t i = 0; i<count; ++i) { phantom::data d = pVariableModel->getData()[i]; void* pValue = nullptr; string tempRedoExpression; string redoExpression; string undoExpression; string baseExpression = m_pVariableNode->getExpression(i)->translate(); void* pOldValue = nullptr; pComponentClass->get(m_pVariableNode->getExpression(i)->loadEffectiveAddress(), &pOldValue); if(pOldValue) { auto pOldClass = classOf(pOldValue); o_assert(pOldClass); string newInstanceExpression = "phantom::typeByName(\""+pOldClass->getQualifiedDecoratedName()+"\", phantom::rootNamespace())->newInstance()"; undoExpression = "("+baseExpression+")=(("+pOldClass->getQualifiedDecoratedName()+"*)("+newInstanceExpression+"))"; } else { undoExpression = "("+baseExpression+")=nullptr"; } if(pNewClass) { string newInstanceExpression = "phantom::typeByName(\""+pNewClass->getQualifiedDecoratedName()+"\", phantom::rootNamespace())->newInstance()"; redoExpression = "("+baseExpression+")=(("+pNewClass->getQualifiedDecoratedName()+"*)("+newInstanceExpression+"))"; } else { redoExpression = "("+baseExpression+")=nullptr"; } reflection::Expression* pRedoExpression = phantom::expressionByName(redoExpression); reflection::Expression* pUndoExpression = phantom::expressionByName(undoExpression); ExpressionCommand* pCommand = o_new(ExpressionCommand)(pDataBase, pUndoExpression, pRedoExpression); pCommand->setName( "In data : '"+ pDataBase->getDataAttributeValue(d, "name") + "' ("+phantom::lexical_cast<phantom::string>((void*)pDataBase->getGuid(d))+")"); pGroup->pushCommand(pCommand); } if(pNewClass) pGroup->setName("Property changed : '" + m_pVariableNode->getQualifiedName()+ " = new "+phantom::qt::nameOf(pNewClass)+" component'"); else pGroup->setName("Property changed : '" + m_pVariableNode->getQualifiedName()+ " = none'"); return pGroup; }
void TCPAcceptor::SetApplication(BaseClientApplication *pApplication) { o_assert(_pApplication == NULL); _pApplication = pApplication; }
ConstructorCallExpression::ConstructorCallExpression( Constructor* a_pConstructor, const vector<Expression*>& a_Expressions ) : CallExpression(a_pConstructor, a_Expressions, a_pConstructor->getOwner()->asType()) { o_assert(m_pValueType->isCopyable()); m_pReturnStorage = m_pValueType->allocate(); }
void IOHandlerManager::Start() { _kq = kqueue(); o_assert(_kq > 0); }