Пример #1
0
UiSyncItem* UiPathPointsItems::askForNewChild(UiSyncItem *i, bool) {
    UiPathPointsItem *item = 0;
    if((i) && (i->parentItem))   item = generateItem(i);
    else                         item = generateItem(0, NxCurvePoint());
    update();
    highlight(item);
    return item;
}
Пример #2
0
void XbelGenerator::generateItem(QTreeWidgetItem *item, int depth)
{
    QString tagName = item->data(0, Qt::UserRole).toString();
    if (tagName == "folder") {
        bool folded = !treeWidget->isItemExpanded(item);
        out << indent(depth) << "<folder folded=\"" << (folded ? "yes" : "no")
                             << "\">\n"
            << indent(depth + 1) << "<title>" << escapedText(item->text(0))
                                 << "</title>\n";

        for (int i = 0; i < item->childCount(); ++i)
            generateItem(item->child(i), depth + 1);

        out << indent(depth) << "</folder>\n";
    } else if (tagName == "bookmark") {
        out << indent(depth) << "<bookmark";
        if (!item->text(1).isEmpty())
            out << " href=" << escapedAttribute(item->text(1));
        out << ">\n"
            << indent(depth + 1) << "<title>" << escapedText(item->text(0))
                                 << "</title>\n"
            << indent(depth) << "</bookmark>\n";
    } else if (tagName == "separator") {
        out << indent(depth) << "<separator/>\n";
    }
}
Пример #3
0
void LootBox::action()
{
	Message *m = State::inst().getMessage();
	Player *p = State::inst().getPlayer();

	if (open)
	{
		m->append("This box is open, you probably want to go back now using 'go center'..");

		return;
	}

	Item *item = generateItem();

	m->append("You have found a loot box! "
		"It contains the following: ");

	m->append(item->getName()
		+ " with stat of "
		+ std::to_string(item->getStat())
		+ ", it is now in your inventory");

	p->getInventory()->putItem(item);
	open = true;
}
Пример #4
0
void KNMusicCategoryModel::resetModel()
{
    //Clear the model.
    clear();
    //Add initial item: the blank item.
    QStandardItem *currentItem=generateItem(m_noCategoryText);
    appendRow(currentItem);
}
Пример #5
0
void WorldPhysics::generateItems() {
  if (!items.empty()) {
    for (int  i=0;i<items.size();i++) {
      delete items[i];
    }
    items.clear();
  }
  for (int  i=0;i<MAX_ITEMS;i++) {
    items.push_back(generateItem());
  }
}
Пример #6
0
bool XmltvIdGenerator::write(PlaylistModel *model)
{
    if (!_file->open(QFile::WriteOnly | QFile::Text))
        return false;

    _out.setDevice(_file);
    _out.setCodec("UTF-8");

    for (int i = 0; i < model->rowCount(); i++) {
        generateItem(model->row(i));
    }
    return true;
}
Пример #7
0
//对生成的道具列表进行更新管理
void ItemManager::update(float dt, cocos2d::Node *render_node, IDisplayObject *pCollisionTarget)
{
    mDistanceVar += dt * COURCESPEED;
    
    updateItemPosition(dt);
    
    testCollision(render_node,pCollisionTarget);
    
    if (mDistanceVar >= ITEMDISTANCE) {
        mDistanceVar = mDistanceVar - ITEMDISTANCE;
        generateItem(render_node);
    }
}
Пример #8
0
bool XbelGenerator::write(QIODevice *device)
{
    out.setDevice(device);
    out.setCodec("UTF-8");
    out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        << "<!DOCTYPE xbel>\n"
        << "<xbel version=\"1.0\">\n";

    for (int i = 0; i < treeWidget->topLevelItemCount(); ++i)
        generateItem(treeWidget->topLevelItem(i), 1);

    out << "</xbel>\n";
    return true;
}
Пример #9
0
Item::Item(itemType newType)
{
    type = newType;
    yPos = 0;
    xPos = 0;
    hpBonus = 0;
    spBonus = 0;
    strBonus = 0;
    defBonus = 0;
    spdBonus = 0;
    hpHealAmount = 0;
    spHealAmount = 0;
    generateItem();
}
Пример #10
0
bool CSVGenerator::write(PlaylistModel *model)
{
    if (!_file->open(QFile::WriteOnly | QFile::Text))
        return false;

    _out.setDevice(_file);
    _out.setCodec("UTF-8");
    _out << QObject::tr("Number") << ";"
         << QObject::tr("Channel") << ";"
         << QObject::tr("URL") << ";"
         << QObject::tr("Categories") << ";"
         << QObject::tr("Language") << ";"
         << QObject::tr("EPG ID") << "\n";

    for (int i = 0; i < model->rowCount(); i++) {
        generateItem(model->row(i));
    }
    return true;
}
Пример #11
0
/**
 * Add records to first shard for a single Kind
 */
