mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Add sip conversions for profile times
This commit is contained in:
parent
53a57e19e0
commit
6a4556ddd0
@ -1592,6 +1592,67 @@ template<int, TYPE2*>
|
||||
%End
|
||||
};
|
||||
|
||||
%MappedType QList < QPair< QString, double > >
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include <QPair>
|
||||
#include <QList>
|
||||
%End
|
||||
|
||||
%ConvertFromTypeCode
|
||||
//convert map to a python dictionary
|
||||
PyObject *d;
|
||||
|
||||
if ((d = PyList_New( sipCpp->size() )) == NULL)
|
||||
return NULL;
|
||||
|
||||
for ( int i = 0; i<sipCpp->size(); i++ )
|
||||
{
|
||||
PyObject *p;
|
||||
if ((p = PyList_New(2) ) == NULL)
|
||||
{
|
||||
Py_DECREF(d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *t1obj = sipConvertFromNewType(new QString(sipCpp->at(i).first), sipType_QString, sipTransferObj);
|
||||
PyObject *t2obj = PyFloat_FromDouble( (double) sipCpp->at(i).second );
|
||||
PyList_SetItem( p, 0, t1obj );
|
||||
PyList_SetItem( p, 1, t2obj );
|
||||
|
||||
PyList_SetItem( d, i, p );
|
||||
}
|
||||
|
||||
return d;
|
||||
%End
|
||||
%ConvertToTypeCode
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
Py_ssize_t i = 0;
|
||||
#else
|
||||
int i = 0;
|
||||
#endif
|
||||
QList < QPair< QString, double > > *qm = new QList< QPair< QString, double > >;
|
||||
|
||||
for ( i = 0; i < PyList_GET_SIZE(sipPy); i++ )
|
||||
{
|
||||
int state;
|
||||
|
||||
PyObject *sipPair = PyList_GetItem( sipPy, i );
|
||||
PyObject *sipString = PyList_GetItem( sipPair, 0 );
|
||||
PyObject *sipDouble = PyList_GetItem( sipPair, 1 );
|
||||
|
||||
QString *t1 = reinterpret_cast<QString *>(sipConvertToType(sipString, sipType_QString, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
|
||||
double value = PyFloat_AsDouble(sipDouble);
|
||||
qm->append( qMakePair( *t1, value ) );
|
||||
sipReleaseType(t1, sipType_QString, state);
|
||||
}
|
||||
|
||||
*sipCppPtr = qm;
|
||||
|
||||
return sipGetState(sipTransferObj);
|
||||
%End
|
||||
};
|
||||
|
||||
%MappedType QList < QPair< QgsVectorLayer *, int > >
|
||||
{
|
||||
%TypeHeaderCode
|
||||
|
@ -46,7 +46,7 @@ class QgsRuntimeProfiler
|
||||
* @brief Return all the current profile times.
|
||||
* @return A list of profile event names and times.
|
||||
*/
|
||||
// const QList<QPair<QString, double>> profileTimes() const;
|
||||
const QList<QPair<QString, double>> profileTimes() const;
|
||||
|
||||
/**
|
||||
* @brief clear Clear all profile data.
|
||||
|
Loading…
x
Reference in New Issue
Block a user