23 #ifndef KDSME_UTIL_OBJECTHELPER_H
24 #define KDSME_UTIL_OBJECTHELPER_H
26 #include "kdsme_core_export.h"
42 KDSME_CORE_EXPORT QString addressToString(
const void *p);
48 KDSME_CORE_EXPORT QString className(
const QObject*
object, DisplayOption option = NoStrip);
49 KDSME_CORE_EXPORT QString displayString(
const QObject *
object, DisplayOption option = NoStrip);
51 KDSME_CORE_EXPORT
const char* enumToString(
const QMetaObject* metaObject,
const char* name,
int value);
52 KDSME_CORE_EXPORT
int stringToEnum(
const QMetaObject* metaObject,
const char* name,
const char* key);
54 KDSME_CORE_EXPORT QString toString(
const QPointF& point);
55 KDSME_CORE_EXPORT QString toString(
const QSizeF& size);
56 KDSME_CORE_EXPORT QString toString(
const QRectF& rect);
65 KDSME_CORE_EXPORT
bool descendantOf(
const QObject *ascendant,
const QObject *
object);
72 KDSME_CORE_EXPORT
int depth(
const QObject* root,
const QObject*
object);
79 template<
class FilterType,
class ItemType>
80 QList<FilterType> copy_if_type(
const QList<ItemType> list) {
81 QList<FilterType> filteredList;
82 Q_FOREACH (
const ItemType
object, list) {
83 if (FilterType filterObject = qobject_cast<FilterType>(
object))
84 filteredList << filterObject;
94 template<
class C,
class P>
95 C filter(
const C& source,
const P& predicate)
99 d.erase(std::remove_if(std::begin(d), std::end(d), predicate), std::end(d));
110 template <
typename T>
111 T *findParentOfType(QObject *
object) {
115 if (qobject_cast<T*>(
object)) {
116 return static_cast<T*
>(object);
118 return findParentOfType<T>(
object->parent());
Definition: abstractexporter.h:33