Example #1
0
void TierWindow::addNewCategory(const QString &name)
{
    TierNode *t = dataTree->getNode(name);

    if (t) {
        QMessageBox::information(this, "Name Taken", "The name is already taken, the category won't be created");
        return;
    }

    TierCategory *c = new TierCategory();
    c->changeName(name);

    dataTree->root.appendChild(c);

    updateTree();
}
Example #2
0
void TierWindow::deleteCurrent()
{
    QMessageBox::StandardButton answer = QMessageBox::question(this, "Deletion of " + currentEdit,
        QString("Are you sure you want to delete the tier/category %1? If you do so, the data will be definitely lost, and if it's a category all subtiers/categories will be lost too.")
        .arg(currentEdit), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);

    if (answer == QMessageBox::Yes) {
        TierNode *n;
        if (currentType == TierT)
            n = currentTier;
        else
            n = currentTierCat;
        TierCategory *parent = dataTree->getParentCategory(n);
        parent->kill(n);
        clearCurrentEdit();
        updateTree();
    }
}
Example #3
0
void TierWindow::updateTier()
{
    helper->applyVals();

    if (currentEdit != currentTier->name()) {
        /* Prevent to have duplicate names */
        if (dataTree->getNode(currentEdit)) {
            currentEdit = currentTier->name();
            QMessageBox::information(this, "Name Taken", "The name is already taken, so the old one will stay");
        } else {
            currentTier->changeName(currentEdit);
        }
    }

    currentTier->importBannedItems(items);
    currentTier->importBannedPokes(pokemons);
    currentTier->importBannedMoves(moves);
    currentTier->importBannedZMoves(zmoves);
    currentTier->importBannedAbilities(abilities);
    currentTier->importRestrictedPokes(restrPokemons);

    int clRes = 0;
    for (int i = 0; i < ChallengeInfo::numberOfClauses; i++) {
        if (clauses[i])
            clRes |= 1 << i;
    }
    currentTier->clauses = clRes;

    TierCategory *c = dataTree->getParentCategory(currentTier);
    if (c->name() != parent) {
        c->removeChild(currentTier);
        /* If the xml file is malformed, and has a tier and a category with the same name, it can crash here */
        TierCategory *c = (TierCategory*)dataTree->getNode(parent);
        c->appendChild(currentTier);
    }

    updateTree();
}
Example #4
0
void TierWindow::updateCategory()
{
    helper->applyVals();

    if (currentEdit != currentTierCat->name()) {
        /* Prevent to have duplicate names */
        if (dataTree->getNode(currentEdit)) {
            currentEdit = currentTierCat->name();
            QMessageBox::information(this, "Name Taken", "The name is already taken, so the old one will stay");
        } else {
            currentTierCat->changeName(currentEdit);
        }
    }

    TierCategory *c = dataTree->getParentCategory(currentTierCat);
    if (c->name() != parent && currentTierCat->name() != parent) {
        c->removeChild(currentTierCat);
        /* If the xml file is malformed, and has a tier and a category with the same name, it can crash here */
        TierCategory *c = (TierCategory*)dataTree->getNode(parent);
        c->appendChild(currentTierCat);
    }

    updateTree();
}