65 ConnSettingsValue *value = conn_settings_value_new();
67 qWarning(
"IAPConf: Unable to create new ConnSettingsValue");
71 switch(variant.
type()) {
74 value->type = CONN_SETTINGS_VALUE_INVALID;
79 value->type = CONN_SETTINGS_VALUE_STRING;
80 value->value.string_val = valueStr;
85 value->type = CONN_SETTINGS_VALUE_INT;
86 value->value.int_val = variant.
toInt();
91 value->type = CONN_SETTINGS_VALUE_DOUBLE;
92 value->value.double_val = variant.
toDouble();
96 value->type = CONN_SETTINGS_VALUE_BOOL;
97 value->value.bool_val = variant.
toBool() ? 1 : 0;
102 value->type = CONN_SETTINGS_VALUE_BYTE_ARRAY;
103 value->value.byte_array.len = array.
size();
104 value->value.byte_array.val = (
unsigned char *)malloc(array.
size());
105 memcpy(value->value.byte_array.val, array.
constData(), array.
size());
111 ConnSettingsValue **list_val = (ConnSettingsValue **)malloc(
112 (list.
size() + 1) *
sizeof(ConnSettingsValue *));
114 for (
int idx = 0; idx < list.
size(); idx++) {
117 list_val[list.
size()] = 0;
119 value->type = CONN_SETTINGS_VALUE_LIST;
120 value->value.list_val = list_val;
125 qWarning(
"IAPConf: Can not handle QVariant of type %d",
127 conn_settings_value_destroy(value);
The QByteArray class provides an array of bytes.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
ConnSettingsValue * variantToValue(const QVariant &variant)
const T & at(int i) const
Returns the item at index position i in the list.
Q_CORE_EXPORT void qWarning(const char *,...)
#define QSTRING_TO_CONST_CSTR(str)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Type type() const
Returns the storage type of the value stored in the variant.
int size() const
Returns the number of items in the list.
int size() const
Returns the number of bytes in this byte array.
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...