/* * fscanf(fpin, " '%[^']' %d %f %f", name &damage, &cost, &weight */ item_t *ReadItemsFromFile(char *file) { FILE *ifp; int damage; item_t *list, *basep = NULL; float cost, weight; char name[32]; ifp = fopen(file, "r"); assert(ifp); while(1) { if(fscanf(ifp, " '%[^'] %d %f %f", name, &damage, &cost, &weight) != 4) break; else if(basep == NULL) basep = list = newItem(list, name, getLength(name), damage, cost, weight); else list = list->next = newItem(list, name, getLength(name), damage, cost, weight); fprintf(stdout, "Testing: %d\n", list->dam); } fclose(ifp); return basep; }
// Build an array from input text. const char* aJsonClass::parseArray(aJsonObject *item, const char *value) { aJsonObject *child; if (*value != '[') return 0; // not an array! item->type = aJson_Array; value = skip(value + 1); if (*value == ']') return value + 1; // empty array. item->child = child = newItem(); if (!item->child) return 0; // memory fail value = skip(parseValue(child, skip(value))); // skip any spacing, get the value. if (!value) return 0; while (*value == ',') { aJsonObject *new_item; if (!(new_item = newItem())) return 0; // memory fail child->next = new_item; new_item->prev = child; child = new_item; value = skip(parseValue(child, skip(value + 1))); if (!value) return 0; // memory fail } if (*value == ']') return value + 1; // end of array return 0; // malformed. }
void CResizableImage::AddAnchor(RECT PixelSurface, SIZE LTType, SIZE RBType, ZoomType ZoomVal) { SIZE tmpSizeLT = {PixelSurface.left,PixelSurface.top}, tmpSizeRB = {PixelSurface.right,PixelSurface.bottom}; PixelToHiMetric(&tmpSizeLT,&tmpSizeLT); PixelToHiMetric(&tmpSizeRB,&tmpSizeRB); RECT HiSurface; HiSurface.left = tmpSizeLT.cx; HiSurface.top = tmpSizeLT.cy; HiSurface.right = tmpSizeRB.cx; HiSurface.bottom = tmpSizeRB.cy; Layout newItem(HiSurface, PixelSurface, LTType, RBType, ZoomVal); m_SurfacesList.push_back(newItem); }
/* * Constructs a ListEdit as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * true to construct a modal dialog. */ ListEdit::ListEdit(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : QDialog(parent, name, modal, fl) { setupUi(this); // signals and slots connections connect(_ok, SIGNAL(clicked()), this, SLOT(accept())); connect(_cancel, SIGNAL(clicked()), this, SLOT(reject())); connect(_new, SIGNAL(clicked()), this, SLOT(newItem())); connect(_up, SIGNAL(clicked()), this, SLOT(moveItemUp())); connect(_edit, SIGNAL(clicked()), this, SLOT(editItem())); connect(_down, SIGNAL(clicked()), this, SLOT(moveItemDown())); connect(_delete, SIGNAL(clicked()), this, SLOT(deleteItem())); }
//Add a fresh scope with a given name Scope& Scope::AppendScope(const std::string& name) { Datum d; d.SetType(Datum::TABLE); Scope *s = new Scope(10); s->mParent = this; d.Set(s); std::pair <std::string, Datum> newItem(name, d); Hashmap<std::string, Datum>::Iterator newLocation = mHashMap.Insert(newItem); std::pair <std::string, Datum> *itemAdress = &(*newLocation); mOrderVector.PushBack(itemAdress); return *s; }
void ImporterWizard::load(ObjImporter::SceneInfo& si) { QTreeWidget* t = m_ui->tree; t->clear(); QList<QTreeWidgetItem*> items; m_objects = new QTreeWidgetItem(t, QStringList() << "Objects"); m_models = new QTreeWidgetItem(t, QStringList() << "Models"); m_animations = new QTreeWidgetItem(t, QStringList() << "Animations"); m_cameras = new QTreeWidgetItem(t, QStringList() << "Cameras"); m_lights = new QTreeWidgetItem(t, QStringList() << "Lights"); m_materials = new QTreeWidgetItem(t, QStringList() << "Materials"); m_textures = new QTreeWidgetItem(t, QStringList() << "Textures"); items << m_objects << m_models << m_animations << m_cameras << m_lights << m_materials << m_textures; t->addTopLevelItems(items); QMap<QString, QString>::const_iterator it; for (it = si.objects.begin(); it != si.objects.end(); ++it) { newItem(m_objects, it); newItem(m_models, it); } for (it = si.animations.begin(); it != si.animations.end(); ++it) { QTreeWidgetItem* x = newItem(m_animations, it); x->setCheckState(0, Qt::Unchecked); x->setDisabled(true); } for (it = si.cameras.begin(); it != si.cameras.end(); ++it) { QTreeWidgetItem* x = newItem(m_animations, it); x->setCheckState(0, Qt::Unchecked); x->setDisabled(true); } for (it = si.lights.begin(); it != si.lights.end(); ++it) { QTreeWidgetItem* x = newItem(m_lights, it); x->setCheckState(0, Qt::Unchecked); x->setDisabled(true); } for (it = si.materials.begin(); it != si.materials.end(); ++it) { newItem(m_materials, it); } for (it = si.textures.begin(); it != si.textures.end(); ++it) { newItem(m_textures, it); } foreach (QTreeWidgetItem* i, items) { i->setFirstColumnSpanned(true); i->setExpanded(true); if (i->childCount() == 0) i->setDisabled(true); }
void IconSettings::cmdAdd_Click(){ if (!cboxDlls->currentText().isEmpty()){ twDlls->insertRow (0); std::auto_ptr<QTableWidgetItem> newItem (new QTableWidgetItem(cboxDlls->currentText())); newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); twDlls->setItem(0, 0, newItem.release()); newItem.reset(new QTableWidgetItem(cboxOveride->currentText())); newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); twDlls->setItem(0, 1, newItem.release()); } twDlls->resizeRowsToContents(); twDlls->resizeColumnsToContents(); twDlls->horizontalHeader()->setStretchLastSection(TRUE); return; }
vertex* addNode(graph *g, int i){ vertex *newV; item *newI; newV=searchV(g,i); if (newV!= NULL) return newV; newV=newVertex(i); newI=newItem(newV); //if(isEmptyList(g->vertices)) printf("Empty graph!!\n"); // debug addHeadNodeList(newI, g->vertices); //if(isEmptyList(g->vertices)) printf("Empty graph after!!\n"); // debug return newV; }
Scene::Item_id Scene::addItem(Scene_item* item) { Bbox bbox_before = bbox(); m_entries.push_back(item); connect(item, SIGNAL(itemChanged()), this, SLOT(itemChanged())); if(bbox_before + item->bbox() != bbox_before) { Q_EMIT updated_bbox(); } QAbstractListModel::beginResetModel(); Q_EMIT updated(); QAbstractListModel::endResetModel(); Item_id id = m_entries.size() - 1; Q_EMIT newItem(id); return id; }
/* native interface */ JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRightsManager_nativeInstallDrmRights (JNIEnv * env, jobject rightsManager, jobject data, jint len, jint mimeType, jobject rights) { int32_t id; T_DRM_Input_Data inData; DrmData* drmInData; jclass cls; jmethodID mid; T_DRM_Rights_Info rightsInfo; switch (mimeType) { case JNI_DRM_MIMETYPE_RIGHTS_XML: mimeType = TYPE_DRM_RIGHTS_XML; break; case JNI_DRM_MIMETYPE_RIGHTS_WBXML: mimeType = TYPE_DRM_RIGHTS_WBXML; break; case JNI_DRM_MIMETYPE_MESSAGE: mimeType = TYPE_DRM_MESSAGE; break; default: return JNI_DRM_FAILURE; } drmInData = newItem(); if (NULL == drmInData) return JNI_DRM_FAILURE; drmInData->env = env; drmInData->pInData = &data; drmInData->len = len; inData.inputHandle = (int32_t)drmInData; inData.mimeType = mimeType; inData.getInputDataLength = getInputStreamDataLength; inData.readInputData = readInputStreamData; memset(&rightsInfo, 0, sizeof(T_DRM_Rights_Info)); if (DRM_FAILURE == SVC_drm_installRights(inData, &rightsInfo)) return JNI_DRM_FAILURE; freeItem(drmInData); return setRightsFields(env, rights, &rightsInfo); }
bool Handler::endElement(const QString &, const QString &, const QString & qName) { if (qName == "title" && inTitle) inTitle = false; else if (qName == "link" && inLink) inLink = false; else if (qName == "item") { if (!titleString.isEmpty() && !linkString.isEmpty()) emit newItem(titleString, linkString); inItem = false; titleString = ""; linkString = ""; } return true; }
void UmlClass::importIdlConstant(UmlItem * parent, const Q3CString & id, const Q3CString & s, const Q3CString & doc, Q3Dict<Q3CString> & prop) { // use a class to define the constant ! UmlClass * x; if ((x = UmlClass::create(parent, legalName(s))) == 0) { UmlCom::trace("<br>cannot create class '" + s + "' in " + parent->fullName()); throw 0; } newItem(x, id); x->lang = Corba; x->set_Stereotype("constant"); if (!doc.isEmpty()) x->set_Description(doc); Q3CString type; Q3CString value; Q3CString * v; if ((v = prop.find("CORBA/ImplementationType")) != 0) { type = *v; prop.remove("CORBA/ImplementationType"); } if ((v = prop.find("CORBA/ConstValue")) != 0) { if (!v->isEmpty()) value = " = " + *v; prop.remove("CORBA/ConstValue"); } Q3CString d = IdlSettings::constDecl(); int index; if ((index = d.find("${type}")) != -1) d.replace(index, 7, type); if ((index = d.find("${value}")) != -1) d.replace(index, 8, value); x->setProperties(prop); x->set_IdlDecl(d); }
void MaMainWindow::newChildItem() { MaTreeWidget* treeWidget = curTreeWidget(); MaItem* curItem = this->curItem(); if (NULL == curItem) return; if (!curItem->isParentItem()) { QString oldItemPath(curItem->absPath()); QTreeWidgetItem* curTreeItem = treeWidget->currentItem(); MaParentItem* parItem = _STORE->convertItemToParentItem(curItem); parItem->save(false); QFile::remove(oldItemPath); curTreeItem->setData(3, Qt::EditRole, qVariantFromValue((void*) parItem)); curTreeItem->setIcon(0, mParentIcon); } newItem(); }
void CAlgorithmPanel::removeAlgorithm() { if(usedAlgorithms->selectedItems().size() != 0) { usedAlgorithms->takeItem(usedAlgorithms->row(usedAlgorithms->currentItem())); imageFilters->remove(processignImagePath); for(int i = 0; i < usedAlgorithms->count(); i++) { QListWidgetItem newItem(usedAlgorithms->item(i)->text()); imageFilters->insert(processignImagePath, newItem); } } else { messageBox.information(0,"VSDF","First select used algorithm to remove."); } }
void SinglePopupEditor::contextNewEpilogue() { PopupTreeWidgetItem * it = m_pLastSelectedItem ? (PopupTreeWidgetItem *)m_pLastSelectedItem->parent() : nullptr; PopupTreeWidgetItem * after = it ? (PopupTreeWidgetItem *)it->child(0) : (PopupTreeWidgetItem *)m_pTreeWidget->topLevelItem(0); if(after) { while(m_pTreeWidget->itemAbove(after)) { if(after->parent() == m_pTreeWidget->itemAbove(after)->parent()) after = (PopupTreeWidgetItem *)m_pTreeWidget->itemAbove(after); } } else { after = it; } m_pTreeWidget->setCurrentItem(newItem(it, after, PopupTreeWidgetItem::Epilogue)); }
void Hashtable::put(const void* key, size_t len, void* value) { unsigned int n = bucketNum(key, len); List* l = (List*)m_buckets.itemAtFast(n); if (! l) { bool added = m_buckets.replaceItem(n, l = new List); ASSERT(added); (void)added; } ASSERT(m_buckets.itemAtFast(n)); Item* i = find(l, key, len); if (i) { deleteValue(i->value); i->value = value; } else { i = newItem(key, len, value); l->add(i); } }
void ColorDialog::addToFavorites() { QTreeWidgetItem *item = ui_->listColors->currentItem(); if (!item) return; int cid = item->data(0, Qt::UserRole).toInt(); if (favoritesMap_.contains(cid)) return; QTreeWidgetItem *newitem = newItem(ui_->listFavorites->invisibleRootItem(), ldraw::color(cid).get_entity()); resetFavoritesMap(); ui_->listFavorites->setCurrentItem(newitem); changed_ = true; }
void UmlUseCase::import(File & f, UmlItem * parent) { Q3CString s; if (f.read(s) != STRING) f.syntaxError(s, "use case's name"); Q3CString id; Q3CString ste; Q3CString doc; Q3Dict<Q3CString> prop; Q3CString s2; int k; do { k = f.readDefinitionBeginning(s2, id, ste, doc, prop); } while (id.isEmpty()); UmlUseCase * x; if (UmlItem::scanning) { if ((x = UmlBaseUseCase::create(parent, s)) == 0) { UmlCom::trace("<br>cannot create use case '" + s + "' in " + parent->fullName()); throw 0; } newItem(x, id); if (!doc.isEmpty()) x->set_Description(doc); x->setProperties(prop); } else if ((x = (UmlUseCase *) findItem(id, anUseCase)) == 0) { UmlCom::trace("<br>unknown use case '" + s + "' in " + parent->fullName()); throw 0; } f.unread(k, s2); x->Uc::import(f); }
/* native interface */ JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRawContent_nativeConstructDrmContent (JNIEnv * env, jobject rawContent, jobject data, jint len, jint mimeType) { int32_t id; T_DRM_Input_Data inData; DrmData* drmInData; switch (mimeType) { case JNI_DRM_MIMETYPE_MESSAGE: mimeType = TYPE_DRM_MESSAGE; break; case JNI_DRM_MIMETYPE_CONTENT: mimeType = TYPE_DRM_CONTENT; break; default: return JNI_DRM_FAILURE; } drmInData = newItem(); if (NULL == drmInData) return JNI_DRM_FAILURE; drmInData->env = env; drmInData->pInData = &data; drmInData->len = len; if (JNI_DRM_FAILURE == addItem(drmInData)) return JNI_DRM_FAILURE; inData.inputHandle = (int32_t)drmInData; inData.mimeType = mimeType; inData.getInputDataLength = getInputStreamDataLength; inData.readInputData = readInputStreamData; id = SVC_drm_openSession(inData); if (id < 0) return JNI_DRM_FAILURE; drmInData->id = id; return id; }
void db_key::showContextMenu(QContextMenuEvent *e, const QModelIndex &index) { QMenu *menu = new QMenu(mainwin); currentIdx = index; pki_key *key = static_cast<pki_key*>(currentIdx.internalPointer()); menu->addAction(tr("New Key"), this, SLOT(newItem())); menu->addAction(tr("Import"), this, SLOT(load())); if (index != QModelIndex()) { menu->addAction(tr("Rename"), this, SLOT(edit())); menu->addAction(tr("Show Details"), this, SLOT(showItem())); menu->addAction(tr("Delete"), this, SLOT(delete_ask())); menu->addAction(tr("Export"), this, SLOT(store())); if (key->isPrivKey() && !key->isToken()) { switch (key->getOwnPass()) { case pki_key::ptCommon: menu->addAction(tr("Change password"), this, SLOT(setOwnPass())); break; case pki_key::ptPrivate: menu->addAction(tr("Reset password"), this, SLOT(resetOwnPass())); break; } } if (key->isToken() && pkcs11::loaded()) { menu->addAction(tr("Change PIN"), this, SLOT(changePin())); menu->addAction(tr("Init PIN with SO PIN (PUK)"), this, SLOT(initPin())); menu->addAction(tr("Change SO PIN (PUK)"), this, SLOT(changeSoPin())); } if (!key->isToken() && pkcs11::loaded()) { menu->addAction(tr("Store on Security token"), this, SLOT(toToken())); } } contextMenu(e, menu); currentIdx = QModelIndex(); return; }
ParameterEdit::ParameterEdit(QWidget* parent, Qt::WindowFlags fl) : QDialog(parent, fl) { setupUi(this); _list->hide(); // parameter lists come from document definitions, so are only visible after a call to setDocument() _list->setDisabled(true); _edit->setDisabled(true); // signals and slots connections connect(_cancel, SIGNAL(clicked()), this, SLOT(reject())); connect(_ok, SIGNAL(clicked()), this, SLOT(accept())); connect(_new, SIGNAL(clicked()), this, SLOT(newItem())); connect(_edit, SIGNAL(clicked()), this, SLOT(edit())); connect(_list, SIGNAL(clicked()), this, SLOT(editItemList())); connect(_delete, SIGNAL(clicked()), this, SLOT(deleteItem())); connect(_table, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(doubleClick(int, int))); connect(_table, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChange())); }
// Parse an object - create a new root, and populate. aJsonObject* aJsonClass::parse(FILE* stream, char** filter) { if (stream == NULL) { return NULL; } aJsonObject *c = newItem(); if (!c) return NULL; /* memory fail */ skip(stream); if (parseValue(c, stream, filter) == EOF) { deleteItem(c); return NULL; } return c; }
void CMainWindow::OnPlaylistItemDblClick(unsigned int index) { const auto& item(m_playlist.GetItem(index)); boost::filesystem::path archivePath; if(item.archiveId != 0) { archivePath = m_playlist.GetArchive(item.archiveId); } if(PlayFile(item.path, archivePath)) { CPlaylist::ITEM newItem(item); CPlaylist::PopulateItemFromTags(newItem, m_tags); m_playlist.UpdateItem(index, newItem); m_currentPlaylistItem = index; m_playlistPanel->SetPlayingItemIndex(index); } }
//Append an item to the list if its not already there. Otherwise, return the existing item Datum& Scope::Append(const std::string& name) { Hashmap<std::string, Datum>::Iterator it = mHashMap.Find(name); //Create a new item if one does not already exist if (it == mHashMap.end()) { Datum d; std::pair <std::string, Datum> newItem(name, d); Hashmap<std::string, Datum>::Iterator newLocation = mHashMap.Insert(newItem); std::pair <std::string, Datum> *itemAdress = &((*newLocation)); mOrderVector.PushBack(itemAdress); return (*newLocation).second; } else { return (*it).second; } }
QGVector::QGVector( const QGVector &a ) // make copy of other vector : QPtrCollection( a ) { len = a.len; numItems = a.numItems; if ( len == 0 ) { vec = 0; return; } vec = NEW( Item, len ); Q_CHECK_PTR( vec ); for ( uint i = 0; i < len; i++ ) { if ( a.vec[i] ) { vec[i] = newItem( a.vec[i] ); Q_CHECK_PTR( vec[i] ); } else { vec[i] = 0; } } }
void BarrelBlock::attack(Player* player, const BlockPos& pos) { BarrelEntity* container = (BarrelEntity*)player->region.getBlockEntity(pos); if(container == nullptr || container->itemInstance == nullptr) return; int stackSize = ((container->itemCount > container->itemInstance->getMaxStackSize()) ? container->itemInstance->getMaxStackSize() : container->itemCount); Inventory* playerInventory = *(Inventory**) (((uintptr_t) player) + 0xD78); // TODO: Do the f*** header of Entity, Mob, Player. ItemInstance newItem(container->itemInstance->getId(), stackSize, container->itemInstance->getAuxValue()); if(!playerInventory->add(newItem)) { player->region.getLevel()->addEntity(std::unique_ptr<Entity>(new ItemEntity(player->region, Vec3(pos), newItem, 1))); } container->itemCount -= stackSize; if(container->itemCount <= 0) container->clear(); container->setChanged(); }
/* * Constructs a ParameterEdit as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * true to construct a modal dialog. */ ParameterEdit::ParameterEdit(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : QDialog(parent, name, modal, fl) { setupUi(this); // signals and slots connections connect(_cancel, SIGNAL(clicked()), this, SLOT(reject())); connect(_ok, SIGNAL(clicked()), this, SLOT(accept())); connect(_new, SIGNAL(clicked()), this, SLOT(newItem())); connect(_edit, SIGNAL(clicked()), this, SLOT(editItem())); connect(_delete, SIGNAL(clicked()), this, SLOT(deleteItem())); _table->horizontalHeader()->setLabel( 0, tr("Active") ); _table->horizontalHeader()->setLabel( 1, tr("Name") ); _table->horizontalHeader()->setLabel( 2, tr("Type") ); _table->horizontalHeader()->setLabel( 3, tr("Value") ); _table->setNumRows(0); }
void ControlList::setStaticContent(const ListItemList* pitems) { const ListItemList& vecItems = *pitems; std::vector<CGUIStaticItemPtr> items; for (unsigned int item = 0; item < vecItems.size(); item++) { ListItem* pItem = vecItems[item]; // NOTE: This code has likely not worked fully correctly for some time // In particular, the click behaviour won't be working. CGUIStaticItemPtr newItem(new CGUIStaticItem(*pItem->item)); items.push_back(newItem); } // set static list IListProvider *provider = new CStaticListProvider(items); ((CGUIBaseContainer *)pGUIControl)->SetListProvider(provider); }
void stackPush(Stack*stack,void*val) { int x; item *i; ENTRY; i=newItem(); DEBUG(-96,"got new item [%x][%x]\n",(int)i,(int)stack->stack); i->next=stack->stack; i->val=val; DEBUG(-96,"Pushed value [%x]\n",(int)val); stack->stack=i; ++stack->depth; i=stack->stack; for(x=0;x<stack->depth;++x) { DEBUG(-127,"stack vals[%i]: [%x]\n",x,(int)i); i=i->next; } EXIT; }
void pTranslationDialog::on_tbReload_clicked() { // reload translations if needed if ( mTranslationManager && mTranslationManager->availableLocales().isEmpty() ) { mTranslationManager->reloadTranslations(); } // keep current locale const QString currentLocale = selectedLocale(); // clear items ui->twLocales->clear(); mRootItems.clear(); // create new ones if ( mTranslationManager ) { foreach ( const QLocale& _locale, mTranslationManager->availableQLocales() ) { const QLocale locale = _locale.language() == QLocale::C ? QLocale( QLocale::English ) : _locale; QTreeWidgetItem* rootItem = this->rootItem( QLocale( locale.language() ) ); if ( rootItem->data( 0, Qt::UserRole ).toString() == locale.name() ) { continue; } rootItem->addChild( newItem( locale ) ); } } // sort items ui->twLocales->sortByColumn( 0, Qt::AscendingOrder ); // restore locale QAbstractItemModel* model = ui->twLocales->model(); QModelIndex index = model->match( model->index( 0, 0 ), Qt::UserRole, currentLocale, 1, Qt::MatchFixedString | Qt::MatchWrap ).value( 0 ); if ( !index.isValid() ) { index = model->match( model->index( 0, 0 ), Qt::UserRole, currentLocale, 1, Qt::MatchStartsWith | Qt::MatchWrap ).value( 0 ); } ui->twLocales->setCurrentIndex( index ); }