コード例 #1
0
void DlgEditTokens::tokenSelectionChanged(const QModelIndex &current, const QModelIndex & /* previous */)
{
    const QModelIndex realIndex = cardDatabaseDisplayModel->mapToSource(current);
    CardInfo *cardInfo = current.row() >= 0 ? cardDatabaseModel->getCard(realIndex.row()) : cardDatabaseModel->getDatabase()->getCard();
    if (!cardInfo->getName().isEmpty())
        currentCard = cardInfo;
    else
        currentCard = 0;
    
    nameEdit->setText(cardInfo->getName());
    const QString cardColor = cardInfo->getColors().isEmpty() ? QString() : (cardInfo->getColors().size() > 1 ? QString("m") : cardInfo->getColors().first());
    colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
    ptEdit->setText(cardInfo->getPowTough());
    annotationEdit->setText(cardInfo->getText());
}
コード例 #2
0
ファイル: carddatabasemodel.cpp プロジェクト: Zors/Cockatrice
bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
{
	CardInfo *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
	
	if (!cardNameBeginning.isEmpty())
		if (!info->getName().startsWith(cardNameBeginning, Qt::CaseInsensitive))
			return false;
	
	if (!cardName.isEmpty())
		if (!info->getName().contains(cardName, Qt::CaseInsensitive))
			return false;
	
	if (!cardText.isEmpty())
		if (!info->getText().contains(cardText, Qt::CaseInsensitive))
			return false;
	
	if (!cardColors.isEmpty())
		if (QSet<QString>::fromList(info->getColors()).intersect(cardColors).isEmpty() && !(info->getColors().isEmpty() && cardColors.contains("X")))
			return false;
		
	if (!cardTypes.isEmpty())
		if (!cardTypes.contains(info->getMainCardType()))
			return false;

	return true;
}