| 807 | static int columnGroupRole = Qt::UserRole + 10000; |
| 808 | |
| 809 | static QString interpretVariant(const QVariant &v, const ShaderConstant &el, |
| 810 | const BufferElementProperties &prop) |
| 811 | { |
| 812 | QString ret; |
| 813 | |
| 814 | QMetaType::Type vt = GetVariantMetatype(v); |
| 815 | |
| 816 | if(vt == QMetaType::Double) |
| 817 | { |
| 818 | double d = v.toDouble(); |
| 819 | // pad with space on left if sign is missing, to better align |
| 820 | if(d < 0.0) |
| 821 | ret = Formatter::Format(d); |
| 822 | else if(d > 0.0) |
| 823 | ret = lit(" ") + Formatter::Format(d); |
| 824 | else if(qIsNaN(d)) |
| 825 | ret = lit(" NaN"); |
| 826 | else |
| 827 | // force negative and positive 0 together |
| 828 | ret = lit(" ") + Formatter::Format(0.0); |
| 829 | } |
| 830 | else if(vt == QMetaType::Float) |
| 831 | { |
| 832 | float f = v.toFloat(); |
| 833 | // pad with space on left if sign is missing, to better align |
| 834 | if(f < 0.0) |
| 835 | ret = Formatter::Format(f); |
| 836 | else if(f > 0.0) |
| 837 | ret = lit(" ") + Formatter::Format(f); |
| 838 | else if(qIsNaN(f)) |
| 839 | ret = lit(" NaN"); |
| 840 | else |
| 841 | // force negative and positive 0 together |
| 842 | ret = lit(" ") + Formatter::Format(0.0); |
| 843 | } |
| 844 | else if(vt == QMetaType::UInt || vt == QMetaType::UShort || vt == QMetaType::UChar) |
| 845 | { |
| 846 | uint32_t u = v.toUInt(); |
| 847 | |
| 848 | if(prop.floatCastWrong) |
| 849 | { |
| 850 | float f = (float)u; |
| 851 | memcpy(&u, &f, sizeof(f)); |
| 852 | } |
| 853 | |
| 854 | const bool hexDisplay = bool(el.type.flags & ShaderVariableFlags::HexDisplay); |
| 855 | const bool binDisplay = bool(el.type.flags & ShaderVariableFlags::BinaryDisplay); |
| 856 | |
| 857 | if(hexDisplay && prop.format.type == ResourceFormatType::Regular) |
| 858 | ret = Formatter::HexFormat(u, prop.format.compByteWidth); |
| 859 | else if(binDisplay && prop.format.type == ResourceFormatType::Regular) |
| 860 | ret = Formatter::BinFormat(u, prop.format.compByteWidth); |
| 861 | else |
| 862 | ret = Formatter::Format(u, hexDisplay); |
| 863 | } |
| 864 | else if(vt == QMetaType::Int || vt == QMetaType::Short || vt == QMetaType::SChar) |
| 865 | { |
| 866 | int32_t i = v.toInt(); |
no test coverage detected