void MainWindowView::addFeature(QAction* triggeredFeature) { if(!m_model || !m_ui->treeView->selectionModel()->hasSelection()) return; QModelIndex paren = m_ui->treeView->selectionModel()->selectedIndexes().first(); if(paren.parent().isValid()) paren = paren.parent(); CardType newType = CardType(triggeredFeature->property("type").toInt()); FeatureItem *fi = new FeatureItem(newType, "any", ""); m_model->insertFeature(fi, m_model->itemFromIndex(paren)); m_ui->treeView->expand(fi->parent()->index()); m_ui->treeView->selectionModel()->select(fi->index(), QItemSelectionModel::ClearAndSelect); }
std::string CardStat::getTypes() const { std::string result = (supertypes ? typeToStr(SuperType(supertypes)) + " " : "") + typeToStr(CardType(cardTypes)) + (artifactType ? std::string(" ") + typeToStr(artifactType) : "") + (enchantmentType ? std::string(" ") + typeToStr(enchantmentType) : "") + (spellType ? std::string(" ") + typeToStr(spellType) : "") + (tribalType ? std::string(" ") + typeToStr(tribalType) : "") + (planeswalker ? std::string(" ") + typeToStr(planeswalker->type) : "") ; if( land ) { result += fetchTypes(land->types,&typeToStr<LandType>); } if( creature ) { result += fetchTypes(creature->types,&typeToStr<CreatureType>); } return result; }