mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-25 00:05:03 -04:00
Fix $CURRENT_DATE replacement in QgsComposerLabel
This commit is contained in:
parent
e70b1524f9
commit
cc452d1ffc
@ -84,14 +84,18 @@ QString QgsComposerLabel::displayText() const
|
||||
|
||||
void QgsComposerLabel::replaceDateText( QString& text ) const
|
||||
{
|
||||
int currentDatePos = text.indexOf( "$CURRENT_DATE" );
|
||||
QString constant = "$CURRENT_DATE";
|
||||
int currentDatePos = text.indexOf( constant );
|
||||
if ( currentDatePos != -1 )
|
||||
{
|
||||
//check if there is a bracket just after $CURRENT_DATE
|
||||
QString formatText;
|
||||
int openingBracketPos = text.indexOf( "(", currentDatePos );
|
||||
int closingBracketPos = text.indexOf( ")", openingBracketPos + 1 );
|
||||
if ( openingBracketPos != -1 && closingBracketPos != -1 && ( closingBracketPos - openingBracketPos ) > 1 )
|
||||
if ( openingBracketPos != -1 &&
|
||||
closingBracketPos != -1 &&
|
||||
( closingBracketPos - openingBracketPos ) > 1 &&
|
||||
openingBracketPos == currentDatePos + constant.size() )
|
||||
{
|
||||
formatText = text.mid( openingBracketPos + 1, closingBracketPos - openingBracketPos - 1 );
|
||||
text.replace( currentDatePos, closingBracketPos - currentDatePos + 1, QDate::currentDate().toString( formatText ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user