void ActionEditor::updatePropertyList() { Solid::DeviceInterface::Type currentType; currentType = actionData()->interfaceFromName( ui.CbDeviceType->currentText() ); ui.CbValueName->clear(); ui.CbValueName->addItems( actionData()->propertyList( currentType ) ); }
void RPG_ActionHandler::PerformAction(RPG_ActionType_e const& action, bool forceAction /*= false*/, RPG_BaseEntity* const interactionEntity /*= NULL*/, hkvVec3 const& interactionPosition /*= hkvVec3(0, 0, 0)*/, int const flags /*= 0*/) { // if the action and the target are the same, we're just updating flags or interaction. bool updatingActionParams = false; if(m_activeAction.m_Action == action) { if(m_activeAction.m_interactionEntity != interactionEntity || !m_activeAction.m_interactionPosition.isIdentical(interactionPosition) || m_activeAction.m_flags != flags) { updatingActionParams = true; } } if(!forceAction && m_activeAction.m_Action != AT_None && action != AT_None) { // there's an action already playing, and we aren't forcing the new one. perfor more checks. if(m_Actions[m_activeAction.m_Action]->CanOverrideActionWith(action) || m_Actions[action]->CanThisActionOverride(m_activeAction.m_Action)) { forceAction = true; } } if (forceAction || updatingActionParams || CanPerformAction(action)) { // bundle the action into a struct for easier network replication RPG_ActionData actionData(action, interactionEntity, interactionPosition, flags); // simulate the action locally ProcessAction(actionData, forceAction); // replicate the action to the server //@todo: Once the network branch is integrated, here's where we replicate this action to the server. /* Work that needs to happen here: - Find out whether this is a non-authoritative client. - If all we're doing is updating action flags, preserve bandwidth by calling a client->server UpdateActionFlags() with just that data - If we're doing a new Action, call a client->server ProcessAction() using the constructed struct. */ } else if(action != AT_None && m_Actions[m_activeAction.m_Action]->CanChainAction(action)) { // can't process the new action, so check to see if we can chain it RPG_ActionData actionData(action, interactionEntity, interactionPosition, flags); m_pendingAction = actionData; } }
void ActionEditor::updateParameter() { QModelIndex current = ui.TvPredicateTree->currentIndex(); PredicateItem * currentItem = static_cast<PredicateItem*>( current.internalPointer() ); ui.CbParameterType->setCurrentIndex( currentItem->itemType ); updatePropertyList(); ui.CbDeviceType->setCurrentIndex( actionData()->interfacePosition( currentItem->ifaceType ) ); int valuePos = actionData()->propertyPosition( currentItem->ifaceType, currentItem->property ); ui.CbValueName->setCurrentIndex( valuePos ); ui.LeValueMatch->setText( currentItem->value.toString() ); ui.CbValueMatch->setCurrentIndex( currentItem->compOperator ); }
ActionEditor::ActionEditor(QWidget *parent) : QDialog(parent) { topItem = new PredicateItem( Solid::Predicate(), 0 ); rootItem = 0; rootModel = new PredicateModel( topItem, this ); // Prepare the dialog resize( QSize(600, 600) ); // Set a decent initial size // setModal( true ); // Set up the interface ui.setupUi(this); ui.TvPredicateTree->setHeaderHidden( true ); ui.TvPredicateTree->setModel( rootModel ); ui.IbActionIcon->setIconSize( KIconLoader::SizeLarge ); ui.CbDeviceType->addItems( actionData()->interfaceList() ); // Connect up with everything needed -> slot names explain connect( ui.TvPredicateTree, SIGNAL(activated(QModelIndex)), this, SLOT(updateParameter()) ); connect( ui.PbParameterSave, SIGNAL(clicked()), this, SLOT(saveParameter()) ); connect( ui.PbParameterReset, SIGNAL(clicked()), this, SLOT(updateParameter()) ); connect( ui.CbDeviceType, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePropertyList()) ); connect( ui.CbParameterType, SIGNAL(currentIndexChanged(int)), this, SLOT(manageControlStatus()) ); connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &ActionEditor::accept); connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &ActionEditor::reject); if (ui.TvPredicateTree->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick)) { connect( ui.TvPredicateTree, SIGNAL(clicked(QModelIndex)), this, SLOT(updateParameter()) ); } }
void ActionEditor::saveParameter() { QModelIndex current = ui.TvPredicateTree->currentIndex(); PredicateItem * currentItem = static_cast<PredicateItem*>( current.internalPointer() ); // Hold onto this so we can determine if the number of children has changed... Solid::Predicate::Type oldType = currentItem->itemType; currentItem->setTypeByInt( ui.CbParameterType->currentIndex() ); currentItem->ifaceType = actionData()->interfaceFromName( ui.CbDeviceType->currentText() ); currentItem->property = actionData()->propertyInternal( currentItem->ifaceType, ui.CbValueName->currentText() ); currentItem->value = QVariant( ui.LeValueMatch->text() ); currentItem->setComparisonByInt( ui.CbValueMatch->currentIndex() ); rootModel->itemUpdated( current ); rootModel->childrenChanging( current, oldType ); }