void System::entityChanged(Entity* e, const list<Component*>& cList) { cout << "Entity changed: " << e->name << endl; auto neededIt = neededComponents.begin(); for(; neededIt != neededComponents.end(); neededIt++){ auto entityComponentsIt = cList.begin(); for(; entityComponentsIt != cList.end(); entityComponentsIt++){ if(*neededIt == (*entityComponentsIt)->getType()) break; //Found this component } if(entityComponentsIt == cList.end()) break; //A neededComponent was not found, can stop searching now //else continue to next } if(neededIt == neededComponents.end()){ //Reached end of loop, pattern matched cout << "Match to system: " << e->name << endl; if(entities.count(e) == 0){ entities.insert(e); entityAdded(e, cList); } }else{ cout << "Non-Match to system: " << e->name << endl; if(entities.count(e) == 1){ entities.erase(e); entityRemoved(e, cList); } } }
void View::NewInvoiceDialog::selectEntity() { Model::Domain::EntityType entityType = _buyRadioButton -> isChecked() ? Model::Domain::SupplierEntity : Model::Domain::CustomerEntity; View::Management::EntitySelector selector(entityType, View::Management::CreateAndSelect, this); if(selector.exec()) { Model::Domain::Entity *entity = selector.entity(); _entityIdLineEdit -> setText(QString::number(entity -> id())); _entityNameLineEdit -> setText(entity -> name()); if(selector.created()) emit entityAdded(*entity); delete entity; } }