Skip to content
Permalink
Browse files

Preserve edits for multiline editor when length exceeds field size

Previously when using the multiline option for text edit widgets
the entire contents of the field would be discarded if the entered
value exceeded the maximum length for a string field.

Now the entered string is truncated to the maximum field length.

(cherry-picked from 7d8fba8)
  • Loading branch information
nyalldawson committed Oct 6, 2016
1 parent d5ef91f commit 322c8f49d99a0ef265f4eafd37899c1ce3097d96
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/gui/editorwidgets/qgstexteditwrapper.cpp
@@ -66,9 +66,19 @@ QVariant QgsTextEditWrapper::value() const

QVariant res( v );
if ( field().convertCompatible( res ) )
{
return res;
}
else if ( field().type() == QVariant::String && field().length() > 0 )
{
// for string fields convertCompatible may return false due to field length limit - in this case just truncate
// input rather then discarding it entirely
return QVariant( v.left( field().length() ) );
}
else
{
return QVariant( field().type() );
}
}

QWidget* QgsTextEditWrapper::createWidget( QWidget* parent )

0 comments on commit 322c8f4

Please sign in to comment.
You can’t perform that action at this time.