コード例 #1
0
int OracleImporter::startImport()
{
    clear();

    int setCards = 0, setIndex= 0;
    QListIterator<SetToDownload> it(allSets);
    const SetToDownload * curSet;

    while (it.hasNext())
    {
        curSet = & it.next();
        if(!curSet->getImport())
            continue;

        CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName());
        if (!setHash.contains(set->getShortName()))
            setHash.insert(set->getShortName(), set);

        int setCards = importTextSpoiler(set, curSet->getCards());

        ++setIndex;

        emit setIndexChanged(setCards, setIndex, curSet->getLongName());
    }

    emit setIndexChanged(setCards, setIndex, QString());

    // total number of sets
    return setIndex;
}
コード例 #2
0
void OracleImporter::httpRequestFinished(int requestId, bool error)
{
	if (error) {
		QMessageBox::information(0, tr("HTTP"), tr("Error."));
		return;
	}
	if (requestId != reqId)
		return;

	CardSet *set = new CardSet(setsToDownload[setIndex].getShortName(), setsToDownload[setIndex].getLongName());
	if (!setHash.contains(set->getShortName()))
		setHash.insert(set->getShortName(), set);
	
	buffer->seek(0);
	buffer->close();
	int cards = importTextSpoiler(set, buffer->data());
	++setIndex;
	
	if (setIndex == setsToDownload.size()) {
		emit setIndexChanged(cards, setIndex, QString());
		setIndex = -1;
	} else {
		downloadNextFile();
		emit setIndexChanged(cards, setIndex, setsToDownload[setIndex].getLongName());
	}
}
コード例 #3
0
int OracleImporter::startImport()
{
    clear();

    int setCards = 0, setIndex= 0;
    QListIterator<SetToDownload> it(allSets);
    const SetToDownload * curSet;

    // add an empty set for tokens
    CardSet *tokenSet = new CardSet(TOKENS_SETNAME, tr("Dummy set containing tokens"), "Tokens");
    sets.insert(TOKENS_SETNAME, tokenSet);

    while (it.hasNext())
    {
        curSet = & it.next();
        if(!curSet->getImport())
            continue;
            
        CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName(), curSet->getSetType(), curSet->getReleaseDate());
        if (!sets.contains(set->getShortName()))
            sets.insert(set->getShortName(), set);

        int setCards = importTextSpoiler(set, curSet->getCards());

        ++setIndex;
            
        emit setIndexChanged(setCards, setIndex, curSet->getLongName());
    }
    
    emit setIndexChanged(setCards, setIndex, QString());

    // total number of sets
    return setIndex;
}
コード例 #4
0
QString PictureLoader::getPicUrl(CardInfo *card)
{
    if (!picDownload) return QString("");

    CardSet *set = card->getPreferredSet();
    QString picUrl = QString("");

    // if sets have been defined for the card, they can contain custom picUrls
    if(set)
    {
        // first check if Hq is enabled and a custom Hq card url exists in cards.xml
        if(picDownloadHq)
        {
            picUrl = card->getCustomPicURLHq(set->getShortName());
            if (!picUrl.isEmpty())
                return picUrl;
        }

        // then, test for a custom, non-Hq card url in cards.xml
        picUrl = card->getCustomPicURL(set->getShortName());
        if (!picUrl.isEmpty())
            return picUrl;
    }

    // otherwise, fallback to the default url
    picUrl = picDownloadHq ? settingsCache->getPicUrlHq() : settingsCache->getPicUrl();
    picUrl.replace("!name!", QUrl::toPercentEncoding(card->getCorrectedName()));

    if (set) {
        picUrl.replace("!setcode!", QUrl::toPercentEncoding(set->getShortName()));
        picUrl.replace("!setname!", QUrl::toPercentEncoding(set->getLongName()));
    }
    int muid = card->getPreferredMuId();
    if (muid)
        picUrl.replace("!cardid!", QUrl::toPercentEncoding(QString::number(muid)));

    if (picUrl.contains("!name!") ||
            picUrl.contains("!setcode!") ||
            picUrl.contains("!setname!") ||
            picUrl.contains("!cardid!")) {
        qDebug() << "Insufficient card data to download" << card->getName() << "Url:" << picUrl;
        return QString("");
    }

    return picUrl;
}
コード例 #5
0
ファイル: setsmodel.cpp プロジェクト: Akira586/Cockatrice
QVariant SetsModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid() || (index.column() >= 2) || (index.row() >= rowCount()) || (role != Qt::DisplayRole))
        return QVariant();

    CardSet *set = sets[index.row()];
    switch (index.column()) {
        case 0: return set->getShortName();
        case 1: return set->getLongName();
        default: return QVariant();
    }
}
コード例 #6
0
ファイル: setsmodel.cpp プロジェクト: DINKIN/Cockatrice
QVariant SetsModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid() || (index.column() >= NUM_COLS) || (index.row() >= rowCount()))
        return QVariant();

    CardSet *set = sets[index.row()];

    if ( role == Qt::CheckStateRole && index.column() == EnabledCol )
        return static_cast< int >( enabledSets.contains(set) ? Qt::Checked : Qt::Unchecked );

    if (role != Qt::DisplayRole)
        return QVariant();

    switch (index.column()) {
        case SortKeyCol: return QString("%1").arg(set->getSortKey(), 8, 10, QChar('0'));
        case IsKnownCol: return set->getIsKnown();
        case SetTypeCol: return set->getSetType();
        case ShortNameCol: return set->getShortName();
        case LongNameCol: return set->getLongName();
        case ReleaseDateCol: return set->getReleaseDate().toString(Qt::ISODate);
        default: return QVariant();
    }
}
コード例 #7
0
int CardInfo::getPreferredMuId()
{
    CardSet *set = getPreferredSet();
    return set ? muIds[set->getShortName()] : 0;
}