Commit 0d25c05a authored by EXT Arnaud Clère's avatar EXT Arnaud Clère

Fixed a few QVariant conversion problems between strings and various

numeric types
parent f675ebd1
......@@ -374,13 +374,17 @@ protected:
}
}
using IBind::_bind; // full overload set so that following overloads calls work (instead of calling themselves and overflowing the call stack)
virtual bool _null( ) { return hidden() ? true : I<=d ? itemBind()->_null() : write(QVariant()); }
virtual bool _bind( QString&& u) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(u)) : write(u ); }
virtual bool _bind( bool&& b) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(b)) : write(b ); }
virtual bool _bind( float&& f) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(f)) : write(f ); }
virtual bool _bind( double&& f) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(f)) : write(f ); }
virtual bool _bind( quint64&& i) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(i)) : write(i<=quint64(std::numeric_limits<unsigned int>::max()) ? static_cast<unsigned int>(i) : i); } // with QSpinBox delegate
virtual bool _bind( qint64&& i) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(i)) : write(i<= qint64(std::numeric_limits<int>::max()) ? static_cast<int>(i) : i); }
virtual bool _bind( quint64&& i) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(i)) : i<=quint64(std::numeric_limits<unsigned int>::max()) ? write(static_cast<unsigned int>(i)) :
write(i ); } // with QSpinBox delegate
virtual bool _bind( qint64&& i) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(i)) : i<= qint64(std::numeric_limits< int>::max()) ? write(static_cast< int>(i)) :
write(i ); }
virtual bool _bind( QVariant&& t) { return hidden() ? true : I<=d ? itemBind()->_bind( QVariant(t)) : write(t ); }
// TODO QDate*, QTime
// TODO QPixmap if metadata suggests a QMimeData image ?
......@@ -572,6 +576,8 @@ protected:
}
}
using IBind::_bind; // full overload set so that following overloads calls work (instead of calling themselves and overflowing the call stack)
virtual bool _null( ) { return hidden() ? true : I<=d ? itemBind()->_null() : read().isNull () ; }
virtual bool _bind( QString&& u) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(u)) : u==read().toString() ; }
virtual bool _bind( bool&& b) { return hidden() ? true : I<=d ? itemBind()->_bind(std::move(b)) : b==read().toBool () ; }
......@@ -593,10 +599,10 @@ protected:
virtual bool _bind( QUtf8Data& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); if (v.type()!=QVariant ::String ) return false; r=QUtf8Data(v.toString().toUtf8()); return true; }
virtual bool _bind( QString& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); if (v.type()!=QVariant ::String ) return false; r= v.toString () ; return true; }
virtual bool _bind( bool& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); if (v.type()!=QVariant ::Bool ) return false; r= v.toBool () ; return true; }
virtual bool _bind( qint64& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); if (v.type()!=QVariant ::LongLong ) return false; r= v.toLongLong () ; return true; }
virtual bool _bind( quint64& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); if (v.type()!=QVariant ::ULongLong) return false; r= v.toULongLong () ; return true; }
virtual bool _bind( float& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); if (v.type()!=QMetaType::Float ) return false; r= v.toFloat () ; return true; }
virtual bool _bind( double& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); if (v.type()!=QVariant ::Double ) return false; r= v.toDouble () ; return true; }
virtual bool _bind( qint64& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); bool isConverted=false; qint64 i=v. toLongLong(&isConverted); if (!isConverted || v.type()==QVariant::Bool || v.type()==QVariant::ByteArray) { return false; } r=i; return true; }
virtual bool _bind( quint64& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); bool isConverted=false; quint64 i=v.toULongLong(&isConverted); if (!isConverted || v.type()==QVariant::Bool || v.type()==QVariant::ByteArray) { return false; } r=i; return true; }
virtual bool _bind( float& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); bool isConverted=false; float i=v.toULongLong(&isConverted); if (!isConverted || v.type()==QVariant::Bool || v.type()==QVariant::ByteArray) { return false; } r=i; return true; }
virtual bool _bind( double& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); bool isConverted=false; double i=v.toULongLong(&isConverted); if (!isConverted || v.type()==QVariant::Bool || v.type()==QVariant::ByteArray) { return false; } r=i; return true; }
virtual bool _bind(QByteArray& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); QVariant v=read(); if (v.type()!=QVariant ::ByteArray) return false; r= v.toByteArray () ; return true; }
virtual bool _bind( QVariant& r) { if (hidden()) return true; if (I<=d) return itemBind()->_bind(r); r=read() ; return true; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment