QtTest: add toString(QModelIndex)

Add toString(QModelIndex) to make debugging itemmodels/views autotests
easier.

[ChangeLog][QtTest] Added QTest::toString(const QModelIndex &idx)

Change-Id: I20ad6b1fb145c00a3239131a3274fdbefc3b3ffd
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Christian Ehrlicher 2018-12-26 14:05:06 +01:00 committed by Tony Sarajärvi
parent 94daa69699
commit 7ef0b575b3

View File

@ -51,6 +51,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qcborcommon.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qabstractitemmodel.h>
#include <QtCore/qobject.h>
#include <QtCore/qvariant.h>
#include <QtCore/qurl.h>
@ -128,6 +129,13 @@ template<> inline char *toString(const QChar &c)
return qstrdup(qPrintable(QString::fromLatin1("QChar: '%1' (0x%2)").arg(c).arg(QString::number(static_cast<int>(c.unicode()), 16))));
}
template<> inline char *toString(const QModelIndex &idx)
{
char msg[128];
qsnprintf(msg, sizeof(msg), "QModelIndex(%d,%d,%p,%p)", idx.row(), idx.column(), idx.internalPointer(), idx.model());
return qstrdup(msg);
}
template<> inline char *toString(const QPoint &p)
{
char msg[128] = {'\0'};