void TextAnnotation::initUpdateTextString() { if (mpComponent) { if (mOriginalTextString.contains("%") || mDynamicTextString.count() > 0) { updateTextString(); connect(mpComponent, SIGNAL(displayTextChanged()), SLOT(updateTextString()), Qt::UniqueConnection); } } }
/*! * \brief TextAnnotation::parseShapeAnnotation * Parses the text annotation string * \param annotation - text annotation string. */ void TextAnnotation::parseShapeAnnotation(QString annotation) { GraphicItem::parseShapeAnnotation(annotation); FilledShape::parseShapeAnnotation(annotation); // parse the shape to get the list of attributes of Text. QStringList list = StringHandler::getStrings(annotation); if (list.size() < 11) return; // 9th item of the list contains the extent points QStringList extentsList = StringHandler::getStrings(StringHandler::removeFirstLastCurlBrackets(list.at(8))); for (int i = 0 ; i < qMin(extentsList.size(), 2) ; i++) { QStringList extentPoints = StringHandler::getStrings(StringHandler::removeFirstLastCurlBrackets(extentsList[i])); if (extentPoints.size() >= 2) mExtents.replace(i, QPointF(extentPoints.at(0).toFloat(), extentPoints.at(1).toFloat())); } // 10th item of the list contains the textString. mOriginalTextString = StringHandler::removeFirstLastQuotes(list.at(9)); mTextString = mOriginalTextString; if (mpComponent) { if (mOriginalTextString.contains("%")) { updateTextString(); connect(mpComponent->getRootParentComponent(), SIGNAL(componentDisplayTextChanged()), SLOT(updateTextString())); } } // 11th item of the list contains the fontSize. mFontSize = list.at(10).toFloat(); //Now comes the optional parameters; fontName and textStyle. annotation = annotation.replace("{", ""); annotation = annotation.replace("}", ""); // parse the shape to get the list of attributes of Text Annotation. list = StringHandler::getStrings(annotation); int index = 19; while(index < list.size()) { QString annotationValue = StringHandler::removeFirstLastQuotes(list.at(index)); // check textStyles enumeration. if(annotationValue == "TextStyle.Bold") { mTextStyles.append(StringHandler::TextStyleBold); index++; } else if(annotationValue == "TextStyle.Italic") { mTextStyles.append(StringHandler::TextStyleItalic); index++; } else if(annotationValue == "TextStyle.UnderLine") { mTextStyles.append(StringHandler::TextStyleUnderLine); index++; } // check textAlignment enumeration. else if(annotationValue == "TextAlignment.Left") { mHorizontalAlignment = StringHandler::TextAlignmentLeft; index++; } else if(annotationValue == "TextAlignment.Center") { mHorizontalAlignment = StringHandler::TextAlignmentCenter; index++; } else if(annotationValue == "TextAlignment.Right") { mHorizontalAlignment = StringHandler::TextAlignmentRight; index++; } else { mFontName = annotationValue; index++; } } }