QVariant ItemsListModel::data (const QModelIndex& index, int role) const { if (!index.isValid () || index.row () >= rowCount ()) return QVariant (); if (role == Qt::DisplayRole) { switch (index.column ()) { case 0: { auto title = CurrentItems_ [index.row ()].Title_; auto pos = 0; while ((pos = title.indexOf ('<', pos)) != -1) { auto end = title.indexOf ('>', pos); if (end > 0) title.remove (pos, end - pos + 1); else break; } title.replace ("«", QString::fromUtf8 ("«")); title.replace ("»", QString::fromUtf8 ("»")); title.replace (""", "\""); title.replace ("–", "-"); title.replace ("—", QString::fromUtf8 ("—")); return title; } case 1: return CurrentItems_ [index.row ()].PubDate_; default: return QVariant (); } } //Color mark an items as read/unread else if (role == Qt::ForegroundRole) { bool palette = XmlSettingsManager::Instance ()-> property ("UsePaletteColors").toBool (); if (CurrentItems_ [index.row ()].Unread_) { if (XmlSettingsManager::Instance ()-> property ("UnreadCustomColor").toBool ()) return XmlSettingsManager::Instance ()-> property ("UnreadItemsColor").value<QColor> (); else return palette ? QApplication::palette ().link ().color () : QVariant (); } else return palette ? QApplication::palette ().linkVisited ().color () : QVariant (); } else if (role == Qt::FontRole && CurrentItems_ [index.row ()].Unread_) return XmlSettingsManager::Instance ()-> property ("UnreadItemsFont"); else if (role == Qt::ToolTipRole && XmlSettingsManager::Instance ()->property ("ShowItemsTooltips").toBool ()) { IDType_t id = CurrentItems_ [index.row ()].ItemID_; Item_ptr item = Core::Instance () .GetStorageBackend ()->GetItem (id); QString result = QString ("<qt><strong>%1</strong><br />").arg (item->Title_); if (item->Author_.size ()) { result += tr ("<b>Author</b>: %1").arg (item->Author_); result += "<br />"; } if (item->Categories_.size ()) { result += tr ("<b>Categories</b>: %1").arg (item->Categories_.join ("; ")); result += "<br />"; } if (item->NumComments_ > 0) { result += tr ("%n comment(s)", "", item->NumComments_); result += "<br />"; } if (item->Enclosures_.size () > 0) { result += tr ("%n enclosure(s)", "", item->Enclosures_.size ()); result += "<br />"; } if (item->MRSSEntries_.size () > 0) { result += tr ("%n MediaRSS entry(s)", "", item->MRSSEntries_.size ()); result += "<br />"; } if (item->CommentsLink_.size ()) { result += tr ("RSS with comments is available"); result += "<br />"; } result += "<br />"; const int maxDescriptionSize = 1000; auto descr = item->Description_; RemoveTag ("img", descr); result += descr.left (maxDescriptionSize); if (descr.size () > maxDescriptionSize) result += "..."; return result; } else if (role == Qt::BackgroundRole) { const QPalette& p = QApplication::palette (); QLinearGradient grad (0, 0, 0, 10); grad.setColorAt (0, p.color (QPalette::AlternateBase)); grad.setColorAt (1, p.color (QPalette::Base)); return QBrush (grad); } else return QVariant (); }
ThreadData ThreadsHandler::thread(ThreadId id) const { const int i = indexOf(id); return i == -1 ? ThreadData() : m_threads.at(i); }
int String::indexOf(char c) const { return indexOf(c, 0); }
void ElemElement::execute(StylesheetExecutionContext& executionContext) const { StylesheetExecutionContext::GetAndReleaseCachedString elemNameGuard(executionContext); XalanDOMString& elemName = elemNameGuard.get(); m_nameAVT->evaluate(elemName, *this, executionContext); bool isIllegalElement = !XalanQName::isValidQName(elemName); if (isIllegalElement == true) { executionContext.warn( XalanMessageLoader::getMessage(XalanMessages::IllegalElementName_1Param, elemName), executionContext.getCurrentNode(), getLocator()); ElemUse::doExecute(executionContext, false); doExecuteChildren(executionContext, true); } else { StylesheetExecutionContext::GetAndReleaseCachedString elemNameSpaceGuard(executionContext); XalanDOMString& elemNameSpace = elemNameSpaceGuard.get(); if (m_namespaceAVT != 0) { m_namespaceAVT->evaluate(elemNameSpace, *this, executionContext); } XalanDOMString::size_type namespaceLen = length(elemNameSpace); bool foundResultNamespaceForPrefix = false; XalanDOMString::size_type len = length(elemName); const XalanDOMString::size_type indexOfNSSep = indexOf(elemName, XalanUnicode::charColon); const bool havePrefix = indexOfNSSep == len ? false : true; StylesheetExecutionContext::GetAndReleaseCachedString prefixGuard(executionContext); XalanDOMString& prefix = prefixGuard.get(); if (havePrefix == true) { substring(elemName, prefix, 0, indexOfNSSep); const XalanDOMString* const theNamespace = executionContext.getResultNamespaceForPrefix(prefix); if (theNamespace != 0) { foundResultNamespaceForPrefix = true; } else { const XalanDOMString* const theNamespace = getNamespacesHandler().getNamespace(prefix); if(theNamespace == 0 && namespaceLen == 0) { executionContext.warn( XalanMessageLoader::getMessage( XalanMessages::CannotResolvePrefix_1Param, prefix), executionContext.getCurrentNode(), getLocator()); if (m_namespaceAVT != 0) { elemName.erase(0, indexOfNSSep + 1); } else { isIllegalElement = true; executionContext.warn( XalanMessageLoader::getMessage( XalanMessages::IllegalElementName_1Param, elemName), executionContext.getCurrentNode(), getLocator()); } } else if (theNamespace != 0 && namespaceLen == 0 && equals(prefix, DOMServices::s_XMLNamespace) == false) { elemNameSpace = *theNamespace; } } } if (isIllegalElement == false) { executionContext.startElement(c_wstr(elemName)); if(0 == m_namespaceAVT && (havePrefix == false || foundResultNamespaceForPrefix == true)) { if (havePrefix == false) { fixupDefaultNamespace(executionContext); } } else { if(havePrefix == false) { if (namespaceLen > 0) { const XalanDOMString* const theDefaultNamespace = executionContext.getResultNamespaceForPrefix(s_emptyString); if (theDefaultNamespace == 0 || equals(*theDefaultNamespace, elemNameSpace) == false) { executionContext.addResultAttribute( DOMServices::s_XMLNamespace, elemNameSpace); } } else { // OK, the namespace we're generating is the default namespace, // so let's make sure that we really need it. If we don't, // we end up with another xmlns="" on the element we're // generating. Although this isn't really an error, it's // a bit unsightly, so let's suppress it... const XalanDOMString& theParentDefaultNamespace = getParentDefaultNamespace(); if (length(theParentDefaultNamespace) == 0) { if (executionContext.getResultNamespaceForPrefix(s_emptyString) != 0) { executionContext.addResultAttribute(DOMServices::s_XMLNamespace, elemNameSpace); } } else { executionContext.addResultAttribute(DOMServices::s_XMLNamespace, elemNameSpace); } } } else { const XalanDOMString* const theNamespace = executionContext.getResultNamespaceForPrefix(prefix); if (theNamespace == 0 || equals(*theNamespace, elemNameSpace) == false) { insert(prefix, 0, DOMServices::s_XMLNamespaceWithSeparator); executionContext.addResultAttribute(prefix, elemNameSpace); } } } } if (isIllegalElement == true) { ElemUse::doExecute(executionContext, false); doExecuteChildren(executionContext, true); } else { ElemUse::doExecute(executionContext, true); doExecuteChildren(executionContext, false); executionContext.endElement(c_wstr(elemName)); } } }
void phdFilterList::delItem(phdFilter * _item) { delItem(indexOf(_item)); }
short RangeImpl::compareBoundaryPoints(DOM_Range::CompareHow how, RangeImpl* srcRange) const { if (fDocument != srcRange->fDocument) { throw DOM_DOMException( DOM_DOMException::WRONG_DOCUMENT_ERR, null); } if( fDetached) { throw DOM_DOMException( DOM_DOMException::INVALID_STATE_ERR, null); } DOM_Node pointA, pointB; int offsetA, offsetB; switch (how) { case (DOM_Range::START_TO_START) : pointB = srcRange->getStartContainer(); pointA = fStartContainer; offsetB = srcRange->getStartOffset(); offsetA = fStartOffset; break; case (DOM_Range::START_TO_END) : pointB = srcRange->getStartContainer(); pointA = fEndContainer; offsetB = srcRange->getStartOffset(); offsetA = fEndOffset; break; case (DOM_Range::END_TO_START) : pointB = srcRange->getEndContainer(); pointA = fStartContainer; offsetB = srcRange->getEndOffset(); offsetA = fStartOffset; break; case (DOM_Range::END_TO_END) : pointB = srcRange->getEndContainer(); pointA = fEndContainer; offsetB = srcRange->getEndOffset(); offsetA = fEndOffset; break; } // case 1: same container if (pointA == pointB) { if (offsetA < offsetB) return -1; //A before B if (offsetA == offsetB) return 0; //A equal to B return 1; // A after B } // case 2: Child C of container A is ancestor of B for (DOM_Node node = pointA.getFirstChild(); node != null; node=node.getNextSibling()) { if (isAncestorOf(node, pointB)) { int index = indexOf(node, pointA); if (offsetA <= index) return -1; return 1; } } // case 3: Child C of container B is ancestor of A for (DOM_Node nd = pointB.getFirstChild(); nd != null; nd=nd.getNextSibling()) { if (isAncestorOf(nd, pointA)) { int index = indexOf(nd, pointB); if (index < offsetB ) return -1; return 1; //B strictly before A } } // case 4: preorder traversal of context tree. DOM_Node ancestor = commonAncestorOf(pointA, pointB); DOM_Node current = ancestor; do { if (current == pointA) return -1; if (current == pointB) return 1; current = nextNode(current, true); } while (current!=null && current!=ancestor); return -2; // this should never happen }
bool KBBGraphicsItemSet::contains(int position) { return (indexOf(position)!=NO_INDEX); }
void WMenu::selectVisual(WMenuItem *item) { selectVisual(indexOf(item), true, true); }
void CDoodMemberManager::modifyMember(Member member) { //TODO CDoodMemberItem *tmpItem = memberListMap.value(member.id); if(member.member_type!=""){ tmpItem->setMember_type(member.member_type); } if(member.remark!=""){ tmpItem->setRemark(member.remark); } tmpItem->setGroupid(member.groupid); tmpItem->setSection(member.team); CDoodMemberItem* item = groupAdminListMap.value(tmpItem->id(),NULL); if(item != NULL && member.member_type == "1"){ removeItem(indexOf(item)); groupAdminListMap.remove(member.id); delete item; } else if(item != NULL && member.member_type == "3"){ removeItem(indexOf(item)); groupAdminListMap.remove(member.id); delete item; QList<CDoodMemberItem*> itemList = groupLeaderListMap.values(); for(int i= 0;i< itemList.size();i++){ removeItem(itemList.value(i)); delete itemList.value(i); } groupLeaderListMap.clear(); CDoodMemberItem* groupLeaderItem = new CDoodMemberItem(this); groupLeaderItem->setId(member.id); groupLeaderItem->setGender(member.gender); groupLeaderItem->setName(member.name); groupLeaderItem->setMember_type(member.member_type); groupLeaderItem->setThumbAvatar(member.thumbAvatar); groupLeaderItem->setRemark(member.remark); groupLeaderItem->setGroupid(member.groupid); groupLeaderItem->setSection("群主"); insertItem(groupLeaderListMap.size(),groupLeaderItem); groupLeaderListMap[member.id] = groupLeaderItem; if(mMy_Id==member.id){ setMy_Type("3"); qDebug() << Q_FUNC_INFO<<"niuniuniu"<<my_Type(); } } else if(item == NULL && member.member_type == "2"){ CDoodMemberItem*groupAdminItem = new CDoodMemberItem(this); groupAdminItem->setId(member.id); groupAdminItem->setGender(member.gender); groupAdminItem->setName(member.name); groupAdminItem->setThumbAvatar(member.thumbAvatar); groupAdminItem->setMember_type(member.member_type); groupAdminItem->setRemark(member.remark); groupAdminItem->setGroupid(member.groupid); groupAdminItem->setSection("管理员"); insertItem(groupAdminListMap.size(),groupAdminItem); groupAdminListMap[member.id] = groupAdminItem; if(mMy_Id==member.id){ setMy_Type("2"); } } CDoodMemberItem *item1 = groupLeaderListMap.value(tmpItem->id(),NULL); if(item1 == NULL && member.member_type == "3"){ QList<CDoodMemberItem*> itemList = groupLeaderListMap.values(); for(int i= 0;i< itemList.size();i++){ removeItem(itemList.value(i)); delete itemList.value(i); } groupLeaderListMap.clear(); CDoodMemberItem* groupLeaderItem = new CDoodMemberItem(this); groupLeaderItem->setId(member.id); groupLeaderItem->setGender(member.gender); groupLeaderItem->setName(member.name); groupLeaderItem->setMember_type(member.member_type); groupLeaderItem->setThumbAvatar(member.thumbAvatar); groupLeaderItem->setRemark(member.remark); groupLeaderItem->setGroupid(member.groupid); groupLeaderItem->setSection("群主"); insertItem(groupLeaderListMap.size(),groupLeaderItem); groupLeaderListMap[member.id] = groupLeaderItem; if(mMy_Id==member.id){ setMy_Type("3"); } } }
bool AnimationState::advanceTime(Number passedTime) { AnimationEvent *event = 0; bool isComplete = false; if(_fadeIn) { _fadeIn = false; _armature->getAnimation()->setActive(this, true); if(_armature->hasEventListener(AnimationEvent::FADE_IN)) { event = new AnimationEvent(AnimationEvent::FADE_IN); event->animationState = this; _armature->_eventList.push_back(event); } } if(_fadeOut) { _fadeOut = false; _armature->getAnimation()->setActive(this, true); if(_armature->hasEventListener(AnimationEvent::FADE_OUT)) { event = new AnimationEvent(AnimationEvent::FADE_OUT); event->animationState = this; _armature->_eventList.push_back(event); } } _currentTime += passedTime * _timeScale; if(_isPlaying && !_isComplete && _pauseBeforeFadeInCompleteState) { Number progress; int currentLoopCount; if(_pauseBeforeFadeInCompleteState == -1) { _pauseBeforeFadeInCompleteState = 0; progress = 0; currentLoopCount = (int)progress; } else { progress = _currentTime / _totalTime; //update loopCount currentLoopCount = (int)progress; if(currentLoopCount != _loopCount) { if(_loopCount == -1) { _armature->getAnimation()->setActive(this, true); if(_armature->hasEventListener(AnimationEvent::START)) { event = new AnimationEvent(AnimationEvent::START); event->animationState = this; _armature->_eventList.push_back(event); } } _loopCount = currentLoopCount; if(_loopCount) { if(_loop && _loopCount * _loopCount >= _loop * _loop - 1) { isComplete = true; progress = 1; currentLoopCount = 0; if(_armature->hasEventListener(AnimationEvent::COMPLETE)) { event = new AnimationEvent(AnimationEvent::COMPLETE); event->animationState = this; _armature->_eventList.push_back(event); } } else { if(_armature->hasEventListener(AnimationEvent::LOOP_COMPLETE)) { event = new AnimationEvent(AnimationEvent::LOOP_COMPLETE); event->animationState = this; _armature->_eventList.push_back(event); } } } } } for(std::map<String , TimelineState*>::iterator iter = _timelineStates.begin() ; iter != _timelineStates.end() ; iter ++) { iter->second->update(progress); } // if(_clip->frameList.size() > 0) { Number playedTime = _totalTime * (progress - currentLoopCount); bool isArrivedFrame = false; int frameIndex; while(!_currentFrame || playedTime > _currentFrame->position + _currentFrame->duration || playedTime < _currentFrame->position) { if(isArrivedFrame) { _armature->arriveAtFrame(_currentFrame, 0, this, true); } isArrivedFrame = true; if(_currentFrame) { frameIndex = indexOf(_clip->frameList , _currentFrame); frameIndex ++; if(frameIndex >= (int)_clip->frameList.size()) { frameIndex = 0; } _currentFrame = _clip->frameList[frameIndex]; } else { _currentFrame = _clip->frameList[0]; } } if(isArrivedFrame) { _armature->arriveAtFrame(_currentFrame, 0, this, false); } } } //update weight and fadeState if(_fadeState > 0) { if(_fadeInTime == 0) { _fadeWeight = 1; _fadeState = 0; _pauseBeforeFadeInCompleteState = 1; _armature->getAnimation()->setActive(this, false); if(_armature->hasEventListener(AnimationEvent::FADE_IN_COMPLETE)) { event = new AnimationEvent(AnimationEvent::FADE_IN_COMPLETE); event->animationState = this; _armature->_eventList.push_back(event); } } else { _fadeWeight = _currentTime / _fadeInTime; if(_fadeWeight >= 1) { _fadeWeight = 1; _fadeState = 0; if(_pauseBeforeFadeInCompleteState == 0) { _currentTime -= _fadeInTime; } _pauseBeforeFadeInCompleteState = 1; _armature->getAnimation()->setActive(this, false); if(_armature->hasEventListener(AnimationEvent::FADE_IN_COMPLETE)) { event = new AnimationEvent(AnimationEvent::FADE_IN_COMPLETE); event->animationState = this; _armature->_eventList.push_back(event); } } } } else if(_fadeState < 0) { if(_fadeOutTime == 0) { _fadeWeight = 0; _fadeState = 0; _armature->getAnimation()->setActive(this, false); if(_armature->hasEventListener(AnimationEvent::FADE_OUT_COMPLETE)) { event = new AnimationEvent(AnimationEvent::FADE_OUT_COMPLETE); event->animationState = this; _armature->_eventList.push_back(event); } return true; } else { _fadeWeight = (1 - (_currentTime - _fadeOutBeginTime) / _fadeOutTime) * _fadeOutWeight; if(_fadeWeight <= 0) { _fadeWeight = 0; _fadeState = 0; _armature->getAnimation()->setActive(this, false); if(_armature->hasEventListener(AnimationEvent::FADE_OUT_COMPLETE)) { event = new AnimationEvent(AnimationEvent::FADE_OUT_COMPLETE); event->animationState = this; _armature->_eventList.push_back(event); } return true; } } } if(isComplete) { _isComplete = true; if(_loop < 0) { fadeOut((_fadeOutWeight ? _fadeOutWeight : _fadeInTime) / _timeScale, true); } else { _armature->getAnimation()->setActive(this, false); } } return false; }
void WMenu::select(WMenuItem *item) { select(indexOf(item), true); }
void uart() { #define SIZE_BUF 128 char buf[SIZE_BUF]; int nbuf = 0; for (int i = 0; i < SIZE_BUF; i++) buf[i] = 0; // init_frame(); // load(); // 初回はデータクリアいるかも? int mode = 1; unsigned char data[8]; for (int i = 0; i < 8; i++) data[i] = 0; int n = 0; int cnt = 0; int nframe = 0; for (int i = 0;; i++) { while (uart0_test()) { int c = uart0_getc(); // println(buf); if (c == '\n') { buf[nbuf] = '\0'; if (startsWith(buf, "MATLED SHOW ")) { decode(buf + (9 + 3), data); println("SHOW"); } else if (startsWith(buf, "MATLED SET ")) { char* pbuf = buf + 11; int nf = parseInt(pbuf); if (nf >= 0 && nf <= N_FRAME) { int n = indexOf(pbuf, ' '); if (n >= 0) { pbuf += n + 1; // println(pbuf); decode(pbuf, fr->frame[nf]); decode(pbuf, data); // 停止時の画面にも表示 n = indexOf(pbuf, ' '); int nw = 100; if (n >= 0) { pbuf += n + 1; nw = parseInt(pbuf); } fr->waitms[nf] = nw; } } } else if (startsWith(buf, "MATLED CLEAR")) { mode = 0; init_frame(); } else if (startsWith(buf, "MATLED RUN")) { mode = 1; println("RUN"); } else if (startsWith(buf, "MATLED STOP")) { mode = 0; println("STOP"); } else if (startsWith(buf, "MATLED SAVE")) { save(); println("SAVE"); } else if (startsWith(buf, "MATLED LOAD")) { load(); println("LOAD"); } nbuf = 0; continue; } else if (c == '\r') { } else { if (nbuf < SIZE_BUF - 1) buf[nbuf++] = c; } } if (mode == 0) { setMatrix(data); } else { setMatrix(fr->frame[nframe]); cnt++; if (cnt >= fr->waitms[nframe]) { cnt = 0; int bknframe = nframe; for (;;) { nframe++; if (nframe == N_FRAME) nframe = 0; if (fr->waitms[nframe]) break; if (bknframe == nframe) { mode = 0; break; } } } } } }
bool StringArray::contains (StringRef stringToLookFor, const bool ignoreCase) const { return indexOf (stringToLookFor, ignoreCase) >= 0; }
void ModeManager::activateMode(Id id) { const int index = indexOf(id); if (index >= 0) d->m_modeStack->setCurrentIndex(index); }
void batchWindow::statusImage(QString url, int percent) { int i = indexOf(url); if (i != -1) ui->tableWidget->item(i, 5)->setText(QString::number(percent)+" %"); }
BOOL isOperator (char op) { if (indexOf(op, "+-*/%^$") != -1) return YES; return NO; }
int TabWidget::webViewIndex(WebView *webView) const { int index = indexOf(webView); return index; }
bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes) { // add to elements stack: m_elementStack.append(new ElementData(qName.utf8())); // First we need a node. if (DBUS("node")) { CONDITION(!m_currentNode.isEmpty(), "Node inside a node."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QCString("Anonymous node found.")); m_currentNode = attributes.value(idx).utf8(); // A node is actually of little interest, so do nothing here. return true; } // Then we need an interface. if (DBUS("interface")) { // We need a nodeName for interfaces: CONDITION(m_currentNode.isEmpty(), "Interface without a node."); CONDITION(m_currentInterface, "Interface within another interface."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QString("Interface without a name found.")); // A interface is roughly equivalent to a class: m_currentInterface = createEntry(); m_currentInterface->section = Entry::CLASS_SEC; m_currentInterface->spec |= Entry::Interface; m_currentInterface->type = "Interface"; m_currentInterface->name = substitute(attributes.value(idx).utf8(), ".", "::"); openScopes(m_currentInterface); return true; } if (DBUS("method") || DBUS("signal")) { // We need a interfaceName for methods and signals: CONDITION(!m_currentInterface, "Method or signal found outside a interface."); CONDITION(m_currentMethod, "Method or signal found inside another method or signal."); CONDITION(m_currentProperty, "Methor or signal found inside a property."); CONDITION(!m_structStack.isEmpty(), "Method or signal found inside a struct."); CONDITION(m_currentEnum, "Methor or signal found inside a enum."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QString("Method or signal without a name found.")); m_currentMethod = createEntry(); m_currentMethod->section = Entry::FUNCTION_SEC; m_currentMethod->name = attributes.value(idx).utf8(); m_currentMethod->mtype = Method; m_currentMethod->type = "void"; if (DBUS("signal")) { m_currentMethod->mtype = Signal; } } if (DBUS("arg")) { // We need a method for arguments: CONDITION(!m_currentMethod, "Argument found outside a method or signal."); CONDITION(m_currentArgument, "Argument found inside another argument."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Argument without a name found.")); COND_DOC_ERROR(!hasType(attributes), QString("Argument without a type found.")); const int direction_idx(indexOf(attributes, "direction")); if ((m_currentMethod->mtype == Signal && direction_idx >= 0 && attributes.value(direction_idx) != "in") || (m_currentMethod->mtype == Method && direction_idx >= 0 && attributes.value(direction_idx) != "in" && attributes.value(direction_idx) != "out")) { m_errorString = "Invalid direction found."; return false; } m_currentArgument = new Argument; m_currentArgument->type = getType(attributes).utf8(); m_currentArgument->name = attributes.value(name_idx).utf8(); if (direction_idx >= 0) { m_currentArgument->attrib = attributes.value(direction_idx).utf8(); } else { if (m_currentMethod->mtype == Signal) { m_currentArgument->attrib = "in"; } else { m_currentArgument->attrib = "out"; } } } if (DBUS("property")) { CONDITION(m_currentMethod, "Property found inside a method or signal."); CONDITION(!m_currentInterface, "Property found outside an interface."); CONDITION(m_currentProperty, "Property found inside another property."); CONDITION(!m_structStack.isEmpty(), "Property found inside a struct."); CONDITION(m_currentEnum, "Property found inside a enum."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Anonymous property found.")); COND_DOC_ERROR(!hasType(attributes), QString("Property without a type found.")); const int access_idx(indexOf(attributes, "access")); COND_DOC_ERROR(access_idx < 0, QString("Property without a access attribute found.")); COND_DOC_ERROR(attributes.value(access_idx) != "read" && attributes.value(access_idx) != "write" && attributes.value(access_idx) != "readwrite", QString("Property with invalid access attribute \"%1\" found."). arg(attributes.value(access_idx))); m_currentProperty = createEntry(); m_currentProperty->section = Entry::FUNCTION_SEC; if (attributes.value(access_idx) == "read" || attributes.value(access_idx) == "readwrite") { m_currentProperty->spec |= Entry::Readable; } if (attributes.value(access_idx) == "write" || attributes.value(access_idx) == "readwrite") { m_currentProperty->spec |= Entry::Writable; } m_currentProperty->name = attributes.value(name_idx).utf8(); m_currentProperty->mtype = Property; m_currentProperty->type = getType(attributes).utf8(); } if (EXTENSION("namespace")) { CONDITION(m_currentNode.isEmpty(), "Namespace found outside a node."); CONDITION(m_currentInterface, "Namespace found inside an interface."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QString("Anonymous namespace found.")); m_namespaceStack.append(openNamespace(attributes.value(idx))); openScopes(m_namespaceStack.last()); } if (EXTENSION("struct")) { CONDITION(m_currentMethod, "Struct found inside a method or signal."); CONDITION(m_currentProperty, "Struct found inside a property."); CONDITION(m_currentEnum, "Struct found inside an enum."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QString("Anonymous struct found.")); Entry * current_struct = createEntry(); current_struct->section = Entry::CLASS_SEC; current_struct->spec = Entry::Struct; current_struct->name = attributes.value(idx).utf8(); openScopes(current_struct); current_struct->type = current_struct->name + " struct"; m_structStack.append(new StructData(current_struct)); } if (EXTENSION("member")) { CONDITION(m_structStack.isEmpty(), "Member found outside of struct."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Anonymous member found.")); COND_DOC_ERROR(!hasType(attributes), QString("Member without a type found.")); createEntry(); m_currentEntry->section = Entry::VARIABLE_SEC; m_currentEntry->name = attributes.value(name_idx).utf8(); m_currentEntry->type = getType(attributes).utf8(); QString type(getDBusType(m_currentEntry->type)); m_structStack.last()->type.append(type.utf8()); } if (EXTENSION("enum") || EXTENSION("flagset")) { CONDITION(m_currentMethod, "Enum found inside a method or signal."); CONDITION(m_currentProperty, "Enum found inside a property."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Anonymous enum found.")); const int type_idx(indexOf(attributes, "type")); QString type = "u"; if (type_idx >= 0) { type = attributes.value(type_idx); } if (type != "y" && type != "q" && type != "u" && type != "t") { DOC_ERROR(QString("Invalid enum type \"%1\" found.").arg(type)); } m_currentEnum = createEntry(); m_currentEnum->section = Entry::ENUM_SEC; m_currentEnum->name = attributes.value(name_idx).utf8(); openScopes(m_currentEnum); m_currentEnum->type = m_currentEntry->name + " enum"; addNamedType(type.utf8()); } if (EXTENSION("value")) { CONDITION(!m_currentEnum, "Value found outside an enum."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Anonymous value found.")); const int value_idx(indexOf(attributes, "value")); createEntry(); m_currentEntry->section = Entry::VARIABLE_SEC; m_currentEntry->name = attributes.value(name_idx).utf8(); m_currentEntry->type = m_currentEnum->name; // "@"; // enum marker! if (value_idx >= 0) { m_currentEntry->initializer = attributes.value(value_idx).utf8(); } } return true; }
void pSocket::onDataReceived() { #ifdef FUNC_DEBUG qDebug() << '\n' << Q_FUNC_INFO; #endif auto data = _socket->readAll(); if (_packetSize == 0) { int n = data.indexOf("\n\n"); if (n == -1) { qDebug() << "Wrong data received. Disconnect" << _socket->localAddress(); _socket->disconnectFromHost(); return; } QByteArray header = data.left(n); auto content = data.mid(n+2); _buffer = content; _limit.fetchAndAddAcquire(content.size()); _packetSize = getValue(header, "size").toInt(); _protoVersion = getValue(header, "version"); _fileType = getValue(header, "type"); if (_packetSize == 0) { qDebug() << "Client trying to send empty data"; _socket->disconnectFromHost(); } if (_fileType == "" || !Settings::types().contains(_fileType) ) { qDebug() << "Sender type is not exist. Disconnect" << _socket->localAddress(); _socket->disconnectFromHost(); return; } } else { _buffer += data; _limit.fetchAndAddAcquire(data.size()); } if (_buffer.size() > MAX_DATA_SIZE || _limit.loadAcquire() > MAX_DAY_SIZE) { qDebug() << "File is too big! Disconnect" << _socket->localAddress(); _socket->disconnectFromHost(); _socket->deleteLater(); return; } #ifdef FUNC_DEBUG qDebug() << '\n' << Q_FUNC_INFO << "read"; #endif if (_buffer.size() == _packetSize) { #ifdef FUNC_DEBUG qDebug() << '\n' << Q_FUNC_INFO << "emit"; #endif _packetSize = 0; emit saveFile(_buffer, _fileType); #ifdef TIME_DEBUG qDebug() << dTime->elapsed(); #endif } #ifdef FUNC_DEBUG qDebug() << '\n' << Q_FUNC_INFO << "end"; #endif }
audio_policy_dev_state_t DeviceVector::getDeviceConnectionState(const sp<DeviceDescriptor> &devDesc) const { ssize_t index = indexOf(devDesc); return index >= 0 ? AUDIO_POLICY_DEVICE_STATE_AVAILABLE : AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE; }
void BaseAtlas::load (const char *current, const char *end) { if (!current) throw invalid_argument("current cannot be null."); if (!end) throw invalid_argument("end cannot be null."); string value; string tuple[4]; BaseAtlasPage *page = 0; while (current != end) { readLine(current, end, value); trim(value); if (value.length() == 0) { page = 0; } else if (!page) { page = newAtlasPage(value); pages.push_back(page); page->name = value; page->format = static_cast<Format>(indexOf(formatNames, 7, readValue(current, end, value))); readTuple(current, end, value, tuple); page->minFilter = static_cast<TextureFilter>(indexOf(textureFilterNames, 7, tuple[0])); page->magFilter = static_cast<TextureFilter>(indexOf(textureFilterNames, 7, tuple[1])); readValue(current, end, value); if (value == "x") { page->uWrap = repeat; page->vWrap = clampToEdge; } else if (value == "y") { page->uWrap = clampToEdge; page->vWrap = repeat; } else if (value == "xy") { page->uWrap = repeat; page->vWrap = repeat; } } else { BaseAtlasRegion *region = newAtlasRegion(page); regions.push_back(region); region->name = value; region->rotate = readValue(current, end, value) == "true"; readTuple(current, end, value, tuple); region->x = atoi(tuple[0].c_str()); region->y = atoi(tuple[1].c_str()); readTuple(current, end, value, tuple); region->width = atoi(tuple[0].c_str()); region->height = atoi(tuple[1].c_str()); if (readTuple(current, end, value, tuple) == 4) { // split is optional region->splits = new int[4]; region->splits[0] = atoi(tuple[0].c_str()); region->splits[1] = atoi(tuple[1].c_str()); region->splits[2] = atoi(tuple[2].c_str()); region->splits[3] = atoi(tuple[3].c_str()); if (readTuple(current, end, value, tuple) == 4) { // pad is optional, but only present with splits region->pads = new int[4]; region->pads[0] = atoi(tuple[0].c_str()); region->pads[1] = atoi(tuple[1].c_str()); region->pads[2] = atoi(tuple[2].c_str()); region->pads[3] = atoi(tuple[3].c_str()); readTuple(current, end, value, tuple); } } region->originalWidth = atoi(tuple[0].c_str()); region->originalHeight = atoi(tuple[1].c_str()); readTuple(current, end, value, tuple); region->offsetX = (float)atoi(tuple[0].c_str()); region->offsetY = (float)atoi(tuple[1].c_str()); region->index = atoi(readValue(current, end, value).c_str()); } } }
void setupBlueToothConnection() { serialPrint("\r\n+STWMOD=1\r\n");//set the bluetooth work in master mode //serialPrint("\r\n+STBD=9600\r\n"); // Set the baudrate to 9600 //changeBaud(); serialPrint("\r\n+STNA=SeeedBTMaster\r\n");//set the bluetooth name as "SeeedBTMaster" serialPrint("\r\n+STPIN=0000\r\n");//Set Master pincode"0000",it must be same as Slave pincode serialPrint("\r\n+STAUTO=0\r\n");// Auto-connection is forbidden here //serialPrintln("Size of Int on MSP: "); //serialPrintInt(sizeof(int)); __delay_cycles(2000000); // This delay is required. serialFlush(); serialPrint("\r\n+INQ=1\r\n");//make the master inquire serialPrint("Master is inquiring!"); __delay_cycles(2000000); // This delay is required. int pos = 0; //find the target slave int firstTry = 1; char recvChar; //serialPrint(printf("%i", test)); while(1){ if(serialAvailable()){ if (firstTry) { firstTry = 0; recvBuf[pos++] = serialRead(); } else { recvBuf[pos++] = serialRead(); recvBuf[pos] = 0; } } nameIndex = indexOf(recvBuf, slaveName, 0);//get the position of slave name if ( nameIndex != -1 && nameIndex > 0){ nameIndex -= 1;//decrease the ';' in front of the slave name, to get the position of the end of the slave address addrIndex = indexOf(recvBuf, retSymb, (nameIndex - strlen(retSymb) - 18)) + strlen(retSymb); slaveAddr = subString(recvBuf, addrIndex, nameIndex); break; } } /* * Now, that we've found the slave address, connect to the slave. */ serialPrintln("Inquiring completed, sending command :"); serialPrintln("connectCmd"); strcat(connectCmd, slaveAddr); strcat(connectCmd, "\r\n"); int connected = 0; firstTry = 1; pos = 0; while (!connected) { serialPrint(connectCmd);//send connection command while(1){ if(serialAvailable()){ if (firstTry) { firstTry = 0; recvBuf[pos++] = serialRead(); } else { recvBuf[pos++] = serialRead(); recvBuf[pos] = 0; } } if (indexOf(recvBuf, "CONNECT:OK", 0) != -1) { //Try to find the OK connected = 1; serialPrintln("Connected!"); break; } else if (indexOf(recvBuf, "CONNECT:FAIL", 0) != -1) { break; } } } }
int32_t UStack::search(void * obj) const { int32_t i = indexOf(obj); return (i >= 0) ? size() - i : i; }
** ** $QT_END_LICENSE$ ** ****************************************************************************/ //! [0] #include <QtDesigner> //! [0] //! [2] QDesignerMemberSheetExtension *memberSheet = 0; QExtensionManager manager = formEditor->extensionManager(); memberSheet = qt_extension<QDesignerMemberSheetExtension*>(manager, widget); int index = memberSheet->indexOf(setEchoMode); memberSheet->setVisible(index, false); delete memberSheet; //! [2] //! [3] class MyMemberSheetExtension : public QObject, public QDesignerMemberSheetExtension { Q_OBJECT Q_INTERFACES(QDesignerMemberSheetExtension) public: ...
void phdFilterList::popItem(phdFilter * _item) { popItem(indexOf(_item)); }
String XmlDocument::expandExternalEntity (const String& entity) { if (needToLoadDTD) { if (dtdText.isNotEmpty()) { dtdText = dtdText.trimCharactersAtEnd (">"); tokenisedDTD.addTokens (dtdText, true); if (tokenisedDTD[tokenisedDTD.size() - 2].equalsIgnoreCase ("system") && tokenisedDTD[tokenisedDTD.size() - 1].isQuotedString()) { auto fn = tokenisedDTD[tokenisedDTD.size() - 1]; tokenisedDTD.clear(); tokenisedDTD.addTokens (getFileContents (fn), true); } else { tokenisedDTD.clear(); auto openBracket = dtdText.indexOfChar ('['); if (openBracket > 0) { auto closeBracket = dtdText.lastIndexOfChar (']'); if (closeBracket > openBracket) tokenisedDTD.addTokens (dtdText.substring (openBracket + 1, closeBracket), true); } } for (int i = tokenisedDTD.size(); --i >= 0;) { if (tokenisedDTD[i].startsWithChar ('%') && tokenisedDTD[i].endsWithChar (';')) { auto parsed = getParameterEntity (tokenisedDTD[i].substring (1, tokenisedDTD[i].length() - 1)); StringArray newToks; newToks.addTokens (parsed, true); tokenisedDTD.remove (i); for (int j = newToks.size(); --j >= 0;) tokenisedDTD.insert (i, newToks[j]); } } } needToLoadDTD = false; } for (int i = 0; i < tokenisedDTD.size(); ++i) { if (tokenisedDTD[i] == entity) { if (tokenisedDTD[i - 1].equalsIgnoreCase ("<!entity")) { auto ent = tokenisedDTD [i + 1].trimCharactersAtEnd (">").trim().unquoted(); // check for sub-entities.. auto ampersand = ent.indexOfChar ('&'); while (ampersand >= 0) { auto semiColon = ent.indexOf (i + 1, ";"); if (semiColon < 0) { setLastError ("entity without terminating semi-colon", false); break; } auto resolved = expandEntity (ent.substring (i + 1, semiColon)); ent = ent.substring (0, ampersand) + resolved + ent.substring (semiColon + 1); ampersand = ent.indexOfChar (semiColon + 1, '&'); } return ent; } } } setLastError ("unknown entity", true); return entity; }
void Area::addView(View *view, View *viewToSplit, Qt::Orientation orientation) { AreaIndex *indexToSplit = indexOf(viewToSplit); addView(view, indexToSplit, orientation); }
void WStackedWidget::setCurrentWidget(WWidget *widget) { setCurrentIndex(indexOf(widget)); }
int String::indexOf(const String &s2) const { return indexOf(s2, 0); }
void SlidingStackedWidget::slideInWgt(QWidget *newwidget, enum t_direction direction) { if (m_active) { return; /* At the moment, do not allow re-entrance before an animation is completed. * other possibility may be to finish the previous animation abrupt, or * to revert the previous animation with a counter animation, before going ahead * or to revert the previous animation abrupt * and all those only, if the newwidget is not the same as that of the previous running animation. */ } else { m_active = true; } enum t_direction directionhint; int now = currentIndex(); /* currentIndex() is a function inherited from QStackedWidget */ int next = indexOf(newwidget); if (now == next) { m_active = false; return; } else if (now < next){ /* Here is a '=', indeed. */ directionhint = m_vertical ? TOP2BOTTOM : RIGHT2LEFT; } else { directionhint = m_vertical ? BOTTOM2TOP : LEFT2RIGHT; } if (direction == AUTOMATIC) { direction = directionhint; } /* NOW....calculate the shifts */ int offsetx = frameRect().width(); /* Inherited from mother */ int offsety = frameRect().height(); /* Inherited from mother */ /* The following is important, to ensure that the new widget has correct geometry information when sliding in first time */ widget(next)->setGeometry (0, 0, offsetx, offsety); if (direction == BOTTOM2TOP) { offsetx = 0; offsety = -offsety; } else if (direction == TOP2BOTTOM) { offsetx = 0; //offsety = offsety; } else if (direction == RIGHT2LEFT) { offsetx = -offsetx; offsety = 0; } else if (direction == LEFT2RIGHT) { //offsetx = offsetx; offsety = 0; } /* Re-position the next widget outside/aside of the display area */ QPoint pnext = widget(next)->pos(); QPoint pnow = widget(now)->pos(); m_pnow = pnow; widget(next)->move(pnext.x() - offsetx, pnext.y() - offsety); /* Make it visible/show */ widget(next)->show(); widget(next)->raise(); /* Animate both, the now and next widget to the side, using animation framework */ QPropertyAnimation *animnow = new QPropertyAnimation(widget(now), "pos"); animnow->setDuration(m_speed); animnow->setEasingCurve(m_animationtype); animnow->setStartValue(QPoint(pnow.x(), pnow.y())); animnow->setEndValue(QPoint(offsetx + pnow.x(), offsety + pnow.y())); QPropertyAnimation *animnext = new QPropertyAnimation(widget(next), "pos"); animnext->setDuration(m_speed); animnext->setEasingCurve(m_animationtype); animnext->setStartValue(QPoint(-offsetx + pnext.x(), offsety + pnext.y())); animnext->setEndValue(QPoint(pnext.x(), pnext.y())); QParallelAnimationGroup *animgroup = new QParallelAnimationGroup; animgroup->addAnimation(animnow); animgroup->addAnimation(animnext); QObject::connect(animgroup, SIGNAL(finished()), this, SLOT(animationDoneSlot())); m_next = next; m_now = now; m_active = true; animgroup->start(); /* Note: * the rest is done via a connect from the animation ready; * animation->finished() provides a signal when animation is done; * so we connect this to some post processing slot, * that we implement here below in animationDoneSlot. */ }