/*! * Delets current element or group (with subgroups). * \param item (in) - deleted element or group item. */ void CatalogForm::del_item( Q3ListViewItem * item ) { // cat->groupSelect(getGroupId(item)); qulonglong id = getElementId(item); if(id) { cat->select(id); if(cat->First()) { cat->delElement(); map_el.remove(id); delete item; item = 0; } } else { id = getGroupId(item); if(id) { Q3ValueList<qulonglong> listDeletedId; cat->delGroup(id, listDeletedId); Q3ValueList<qulonglong>::iterator it = listDeletedId.begin(); while(it!= listDeletedId.end()) { if(map_el.contains(*it)) map_el.remove(*it); else if(map_gr.contains(*it)) map_gr.remove(*it); ++it; } delete item; // destructor delete all subitems item = 0; } } }
/*! * Selects current group or element. * \param item (in) - selected element or group item */ void CatalogForm::select( Q3ListViewItem * item ) { qulonglong res = getGroupId(item); if(!res) { res = getElementId(item); cat->select(res); if(!cat->isElementMarkDeleted()) { setId(res); doOk(); } } else { cat->groupSelect(res); if(!cat->isGroupMarkDeleted()) { setId(res); doOk(); } } emit(selected(res)); // return res; }
void cUI::removeElement(int id, float time) { id = getElementId(id); if (id != -1) { if (time <= 0.00f) { element[id].isValid = false; element[id].resetFadeTimer(); } else { element[id].setFadeTimer(time, FADE_OUT); } } }
// --------------------------------------------------------------------------- // ComplexTypeInfo: Setter methods // --------------------------------------------------------------------------- void ComplexTypeInfo::addAttDef(SchemaAttDef* const toAdd) { // Tell this guy the element id of its parent (us) toAdd->setElemId(getElementId()); fAttDefs->put((void*)(toAdd->getAttName()->getLocalPart()), toAdd->getAttName()->getURI(), toAdd); // update and/or create fAttList fAttList->addAttDef(toAdd); }
/*! * Undo marks deleted current element or group (with subgroups). * \param item (in) - marked deleted element or group item. */ void CatalogForm::undo_mark_deleted( Q3ListViewItem * item ) { qulonglong id = getElementId(item); if(id) { cat->select(id); if(cat->First()) { cat->setMarkDeletedElement(id,false); item->setPixmap(0,getElementPixmap()); } } else { id = getGroupId(item); if(id) { // cat->select(QString("id=%1").arg(id),md_group); //if(cat->FirstInGroupTable()) Q3ValueList<qulonglong> listDeletedId; // cat->setMarkDeletedGroup(id, listDeletedId,false); cat->getMarkDeletedList(id, listDeletedId); Q3ValueList<qulonglong>::iterator it = listDeletedId.begin(); while(it != listDeletedId.end()) //first delete elements in this group { if(map_el.contains(*it)) { map_el[*it]->setPixmap(0, getElementPixmap()); cat->setMarkDeletedElement(*it,false); it = listDeletedId.remove(it); } else { ++it; } } it = listDeletedId.begin(); while(it != listDeletedId.end()) //second delete groups { if(map_gr.contains(*it)) { map_gr[*it]->setPixmap(0, getGroupPixmap()); cat->setMarkDeletedGroup(*it,false); it = listDeletedId.remove(it); //map_el[*it]->invalidateHeight();// setHeight(10); } else { ++it; } } } } }
/*! * Marks deleted current element or group (with subgroups). * While for mark deleted items sets ahother pixmap only. * \param item (in) - marked deleted element or group item. */ void CatalogForm::mark_deleted( Q3ListViewItem * item ) { qulonglong id = getElementId(item); if(id) { cat->select(id); // cat->setSelected(true); if(cat->First()) { cat->setMarkDeletedElement(id,true); item->setPixmap(0,getMarkDeletedPixmap()); } } else { id = getGroupId(item); if(id) { loadElements(id); // populate items in group Q3ValueList<qulonglong> listDeletedId; cat->getMarkDeletedList(id,listDeletedId); Q3ValueList<qulonglong>::iterator it = listDeletedId.begin(); while(it != listDeletedId.end()) //first delete elements in this group { if(map_el.contains(*it)) { map_el[*it]->setPixmap(0, getMarkDeletedPixmap()); cat->setMarkDeletedElement(*it,true); it = listDeletedId.remove(it); } else { ++it; } } it = listDeletedId.begin(); while(it != listDeletedId.end()) //second delete groups { if(map_gr.contains(*it)) { map_gr[*it]->setPixmap(0, getMarkDeletedPixmap()); cat->setMarkDeletedGroup(*it,true); it = listDeletedId.remove(it); //map_el[*it]->invalidateHeight();// setHeight(10); } else { ++it; } } } } }
// --------------------------------------------------------------------------- // ComplexTypeInfo: Setter methods // --------------------------------------------------------------------------- void ComplexTypeInfo::addAttDef(SchemaAttDef* const toAdd) { // Fault in the att list if required if (!fAttDefs) faultInAttDefList(); // Tell this guy the element id of its parent (us) toAdd->setElemId(getElementId()); fAttDefs->put((void*)(toAdd->getAttName()->getLocalPart()), toAdd->getAttName()->getURI(), toAdd); // update and/or create fAttList if(!fAttList) ((ComplexTypeInfo*)this)->fAttList = new (fMemoryManager) SchemaAttDefList(fAttDefs,fMemoryManager); fAttList->addAttDef(toAdd); }
// --------------------------------------------------------------------------- // ComplexTypeInfo: Helper methods // --------------------------------------------------------------------------- XMLAttDef* ComplexTypeInfo::findAttr(const XMLCh* const , const unsigned int uriId , const XMLCh* const baseName , const XMLCh* const prefix , const XMLElementDecl::LookupOpts options , bool& wasAdded) const { SchemaAttDef* retVal = 0; // If no att list faulted in yet, then it cannot exist if (fAttDefs) retVal = fAttDefs->get(baseName, uriId); // Fault it in if not found and ask to add it if (!retVal && (options == XMLElementDecl::AddIfNotFound)) { // Fault in the list itself if not already if (!fAttDefs) faultInAttDefList(); // And add a default attribute for this name retVal = new (fMemoryManager) SchemaAttDef ( prefix , baseName , uriId , XMLAttDef::CData , XMLAttDef::Implied , fMemoryManager ); retVal->setElemId(getElementId()); fAttDefs->put((void*)retVal->getAttName()->getLocalPart(), uriId, retVal); // update and/or create fAttList if(!fAttList) ((ComplexTypeInfo*)this)->fAttList = new (fMemoryManager) SchemaAttDefList(fAttDefs,fMemoryManager); fAttList->addAttDef(retVal); wasAdded = true; } else { wasAdded = false; } return retVal; }
/*! * Adds new group. * \param parentItem (in) - parent group. If parent group == 0, group adds in root. */ void CatalogForm::new_group( Q3ListViewItem * parentItem ) { qulonglong id = getGroupId(parentItem); Q3ListViewItem * item; QPixmap pixmap(getGroupPixmap()); //cat->groupSelect( id ); if(!id) { id = getElementId(parentItem); if(id) { cfg_message(0,tr("Can't added group to element")); return; } else { // printf(">>>>id=0\n"); cat->newGroup(id); item = new Q3ListViewItem(ListView); ListView->insertItem(item); } } else { //cat->groupSelect(id); if(cat->isGroupMarkDeleted()) { cfg_message(0,tr("Can't added group to mark deleted group")); return; } cat->newGroup(id); item = new Q3ListViewItem(map_gr[id]); } //item->setText(0,cat->GroupSysValue(fieldListGroup[0]).toString()); item->setPixmap(0,pixmap); map_gr.insert(cat->GroupSysValue("id").toULongLong(),item); edit(item,true); ListView->ensureItemVisible(item); ListView->setCurrentItem(item); ListView->setSelected(item,true); //ListView->setFocus(); }
void CatalogForm::edit( Q3ListViewItem * item, bool afterNew) { // QWidget *wd = topLevelWidget(); aLog::print(aLog::Debug, tr("Catalog Form edit element start")); MainForm * mw = (MainForm*) topLevelWidget(); if(mw) { qulonglong id = getElementId(item); if(id) { aLog::print(aLog::Debug, tr("Catalog Form edit element with id=%1").arg(id)); cat->select(id); if(idElementForm) { if(!cat->isElementMarkDeleted()) { aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idElementForm); if(editForm) { if(afterNew) editForm->setMode(0); else editForm->setMode(1); editForm->Select(id); connect(editForm, SIGNAL(closeForm(qulonglong)), this, SLOT(Refresh(qulonglong))); editForm->show(); } else { aLog::print(aLog::Error, tr("Catalog Form edit element form is null")); } } else cfg_message(0, tr("Can't edit mark deleted element")); } else cfg_message(1,tr("Catalog haven't edit element form")); } else { id = getGroupId(item); aLog::print(aLog::Debug, tr("Catalog Form edit group with id = %1").arg(id)); if(id) { cat->groupSelect(id); if(idGroupForm) { if(!cat->isGroupMarkDeleted()) { aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idGroupForm); if(editForm) { if(afterNew) editForm->setMode(0); else editForm->setMode(1); editForm->SelectGroup(id); connect(editForm, SIGNAL(closeForm(qulonglong)), this, SLOT(Refresh(qulonglong))); editForm->show(); } else { aLog::print(aLog::Error, tr("Catalog Form edit group form is null")); } } else cfg_message(0, tr("Can't edit mark deleted group")); } else cfg_message(1,tr("Catalog haven't edit group form")); } } } else { aLog::print(aLog::Error, tr("Catalog Form main widget is not 'MainForm'")); } }
/** * Modifiers */ __INLINE void ElementRef::addAttr (AttributeRef& attr) { #if PARANOID AssertBug ( &document == &(attr.document), "AttributeRef and ElementRef do not have the same document !\n" ); AssertBug ( attr.getParentElementPtr() == NullPtr || attr.getParentElementPtr() == getElementPtr(), "AttributeRef already added to another ElementRef \n" ); AssertBug ( attr.getAttributePtr() != NullPtr, "AttributeRef not defined !\n" ); #endif for (AttributeRef myAttr = getFirstAttr(); myAttr; myAttr = myAttr.getNext()) { if (myAttr.getKeyId() == attr.getKeyId() && myAttr.getAttributeType() == attr.getAttributeType()) { NotImplemented("Duplicate attributes : key=%x:%s, type=%x, attribute=%s\n", myAttr.getKeyId(), myAttr.getKey().c_str(), myAttr.getAttributeType(), myAttr.generateVersatileXPath().c_str()); } } ElementSegment* me = getMe<Write>(); __checkElementFlag_HasAttributesAndChildren(me->flags); if (attr.getAttributeType() == AttributeType_NamespaceAlias && !(me->flags & ElementFlag_HasNamespaceAlias)) { getDocumentAllocator().alter(me); me->flags |= ElementFlag_HasNamespaceAlias; getDocumentAllocator().protect(me); } SegmentPtr nextAttrPtr = NullPtr; if (me->attributesAndChildren.attrPtr == NullPtr) { getDocumentAllocator().alter(me); me->attributesAndChildren.attrPtr = attr.getAttributePtr(); getDocumentAllocator().protect(me); } else { SegmentPtr lastAttrPtr = me->attributesAndChildren.attrPtr; AttributeSegment* lastAttrSeg = getDocumentAllocator().getSegment<AttributeSegment, Read>(lastAttrPtr); while (lastAttrSeg->nextPtr != NullPtr) { lastAttrPtr = lastAttrSeg->nextPtr; lastAttrSeg = getDocumentAllocator().getSegment<AttributeSegment, Read>(lastAttrPtr); } getDocumentAllocator().authorizeWrite(lastAttrPtr, lastAttrSeg); getDocumentAllocator().alter(lastAttrSeg); lastAttrSeg->nextPtr = attr.getAttributePtr(); getDocumentAllocator().protect(lastAttrSeg); } AttributeSegment * attrSeg = getDocumentAllocator().getSegment<AttributeSegment, Read>(attr.getAttributePtr()); getDocumentAllocator().alter(attrSeg); attrSeg->nextPtr = nextAttrPtr; getDocumentAllocator().protect(attrSeg); attr.setParentElementPtr(getElementPtr()); Log_Element ( "Added attr on elementRef=%llx:%x (%llx, ref at %p), attr=%x (elt=%llx,attr=%llx, ref at %p)\n", getElementId(), getKeyId(), getElementPtr(), this, attr.getKeyId(), attr.getParentElementPtr(), attr.getAttributePtr(), &attr ); if (attr.isBaseType()) { getDocument().appendJournal(*this, JournalOperation_UpdateAttribute, *this, attr.getKeyId()); } }
/* * Textual contents setting */ __INLINE void ElementRef::setText (const char* text, DomTextSize textSize) { AssertBug(isText() || isPI() || isComment(), "Not a text element ! id=%llx, path=%s\n", getElementId(), generateVersatileXPath().c_str()); ElementSegment* me = getMe<Write>(); AssertBug(me->flags & ElementFlag_HasTextualContents, "Invalid flags %x\n", me->flags); if (me->textualContents.size > me->textualContents.shortFormatSize) { // We shall reuse a bit here... Nevermind... getDocumentAllocator().freeSegment(me->textualContents.contentsPtr, me->textualContents.size); } if (textSize <= me->textualContents.shortFormatSize) { getDocumentAllocator().alter(me); me->textualContents.size = textSize; memcpy(me->textualContents.contents, text, textSize); getDocumentAllocator().protect(me); } else { SegmentPtr contentsPtr = getDocumentAllocator().getFreeSegmentPtr(textSize, getAllocationProfile()); char* textSegment = getDocumentAllocator().getSegment<char, Write>(contentsPtr, textSize); getDocumentAllocator().alter(textSegment, textSize); memcpy(textSegment, text, textSize); getDocumentAllocator().protect(textSegment, textSize); getDocumentAllocator().alter(me); me->textualContents.size = textSize; me->textualContents.contentsPtr = contentsPtr; getDocumentAllocator().protect(me); } if ( getFather() ) { getDocument().appendJournal(*this, JournalOperation_UpdateTextNode, *this, 0); } }