Exemplo n.º 1
0
LoadStatus CardDatabase::loadCardDatabase(const QString &path, bool tokens)
{
    LoadStatus tempLoadStatus = NotLoaded;
    if (!path.isEmpty())
        tempLoadStatus = loadFromFile(path, tokens);

    if (tempLoadStatus == Ok) {
        SetList allSets;
        QHashIterator<QString, CardSet *> setsIterator(sets);
        while (setsIterator.hasNext())
            allSets.append(setsIterator.next().value());
        allSets.sortByKey();
        for (int i = 0; i < allSets.size(); ++i)
            allSets[i]->setSortKey(i);

        emit cardListChanged();
    }

    if (!tokens) {
        loadStatus = tempLoadStatus;
        qDebug() << "loadCardDatabase(): Path = " << path << " Status = " << loadStatus;
    }


    return tempLoadStatus;
}
Exemplo n.º 2
0
CardSet* CardInfo::getPreferredSet()
{
    if(sets.isEmpty())
        return 0;
    SetList sortedSets = sets;
    sortedSets.sortByKey();
    return sortedSets.first();
}
Exemplo n.º 3
0
void CardDatabase::checkUnknownSets()
{
    SetList sets = getSetList();

    // no set is enabled. Probably this is the first time running trice
    if(!sets.getEnabledSetsNum())
    {
        sets.guessSortKeys();
        sets.sortByKey();
        sets.enableAll();

        detectedFirstRun = true;
        return;
    }

    int numUnknownSets = sets.getUnknownSetsNum();
    // no unkown sets. 
    if(!numUnknownSets)
        return;

    QMessageBox msgbox(QMessageBox::Question, tr("New sets found"), tr("%1 new set(s) have been found in the card database. Do you want to enable them?").arg(numUnknownSets), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);

    switch(msgbox.exec())
    {
        case QMessageBox::No:
            sets.markAllAsKnown();
            break;
        case QMessageBox::Yes:
            sets.enableAllUnknown();
            break;
        default:
            break;
    }

    return;
}