예제 #1
0
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();
    }
}
예제 #2
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;
}
예제 #3
0
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();
    }
}