diff --git a/src/qcdscene.cpp b/src/qcdscene.cpp index ca0bdd3..4bbe30e 100644 --- a/src/qcdscene.cpp +++ b/src/qcdscene.cpp @@ -60,6 +60,11 @@ void QCDScene::replace( const QString2String &strings ) f->second->replace( item, st.key(), st.value() ); } } + foreach(QGraphicsItem *item, list ) { + QShapeFactory::iterator f = sfactory.find( item->type() ); + if( f != sfactory.end() ) + f->second->replace( item, "", "" ); // to clean placeholders + } } bool QCDScene::load( const QString &fileName, QString *errMessage ) diff --git a/src/qlightroundtextitem.cpp b/src/qlightroundtextitem.cpp index 27c0f8a..b9e23ed 100644 --- a/src/qlightroundtextitem.cpp +++ b/src/qlightroundtextitem.cpp @@ -264,7 +264,15 @@ QItemDialog *QShapeControllerRoundText::createDialog( QWidget *parent ) const void QShapeControllerRoundText::replace( QGraphicsItem *item, const QString &from, const QString &to ) const { QLightRoundTextItem *textItem = static_cast< QLightRoundTextItem * >( item ); - if( textItem->text() == from ) + bool placeHolder = textItem->text().left( 1 ) == "?" && textItem->text().right( 1 ) == "?"; + + bool replace = false; + if( from.isEmpty() ) + replace = placeHolder; + else + replace = textItem->text() == ( placeHolder ? QString( "?%1?" ).arg( from ) : from ); + + if( replace ) textItem->setText( to ); } diff --git a/src/qlighttextitem.cpp b/src/qlighttextitem.cpp index ba07e26..6b89672 100644 --- a/src/qlighttextitem.cpp +++ b/src/qlighttextitem.cpp @@ -81,7 +81,16 @@ void QShapeControllerText::writeData( QXmlStreamWriter &writer, const QGraphicsI void QShapeControllerText::replace( QGraphicsItem *item, const QString &from, const QString &to ) const { QGraphicsSimpleTextItem *textItem = static_cast< QGraphicsSimpleTextItem * >( item ); - if( textItem->text() == from ) + + bool placeHolder = textItem->text().left( 1 ) == "?" && textItem->text().right( 1 ) == "?"; + + bool replace = false; + if( from.isEmpty() ) + replace = placeHolder; + else + replace = textItem->text() == ( placeHolder ? QString( "?%1?" ).arg( from ) : from ); + + if( replace ) textItem->setText( to ); }