Go to the documentation of this file.
16#ifndef KDSME_UTIL_OBJECTHELPER_H
17#define KDSME_UTIL_OBJECTHELPER_H
19#include "kdsme_core_export.h"
45KDSME_CORE_EXPORT
const char *
enumToString(
const QMetaObject *metaObject,
const char *name,
int value);
46KDSME_CORE_EXPORT
int stringToEnum(
const QMetaObject *metaObject,
const char *name,
const char *key);
48KDSME_CORE_EXPORT QString
toString(
const QPointF &point);
49KDSME_CORE_EXPORT QString
toString(
const QSizeF &size);
50KDSME_CORE_EXPORT QString
toString(
const QRectF &rect);
59KDSME_CORE_EXPORT
bool descendantOf(
const QObject *ascendant,
const QObject *
object);
66KDSME_CORE_EXPORT
int depth(
const QObject *root,
const QObject *
object);
73template<
class FilterType,
class ItemType>
76 QList<FilterType> filteredList;
77 for (
const ItemType &
object : list) {
78 if (FilterType filterObject = qobject_cast<FilterType>(
object))
79 filteredList << filterObject;
89template<
class C,
class P>
90C
filter(
const C &source,
const P &predicate)
94 d.erase(std::remove_if(std::begin(d), std::end(d), predicate), std::end(d));
111 if (qobject_cast<T *>(
object)) {
112 return static_cast<T *
>(object);
KDSME_CORE_EXPORT QString toString(const QPointF &point)
KDSME_CORE_EXPORT QString displayString(const QObject *object, DisplayOption option=NoStrip)
KDSME_CORE_EXPORT int depth(const QObject *root, const QObject *object)
KDSME_CORE_EXPORT QString className(const QObject *object, DisplayOption option=NoStrip)
KDSME_CORE_EXPORT int stringToEnum(const QMetaObject *metaObject, const char *name, const char *key)
C filter(const C &source, const P &predicate)
KDSME_CORE_EXPORT bool descendantOf(const QObject *ascendant, const QObject *object)
T * findParentOfType(QObject *object)
KDSME_CORE_EXPORT QString addressToString(const void *p)
KDSME_CORE_EXPORT const char * enumToString(const QMetaObject *metaObject, const char *name, int value)
QList< FilterType > copy_if_type(const QList< ItemType > &list)