MojErr MojDbShardManagerTest::createShardObjects1 (MojDb& db, MojDbShardInfo& shard)
{
    MojObject objKind;
    MojString kindId;

    MojErr err = kindId.assign(_T("TestShard1:1"));
    MojErrCheck(err);
    err = objKind.putString(_T("_kind"), kindId.data());
    MojErrCheck(err);

    //generate
    err = generateItem(shard);
    MojErrCheck(err);

    err = addKind(TestShardKind1Str, db);
    MojErrCheck(err);
    err = verifyKindExistance(kindId, db);
    MojErrCheck(err);

    //store shard info
    err = db.shardEngine()->put(shard);
    MojErrCheck(err);

    //add record
    MojObject record;
    err = record.putString(_T("_kind"), kindId.data());
    MojErrCheck(err);

    //add value
    MojObject objId(static_cast<MojInt32>(shard.id));
    err = record.put(_T("recId"), objId);
    MojErrCheck(err);

    //put
    MojString strShardId;
    MojDbShardEngine::convertId(shard.id, strShardId);
    err = db.put(record, MojDb::FlagNone, MojDbReq(), strShardId);
    MojErrCheck(err);

    return MojErrNone;
}
Пример #12
0
void KNMusicCategoryModel::onCategoryRecover(const QList<QStandardItem *> &musicRow)
{
    //Check if it need to be add to blank item.
    QString categoryText=musicRow.at(m_categoryIndex)->text();
    if(categoryText.isEmpty())
    {
        QModelIndex resultIndex=index(0,0);
        setData(resultIndex,
                data(resultIndex, CategoryItemSizeRole).toInt()+1,
                CategoryItemSizeRole);
        setData(resultIndex,
                1,
                CategoryItemVisibleRole);
        return;
    }
    //Search the category text.
    QModelIndexList results=
            match(index(1,0),
                  Qt::DisplayRole,
                  categoryText,
                  1,
                  Qt::MatchFixedString | Qt::MatchCaseSensitive);
    if(results.isEmpty())
    {
        //We need to generate a new item for it.
        QStandardItem *item=generateItem(categoryText);
        item->setData(1, CategoryItemSizeRole);
        item->setData(musicRow.at(Name)->data(ArtworkKeyRole),
                      CategoryArtworkKeyRole);
        appendRow(item);
    }
    else
    {
        //Add the counter of the result.
        QModelIndex resultIndex=results.first();
        setData(resultIndex,
                data(resultIndex, CategoryItemSizeRole).toInt()+1,
                CategoryItemSizeRole);
    }
}
Пример #13
0
void UiPathPointsItems::update() {
    quint16 currentIndex = 0;
    if((treeWidget()->currentItem()) && (((UiSyncItem*)treeWidget()->currentItem())->parentItem))
        currentIndex = ((UiPathPointsItem*)treeWidget()->currentItem())->index;

    //Existing
    QList<UiPathPointsItem*> childrenItems;
    for(quint16 i = 0 ; i < childCount() ; i++)
        childrenItems << (UiPathPointsItem*)child(i);

    for(quint16 i = 0 ; i < count() ; i++) {
        UiPathPointsItem *item = 0;
        for(quint16 j = 0 ; j < childrenItems.count() ; j++) {
            if(at(i) == childrenItems.at(j)->point) {
                item = childrenItems.at(j);
                childrenItems.removeAt(j);
                break;
            }
        }
        if(item)    item->index = i;
        else        generateItem(i, at(i), false);
    }

    //Remove exitings
    foreach(UiPathPointsItem *childrenItem, childrenItems)
        delete childrenItem;

    treeWidget()->sortItems(0, Qt::AscendingOrder);
    treeWidget()->expandItem(this);
    dataChanged();
    for(quint16 i = 0 ; i < childCount() ; i++) {
        if(((UiPathPointsItem*)child(i))->index == currentIndex) {
            treeWidget()->setCurrentItem(child(i));
            treeWidget()->scrollToItem(child(i));
            break;
        }
    }
}
Пример #14
0
/**
 * testShardEngine
 */
MojErr MojDbShardManagerTest::testShardEngine (MojDbShardEngine* ip_eng)
{
    MojAssert(ip_eng);

    MojErr err;
    MojUInt32 id;
    MojString str;
    bool found;

    //get shard by wrong id
    MojDbShardInfo info;
    err = ip_eng->get(0xFFFFFFFE, info, found);
    MojTestErrCheck(err);
    MojTestAssert(!found);

    //store sample shard info
    MojDbShardInfo shardInfo;
    generateItem(shardInfo);
    shardInfo.mountPath.assign("/tmp/db8-test/media01");
    id = shardInfo.id;
    err = ip_eng->put(shardInfo);
    MojTestErrCheck(err);

    //get info
    err = ip_eng->get(id, shardInfo, found);
    MojTestErrCheck(err);
    MojTestAssert(found);

    if (shardInfo.mountPath.compare("/tmp/db8-test/media01") != 0)
        err = MojErrDbVerificationFailed;

    MojTestErrCheck(err);

    //set activity flag, read and verify it
    shardInfo.active = true;
    err = ip_eng->update(shardInfo);
    MojTestErrCheck(err);

    err = ip_eng->get(id, shardInfo, found);
    MojTestErrCheck(err);
    MojTestAssert(found);

    if (!shardInfo.active)
        err = MojErrDbVerificationFailed;

    MojTestErrCheck(err);

    //check existance of id, even for wrong id
    err = ip_eng->isIdExist(id, found);
    MojTestErrCheck(err);

    if (!found)
        err = MojErrDbVerificationFailed;
    MojTestErrCheck(err);

    err = ip_eng->isIdExist(0xFFFFFFFF, found);
    MojTestErrCheck(err);

    if (found)
        err = MojErrDbVerificationFailed;
    MojTestErrCheck(err);

    return err;
}
Пример #15
0
UiPathPointsItem* UiPathPointsItems::generateItem(UiSyncItem *otherItem, bool doInsert) {
    if(otherItem->parentItem)   return generateItem(((UiPathPointsItem*)otherItem)->index+1, ((UiPathPointsItem*)otherItem)->point, doInsert);
    else                        return 0;
}
Пример #16
0
bool UiPathPointsItems::askForPaste(UiSyncItem*, const QList<UiSyncItem*> &listItems) {
    foreach(UiSyncItem *listItem, listItems)
        generateItem(listItem);
    update();
    return false;
}