[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/office/datakiosk/src
From: Adam Treat <treat () kde ! org>
Date: 2006-02-28 21:41:36
Message-ID: 1141162896.666160.15966.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 514632 by treat:
* Workaround for incorrect handling of string type default values
M +22 -1 datatableeditorfactory.cpp
--- trunk/extragear/office/datakiosk/src/datatableeditorfactory.cpp #514631:514632
@@ -578,9 +578,29 @@
QString txt = text();
if ( txt.isEmpty() && m_dataField->type() != QVariant::String )
+ {
return "NULL";
+ }
+ else if ( txt.isEmpty()
+ && m_dataField->type() == QVariant::String
+ && m_dataField->isRequired() )
+ {
+ // Qt's SQL module doesn't take into account that a string can have
+ // a default value of '' which Qt interprets as QString::null. This
+ // is wrong. Hence this workaround.
+
+ // This model's the MySQL behavior of string types implicitly having a
+ // default value of '', but I only do this if the field is required.
+ if ( m_dataField->defaultValue().isValid()
+ && !m_dataField->defaultValue().isNull())
+ return m_dataField->defaultValue().toString();
+ else
+ return "";
+ }
else if ( txt.isEmpty() )
+ {
return QString::null;
+ }
return txt;
}
@@ -592,7 +612,8 @@
void DataLineEdit::setDefaultValue()
{
- if ( m_dataField->defaultValue().isValid() && !m_dataField->defaultValue().isNull() )
+ if ( m_dataField->defaultValue().isValid()
+ && !m_dataField->defaultValue().isNull() )
setText( m_dataField->defaultValue().toString() );
else if ( isNumeric() && m_dataField->isRequired() )
setText( "0" );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic