| 9576 | } |
| 9577 | |
| 9578 | void |
| 9579 | Node::replaceCustomDataInlabel(const QString & data) |
| 9580 | { |
| 9581 | assert( QThread::currentThread() == qApp->thread() ); |
| 9582 | boost::shared_ptr<KnobString> labelKnob = _imp->nodeLabelKnob.lock(); |
| 9583 | if (!labelKnob) { |
| 9584 | return; |
| 9585 | } |
| 9586 | QString label = QString::fromUtf8( labelKnob->getValue().c_str() ); |
| 9587 | ///Since the label is html encoded, find the text's start |
| 9588 | int foundFontTag = label.indexOf( QString::fromUtf8("<font") ); |
| 9589 | bool htmlPresent = (foundFontTag != -1); |
| 9590 | ///we're sure this end tag is the one of the font tag |
| 9591 | QString endFont( QString::fromUtf8("\">") ); |
| 9592 | int endFontTag = label.indexOf(endFont, foundFontTag); |
| 9593 | QString customTagStart( QString::fromUtf8(NATRON_CUSTOM_HTML_TAG_START) ); |
| 9594 | QString customTagEnd( QString::fromUtf8(NATRON_CUSTOM_HTML_TAG_END) ); |
| 9595 | int foundNatronCustomDataTag = label.indexOf(customTagStart, endFontTag == -1 ? 0 : endFontTag); |
| 9596 | if (foundNatronCustomDataTag != -1) { |
| 9597 | ///remove the current custom data |
| 9598 | int foundNatronEndTag = label.indexOf(customTagEnd, foundNatronCustomDataTag); |
| 9599 | assert(foundNatronEndTag != -1); |
| 9600 | |
| 9601 | foundNatronEndTag += customTagEnd.size(); |
| 9602 | label.remove(foundNatronCustomDataTag, foundNatronEndTag - foundNatronCustomDataTag); |
| 9603 | } |
| 9604 | |
| 9605 | int i = htmlPresent ? endFontTag + endFont.size() : 0; |
| 9606 | label.insert(i, customTagStart); |
| 9607 | label.insert(i + customTagStart.size(), data); |
| 9608 | label.insert(i + customTagStart.size() + data.size(), customTagEnd); |
| 9609 | labelKnob->setValue( label.toStdString() ); |
| 9610 | } |
| 9611 | |
| 9612 | boost::shared_ptr<KnobBool> |
| 9613 | Node::getDisabledKnob() const |