104 return QVariant(int(qRound(s.toDouble(ok)))); |
104 return QVariant(int(qRound(s.toDouble(ok)))); |
105 case QMetaType::UInt: |
105 case QMetaType::UInt: |
106 return QVariant(uint(qRound(s.toDouble(ok)))); |
106 return QVariant(uint(qRound(s.toDouble(ok)))); |
107 case QMetaType::QColor: |
107 case QMetaType::QColor: |
108 return QVariant::fromValue(colorFromString(s, ok)); |
108 return QVariant::fromValue(colorFromString(s, ok)); |
109 #ifndef QT_NO_TEXTDATE |
109 #ifndef QT_NO_DATESTRING |
110 case QMetaType::QDate: |
110 case QMetaType::QDate: |
111 return QVariant::fromValue(dateFromString(s, ok)); |
111 return QVariant::fromValue(dateFromString(s, ok)); |
112 case QMetaType::QTime: |
112 case QMetaType::QTime: |
113 return QVariant::fromValue(timeFromString(s, ok)); |
113 return QVariant::fromValue(timeFromString(s, ok)); |
114 case QMetaType::QDateTime: |
114 case QMetaType::QDateTime: |
115 return QVariant::fromValue(dateTimeFromString(s, ok)); |
115 return QVariant::fromValue(dateTimeFromString(s, ok)); |
116 #endif // QT_NO_TEXTDATE |
116 #endif // QT_NO_DATESTRING |
117 case QMetaType::QPointF: |
117 case QMetaType::QPointF: |
118 return QVariant::fromValue(pointFFromString(s, ok)); |
118 return QVariant::fromValue(pointFFromString(s, ok)); |
119 case QMetaType::QPoint: |
119 case QMetaType::QPoint: |
120 return QVariant::fromValue(pointFFromString(s, ok).toPoint()); |
120 return QVariant::fromValue(pointFFromString(s, ok).toPoint()); |
121 case QMetaType::QSizeF: |
121 case QMetaType::QSizeF: |
150 if (ok) *ok = rv.isValid(); |
150 if (ok) *ok = rv.isValid(); |
151 return rv; |
151 return rv; |
152 } |
152 } |
153 } |
153 } |
154 |
154 |
155 #ifndef QT_NO_TEXTDATE |
155 #ifndef QT_NO_DATESTRING |
156 QDate QDeclarativeStringConverters::dateFromString(const QString &s, bool *ok) |
156 QDate QDeclarativeStringConverters::dateFromString(const QString &s, bool *ok) |
157 { |
157 { |
158 QDate d = QDate::fromString(s, Qt::ISODate); |
158 QDate d = QDate::fromString(s, Qt::ISODate); |
159 if (ok) *ok = d.isValid(); |
159 if (ok) *ok = d.isValid(); |
160 return d; |
160 return d; |
171 { |
171 { |
172 QDateTime d = QDateTime::fromString(s, Qt::ISODate); |
172 QDateTime d = QDateTime::fromString(s, Qt::ISODate); |
173 if (ok) *ok = d.isValid(); |
173 if (ok) *ok = d.isValid(); |
174 return d; |
174 return d; |
175 } |
175 } |
176 #endif // QT_NO_TEXTDATE |
176 #endif // QT_NO_DATESTRING |
177 |
177 |
178 //expects input of "x,y" |
178 //expects input of "x,y" |
179 QPointF QDeclarativeStringConverters::pointFFromString(const QString &s, bool *ok) |
179 QPointF QDeclarativeStringConverters::pointFFromString(const QString &s, bool *ok) |
180 { |
180 { |
181 if (s.count(QLatin1Char(',')) != 1) { |
181 if (s.count(QLatin1Char(',')) != 1) { |