Added new methods to QStringLists: __len__, __getitem__ and __setitem__
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
6d53b50163
commit
42526f3202
1 changed files with 28 additions and 3 deletions
|
|
@ -966,14 +966,13 @@
|
||||||
if (_i < 0 || _i >= %CPPSELF.size()) {
|
if (_i < 0 || _i >= %CPPSELF.size()) {
|
||||||
PyErr_SetString(PyExc_IndexError, "index out of bounds");
|
PyErr_SetString(PyExc_IndexError, "index out of bounds");
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
return Converter<QString>::createWrapper(new QString(%CPPSELF.at(_i)));
|
|
||||||
}
|
}
|
||||||
|
return %CONVERTTOPYTHON[%TYPE](%CPPSELF.at(_i));
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</add-function>
|
</add-function>
|
||||||
<add-function signature="__setitem__">
|
<add-function signature="__setitem__">
|
||||||
<inject-code class="target" position="beginning">
|
<inject-code class="target" position="beginning">
|
||||||
PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value);
|
PyObject* args = Py_BuildValue("(nO)", _i, _value);
|
||||||
PyObject* result = PyQString_replace(self, args);
|
PyObject* result = PyQString_replace(self, args);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
@ -1381,6 +1380,32 @@
|
||||||
<modify-function signature="fromVector(QVector<QString>)" remove="all" />
|
<modify-function signature="fromVector(QVector<QString>)" remove="all" />
|
||||||
<modify-function signature="operator<<(const QString&)" remove="all"/>
|
<modify-function signature="operator<<(const QString&)" remove="all"/>
|
||||||
<modify-function signature="operator<<(const QStringList&)" remove="all"/>
|
<modify-function signature="operator<<(const QStringList&)" remove="all"/>
|
||||||
|
<add-function signature="__len__">
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
return %CPPSELF.count();
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
|
<add-function signature="__getitem__">
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
if (_i < 0 || _i >= %CPPSELF.size()) {
|
||||||
|
PyErr_SetString(PyExc_IndexError, "index out of bounds");
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return Converter<QString>::createWrapper(new QString(%CPPSELF.at(_i)));
|
||||||
|
}
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
|
<add-function signature="__setitem__">
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value);
|
||||||
|
PyObject* result = PyQStringList_replace(self, args);
|
||||||
|
Py_DECREF(args);
|
||||||
|
if (result) {
|
||||||
|
Py_DECREF(result);
|
||||||
|
}
|
||||||
|
return !result ? -1 : 0;
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
</value-type>
|
</value-type>
|
||||||
<object-type name="QAbstractListModel">
|
<object-type name="QAbstractListModel">
|
||||||
<extra-includes>
|
<extra-includes>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue